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

Commit 13997f50 authored by Robert Carr's avatar Robert Carr
Browse files

Deliver exceptions to sources of PALs.

Deliver exceptions to sources of pending activity
launches, as this generally indicates programmer
error on the client side.

Change-Id: I4cb5c4a7bdffe2bf5a3cc43c9cba8fec01c9e959
parent 15ca73ac
Loading
Loading
Loading
Loading
+19 −5
Original line number Original line Diff line number Diff line
@@ -364,13 +364,26 @@ public final class ActivityStackSupervisor implements DisplayListener {
        final ActivityRecord sourceRecord;
        final ActivityRecord sourceRecord;
        final int startFlags;
        final int startFlags;
        final ActivityStack stack;
        final ActivityStack stack;
        final ProcessRecord callerApp;


        PendingActivityLaunch(ActivityRecord _r, ActivityRecord _sourceRecord,
        PendingActivityLaunch(ActivityRecord _r, ActivityRecord _sourceRecord,
                int _startFlags, ActivityStack _stack) {
                int _startFlags, ActivityStack _stack, ProcessRecord _callerApp) {
            r = _r;
            r = _r;
            sourceRecord = _sourceRecord;
            sourceRecord = _sourceRecord;
            startFlags = _startFlags;
            startFlags = _startFlags;
            stack = _stack;
            stack = _stack;
            callerApp = _callerApp;
        }

        void sendErrorResult(String message) {
            try {
                if (callerApp.thread != null) {
                    callerApp.thread.scheduleCrash(message);
                }
            } catch (RemoteException e) {
                Slog.e(TAG, "Exception scheduling crash of failed "
                        + "activity launcher sourceRecord=" + sourceRecord, e);
            }
        }
        }
    }
    }


@@ -1668,8 +1681,8 @@ public final class ActivityStackSupervisor implements DisplayListener {
                || stack.mResumedActivity.info.applicationInfo.uid != callingUid)) {
                || stack.mResumedActivity.info.applicationInfo.uid != callingUid)) {
            if (!mService.checkAppSwitchAllowedLocked(callingPid, callingUid,
            if (!mService.checkAppSwitchAllowedLocked(callingPid, callingUid,
                    realCallingPid, realCallingUid, "Activity start")) {
                    realCallingPid, realCallingUid, "Activity start")) {
                PendingActivityLaunch pal =
                PendingActivityLaunch pal =  new PendingActivityLaunch(r, 
                        new PendingActivityLaunch(r, sourceRecord, startFlags, stack);
                        sourceRecord, startFlags, stack, callerApp);
                mPendingActivityLaunches.add(pal);
                mPendingActivityLaunches.add(pal);
                ActivityOptions.abort(options);
                ActivityOptions.abort(options);
                return ActivityManager.START_SWITCHES_CANCELED;
                return ActivityManager.START_SWITCHES_CANCELED;
@@ -2538,7 +2551,8 @@ public final class ActivityStackSupervisor implements DisplayListener {
                startActivityUncheckedLocked(pal.r, pal.sourceRecord, null, null, pal.startFlags,
                startActivityUncheckedLocked(pal.r, pal.sourceRecord, null, null, pal.startFlags,
                        doResume && mPendingActivityLaunches.isEmpty(), null, null);
                        doResume && mPendingActivityLaunches.isEmpty(), null, null);
            } catch (Exception e) {
            } catch (Exception e) {
                Slog.w(TAG, "Exception during pending activity launch pal=" + pal, e);
                Slog.e(TAG, "Exception during pending activity launch pal=" + pal, e);
                pal.sendErrorResult(e.getMessage());
            }
            }
        }
        }
    }
    }