summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/app/TaskInfo.java11
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java2
-rw-r--r--services/core/java/com/android/server/wm/ActivityRecord.java15
-rw-r--r--services/core/java/com/android/server/wm/ActivityTaskManagerService.java16
-rw-r--r--services/core/java/com/android/server/wm/Task.java2
-rw-r--r--services/core/java/com/android/server/wm/TaskDisplayArea.java2
6 files changed, 46 insertions, 2 deletions
diff --git a/core/java/android/app/TaskInfo.java b/core/java/android/app/TaskInfo.java
index 9019ddf941d9..6ad5eea8b602 100644
--- a/core/java/android/app/TaskInfo.java
+++ b/core/java/android/app/TaskInfo.java
@@ -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;
@@ -123,6 +124,13 @@ public class TaskInfo {
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
+ "}";
}
}
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 29b85acc6825..85cbcdf61e5b 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -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);
}
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index 5d3b9c197267..0545da30ff6d 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -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;
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
index b803fc37a421..819c8e076dd2 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
@@ -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,
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index d60b6e0ef81d..f420c1d03d59 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -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() {
diff --git a/services/core/java/com/android/server/wm/TaskDisplayArea.java b/services/core/java/com/android/server/wm/TaskDisplayArea.java
index badd7fda2897..081a61e85111 100644
--- a/services/core/java/com/android/server/wm/TaskDisplayArea.java
+++ b/services/core/java/com/android/server/wm/TaskDisplayArea.java
@@ -462,7 +462,7 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
mLastLeafTaskToFrontId = t.mTaskId;
EventLogTags.writeWmTaskToFront(t.mUserId, t.mTaskId);
- // Notifying only when a leak task moved to front. Or the listeners would be notified
+ // Notifying only when a leaf task moved to front. Or the listeners would be notified
// couple times from the leaf task all the way up to the root task.
mAtmService.getTaskChangeNotificationController().notifyTaskMovedToFront(t.getTaskInfo());
}