Merge changes I28f7ac47,If075675e into oc-dev am: 4f5c38b357
am: 97fb03ca2f
Change-Id: I7fb14effb541dc5329e25a1fd026ad1372346f98
diff --git a/packages/SystemUI/src/com/android/systemui/RecentsComponent.java b/packages/SystemUI/src/com/android/systemui/RecentsComponent.java
index cdad8ae..44a044b 100644
--- a/packages/SystemUI/src/com/android/systemui/RecentsComponent.java
+++ b/packages/SystemUI/src/com/android/systemui/RecentsComponent.java
@@ -22,9 +22,6 @@
public interface RecentsComponent {
void showRecentApps(boolean triggeredFromAltTab, boolean fromHome);
- void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey);
- void toggleRecents();
- void preloadRecents();
void showNextAffiliatedTask();
void showPrevAffiliatedTask();
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java
index 0da4681..5ca9fa5 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java
@@ -70,7 +70,7 @@
TaskStackListener mTaskStackListener = new TaskStackListener() {
@Override
public void onActivityPinned(String packageName, int taskId) {
- if (!checkCurrentUserId(false /* debug */)) {
+ if (!checkCurrentUserId(mContext, false /* debug */)) {
return;
}
@@ -85,7 +85,7 @@
@Override
public void onActivityUnpinned() {
- if (!checkCurrentUserId(false /* debug */)) {
+ if (!checkCurrentUserId(mContext, false /* debug */)) {
return;
}
@@ -114,7 +114,7 @@
@Override
public void onPinnedActivityRestartAttempt(boolean clearedTask) {
- if (!checkCurrentUserId(false /* debug */)) {
+ if (!checkCurrentUserId(mContext, false /* debug */)) {
return;
}
diff --git a/packages/SystemUI/src/com/android/systemui/pip/tv/PipManager.java b/packages/SystemUI/src/com/android/systemui/pip/tv/PipManager.java
index 1c5da4d..6490b33 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/tv/PipManager.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/tv/PipManager.java
@@ -577,7 +577,7 @@
@Override
public void onTaskStackChanged() {
if (DEBUG) Log.d(TAG, "onTaskStackChanged()");
- if (!checkCurrentUserId(DEBUG)) {
+ if (!checkCurrentUserId(mContext, DEBUG)) {
return;
}
if (getState() != STATE_NO_PIP) {
@@ -614,7 +614,7 @@
@Override
public void onActivityPinned(String packageName, int taskId) {
if (DEBUG) Log.d(TAG, "onActivityPinned()");
- if (!checkCurrentUserId(DEBUG)) {
+ if (!checkCurrentUserId(mContext, DEBUG)) {
return;
}
StackInfo stackInfo = getPinnedStackInfo();
@@ -641,7 +641,7 @@
@Override
public void onPinnedActivityRestartAttempt(boolean clearedTask) {
if (DEBUG) Log.d(TAG, "onPinnedActivityRestartAttempt()");
- if (!checkCurrentUserId(DEBUG)) {
+ if (!checkCurrentUserId(mContext, DEBUG)) {
return;
}
// If PIPed activity is launched again by Launcher or intent, make it fullscreen.
@@ -651,7 +651,7 @@
@Override
public void onPinnedStackAnimationEnded() {
if (DEBUG) Log.d(TAG, "onPinnedStackAnimationEnded()");
- if (!checkCurrentUserId(DEBUG)) {
+ if (!checkCurrentUserId(mContext, DEBUG)) {
return;
}
switch (getState()) {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/Recents.java b/packages/SystemUI/src/com/android/systemui/recents/Recents.java
index 72dd2da..9ba32b3 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/Recents.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/Recents.java
@@ -19,7 +19,6 @@
import static com.android.systemui.statusbar.phone.StatusBar.SYSTEM_DIALOG_REASON_RECENT_APPS;
import android.app.ActivityManager;
-import android.app.UiModeManager;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
@@ -33,7 +32,6 @@
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
-import android.os.Looper;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.os.UserHandle;
@@ -41,7 +39,6 @@
import android.util.EventLog;
import android.util.Log;
import android.view.Display;
-import android.view.WindowManager;
import android.widget.Toast;
import com.android.internal.logging.MetricsLogger;
@@ -60,11 +57,12 @@
import com.android.systemui.recents.events.component.ShowUserToastEvent;
import com.android.systemui.recents.events.ui.RecentsDrawnEvent;
import com.android.systemui.recents.misc.SystemServicesProxy;
-import com.android.systemui.recents.model.HighResThumbnailLoader;
import com.android.systemui.recents.model.RecentsTaskLoader;
import com.android.systemui.stackdivider.Divider;
import com.android.systemui.statusbar.CommandQueue;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
@@ -322,16 +320,11 @@
}
}
- @Override
- public void toggleRecentApps() {
- toggleRecents();
- }
-
/**
* Toggles the Recents activity.
*/
@Override
- public void toggleRecents() {
+ public void toggleRecentApps() {
// Ensure the device has been provisioned before allowing the user to interact with
// recents
if (!isUserSetup()) {
@@ -368,7 +361,7 @@
* Preloads info for the Recents activity.
*/
@Override
- public void preloadRecents() {
+ public void preloadRecentApps() {
// Ensure the device has been provisioned before allowing the user to interact with
// recents
if (!isUserSetup()) {
@@ -792,4 +785,10 @@
}
return false;
}
+
+ @Override
+ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ pw.println("Recents");
+ pw.println(" currentUserId=" + SystemServicesProxy.getInstance(mContext).getCurrentUser());
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java
index e229c90..a903f38 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java
@@ -119,6 +119,11 @@
@Override
public void onTaskStackChangedBackground() {
+ // Check this is for the right user
+ if (!checkCurrentUserId(mContext, false /* debug */)) {
+ return;
+ }
+
// Preloads the next task
RecentsConfiguration config = Recents.getConfiguration();
if (config.svelteLevel == RecentsConfiguration.SVELTE_NONE) {
@@ -161,6 +166,11 @@
@Override
public void onActivityPinned(String packageName, int taskId) {
+ // Check this is for the right user
+ if (!checkCurrentUserId(mContext, false /* debug */)) {
+ return;
+ }
+
// This time needs to be fetched the same way the last active time is fetched in
// {@link TaskRecord#touchActiveTime}
Recents.getConfiguration().getLaunchState().launchedFromPipApp = true;
@@ -172,12 +182,22 @@
@Override
public void onActivityUnpinned() {
+ // Check this is for the right user
+ if (!checkCurrentUserId(mContext, false /* debug */)) {
+ return;
+ }
+
EventBus.getDefault().send(new ActivityUnpinnedEvent());
sLastPipTime = -1;
}
@Override
public void onTaskSnapshotChanged(int taskId, TaskSnapshot snapshot) {
+ // Check this is for the right user
+ if (!checkCurrentUserId(mContext, false /* debug */)) {
+ return;
+ }
+
EventBus.getDefault().send(new TaskSnapshotChangedEvent(taskId, snapshot));
}
}
@@ -413,30 +433,34 @@
public void preloadRecents() {
// Preload only the raw task list into a new load plan (which will be consumed by the
- // RecentsActivity) only if there is a task to animate to.
- SystemServicesProxy ssp = Recents.getSystemServices();
- MutableBoolean isHomeStackVisible = new MutableBoolean(true);
- if (!ssp.isRecentsActivityVisible(isHomeStackVisible)) {
- ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
- if (runningTask == null) {
- return;
- }
+ // RecentsActivity) only if there is a task to animate to. Post this to ensure that we
+ // don't block the touch feedback on the nav bar button which triggers this.
+ mHandler.post(() -> {
+ SystemServicesProxy ssp = Recents.getSystemServices();
+ MutableBoolean isHomeStackVisible = new MutableBoolean(true);
+ if (!ssp.isRecentsActivityVisible(isHomeStackVisible)) {
+ ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
+ if (runningTask == null) {
+ return;
+ }
- RecentsTaskLoader loader = Recents.getTaskLoader();
- sInstanceLoadPlan = loader.createLoadPlan(mContext);
- loader.preloadTasks(sInstanceLoadPlan, runningTask.id, !isHomeStackVisible.value);
- TaskStack stack = sInstanceLoadPlan.getTaskStack();
- if (stack.getTaskCount() > 0) {
- // Only preload the icon (but not the thumbnail since it may not have been taken for
- // the pausing activity)
- preloadIcon(runningTask.id);
+ RecentsTaskLoader loader = Recents.getTaskLoader();
+ sInstanceLoadPlan = loader.createLoadPlan(mContext);
+ loader.preloadTasks(sInstanceLoadPlan, runningTask.id, !isHomeStackVisible.value);
+ TaskStack stack = sInstanceLoadPlan.getTaskStack();
+ if (stack.getTaskCount() > 0) {
+ // Only preload the icon (but not the thumbnail since it may not have been taken
+ // for the pausing activity)
+ preloadIcon(runningTask.id);
- // At this point, we don't know anything about the stack state. So only calculate
- // the dimensions of the thumbnail that we need for the transition into Recents, but
- // do not draw it until we construct the activity options when we start Recents
- updateHeaderBarLayout(stack, null /* window rect override*/);
+ // At this point, we don't know anything about the stack state. So only
+ // calculate the dimensions of the thumbnail that we need for the transition
+ // into Recents, but do not draw it until we construct the activity options when
+ // we start Recents
+ updateHeaderBarLayout(stack, null /* window rect override*/);
+ }
}
- }
+ });
}
public void cancelPreloadingRecents() {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
index a155a71..cbfa0e5 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
@@ -85,7 +85,6 @@
import com.android.internal.app.AssistUtils;
import com.android.internal.os.BackgroundThread;
-import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.UiOffloadThread;
@@ -95,6 +94,8 @@
import com.android.systemui.recents.RecentsImpl;
import com.android.systemui.recents.model.Task;
import com.android.systemui.recents.model.ThumbnailData;
+import com.android.systemui.statusbar.policy.UserInfoController;
+import com.android.systemui.statusbar.policy.UserInfoController.OnUserInfoChangedListener;
import java.io.IOException;
import java.util.ArrayList;
@@ -102,8 +103,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Random;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
/**
* Acts as a shim around the real system services that we need to access data from, and provides
@@ -143,6 +142,7 @@
Display mDisplay;
String mRecentsPackage;
ComponentName mAssistComponent;
+ private int mCurrentUserId;
boolean mIsSafeMode;
boolean mHasFreeformWorkspaceSupport;
@@ -185,9 +185,9 @@
* TaskStackListener should make this call to verify that we don't act on events from other
* user's processes.
*/
- protected final boolean checkCurrentUserId(boolean debug) {
+ protected final boolean checkCurrentUserId(Context context, boolean debug) {
int processUserId = UserHandle.myUserId();
- int currentUserId = KeyguardUpdateMonitor.getCurrentUser();
+ int currentUserId = SystemServicesProxy.getInstance(context).getCurrentUser();
if (processUserId != currentUserId) {
if (debug) {
Log.d(TAG, "UID mismatch. SystemUI is running uid=" + processUserId
@@ -284,6 +284,10 @@
}
};
+ private final UserInfoController.OnUserInfoChangedListener mOnUserInfoChangedListener =
+ (String name, Drawable picture, String userAccount) ->
+ mCurrentUserId = mAm.getCurrentUser();
+
/**
* List of {@link TaskStackListener} registered from {@link #registerTaskStackListener}.
*/
@@ -312,6 +316,7 @@
Settings.Global.getInt(context.getContentResolver(),
DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT, 0) != 0;
mIsSafeMode = mPm.isSafeMode();
+ mCurrentUserId = mAm.getCurrentUser();
// Get the dummy thumbnail width/heights
Resources res = context.getResources();
@@ -329,6 +334,12 @@
// Resolve the assist intent
mAssistComponent = mAssistUtils.getAssistComponentForUser(UserHandle.myUserId());
+ // Since SystemServicesProxy can be accessed from a per-SysUI process component, create a
+ // per-process listener to keep track of the current user id to reduce the number of binder
+ // calls to fetch it.
+ UserInfoController userInfoController = Dependency.get(UserInfoController.class);
+ userInfoController.addCallback(mOnUserInfoChangedListener);
+
if (RecentsDebugFlags.Static.EnableMockTasks) {
// Create a dummy icon
mDummyIcon = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
@@ -1029,15 +1040,11 @@
}
/**
- * Returns the current user id.
+ * Returns the current user id. Used instead of KeyguardUpdateMonitor in SystemUI components
+ * that run in the non-primary SystemUI process.
*/
public int getCurrentUser() {
- if (mAm == null) return 0;
-
- // This must call through ActivityManager, as the SystemServicesProxy can be called in a
- // secondary user's SystemUI process, and KeyguardUpdateMonitor is only updated in the
- // primary user's SystemUI process
- return mAm.getCurrentUser();
+ return mCurrentUserId;
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java
index ed09640..93033ea 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java
@@ -22,7 +22,6 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.UserInfo;
import android.content.res.Resources;
-import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.os.UserHandle;
import android.os.UserManager;
@@ -33,15 +32,13 @@
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;
-import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.Prefs;
import com.android.systemui.R;
import com.android.systemui.recents.Recents;
-import com.android.systemui.recents.RecentsConfiguration;
import com.android.systemui.recents.RecentsDebugFlags;
import com.android.systemui.recents.misc.SystemServicesProxy;
-
import com.android.systemui.recents.views.grid.TaskGridLayoutAlgorithm;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;