summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Marcello Galhardo <mgalhardo@google.com> 2023-11-07 12:33:15 +0000
committer Marcello Galhardo <mgalhardo@google.com> 2023-11-07 14:18:42 +0000
commit90300de6373f25658942d87dbdb9cb8f8407bc6b (patch)
tree339b4ca60df1bab24da65e2650ce26ccba4cf214
parentecac62c7354f8aee9af7eca4602bf2731d1a036e (diff)
Catch any SecurityException thrown by starting a NoteTaskControllerUpdateService
* If the user is stopped before NoteTaskControllerUpdateService is started, a security excepton is triggered. To avoid that, we try-catch the start method. Test: atest NoteTaskControllerTest Fixes: b/300829451 Change-Id: Ia6416267d1b6a4ebeef660f4eaca6ed7361537e9
-rw-r--r--packages/SystemUI/src/com/android/systemui/notetask/NoteTaskController.kt8
1 files changed, 7 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskController.kt b/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskController.kt
index 093d098de3e3..d9a8080a1e83 100644
--- a/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskController.kt
+++ b/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskController.kt
@@ -325,7 +325,13 @@ constructor(
} else {
// TODO(b/278729185): Replace fire and forget service with a bounded service.
val intent = NoteTaskControllerUpdateService.createIntent(context)
- context.startServiceAsUser(intent, user)
+ try {
+ // If the user is stopped before 'startServiceAsUser' kicks-in, a
+ // 'SecurityException' will be thrown.
+ context.startServiceAsUser(intent, user)
+ } catch (e: SecurityException) {
+ debugLog(error = e) { "Unable to start 'NoteTaskControllerUpdateService'." }
+ }
}
}