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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: net/android/cellular_signal_strength.cc
diff --git a/net/android/cellular_signal_strength.cc b/net/android/cellular_signal_strength.cc
new file mode 100644
index 0000000000000000000000000000000000000000..cec4ecc23fc65181afc00fa4918632ddd9c1c29b
--- /dev/null
+++ b/net/android/cellular_signal_strength.cc
@@ -0,0 +1,57 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/android/cellular_signal_strength.h"
+
+#include "base/android/context_utils.h"
+#include "jni/AndroidCellularSignalStrength_jni.h"
+
+namespace net {
+
+namespace android {
+
+namespace cellular_signal_strength {
+
+// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.net
+enum CellularSignalStrengthError {
+ // Value returned by CellularSignalStrength APIs when a valid value is
+ // unavailable.
+ 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.
+};
+
+static_assert(
+ INT32_MIN == ERROR_NOT_SUPPORTED,
+ "CellularSignalStrengthError.ERROR_NOT_SUPPORTED has unexpected value");
+
+bool GetRssiDbm(int32_t* rssi) {
+ 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.
+ base::android::AttachCurrentThread(),
+ base::android::GetApplicationContext());
+ if (rssi_tmp == ERROR_NOT_SUPPORTED)
+ return false;
+
+ *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
+ return true;
+}
+
+bool GetSignalLevel(int32_t* signal_level) {
+ int32_t signal_level_tmp = Java_AndroidCellularSignalStrength_getSignalLevel(
+ base::android::AttachCurrentThread(),
+ base::android::GetApplicationContext());
+ if (signal_level_tmp == ERROR_NOT_SUPPORTED)
+ return false;
+
+ *signal_level = signal_level_tmp;
+ return true;
+}
+
+bool Register(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+} // namespace cellular_signal_strength
+
+} // namespace android
+
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698