commit | 9d02a125fbc7825a7e47d97fe33e5513d5252427 | [log] [tgz] |
---|---|---|
author | Neil Fuller <nfuller@google.com> | Wed Apr 07 20:29:50 2021 +0100 |
committer | Neil Fuller <nfuller@google.com> | Wed Apr 07 21:02:26 2021 +0100 |
tree | 68f263b8e3b650c3ed819b0e8e6bc324bbdd07f3 | |
parent | adb4b12d77318526306963f14de7c5b6fa0a4683 [diff] |
Fix state dumping when service stopped Avoid a NullPointerException. Bug: 178169250 Test: Command line testing Change-Id: If01e31fc72c3284dacef8735fd997a7783faf6e0
diff --git a/services/core/java/com/android/server/timezonedetector/location/LocationTimeZoneManagerService.java b/services/core/java/com/android/server/timezonedetector/location/LocationTimeZoneManagerService.java index ca4a640..6719695 100644 --- a/services/core/java/com/android/server/timezonedetector/location/LocationTimeZoneManagerService.java +++ b/services/core/java/com/android/server/timezonedetector/location/LocationTimeZoneManagerService.java
@@ -437,8 +437,11 @@ }, BLOCKING_OP_WAIT_DURATION_MILLIS); } - /** Returns a snapshot of the current controller state for tests. */ - @NonNull + /** + * Returns a snapshot of the current controller state for tests. Returns {@code null} if the + * service is stopped. + */ + @Nullable LocationTimeZoneManagerServiceState getStateForTests() { enforceManageTimeZoneDetectorPermission();
diff --git a/services/core/java/com/android/server/timezonedetector/location/LocationTimeZoneManagerShellCommand.java b/services/core/java/com/android/server/timezonedetector/location/LocationTimeZoneManagerShellCommand.java index bdf4a70..40638080 100644 --- a/services/core/java/com/android/server/timezonedetector/location/LocationTimeZoneManagerShellCommand.java +++ b/services/core/java/com/android/server/timezonedetector/location/LocationTimeZoneManagerShellCommand.java
@@ -217,6 +217,11 @@ return 1; } + if (state == null) { + // Controller is stopped. + return 0; + } + DualDumpOutputStream outputStream; boolean useProto = Objects.equals(DUMP_STATE_OPTION_PROTO, getNextOption()); if (useProto) {