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

Commit 9dae6663 authored by Winson Chung's avatar Winson Chung Committed by android-build-merger
Browse files

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

am: 4d270b6d

Change-Id: I078a3353667dec6895bdf66e768ebc6019d3ef4e
parents 06832e0c 4d270b6d
Loading
Loading
Loading
Loading
+21 −18
Original line number Diff line number Diff line
@@ -5152,33 +5152,36 @@ public class ActivityManagerService extends IActivityManager.Stub
        enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "startRecentsActivity()");
        final long origId = Binder.clearCallingIdentity();
        try {
            final int recentsUid;
            final String recentsPackage;
            final List<IBinder> topVisibleActivities;
            synchronized (this) {
                final int recentsUid = mRecentTasks.getRecentsComponentUid();
                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
                // starting the activity
                // Start a new recents animation
                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) {
                final AppOpsManager appOpsManager = (AppOpsManager)
                        mContext.getSystemService(Context.APP_OPS_SERVICE);
                final AssistDataReceiverProxy proxy = new AssistDataReceiverProxy(
                        assistDataReceiver, recentsPackage);
                final AssistDataRequester requester = new AssistDataRequester(mContext, this,
                            mWindowManager, appOpsManager, proxy, this,
                            OP_ASSIST_STRUCTURE, OP_NONE);
                    requester.requestAssistData(mStackSupervisor.getTopVisibleActivities(),
                        mWindowManager, appOpsManager, proxy, this, OP_ASSIST_STRUCTURE, OP_NONE);
                requester.requestAssistData(topVisibleActivities,
                        true /* fetchData */, false /* fetchScreenshots */,
                            true /* allowFetchData */, false /* alloweFetchScreenshots */,
                        true /* allowFetchData */, false /* allowFetchScreenshots */,
                        recentsUid, recentsPackage);
            }
                // Start a new recents animation
                final RecentsAnimation anim = new RecentsAnimation(this, mStackSupervisor,
                        mActivityStartController, mWindowManager, mUserController);
                anim.startRecentsActivity(intent, recentsAnimationRunner, recentsComponent,
                        recentsUid);
            }
        } finally {
            Binder.restoreCallingIdentity(origId);
        }