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

Commit 4d270b6d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Don't hold AM lock during assist data request." into pi-dev

parents 7ad26e4b 7dbdbc85
Loading
Loading
Loading
Loading
+21 −18
Original line number Original line Diff line number Diff line
@@ -5152,33 +5152,36 @@ public class ActivityManagerService extends IActivityManager.Stub
        enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "startRecentsActivity()");
        enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "startRecentsActivity()");
        final long origId = Binder.clearCallingIdentity();
        final long origId = Binder.clearCallingIdentity();
        try {
        try {
            final int recentsUid;
            final String recentsPackage;
            final List<IBinder> topVisibleActivities;
            synchronized (this) {
            synchronized (this) {
                final int recentsUid = mRecentTasks.getRecentsComponentUid();
                final ComponentName recentsComponent = mRecentTasks.getRecentsComponent();
                final ComponentName recentsComponent = mRecentTasks.getRecentsComponent();
                final String recentsPackage = recentsComponent.getPackageName();
                recentsPackage = recentsComponent.getPackageName();
                recentsUid = mRecentTasks.getRecentsComponentUid();
                topVisibleActivities = mStackSupervisor.getTopVisibleActivities();
                // If provided, kick off the request for the assist data in the background before
                // Start a new recents animation
                // starting the activity
                final RecentsAnimation anim = new RecentsAnimation(this, mStackSupervisor,
                        mActivityStartController, mWindowManager, mUserController);
                anim.startRecentsActivity(intent, recentsAnimationRunner, recentsComponent,
                        recentsUid);
            }
            // If provided, kick off the request for the assist data in the background. Do not hold
            // the AM lock as this will just proxy directly to the assist data receiver provided.
            if (assistDataReceiver != null) {
            if (assistDataReceiver != null) {
                final AppOpsManager appOpsManager = (AppOpsManager)
                final AppOpsManager appOpsManager = (AppOpsManager)
                        mContext.getSystemService(Context.APP_OPS_SERVICE);
                        mContext.getSystemService(Context.APP_OPS_SERVICE);
                final AssistDataReceiverProxy proxy = new AssistDataReceiverProxy(
                final AssistDataReceiverProxy proxy = new AssistDataReceiverProxy(
                        assistDataReceiver, recentsPackage);
                        assistDataReceiver, recentsPackage);
                final AssistDataRequester requester = new AssistDataRequester(mContext, this,
                final AssistDataRequester requester = new AssistDataRequester(mContext, this,
                            mWindowManager, appOpsManager, proxy, this,
                        mWindowManager, appOpsManager, proxy, this, OP_ASSIST_STRUCTURE, OP_NONE);
                            OP_ASSIST_STRUCTURE, OP_NONE);
                requester.requestAssistData(topVisibleActivities,
                    requester.requestAssistData(mStackSupervisor.getTopVisibleActivities(),
                        true /* fetchData */, false /* fetchScreenshots */,
                        true /* fetchData */, false /* fetchScreenshots */,
                            true /* allowFetchData */, false /* alloweFetchScreenshots */,
                        true /* allowFetchData */, false /* allowFetchScreenshots */,
                        recentsUid, recentsPackage);
                        recentsUid, recentsPackage);
            }
            }
                // Start a new recents animation
                final RecentsAnimation anim = new RecentsAnimation(this, mStackSupervisor,
                        mActivityStartController, mWindowManager, mUserController);
                anim.startRecentsActivity(intent, recentsAnimationRunner, recentsComponent,
                        recentsUid);
            }
        } finally {
        } finally {
            Binder.restoreCallingIdentity(origId);
            Binder.restoreCallingIdentity(origId);
        }
        }