Loading services/core/java/com/android/server/timezonedetector/DeviceActivityMonitor.java +3 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,9 @@ interface DeviceActivityMonitor extends Dumpable { * A listener for device activities. See {@link DeviceActivityMonitor#addListener(Listener)}. */ interface Listener { /** A flight has started. */ void onFlightStart(); /** A flight has completed. */ void onFlightComplete(); } Loading services/core/java/com/android/server/timezonedetector/DeviceActivityMonitorImpl.java +13 −2 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import com.android.internal.annotations.GuardedBy; import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.function.Consumer; /** * The real implementation of {@link DeviceActivityMonitor}. Loading Loading @@ -59,6 +60,8 @@ class DeviceActivityMonitorImpl implements DeviceActivityMonitor { contentResolver, Settings.Global.AIRPLANE_MODE_ON); if (state == 0) { notifyFlightComplete(); } else if (state == 1) { notifyFlightStart(); } } catch (Settings.SettingNotFoundException e) { Slog.e(LOG_TAG, "Unable to read airplane mode state", e); Loading @@ -77,9 +80,17 @@ class DeviceActivityMonitorImpl implements DeviceActivityMonitor { mListeners.add(listener); } private void notifyFlightStart() { notify("notifyFlightStart", Listener::onFlightStart); } private void notifyFlightComplete() { notify("notifyFlightComplete", Listener::onFlightComplete); } private void notify(String logMessage, Consumer<Listener> notifier) { if (DBG) { Slog.d(LOG_TAG, "notifyFlightComplete"); Slog.d(LOG_TAG, logMessage); } // Copy the listeners holding the "this" lock but don't hold the lock while delivering the Loading @@ -89,7 +100,7 @@ class DeviceActivityMonitorImpl implements DeviceActivityMonitor { listeners = new ArrayList<>(mListeners); } for (Listener listener : listeners) { listener.onFlightComplete(); notifier.accept(listener); } } Loading services/core/java/com/android/server/timezonedetector/TimeZoneDetectorService.java +13 −6 Original line number Diff line number Diff line Loading @@ -88,10 +88,17 @@ public final class TimeZoneDetectorService extends ITimeZoneDetectorService.Stub DeviceActivityMonitorImpl.create(context, handler); // Wire up the telephony fallback behavior to activity detection. deviceActivityMonitor.addListener(new DeviceActivityMonitor.Listener() { deviceActivityMonitor.addListener( new DeviceActivityMonitor.Listener() { @Override public void onFlightStart() { // do nothing } @Override public void onFlightComplete() { timeZoneDetectorStrategy.enableTelephonyTimeZoneFallback("onFlightComplete()"); timeZoneDetectorStrategy.enableTelephonyTimeZoneFallback( "onFlightComplete()"); } }); Loading Loading
services/core/java/com/android/server/timezonedetector/DeviceActivityMonitor.java +3 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,9 @@ interface DeviceActivityMonitor extends Dumpable { * A listener for device activities. See {@link DeviceActivityMonitor#addListener(Listener)}. */ interface Listener { /** A flight has started. */ void onFlightStart(); /** A flight has completed. */ void onFlightComplete(); } Loading
services/core/java/com/android/server/timezonedetector/DeviceActivityMonitorImpl.java +13 −2 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import com.android.internal.annotations.GuardedBy; import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.function.Consumer; /** * The real implementation of {@link DeviceActivityMonitor}. Loading Loading @@ -59,6 +60,8 @@ class DeviceActivityMonitorImpl implements DeviceActivityMonitor { contentResolver, Settings.Global.AIRPLANE_MODE_ON); if (state == 0) { notifyFlightComplete(); } else if (state == 1) { notifyFlightStart(); } } catch (Settings.SettingNotFoundException e) { Slog.e(LOG_TAG, "Unable to read airplane mode state", e); Loading @@ -77,9 +80,17 @@ class DeviceActivityMonitorImpl implements DeviceActivityMonitor { mListeners.add(listener); } private void notifyFlightStart() { notify("notifyFlightStart", Listener::onFlightStart); } private void notifyFlightComplete() { notify("notifyFlightComplete", Listener::onFlightComplete); } private void notify(String logMessage, Consumer<Listener> notifier) { if (DBG) { Slog.d(LOG_TAG, "notifyFlightComplete"); Slog.d(LOG_TAG, logMessage); } // Copy the listeners holding the "this" lock but don't hold the lock while delivering the Loading @@ -89,7 +100,7 @@ class DeviceActivityMonitorImpl implements DeviceActivityMonitor { listeners = new ArrayList<>(mListeners); } for (Listener listener : listeners) { listener.onFlightComplete(); notifier.accept(listener); } } Loading
services/core/java/com/android/server/timezonedetector/TimeZoneDetectorService.java +13 −6 Original line number Diff line number Diff line Loading @@ -88,10 +88,17 @@ public final class TimeZoneDetectorService extends ITimeZoneDetectorService.Stub DeviceActivityMonitorImpl.create(context, handler); // Wire up the telephony fallback behavior to activity detection. deviceActivityMonitor.addListener(new DeviceActivityMonitor.Listener() { deviceActivityMonitor.addListener( new DeviceActivityMonitor.Listener() { @Override public void onFlightStart() { // do nothing } @Override public void onFlightComplete() { timeZoneDetectorStrategy.enableTelephonyTimeZoneFallback("onFlightComplete()"); timeZoneDetectorStrategy.enableTelephonyTimeZoneFallback( "onFlightComplete()"); } }); Loading