Loading core/java/android/app/ActivityThread.java +23 −6 Original line number Diff line number Diff line Loading @@ -1294,8 +1294,11 @@ public final class ActivityThread extends ClientTransactionHandler } @Override public void scheduleCrash(String msg, int typeId) { sendMessage(H.SCHEDULE_CRASH, msg, typeId); public void scheduleCrash(String msg, int typeId, @Nullable Bundle extras) { SomeArgs args = SomeArgs.obtain(); args.arg1 = msg; args.arg2 = extras; sendMessage(H.SCHEDULE_CRASH, args, typeId); } public void dumpActivity(ParcelFileDescriptor pfd, IBinder activitytoken, Loading Loading @@ -1925,11 +1928,11 @@ public final class ActivityThread extends ClientTransactionHandler } } private void throwRemoteServiceException(String message, int typeId) { private void throwRemoteServiceException(String message, int typeId, @Nullable Bundle extras) { // Use a switch to ensure all the type IDs are unique. switch (typeId) { case ForegroundServiceDidNotStartInTimeException.TYPE_ID: throw new ForegroundServiceDidNotStartInTimeException(message); throw generateForegroundServiceDidNotStartInTimeException(message, extras); case CannotDeliverBroadcastException.TYPE_ID: throw new CannotDeliverBroadcastException(message); Loading @@ -1952,6 +1955,15 @@ public final class ActivityThread extends ClientTransactionHandler } } private ForegroundServiceDidNotStartInTimeException generateForegroundServiceDidNotStartInTimeException(String message, Bundle extras) { final String serviceClassName = ForegroundServiceDidNotStartInTimeException.getServiceClassNameFromExtras(extras); final Exception inner = (serviceClassName == null) ? null : Service.getStartForegroundServiceStackTrace(serviceClassName); throw new ForegroundServiceDidNotStartInTimeException(message, inner); } class H extends Handler { public static final int BIND_APPLICATION = 110; @UnsupportedAppUsage Loading Loading @@ -2169,9 +2181,14 @@ public final class ActivityThread extends ClientTransactionHandler handleDispatchPackageBroadcast(msg.arg1, (String[])msg.obj); Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); break; case SCHEDULE_CRASH: throwRemoteServiceException((String) msg.obj, msg.arg1); case SCHEDULE_CRASH: { SomeArgs args = (SomeArgs) msg.obj; String message = (String) args.arg1; Bundle extras = (Bundle) args.arg2; args.recycle(); throwRemoteServiceException(message, msg.arg1, extras); break; } case DUMP_HEAP: handleDumpHeap((DumpHeapData) msg.obj); break; Loading core/java/android/app/ContextImpl.java +8 −0 Original line number Diff line number Diff line Loading @@ -1862,6 +1862,14 @@ class ContextImpl extends Context { "Not allowed to start service " + service + ": " + cn.getClassName()); } } // If we started a foreground service in the same package, remember the stack trace. if (cn != null && requireForeground) { if (cn.getPackageName().equals(getOpPackageName())) { Service.setStartForegroundServiceStackTrace(cn.getClassName(), new StackTrace("Last startServiceCommon() call for this service was " + "made here")); } } return cn; } catch (RemoteException e) { throw e.rethrowFromSystemServer(); Loading core/java/android/app/IActivityManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -321,6 +321,8 @@ interface IActivityManager { boolean isTopActivityImmersive(); void crashApplicationWithType(int uid, int initialPid, in String packageName, int userId, in String message, boolean force, int exceptionTypeId); void crashApplicationWithTypeWithExtras(int uid, int initialPid, in String packageName, int userId, in String message, boolean force, int exceptionTypeId, in Bundle extras); /** @deprecated -- use getProviderMimeTypeAsync */ @UnsupportedAppUsage(maxTargetSdk = 29, publicAlternatives = "Use {@link android.content.ContentResolver#getType} public API instead.") Loading core/java/android/app/IApplicationThread.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -107,7 +107,7 @@ oneway interface IApplicationThread { void scheduleOnNewActivityOptions(IBinder token, in Bundle options); void scheduleSuicide(); void dispatchPackageBroadcast(int cmd, in String[] packages); void scheduleCrash(in String msg, int typeId); void scheduleCrash(in String msg, int typeId, in Bundle extras); void dumpHeap(boolean managed, boolean mallocInfo, boolean runGc, in String path, in ParcelFileDescriptor fd, in RemoteCallback finishCallback); void dumpActivity(in ParcelFileDescriptor fd, IBinder servicetoken, in String prefix, Loading core/java/android/app/RemoteServiceException.java +23 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,10 @@ package android.app; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.ComponentName; import android.os.Bundle; import android.util.AndroidRuntimeException; /** Loading @@ -33,6 +37,10 @@ public class RemoteServiceException extends AndroidRuntimeException { super(msg); } public RemoteServiceException(String msg, Throwable cause) { super(msg, cause); } /** * Exception used to crash an app process when it didn't call {@link Service#startForeground} * in time after the service was started with Loading @@ -44,8 +52,21 @@ public class RemoteServiceException extends AndroidRuntimeException { /** The type ID passed to {@link IApplicationThread#scheduleCrash}. */ public static final int TYPE_ID = 1; public ForegroundServiceDidNotStartInTimeException(String msg) { super(msg); private static final String KEY_SERVICE_CLASS_NAME = "serviceclassname"; public ForegroundServiceDidNotStartInTimeException(String msg, Throwable cause) { super(msg, cause); } public static Bundle createExtrasForService(@NonNull ComponentName service) { Bundle b = new Bundle(); b.putString(KEY_SERVICE_CLASS_NAME, service.getClassName()); return b; } @Nullable public static String getServiceClassNameFromExtras(@Nullable Bundle extras) { return (extras == null) ? null : extras.getString(KEY_SERVICE_CLASS_NAME); } } Loading Loading
core/java/android/app/ActivityThread.java +23 −6 Original line number Diff line number Diff line Loading @@ -1294,8 +1294,11 @@ public final class ActivityThread extends ClientTransactionHandler } @Override public void scheduleCrash(String msg, int typeId) { sendMessage(H.SCHEDULE_CRASH, msg, typeId); public void scheduleCrash(String msg, int typeId, @Nullable Bundle extras) { SomeArgs args = SomeArgs.obtain(); args.arg1 = msg; args.arg2 = extras; sendMessage(H.SCHEDULE_CRASH, args, typeId); } public void dumpActivity(ParcelFileDescriptor pfd, IBinder activitytoken, Loading Loading @@ -1925,11 +1928,11 @@ public final class ActivityThread extends ClientTransactionHandler } } private void throwRemoteServiceException(String message, int typeId) { private void throwRemoteServiceException(String message, int typeId, @Nullable Bundle extras) { // Use a switch to ensure all the type IDs are unique. switch (typeId) { case ForegroundServiceDidNotStartInTimeException.TYPE_ID: throw new ForegroundServiceDidNotStartInTimeException(message); throw generateForegroundServiceDidNotStartInTimeException(message, extras); case CannotDeliverBroadcastException.TYPE_ID: throw new CannotDeliverBroadcastException(message); Loading @@ -1952,6 +1955,15 @@ public final class ActivityThread extends ClientTransactionHandler } } private ForegroundServiceDidNotStartInTimeException generateForegroundServiceDidNotStartInTimeException(String message, Bundle extras) { final String serviceClassName = ForegroundServiceDidNotStartInTimeException.getServiceClassNameFromExtras(extras); final Exception inner = (serviceClassName == null) ? null : Service.getStartForegroundServiceStackTrace(serviceClassName); throw new ForegroundServiceDidNotStartInTimeException(message, inner); } class H extends Handler { public static final int BIND_APPLICATION = 110; @UnsupportedAppUsage Loading Loading @@ -2169,9 +2181,14 @@ public final class ActivityThread extends ClientTransactionHandler handleDispatchPackageBroadcast(msg.arg1, (String[])msg.obj); Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); break; case SCHEDULE_CRASH: throwRemoteServiceException((String) msg.obj, msg.arg1); case SCHEDULE_CRASH: { SomeArgs args = (SomeArgs) msg.obj; String message = (String) args.arg1; Bundle extras = (Bundle) args.arg2; args.recycle(); throwRemoteServiceException(message, msg.arg1, extras); break; } case DUMP_HEAP: handleDumpHeap((DumpHeapData) msg.obj); break; Loading
core/java/android/app/ContextImpl.java +8 −0 Original line number Diff line number Diff line Loading @@ -1862,6 +1862,14 @@ class ContextImpl extends Context { "Not allowed to start service " + service + ": " + cn.getClassName()); } } // If we started a foreground service in the same package, remember the stack trace. if (cn != null && requireForeground) { if (cn.getPackageName().equals(getOpPackageName())) { Service.setStartForegroundServiceStackTrace(cn.getClassName(), new StackTrace("Last startServiceCommon() call for this service was " + "made here")); } } return cn; } catch (RemoteException e) { throw e.rethrowFromSystemServer(); Loading
core/java/android/app/IActivityManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -321,6 +321,8 @@ interface IActivityManager { boolean isTopActivityImmersive(); void crashApplicationWithType(int uid, int initialPid, in String packageName, int userId, in String message, boolean force, int exceptionTypeId); void crashApplicationWithTypeWithExtras(int uid, int initialPid, in String packageName, int userId, in String message, boolean force, int exceptionTypeId, in Bundle extras); /** @deprecated -- use getProviderMimeTypeAsync */ @UnsupportedAppUsage(maxTargetSdk = 29, publicAlternatives = "Use {@link android.content.ContentResolver#getType} public API instead.") Loading
core/java/android/app/IApplicationThread.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -107,7 +107,7 @@ oneway interface IApplicationThread { void scheduleOnNewActivityOptions(IBinder token, in Bundle options); void scheduleSuicide(); void dispatchPackageBroadcast(int cmd, in String[] packages); void scheduleCrash(in String msg, int typeId); void scheduleCrash(in String msg, int typeId, in Bundle extras); void dumpHeap(boolean managed, boolean mallocInfo, boolean runGc, in String path, in ParcelFileDescriptor fd, in RemoteCallback finishCallback); void dumpActivity(in ParcelFileDescriptor fd, IBinder servicetoken, in String prefix, Loading
core/java/android/app/RemoteServiceException.java +23 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,10 @@ package android.app; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.ComponentName; import android.os.Bundle; import android.util.AndroidRuntimeException; /** Loading @@ -33,6 +37,10 @@ public class RemoteServiceException extends AndroidRuntimeException { super(msg); } public RemoteServiceException(String msg, Throwable cause) { super(msg, cause); } /** * Exception used to crash an app process when it didn't call {@link Service#startForeground} * in time after the service was started with Loading @@ -44,8 +52,21 @@ public class RemoteServiceException extends AndroidRuntimeException { /** The type ID passed to {@link IApplicationThread#scheduleCrash}. */ public static final int TYPE_ID = 1; public ForegroundServiceDidNotStartInTimeException(String msg) { super(msg); private static final String KEY_SERVICE_CLASS_NAME = "serviceclassname"; public ForegroundServiceDidNotStartInTimeException(String msg, Throwable cause) { super(msg, cause); } public static Bundle createExtrasForService(@NonNull ComponentName service) { Bundle b = new Bundle(); b.putString(KEY_SERVICE_CLASS_NAME, service.getClassName()); return b; } @Nullable public static String getServiceClassNameFromExtras(@Nullable Bundle extras) { return (extras == null) ? null : extras.getString(KEY_SERVICE_CLASS_NAME); } } Loading