Merge "Disable auto time zone on non-telephony devices" into rvc-dev

This commit is contained in:
Neil Fuller
2020-03-05 08:36:06 +00:00
committed by Android (Google) Code Review

View File

@@ -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