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

Unified Diff: net/android/java/src/org/chromium/net/AndroidNetworkLibrary.java

Issue 254823005: Move android Telephony APIs to from content/ to net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: NET_EXPORT the moved APIs. Created 6 years, 8 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
« no previous file with comments | « content/renderer/render_view_impl.cc ('k') | net/android/network_library.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/android/java/src/org/chromium/net/AndroidNetworkLibrary.java
diff --git a/net/android/java/src/org/chromium/net/AndroidNetworkLibrary.java b/net/android/java/src/org/chromium/net/AndroidNetworkLibrary.java
index e4caee50583f6b0ccb24452529666261b456f1c9..839a4953604a158ce4ccd714c312c5755ffb7e75 100644
--- a/net/android/java/src/org/chromium/net/AndroidNetworkLibrary.java
+++ b/net/android/java/src/org/chromium/net/AndroidNetworkLibrary.java
@@ -8,6 +8,7 @@ import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.security.KeyChain;
+import android.telephony.TelephonyManager;
import android.util.Log;
import org.chromium.base.CalledByNative;
@@ -238,4 +239,32 @@ class AndroidNetworkLibrary {
CertificateException, KeyStoreException {
X509Util.clearTestRootCertificates();
}
+
+ /**
+ * Returns the ISO country code equivalent of the current MCC.
+ */
+ @CalledByNative
+ private static String getNetworkCountryIso(Context context) {
+ TelephonyManager telephonyManager =
+ (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+ if (telephonyManager != null) {
+ return telephonyManager.getNetworkCountryIso();
+ }
+ return "";
+ }
+
+ /**
+ * Returns the MCC+MNC (mobile country code + mobile network code) as
+ * the numeric name of the current registered operator.
+ */
+ @CalledByNative
+ private static String getNetworkOperator(Context context) {
+ TelephonyManager telephonyManager =
+ (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+ if (telephonyManager != null) {
+ return telephonyManager.getNetworkOperator();
+ }
+ return "";
+ }
+
}
« no previous file with comments | « content/renderer/render_view_impl.cc ('k') | net/android/network_library.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698