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

Commit b7ab3a76 authored by Mady Mellor's avatar Mady Mellor
Browse files

Add locus id to ActivityRecord / TaskInfo

- Bubbles needs to know if a task has a LocusId for the
  Suppress Bubble API
- Apps can already set a locusId on the activity, this
  occurs after the activity has been created.
- This CL adds the locusId to the ActivityRecord and
  triggers a task info change
- TaskInfo uses the top activity in the stack to populate
  the locusId

Bug: 170267239
Test: atest NotificationManagerTest (in CTS CL)
Change-Id: I33cf784e3f3f89835d91e31961b3abe7a7b68c8d
parent e0532b99
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.annotation.TestApi;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.ComponentName;
import android.content.Intent;
import android.content.LocusId;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.Point;
@@ -122,6 +123,13 @@ public class TaskInfo {
    @Nullable
    public ActivityManager.TaskDescription taskDescription;

    /**
     * The locusId of the task.
     * @hide
     */
    @Nullable
    public LocusId mTopActivityLocusId;

    /**
     * True if the task can go in the split-screen primary stack.
     * @hide
@@ -381,6 +389,7 @@ public class TaskInfo {
        isVisible = source.readBoolean();
        topActivityToken = source.readStrongBinder();
        topActivityInSizeCompat = source.readBoolean();
        mTopActivityLocusId = source.readTypedObject(LocusId.CREATOR);
    }

    /**
@@ -417,6 +426,7 @@ public class TaskInfo {
        dest.writeBoolean(isVisible);
        dest.writeStrongBinder(topActivityToken);
        dest.writeBoolean(topActivityInSizeCompat);
        dest.writeTypedObject(mTopActivityLocusId, flags);
    }

    @Override
@@ -443,6 +453,7 @@ public class TaskInfo {
                + " isVisible=" + isVisible
                + " topActivityToken=" + topActivityToken
                + " topActivityInSizeCompat=" + topActivityInSizeCompat
                + " locusId= " + mTopActivityLocusId
                + "}";
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -16615,7 +16615,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            throw new SecurityException("Calling uid " + callingUid + " cannot set locusId"
                    + "for package " + activity.getPackageName());
        }
        mActivityTaskManager.setLocusId(locusId, appToken);
        if (mUsageStatsService != null) {
            mUsageStatsService.reportLocusUpdate(activity, userId, locusId, appToken);
        }
+15 −0
Original line number Diff line number Diff line
@@ -249,6 +249,7 @@ import android.app.servertransaction.TransferSplashScreenViewStateItem;
import android.app.usage.UsageEvents.Event;
import android.content.ComponentName;
import android.content.Intent;
import android.content.LocusId;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.res.CompatibilityInfo;
@@ -548,6 +549,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

    TaskDescription taskDescription; // the recents information for this activity

    // The locusId associated with this activity, if set.
    private LocusId mLocusId;

    // These configurations are collected from application's resources based on size-sensitive
    // qualifiers. For example, layout-w800dp will be added to mHorizontalSizeConfigurations as 800
    // and drawable-sw400dp will be added to both as 400.
@@ -6129,6 +6133,17 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        getTask().updateTaskDescription();
    }

    void setLocusId(LocusId locusId) {
        if (Objects.equals(locusId, mLocusId)) return;
        mLocusId = locusId;
        final Task task = getTask();
        if (task != null) getTask().dispatchTaskInfoChangedIfNeeded(false /* force */);
    }

    LocusId getLocusId() {
        return mLocusId;
    }

    void setVoiceSessionLocked(IVoiceInteractionSession session) {
        voiceSession = session;
        pendingVoiceInteractionStart = false;
+16 −0
Original line number Diff line number Diff line
@@ -161,6 +161,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.IIntentSender;
import android.content.Intent;
import android.content.LocusId;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.ConfigurationInfo;
@@ -1947,6 +1948,21 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        }
    }

    /**
     * Sets the locusId for a particular activity.
     *
     * @param locusId the locusId to set.
     * @param appToken the ActivityRecord's appToken.
     */
    public void setLocusId(LocusId locusId, IBinder appToken) {
        synchronized (mGlobalLock) {
            final ActivityRecord r = ActivityRecord.isInRootTaskLocked(appToken);
            if (r != null) {
                r.setLocusId(locusId);
            }
        }
    }

    NeededUriGrants collectGrants(Intent intent, ActivityRecord target) {
        if (target != null) {
            return mUgmInternal.checkGrantUriPermissionFromIntent(intent,
+2 −0
Original line number Diff line number Diff line
@@ -4239,6 +4239,8 @@ class Task extends WindowContainer<WindowContainer> {
                : INVALID_TASK_ID;
        info.isFocused = isFocused();
        info.isVisible = hasVisibleChildren();
        ActivityRecord topRecord = getTopNonFinishingActivity();
        info.mTopActivityLocusId = topRecord != null ? topRecord.getLocusId() : null;
    }

    @Nullable PictureInPictureParams getPictureInPictureParams() {
Loading