Loading services/core/java/com/android/server/timedetector/TimeDetectorService.java +6 −2 Original line number Diff line number Diff line Loading @@ -37,6 +37,9 @@ import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.Objects; /** * The implementation of ITimeDetectorService.aidl. */ public final class TimeDetectorService extends ITimeDetectorService.Stub { private static final String TAG = "TimeDetectorService"; Loading Loading @@ -75,7 +78,7 @@ public final class TimeDetectorService extends ITimeDetectorService.Stub { Settings.Global.getUriFor(Settings.Global.AUTO_TIME), true, new ContentObserver(handler) { public void onChange(boolean selfChange) { timeDetectorService.handleAutoTimeDetectionToggle(); timeDetectorService.handleAutoTimeDetectionChanged(); } }); Loading Loading @@ -114,8 +117,9 @@ public final class TimeDetectorService extends ITimeDetectorService.Stub { mHandler.post(() -> mTimeDetectorStrategy.suggestNetworkTime(timeSignal)); } /** Internal method for handling the auto time setting being changed. */ @VisibleForTesting public void handleAutoTimeDetectionToggle() { public void handleAutoTimeDetectionChanged() { mHandler.post(mTimeDetectorStrategy::handleAutoTimeDetectionChanged); } Loading services/core/java/com/android/server/timedetector/TimeDetectorStrategy.java +2 −2 Original line number Diff line number Diff line Loading @@ -26,8 +26,8 @@ import android.os.TimestampedValue; import java.io.PrintWriter; /** * The interface for classes that implement the time detection algorithm used by the * TimeDetectorService. * The interface for the class that implements the time detection algorithm used by the * {@link TimeDetectorService}. * * <p>Most calls will be handled by a single thread but that is not true for all calls. For example * {@link #dump(PrintWriter, String[])}) may be called on a different thread so implementations must Loading services/core/java/com/android/server/timedetector/TimeDetectorStrategyImpl.java +1 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * An implementation of TimeDetectorStrategy that passes phone and manual suggestions to * An implementation of {@link TimeDetectorStrategy} that passes phone and manual suggestions to * {@link AlarmManager}. When there are multiple phone sources, the one with the lowest ID is used * unless the data becomes too stale. * Loading services/core/java/com/android/server/timezonedetector/TimeZoneDetectorCallbackImpl.java +2 −2 Original line number Diff line number Diff line Loading @@ -24,9 +24,9 @@ import android.os.SystemProperties; import android.provider.Settings; /** * The real implementation of {@link TimeZoneDetectorStrategy.Callback}. * The real implementation of {@link TimeZoneDetectorStrategyImpl.Callback}. */ public final class TimeZoneDetectorCallbackImpl implements TimeZoneDetectorStrategy.Callback { public final class TimeZoneDetectorCallbackImpl implements TimeZoneDetectorStrategyImpl.Callback { private static final String TIMEZONE_PROPERTY = "persist.sys.timezone"; Loading services/core/java/com/android/server/timezonedetector/TimeZoneDetectorService.java +17 −7 Original line number Diff line number Diff line Loading @@ -67,19 +67,21 @@ public final class TimeZoneDetectorService extends ITimeZoneDetectorService.Stub private static TimeZoneDetectorService create(@NonNull Context context) { final TimeZoneDetectorStrategy timeZoneDetectorStrategy = TimeZoneDetectorStrategy.create(context); TimeZoneDetectorStrategyImpl.create(context); Handler handler = FgThread.getHandler(); TimeZoneDetectorService service = new TimeZoneDetectorService(context, handler, timeZoneDetectorStrategy); ContentResolver contentResolver = context.getContentResolver(); contentResolver.registerContentObserver( Settings.Global.getUriFor(Settings.Global.AUTO_TIME_ZONE), true, new ContentObserver(handler) { public void onChange(boolean selfChange) { timeZoneDetectorStrategy.handleAutoTimeZoneDetectionChange(); service.handleAutoTimeZoneDetectionChanged(); } }); return new TimeZoneDetectorService(context, handler, timeZoneDetectorStrategy); return service; } @VisibleForTesting Loading Loading @@ -111,17 +113,25 @@ public final class TimeZoneDetectorService extends ITimeZoneDetectorService.Stub @Nullable String[] args) { if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return; mTimeZoneDetectorStrategy.dumpState(pw, args); mTimeZoneDetectorStrategy.dump(pw, args); } /** Internal method for handling the auto time zone setting being changed. */ @VisibleForTesting public void handleAutoTimeZoneDetectionChanged() { mHandler.post(mTimeZoneDetectorStrategy::handleAutoTimeZoneDetectionChanged); } private void enforceSuggestPhoneTimeZonePermission() { mContext.enforceCallingPermission( android.Manifest.permission.SET_TIME_ZONE, "set time zone"); android.Manifest.permission.SUGGEST_PHONE_TIME_AND_ZONE, "suggest phone time and time zone"); } private void enforceSuggestManualTimeZonePermission() { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.SET_TIME_ZONE, "set time zone"); android.Manifest.permission.SUGGEST_MANUAL_TIME_AND_ZONE, "suggest manual time and time zone"); } } Loading
services/core/java/com/android/server/timedetector/TimeDetectorService.java +6 −2 Original line number Diff line number Diff line Loading @@ -37,6 +37,9 @@ import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.Objects; /** * The implementation of ITimeDetectorService.aidl. */ public final class TimeDetectorService extends ITimeDetectorService.Stub { private static final String TAG = "TimeDetectorService"; Loading Loading @@ -75,7 +78,7 @@ public final class TimeDetectorService extends ITimeDetectorService.Stub { Settings.Global.getUriFor(Settings.Global.AUTO_TIME), true, new ContentObserver(handler) { public void onChange(boolean selfChange) { timeDetectorService.handleAutoTimeDetectionToggle(); timeDetectorService.handleAutoTimeDetectionChanged(); } }); Loading Loading @@ -114,8 +117,9 @@ public final class TimeDetectorService extends ITimeDetectorService.Stub { mHandler.post(() -> mTimeDetectorStrategy.suggestNetworkTime(timeSignal)); } /** Internal method for handling the auto time setting being changed. */ @VisibleForTesting public void handleAutoTimeDetectionToggle() { public void handleAutoTimeDetectionChanged() { mHandler.post(mTimeDetectorStrategy::handleAutoTimeDetectionChanged); } Loading
services/core/java/com/android/server/timedetector/TimeDetectorStrategy.java +2 −2 Original line number Diff line number Diff line Loading @@ -26,8 +26,8 @@ import android.os.TimestampedValue; import java.io.PrintWriter; /** * The interface for classes that implement the time detection algorithm used by the * TimeDetectorService. * The interface for the class that implements the time detection algorithm used by the * {@link TimeDetectorService}. * * <p>Most calls will be handled by a single thread but that is not true for all calls. For example * {@link #dump(PrintWriter, String[])}) may be called on a different thread so implementations must Loading
services/core/java/com/android/server/timedetector/TimeDetectorStrategyImpl.java +1 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * An implementation of TimeDetectorStrategy that passes phone and manual suggestions to * An implementation of {@link TimeDetectorStrategy} that passes phone and manual suggestions to * {@link AlarmManager}. When there are multiple phone sources, the one with the lowest ID is used * unless the data becomes too stale. * Loading
services/core/java/com/android/server/timezonedetector/TimeZoneDetectorCallbackImpl.java +2 −2 Original line number Diff line number Diff line Loading @@ -24,9 +24,9 @@ import android.os.SystemProperties; import android.provider.Settings; /** * The real implementation of {@link TimeZoneDetectorStrategy.Callback}. * The real implementation of {@link TimeZoneDetectorStrategyImpl.Callback}. */ public final class TimeZoneDetectorCallbackImpl implements TimeZoneDetectorStrategy.Callback { public final class TimeZoneDetectorCallbackImpl implements TimeZoneDetectorStrategyImpl.Callback { private static final String TIMEZONE_PROPERTY = "persist.sys.timezone"; Loading
services/core/java/com/android/server/timezonedetector/TimeZoneDetectorService.java +17 −7 Original line number Diff line number Diff line Loading @@ -67,19 +67,21 @@ public final class TimeZoneDetectorService extends ITimeZoneDetectorService.Stub private static TimeZoneDetectorService create(@NonNull Context context) { final TimeZoneDetectorStrategy timeZoneDetectorStrategy = TimeZoneDetectorStrategy.create(context); TimeZoneDetectorStrategyImpl.create(context); Handler handler = FgThread.getHandler(); TimeZoneDetectorService service = new TimeZoneDetectorService(context, handler, timeZoneDetectorStrategy); ContentResolver contentResolver = context.getContentResolver(); contentResolver.registerContentObserver( Settings.Global.getUriFor(Settings.Global.AUTO_TIME_ZONE), true, new ContentObserver(handler) { public void onChange(boolean selfChange) { timeZoneDetectorStrategy.handleAutoTimeZoneDetectionChange(); service.handleAutoTimeZoneDetectionChanged(); } }); return new TimeZoneDetectorService(context, handler, timeZoneDetectorStrategy); return service; } @VisibleForTesting Loading Loading @@ -111,17 +113,25 @@ public final class TimeZoneDetectorService extends ITimeZoneDetectorService.Stub @Nullable String[] args) { if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return; mTimeZoneDetectorStrategy.dumpState(pw, args); mTimeZoneDetectorStrategy.dump(pw, args); } /** Internal method for handling the auto time zone setting being changed. */ @VisibleForTesting public void handleAutoTimeZoneDetectionChanged() { mHandler.post(mTimeZoneDetectorStrategy::handleAutoTimeZoneDetectionChanged); } private void enforceSuggestPhoneTimeZonePermission() { mContext.enforceCallingPermission( android.Manifest.permission.SET_TIME_ZONE, "set time zone"); android.Manifest.permission.SUGGEST_PHONE_TIME_AND_ZONE, "suggest phone time and time zone"); } private void enforceSuggestManualTimeZonePermission() { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.SET_TIME_ZONE, "set time zone"); android.Manifest.permission.SUGGEST_MANUAL_TIME_AND_ZONE, "suggest manual time and time zone"); } }