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

Commit 3be4f26e authored by Winson Chung's avatar Winson Chung
Browse files

Fix crash from reporting per-user assist data with swipe up

- In P, we would report the assist data directly to Launcher app which
  would then delegate it to AiAi.  Starting in Q, we have a per-user bound
  service to AiAi for content capture, so we should report the assist data
  for each user.  ag/5523112 incorrectly assumed that we would delegate
  this for the primary user's service.

Bug: 121130875
Test: Repeat a couple times: Launch a work profile app, hit home
Change-Id: I5d58fc4925f0f344045cb41f9c8fd6fbc5472893
parent 4895d8f0
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -134,10 +134,8 @@ class RecentsAnimation implements RecentsAnimationCallbacks,

        mWindowManager.deferSurfaceLayout();
        try {
            final int userId = mService.getCurrentUserId();

            // Kick off the assist data request in the background before showing the target activity
            requestAssistData(recentsComponent, recentsUid, assistDataReceiver, userId);
            requestAssistData(recentsComponent, recentsUid, assistDataReceiver);

            if (hasExistingActivity) {
                // Move the recents activity into place for the animation if it is not top most
@@ -164,7 +162,7 @@ class RecentsAnimation implements RecentsAnimationCallbacks,
                        .setCallingUid(recentsUid)
                        .setCallingPackage(recentsComponent.getPackageName())
                        .setActivityOptions(SafeActivityOptions.fromBundle(options.toBundle()))
                        .setMayWait(userId)
                        .setMayWait(mService.getCurrentUserId())
                        .execute();

                // Move the recents activity into place for the animation
@@ -221,7 +219,7 @@ class RecentsAnimation implements RecentsAnimationCallbacks,
     * Requests assist data for the top visible activities.
     */
    private void requestAssistData(ComponentName recentsComponent, int recentsUid,
            @Deprecated IAssistDataReceiver assistDataReceiver, int userId) {
            @Deprecated IAssistDataReceiver assistDataReceiver) {
        final AppOpsManager appOpsManager = (AppOpsManager)
                mService.mContext.getSystemService(Context.APP_OPS_SERVICE);
        final List<IBinder> topActivities =
@@ -237,8 +235,9 @@ class RecentsAnimation implements RecentsAnimationCallbacks,
                    final ContentCaptureManagerInternal imService =
                            LocalServices.getService(ContentCaptureManagerInternal.class);
                    final IBinder activityToken = topActivities.get(activityIndex);
                    if (imService == null
                            || !imService.sendActivityAssistData(userId, activityToken, data)) {
                    final ActivityRecord r = ActivityRecord.forTokenLocked(activityToken);
                    if (r != null && (imService == null
                            || !imService.sendActivityAssistData(r.mUserId, activityToken, data))) {
                        // Otherwise, use the provided assist data receiver
                        super.onAssistDataReceivedLocked(data, activityIndex, activityCount);
                    }
@@ -263,7 +262,10 @@ class RecentsAnimation implements RecentsAnimationCallbacks,
                        int activityCount) {
                    // Try to notify the intelligence service
                    final IBinder activityToken = topActivities.get(activityIndex);
                    imService.sendActivityAssistData(userId, activityToken, data);
                    final ActivityRecord r = ActivityRecord.forTokenLocked(activityToken);
                    if (r != null) {
                        imService.sendActivityAssistData(r.mUserId, activityToken, data);
                    }
                }
            };
        }