Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 779f120a authored by Makoto Onuki's avatar Makoto Onuki Committed by Android (Google) Code Review
Browse files

Merge "Use descriptive exception for FGS start timeout" into sc-dev

parents d05767a0 9de6e4e2
Loading
Loading
Loading
Loading
+16 −9
Original line number Diff line number Diff line
@@ -236,12 +236,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;

final class RemoteServiceException extends AndroidRuntimeException {
    public RemoteServiceException(String msg) {
        super(msg);
    }
}

/**
 * This manages the execution of the main thread in an
 * application process, scheduling and executing activities,
@@ -1274,8 +1268,9 @@ public final class ActivityThread extends ClientTransactionHandler
            sendMessage(H.DISPATCH_PACKAGE_BROADCAST, packages, cmd);
        }

        public void scheduleCrash(String msg) {
            sendMessage(H.SCHEDULE_CRASH, msg);
        @Override
        public void scheduleCrash(String msg, int typeId) {
            sendMessage(H.SCHEDULE_CRASH, msg, typeId);
        }

        public void dumpActivity(ParcelFileDescriptor pfd, IBinder activitytoken,
@@ -1892,6 +1887,17 @@ public final class ActivityThread extends ClientTransactionHandler
        }
    }

    private void throwRemoteServiceException(String message, int typeId) {
        // Use a switch to ensure all the type IDs are unique.
        switch (typeId) {
            case ForegroundServiceDidNotStartInTimeException.TYPE_ID: // 1
                throw new ForegroundServiceDidNotStartInTimeException(message);
            case RemoteServiceException.TYPE_ID: // 0
            default:
                throw new RemoteServiceException(message);
        }
    }

    class H extends Handler {
        public static final int BIND_APPLICATION        = 110;
        @UnsupportedAppUsage
@@ -2105,7 +2111,8 @@ public final class ActivityThread extends ClientTransactionHandler
                    Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
                    break;
                case SCHEDULE_CRASH:
                    throw new RemoteServiceException((String)msg.obj);
                    throwRemoteServiceException((String) msg.obj, msg.arg1);
                    break;
                case DUMP_HEAP:
                    handleDumpHeap((DumpHeapData) msg.obj);
                    break;
+33 −0
Original line number Diff line number Diff line
/*
 * 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;

/**
 * Exception used to crash an app process when it didn't call {@link Service#startForeground}
 * in time after the service was started with
 * {@link android.content.Context#startForegroundService}.
 *
 * @hide
 */
public class ForegroundServiceDidNotStartInTimeException extends RemoteServiceException {
    /** The type ID passed to {@link IApplicationThread#scheduleCrash}. */
    public static final int TYPE_ID = 1;

    public ForegroundServiceDidNotStartInTimeException(String msg) {
        super(msg);
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -321,6 +321,8 @@ interface IActivityManager {
    boolean isTopActivityImmersive();
    void crashApplication(int uid, int initialPid, in String packageName, int userId,
            in String message, boolean force);
    void crashApplicationWithType(int uid, int initialPid, in String packageName, int userId,
            in String message, boolean force, int exceptionTypeId);
    /** @deprecated -- use getProviderMimeTypeAsync */
    @UnsupportedAppUsage(maxTargetSdk = 29, publicAlternatives =
            "Use {@link android.content.ContentResolver#getType} public API instead.")
+1 −1
Original line number Diff line number Diff line
@@ -106,7 +106,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);
    void scheduleCrash(in String msg, int typeId);
    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,
+38 −0
Original line number Diff line number Diff line
/*
 * 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);
    }
}
Loading