Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: net/android/cellular_signal_strength.cc

Issue 1879743002: Expose cellular signal strength on Android to native (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed pauljensen comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/android/cellular_signal_strength.h"
6
7 #include <stdint.h>
8
9 #include "base/android/context_utils.h"
10 #include "jni/AndroidCellularSignalStrength_jni.h"
11
12 namespace net {
13
14 namespace android {
15
16 namespace cellular_signal_strength {
17
18 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.net
19 enum CellularSignalStrengthError {
20 // Value returned by CellularSignalStrength APIs when a valid value is
21 // unavailable.
22 ERROR_NOT_SUPPORTED = -2147483647 - 1,
pauljensen 2016/05/23 12:25:10 why the subtraction?
tbansal1 2016/06/09 17:50:30 This is INT32_MIN. I just set it directly to -214
23 };
24
25 bool GetRssiDbm(int* rssi) {
26 static_assert(
27 INT32_MIN == ERROR_NOT_SUPPORTED,
28 "CellularSignalStrengthError.ERROR_NOT_SUPPORTED has unexpected value");
pauljensen 2016/05/23 12:25:10 can we move this assert up a scope level to right
tbansal1 2016/06/09 17:50:30 Done.
29 int rssi_tmp = Java_AndroidCellularSignalStrength_getRssiDbm(
30 base::android::AttachCurrentThread(),
31 base::android::GetApplicationContext());
32 if (rssi_tmp == ERROR_NOT_SUPPORTED)
33 return false;
34
35 *rssi = rssi_tmp;
36 return true;
37 }
38
39 bool GetSignalLevel(int* signal_level) {
40 int signal_level_tmp = Java_AndroidCellularSignalStrength_getSignalLevel(
41 base::android::AttachCurrentThread(),
42 base::android::GetApplicationContext());
43 if (signal_level_tmp == ERROR_NOT_SUPPORTED)
44 return false;
45
46 *signal_level = signal_level_tmp;
47 return true;
48 }
49
50 bool Register(JNIEnv* env) {
51 return RegisterNativesImpl(env);
52 }
53
54 } // namespace cellular_signal_strength
55
56 } // namespace android
57
58 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698