Merge changes I28f7ac47,If075675e into oc-dev
* changes: Fixing regression in Recents preloading. Adding cached value for current user for per-SysUI process components.
This commit is contained in:
@@ -22,9 +22,6 @@ import android.view.View;
|
||||
|
||||
public interface RecentsComponent {
|
||||
void showRecentApps(boolean triggeredFromAltTab, boolean fromHome);
|
||||
void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey);
|
||||
void toggleRecents();
|
||||
void preloadRecents();
|
||||
void showNextAffiliatedTask();
|
||||
void showPrevAffiliatedTask();
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public class PipManager implements BasePipManager {
|
||||
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 @@ public class PipManager implements BasePipManager {
|
||||
|
||||
@Override
|
||||
public void onActivityUnpinned() {
|
||||
if (!checkCurrentUserId(false /* debug */)) {
|
||||
if (!checkCurrentUserId(mContext, false /* debug */)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public class PipManager implements BasePipManager {
|
||||
|
||||
@Override
|
||||
public void onPinnedActivityRestartAttempt(boolean clearedTask) {
|
||||
if (!checkCurrentUserId(false /* debug */)) {
|
||||
if (!checkCurrentUserId(mContext, false /* debug */)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -577,7 +577,7 @@ public class PipManager implements BasePipManager {
|
||||
@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 @@ public class PipManager implements BasePipManager {
|
||||
@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 @@ public class PipManager implements BasePipManager {
|
||||
@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 @@ public class PipManager implements BasePipManager {
|
||||
@Override
|
||||
public void onPinnedStackAnimationEnded() {
|
||||
if (DEBUG) Log.d(TAG, "onPinnedStackAnimationEnded()");
|
||||
if (!checkCurrentUserId(DEBUG)) {
|
||||
if (!checkCurrentUserId(mContext, DEBUG)) {
|
||||
return;
|
||||
}
|
||||
switch (getState()) {
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.systemui.recents;
|
||||
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.hardware.display.DisplayManager;
|
||||
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.provider.Settings;
|
||||
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.ScreenPinningRequestEvent;
|
||||
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 @@ public class Recents extends SystemUI
|
||||
}
|
||||
}
|
||||
|
||||
@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 @@ public class Recents extends SystemUI
|
||||
* 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 @@ public class Recents extends SystemUI
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
||||
pw.println("Recents");
|
||||
pw.println(" currentUserId=" + SystemServicesProxy.getInstance(mContext).getCurrentUser());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,6 +119,11 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
|
||||
|
||||
@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 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
|
||||
|
||||
@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 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
|
||||
|
||||
@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 class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
|
||||
|
||||
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() {
|
||||
|
||||
@@ -85,7 +85,6 @@ import android.view.accessibility.AccessibilityManager;
|
||||
|
||||
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.RecentsDebugFlags;
|
||||
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.Collections;
|
||||
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 @@ public class SystemServicesProxy {
|
||||
Display mDisplay;
|
||||
String mRecentsPackage;
|
||||
ComponentName mAssistComponent;
|
||||
private int mCurrentUserId;
|
||||
|
||||
boolean mIsSafeMode;
|
||||
boolean mHasFreeformWorkspaceSupport;
|
||||
@@ -185,9 +185,9 @@ public class SystemServicesProxy {
|
||||
* 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 @@ public class SystemServicesProxy {
|
||||
}
|
||||
};
|
||||
|
||||
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 @@ public class SystemServicesProxy {
|
||||
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 @@ public class SystemServicesProxy {
|
||||
// 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 @@ public class SystemServicesProxy {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,7 +22,6 @@ import android.content.pm.ActivityInfo;
|
||||
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.SparseArray;
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user