summaryrefslogtreecommitdiff
path: root/core/java/android/app/RemoteServiceException.java
diff options
context:
space:
mode:
authorMakoto Onuki <omakoto@google.com>2021-04-01 15:25:27 -0700
committerMakoto Onuki <omakoto@google.com>2021-04-06 12:03:36 -0700
commit9de6e4e26b993f438de77a1171a3cc989193e745 (patch)
tree1f58cde5d86b3a75c46c4a3e9f5971a2f71a79e0 /core/java/android/app/RemoteServiceException.java
parent53a24c73191a209e0ef2f54297618ac3a260d3d5 (diff)
Use descriptive exception for FGS start timeout
If the app doesn't call startForeground() in time, throw a new exception ForegroundServiceDidNotStartInTimeException. Test: Manual test with a test app: 04-01 15:24:39.438 10293 9078 9078 E AndroidRuntime: FATAL EXCEPTION: main 04-01 15:24:39.438 10293 9078 9078 E AndroidRuntime: Process: com.google.omakoto.testapp, PID: 9078 04-01 15:24:39.438 10293 9078 9078 E AndroidRuntime: android.app.ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{92c1599 u0 com.google.omakoto.testapp/.MyFgs} 04-01 15:24:39.438 10293 9078 9078 E AndroidRuntime: at android.app.ActivityThread.throwRemoteServiceException(ActivityThread.java:1894) Bug: 124137635 Change-Id: I7d97e15ba47a32a242fb461e7312adf3f28ab3a6
Diffstat (limited to 'core/java/android/app/RemoteServiceException.java')
-rw-r--r--core/java/android/app/RemoteServiceException.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/core/java/android/app/RemoteServiceException.java b/core/java/android/app/RemoteServiceException.java
new file mode 100644
index 000000000000..4b32463e2996
--- /dev/null
+++ b/core/java/android/app/RemoteServiceException.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.app;
+
+import android.util.AndroidRuntimeException;
+
+/**
+ * Exception used by {@link ActivityThread} to crash an app process.
+ *
+ * @hide
+ */
+public class RemoteServiceException extends AndroidRuntimeException {
+ /**
+ * The type ID passed to {@link IApplicationThread#scheduleCrash}.
+ *
+ * Assign a unique ID to each subclass. See the above method for the numbers that are already
+ * taken.
+ */
+ public static final int TYPE_ID = 0;
+
+ public RemoteServiceException(String msg) {
+ super(msg);
+ }
+}