Merge changes I46e93397,Ie0a157a9 into pi-dev
* changes: Also set calling pid when registering for next activity start Revert "Revert "Elevate remote/recents animation priority""
This commit is contained in:
@@ -27,6 +27,7 @@ import android.os.IBinder;
|
||||
import android.os.SystemClock;
|
||||
import android.service.voice.IVoiceInteractionSession;
|
||||
import android.util.SparseIntArray;
|
||||
import android.view.RemoteAnimationAdapter;
|
||||
|
||||
import com.android.internal.app.IVoiceInteractor;
|
||||
|
||||
@@ -263,6 +264,17 @@ public abstract class ActivityManagerInternal {
|
||||
*/
|
||||
public abstract void setHasOverlayUi(int pid, boolean hasOverlayUi);
|
||||
|
||||
/**
|
||||
* Sets if the given pid is currently running a remote animation, which is taken a signal for
|
||||
* determining oom adjustment and scheduling behavior.
|
||||
*
|
||||
* @param pid The pid we are setting overlay UI for.
|
||||
* @param runningRemoteAnimation True if the process is running a remote animation, false
|
||||
* otherwise.
|
||||
* @see RemoteAnimationAdapter
|
||||
*/
|
||||
public abstract void setRunningRemoteAnimation(int pid, boolean runningRemoteAnimation);
|
||||
|
||||
/**
|
||||
* Called after the network policy rules are updated by
|
||||
* {@link com.android.server.net.NetworkPolicyManagerService} for a specific {@param uid} and
|
||||
|
||||
@@ -52,6 +52,9 @@ public class RemoteAnimationAdapter implements Parcelable {
|
||||
private final long mDuration;
|
||||
private final long mStatusBarTransitionDelay;
|
||||
|
||||
/** @see #getCallingPid */
|
||||
private int mCallingPid;
|
||||
|
||||
/**
|
||||
* @param runner The interface that gets notified when we actually need to start the animation.
|
||||
* @param duration The duration of the animation.
|
||||
@@ -83,6 +86,20 @@ public class RemoteAnimationAdapter implements Parcelable {
|
||||
return mStatusBarTransitionDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* To be called by system_server to keep track which pid is running this animation.
|
||||
*/
|
||||
public void setCallingPid(int pid) {
|
||||
mCallingPid = pid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The pid of the process running the animation.
|
||||
*/
|
||||
public int getCallingPid() {
|
||||
return mCallingPid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
|
||||
@@ -70,6 +70,16 @@ public class RemoteAnimationDefinition implements Parcelable {
|
||||
mTransitionAnimationMap = in.readSparseArray(null /* loader */);
|
||||
}
|
||||
|
||||
/**
|
||||
* To be called by system_server to keep track which pid is running the remote animations inside
|
||||
* this definition.
|
||||
*/
|
||||
public void setCallingPid(int pid) {
|
||||
for (int i = mTransitionAnimationMap.size() - 1; i >= 0; i--) {
|
||||
mTransitionAnimationMap.valueAt(i).setCallingPid(pid);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
|
||||
@@ -5150,6 +5150,7 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
public void startRecentsActivity(Intent intent, IAssistDataReceiver assistDataReceiver,
|
||||
IRecentsAnimationRunner recentsAnimationRunner) {
|
||||
enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "startRecentsActivity()");
|
||||
final int callingPid = Binder.getCallingPid();
|
||||
final long origId = Binder.clearCallingIdentity();
|
||||
try {
|
||||
final int recentsUid;
|
||||
@@ -5163,7 +5164,7 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
|
||||
// Start a new recents animation
|
||||
final RecentsAnimation anim = new RecentsAnimation(this, mStackSupervisor,
|
||||
mActivityStartController, mWindowManager, mUserController);
|
||||
mActivityStartController, mWindowManager, mUserController, callingPid);
|
||||
anim.startRecentsActivity(intent, recentsAnimationRunner, recentsComponent,
|
||||
recentsUid);
|
||||
}
|
||||
@@ -14341,6 +14342,28 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
}
|
||||
}
|
||||
|
||||
void setRunningRemoteAnimation(int pid, boolean runningRemoteAnimation) {
|
||||
synchronized (ActivityManagerService.this) {
|
||||
final ProcessRecord pr;
|
||||
synchronized (mPidsSelfLocked) {
|
||||
pr = mPidsSelfLocked.get(pid);
|
||||
if (pr == null) {
|
||||
Slog.w(TAG, "setRunningRemoteAnimation called on unknown pid: " + pid);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (pr.runningRemoteAnimation == runningRemoteAnimation) {
|
||||
return;
|
||||
}
|
||||
pr.runningRemoteAnimation = runningRemoteAnimation;
|
||||
if (DEBUG_OOM_ADJ) {
|
||||
Slog.i(TAG, "Setting runningRemoteAnimation=" + pr.runningRemoteAnimation
|
||||
+ " for pid=" + pid);
|
||||
}
|
||||
updateOomAdjLocked(pr, true);
|
||||
}
|
||||
}
|
||||
|
||||
public final void enterSafeMode() {
|
||||
synchronized(this) {
|
||||
// It only makes sense to do this before the system is ready
|
||||
@@ -22751,6 +22774,12 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
foregroundActivities = true;
|
||||
procState = PROCESS_STATE_CUR_TOP;
|
||||
if (DEBUG_OOM_ADJ_REASON) Slog.d(TAG, "Making top: " + app);
|
||||
} else if (app.runningRemoteAnimation) {
|
||||
adj = ProcessList.VISIBLE_APP_ADJ;
|
||||
schedGroup = ProcessList.SCHED_GROUP_TOP_APP;
|
||||
app.adjType = "running-remote-anim";
|
||||
procState = PROCESS_STATE_CUR_TOP;
|
||||
if (DEBUG_OOM_ADJ_REASON) Slog.d(TAG, "Making running remote anim: " + app);
|
||||
} else if (app.instr != null) {
|
||||
// Don't want to kill running instrumentation.
|
||||
adj = ProcessList.FOREGROUND_APP_ADJ;
|
||||
@@ -22826,7 +22855,9 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
app.adjType = "vis-activity";
|
||||
if (DEBUG_OOM_ADJ_REASON) Slog.d(TAG, "Raise to vis-activity: " + app);
|
||||
}
|
||||
schedGroup = ProcessList.SCHED_GROUP_DEFAULT;
|
||||
if (schedGroup < ProcessList.SCHED_GROUP_DEFAULT) {
|
||||
schedGroup = ProcessList.SCHED_GROUP_DEFAULT;
|
||||
}
|
||||
app.cached = false;
|
||||
app.empty = false;
|
||||
foregroundActivities = true;
|
||||
@@ -22849,7 +22880,9 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
app.adjType = "pause-activity";
|
||||
if (DEBUG_OOM_ADJ_REASON) Slog.d(TAG, "Raise to pause-activity: " + app);
|
||||
}
|
||||
schedGroup = ProcessList.SCHED_GROUP_DEFAULT;
|
||||
if (schedGroup < ProcessList.SCHED_GROUP_DEFAULT) {
|
||||
schedGroup = ProcessList.SCHED_GROUP_DEFAULT;
|
||||
}
|
||||
app.cached = false;
|
||||
app.empty = false;
|
||||
foregroundActivities = true;
|
||||
@@ -25990,6 +26023,11 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRunningRemoteAnimation(int pid, boolean runningRemoteAnimation) {
|
||||
ActivityManagerService.this.setRunningRemoteAnimation(pid, runningRemoteAnimation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after the network policy rules are updated by
|
||||
* {@link com.android.server.net.NetworkPolicyManagerService} for a specific {@param uid}
|
||||
@@ -26539,6 +26577,7 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
throws RemoteException {
|
||||
enforceCallingPermission(CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS,
|
||||
"registerRemoteAnimations");
|
||||
definition.setCallingPid(Binder.getCallingPid());
|
||||
synchronized (this) {
|
||||
final ActivityRecord r = ActivityRecord.isInStackLocked(token);
|
||||
if (r == null) {
|
||||
@@ -26558,6 +26597,7 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
RemoteAnimationAdapter adapter) throws RemoteException {
|
||||
enforceCallingPermission(CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS,
|
||||
"registerRemoteAnimationForNextActivityStart");
|
||||
adapter.setCallingPid(Binder.getCallingPid());
|
||||
synchronized (this) {
|
||||
final long origId = Binder.clearCallingIdentity();
|
||||
try {
|
||||
|
||||
@@ -129,6 +129,12 @@ final class ProcessRecord {
|
||||
// When true the process will oom adj score will be set to
|
||||
// ProcessList#PERCEPTIBLE_APP_ADJ at minimum to reduce the chance
|
||||
// of the process getting killed.
|
||||
boolean runningRemoteAnimation; // Is the process currently running a RemoteAnimation? When true
|
||||
// the process will be set to use the
|
||||
// ProcessList#SCHED_GROUP_TOP_APP scheduling group to boost
|
||||
// performance, as well as oom adj score will be set to
|
||||
// ProcessList#VISIBLE_APP_ADJ at minimum to reduce the chance
|
||||
// of the process getting killed.
|
||||
boolean pendingUiClean; // Want to clean up resources from showing UI?
|
||||
boolean hasAboveClient; // Bound using BIND_ABOVE_CLIENT, so want to be lower
|
||||
boolean treatLikeActivity; // Bound using BIND_TREAT_LIKE_ACTIVITY
|
||||
@@ -336,9 +342,10 @@ final class ProcessRecord {
|
||||
pw.print(" hasAboveClient="); pw.print(hasAboveClient);
|
||||
pw.print(" treatLikeActivity="); pw.println(treatLikeActivity);
|
||||
}
|
||||
if (hasTopUi || hasOverlayUi) {
|
||||
if (hasTopUi || hasOverlayUi || runningRemoteAnimation) {
|
||||
pw.print(prefix); pw.print("hasTopUi="); pw.print(hasTopUi);
|
||||
pw.print(" hasOverlayUi="); pw.println(hasOverlayUi);
|
||||
pw.print(" hasOverlayUi="); pw.print(hasOverlayUi);
|
||||
pw.print(" runningRemoteAnimation="); pw.println(runningRemoteAnimation);
|
||||
}
|
||||
if (foregroundServices || forcingToImportant != null) {
|
||||
pw.print(prefix); pw.print("foregroundServices="); pw.print(foregroundServices);
|
||||
|
||||
@@ -50,6 +50,7 @@ class RecentsAnimation implements RecentsAnimationCallbacks {
|
||||
private final WindowManagerService mWindowManager;
|
||||
private final UserController mUserController;
|
||||
private final Handler mHandler;
|
||||
private final int mCallingPid;
|
||||
|
||||
private final Runnable mCancelAnimationRunnable;
|
||||
|
||||
@@ -58,13 +59,14 @@ class RecentsAnimation implements RecentsAnimationCallbacks {
|
||||
|
||||
RecentsAnimation(ActivityManagerService am, ActivityStackSupervisor stackSupervisor,
|
||||
ActivityStartController activityStartController, WindowManagerService wm,
|
||||
UserController userController) {
|
||||
UserController userController, int callingPid) {
|
||||
mService = am;
|
||||
mStackSupervisor = stackSupervisor;
|
||||
mActivityStartController = activityStartController;
|
||||
mHandler = new Handler(mStackSupervisor.mLooper);
|
||||
mWindowManager = wm;
|
||||
mUserController = userController;
|
||||
mCallingPid = callingPid;
|
||||
|
||||
mCancelAnimationRunnable = () -> {
|
||||
// The caller has not finished the animation in a predefined amount of time, so
|
||||
@@ -94,9 +96,10 @@ class RecentsAnimation implements RecentsAnimationCallbacks {
|
||||
}
|
||||
}
|
||||
|
||||
mService.setRunningRemoteAnimation(mCallingPid, true);
|
||||
|
||||
mWindowManager.deferSurfaceLayout();
|
||||
try {
|
||||
|
||||
final ActivityDisplay display;
|
||||
if (hasExistingHomeActivity) {
|
||||
// Move the home activity into place for the animation if it is not already top most
|
||||
@@ -153,6 +156,8 @@ class RecentsAnimation implements RecentsAnimationCallbacks {
|
||||
synchronized (mService) {
|
||||
if (mWindowManager.getRecentsAnimationController() == null) return;
|
||||
|
||||
mService.setRunningRemoteAnimation(mCallingPid, false);
|
||||
|
||||
mWindowManager.inSurfaceTransaction(() -> {
|
||||
Trace.traceBegin(TRACE_TAG_ACTIVITY_MANAGER,
|
||||
"RecentsAnimation#onAnimationFinished_inSurfaceTransaction");
|
||||
|
||||
@@ -121,10 +121,16 @@ class SafeActivityOptions {
|
||||
if (mOriginalOptions != null) {
|
||||
checkPermissions(intent, aInfo, callerApp, supervisor, mOriginalOptions,
|
||||
mOriginalCallingPid, mOriginalCallingUid);
|
||||
if (mOriginalOptions.getRemoteAnimationAdapter() != null) {
|
||||
mOriginalOptions.getRemoteAnimationAdapter().setCallingPid(mOriginalCallingPid);
|
||||
}
|
||||
}
|
||||
if (mCallerOptions != null) {
|
||||
checkPermissions(intent, aInfo, callerApp, supervisor, mCallerOptions,
|
||||
mRealCallingPid, mRealCallingUid);
|
||||
if (mCallerOptions.getRemoteAnimationAdapter() != null) {
|
||||
mCallerOptions.getRemoteAnimationAdapter().setCallingPid(mRealCallingPid);
|
||||
}
|
||||
}
|
||||
return mergeActivityOptions(mOriginalOptions, mCallerOptions);
|
||||
}
|
||||
|
||||
@@ -103,6 +103,7 @@ class RemoteAnimationController {
|
||||
onAnimationFinished();
|
||||
}
|
||||
});
|
||||
sendRunningRemoteAnimation(true);
|
||||
}
|
||||
|
||||
private RemoteAnimationTarget[] createAnimations() {
|
||||
@@ -131,6 +132,7 @@ class RemoteAnimationController {
|
||||
mService.closeSurfaceTransaction("RemoteAnimationController#finished");
|
||||
}
|
||||
}
|
||||
sendRunningRemoteAnimation(false);
|
||||
}
|
||||
|
||||
private void invokeAnimationCancelled() {
|
||||
@@ -148,6 +150,14 @@ class RemoteAnimationController {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendRunningRemoteAnimation(boolean running) {
|
||||
final int pid = mRemoteAnimationAdapter.getCallingPid();
|
||||
if (pid == 0) {
|
||||
throw new RuntimeException("Calling pid of remote animation was null");
|
||||
}
|
||||
mService.sendSetRunningRemoteAnimation(pid, running);
|
||||
}
|
||||
|
||||
private static final class FinishedCallback extends IRemoteAnimationFinishedCallback.Stub {
|
||||
|
||||
RemoteAnimationController mOuter;
|
||||
@@ -251,6 +261,7 @@ class RemoteAnimationController {
|
||||
mHandler.removeCallbacks(mTimeoutRunnable);
|
||||
releaseFinishedCallback();
|
||||
invokeAnimationCancelled();
|
||||
sendRunningRemoteAnimation(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4555,6 +4555,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
public static final int NOTIFY_KEYGUARD_FLAGS_CHANGED = 56;
|
||||
public static final int NOTIFY_KEYGUARD_TRUSTED_CHANGED = 57;
|
||||
public static final int SET_HAS_OVERLAY_UI = 58;
|
||||
public static final int SET_RUNNING_REMOTE_ANIMATION = 59;
|
||||
|
||||
/**
|
||||
* Used to denote that an integer field in a message will not be used.
|
||||
@@ -4969,6 +4970,10 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
mAmInternal.setHasOverlayUi(msg.arg1, msg.arg2 == 1);
|
||||
}
|
||||
break;
|
||||
case SET_RUNNING_REMOTE_ANIMATION: {
|
||||
mAmInternal.setRunningRemoteAnimation(msg.arg1, msg.arg2 == 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (DEBUG_WINDOW_TRACE) {
|
||||
Slog.v(TAG_WM, "handleMessage: exit");
|
||||
@@ -7418,5 +7423,10 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
SurfaceControl.Builder makeSurfaceBuilder(SurfaceSession s) {
|
||||
return mSurfaceBuilderFactory.make(s);
|
||||
}
|
||||
|
||||
void sendSetRunningRemoteAnimation(int pid, boolean runningRemoteAnimation) {
|
||||
mH.obtainMessage(H.SET_RUNNING_REMOTE_ANIMATION, pid, runningRemoteAnimation ? 1 : 0)
|
||||
.sendToTarget();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user