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

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 Paul's comments Created 4 years, 6 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 "base/android/context_utils.h"
8 #include "jni/AndroidCellularSignalStrength_jni.h"
9
10 namespace net {
11
12 namespace android {
13
14 namespace cellular_signal_strength {
15
16 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.net
17 enum CellularSignalStrengthError {
18 // Value returned by CellularSignalStrength APIs when a valid value is
19 // unavailable.
20 ERROR_NOT_SUPPORTED = -2147483648,
bengr 2016/06/10 20:57:37 Why not just use INT32_MIN? Add a comment that doi
tbansal1 2016/06/16 00:58:01 Done.
21 };
22
23 static_assert(
24 INT32_MIN == ERROR_NOT_SUPPORTED,
25 "CellularSignalStrengthError.ERROR_NOT_SUPPORTED has unexpected value");
26
27 bool GetRssiDbm(int32_t* rssi) {
28 int32_t rssi_tmp = Java_AndroidCellularSignalStrength_getRssiDbm(
bengr 2016/06/10 20:57:37 It might be better to avoid using the term RSSI an
tbansal1 2016/06/16 00:58:01 Done.
29 base::android::AttachCurrentThread(),
30 base::android::GetApplicationContext());
31 if (rssi_tmp == ERROR_NOT_SUPPORTED)
32 return false;
33
34 *rssi = rssi_tmp;
bengr 2016/06/10 20:57:37 I don't like _tmp, but can't think of anything bet
tbansal1 2016/06/16 00:58:02 I would prefer not to put |rssi_to_return| in the
35 return true;
36 }
37
38 bool GetSignalLevel(int32_t* signal_level) {
39 int32_t signal_level_tmp = Java_AndroidCellularSignalStrength_getSignalLevel(
40 base::android::AttachCurrentThread(),
41 base::android::GetApplicationContext());
42 if (signal_level_tmp == ERROR_NOT_SUPPORTED)
43 return false;
44
45 *signal_level = signal_level_tmp;
46 return true;
47 }
48
49 bool Register(JNIEnv* env) {
50 return RegisterNativesImpl(env);
51 }
52
53 } // namespace cellular_signal_strength
54
55 } // namespace android
56
57 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698