summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/timezonedetector/TimeZoneDetectorCallbackImpl.java16
1 files changed, 15 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorCallbackImpl.java b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorCallbackImpl.java
index 2520316b5d54..35194658a48f 100644
--- a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorCallbackImpl.java
+++ b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorCallbackImpl.java
@@ -20,6 +20,7 @@ import android.annotation.Nullable;
import android.app.AlarmManager;
import android.content.ContentResolver;
import android.content.Context;
+import android.net.ConnectivityManager;
import android.os.SystemProperties;
import android.provider.Settings;
@@ -40,7 +41,20 @@ public final class TimeZoneDetectorCallbackImpl implements TimeZoneDetectorStrat
@Override
public boolean isAutoTimeZoneDetectionEnabled() {
- return Settings.Global.getInt(mCr, Settings.Global.AUTO_TIME_ZONE, 1 /* default */) > 0;
+ if (isAutoTimeZoneDetectionSupported()) {
+ return Settings.Global.getInt(mCr, Settings.Global.AUTO_TIME_ZONE, 1 /* default */) > 0;
+ }
+ return false;
+ }
+
+ private boolean isAutoTimeZoneDetectionSupported() {
+ return deviceHasTelephonyNetwork();
+ }
+
+ private boolean deviceHasTelephonyNetwork() {
+ // TODO b/150583524 Avoid the use of a deprecated API.
+ return mContext.getSystemService(ConnectivityManager.class)
+ .isNetworkSupported(ConnectivityManager.TYPE_MOBILE);
}
@Override