Fix trampoline activities when relaunching PiP
- We should be checking the actual launched-from package since that stores
the source package across trampoline activities
Bug: 35458117
Test: Enter PiP from a trampoline activity, launch again from Launcher
and ensure that it is expanded
Change-Id: Ia0e586e8b21dee63b513bd61a41a24e7da4325e1
This commit is contained in:
@@ -32,9 +32,10 @@ oneway interface ITaskStackListener {
|
||||
* running in the pinned stack and the activity is not actually started, but the task is either
|
||||
* brought to the front or a new Intent is delivered to it.
|
||||
*
|
||||
* @param sourceComponent the component name of the activity that initiated the restart attempt
|
||||
* @param launchedFromPackage the package name of the activity that initiated the restart
|
||||
* attempt
|
||||
*/
|
||||
void onPinnedActivityRestartAttempt(in ComponentName sourceComponent);
|
||||
void onPinnedActivityRestartAttempt(String launchedFromPackage);
|
||||
|
||||
/**
|
||||
* Called whenever the pinned stack is done animating a resize.
|
||||
|
||||
@@ -35,7 +35,7 @@ public abstract class TaskStackListener extends ITaskStackListener.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPinnedActivityRestartAttempt(ComponentName sourceComponent) throws RemoteException {
|
||||
public void onPinnedActivityRestartAttempt(String launchedFromPackage) throws RemoteException {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -76,7 +76,7 @@ public class PipManager implements BasePipManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPinnedActivityRestartAttempt(ComponentName sourceComponent) {
|
||||
public void onPinnedActivityRestartAttempt(String launchedFromPackage) {
|
||||
if (!checkCurrentUserId(false /* debug */)) {
|
||||
return;
|
||||
}
|
||||
@@ -84,11 +84,11 @@ public class PipManager implements BasePipManager {
|
||||
// Expand the activity back to fullscreen only if it was attempted to be restarted from
|
||||
// another package than the top activity in the stack
|
||||
boolean expandPipToFullscreen = true;
|
||||
if (sourceComponent != null) {
|
||||
if (launchedFromPackage != null) {
|
||||
ComponentName topActivity = PipUtils.getTopPinnedActivity(mContext,
|
||||
mActivityManager);
|
||||
if (topActivity != null && topActivity.getPackageName().equals(
|
||||
sourceComponent.getPackageName())) {
|
||||
if (topActivity != null
|
||||
&& topActivity.getPackageName().equals(launchedFromPackage)) {
|
||||
expandPipToFullscreen = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -695,7 +695,7 @@ public class PipManager implements BasePipManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPinnedActivityRestartAttempt(ComponentName sourceComponent) {
|
||||
public void onPinnedActivityRestartAttempt(String launchedFromPackage) {
|
||||
if (DEBUG) Log.d(TAG, "onPinnedActivityRestartAttempt()");
|
||||
if (!checkCurrentUserId(DEBUG)) {
|
||||
return;
|
||||
|
||||
@@ -153,7 +153,7 @@ public class SystemServicesProxy {
|
||||
public void onTaskStackChanged() { }
|
||||
public void onTaskSnapshotChanged(int taskId, TaskSnapshot snapshot) { }
|
||||
public void onActivityPinned() { }
|
||||
public void onPinnedActivityRestartAttempt(ComponentName sourceComponent) { }
|
||||
public void onPinnedActivityRestartAttempt(String launchedFromPackage) { }
|
||||
public void onPinnedStackAnimationEnded() { }
|
||||
public void onActivityForcedResizable(String packageName, int taskId) { }
|
||||
public void onActivityDismissingDockedStack() { }
|
||||
@@ -198,10 +198,10 @@ public class SystemServicesProxy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPinnedActivityRestartAttempt(ComponentName sourceComponent)
|
||||
public void onPinnedActivityRestartAttempt(String launchedFromPackage)
|
||||
throws RemoteException{
|
||||
mHandler.removeMessages(H.ON_PINNED_ACTIVITY_RESTART_ATTEMPT);
|
||||
mHandler.obtainMessage(H.ON_PINNED_ACTIVITY_RESTART_ATTEMPT, sourceComponent)
|
||||
mHandler.obtainMessage(H.ON_PINNED_ACTIVITY_RESTART_ATTEMPT, launchedFromPackage)
|
||||
.sendToTarget();
|
||||
}
|
||||
|
||||
@@ -1244,8 +1244,7 @@ public class SystemServicesProxy {
|
||||
}
|
||||
case ON_PINNED_ACTIVITY_RESTART_ATTEMPT: {
|
||||
for (int i = mTaskStackListeners.size() - 1; i >= 0; i--) {
|
||||
mTaskStackListeners.get(i).onPinnedActivityRestartAttempt(
|
||||
(ComponentName) msg.obj);
|
||||
mTaskStackListeners.get(i).onPinnedActivityRestartAttempt((String) msg.obj);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -585,10 +585,8 @@ class ActivityStarter {
|
||||
// The activity was already running in the pinned stack so it wasn't started, but either
|
||||
// brought to the front or the new intent was delivered to it since it was already in
|
||||
// front. Notify anyone interested in this piece of information.
|
||||
final ComponentName sourceComponent = sourceRecord == null ? null :
|
||||
sourceRecord.realActivity;
|
||||
mService.mTaskChangeNotificationController.notifyPinnedActivityRestartAttempt(
|
||||
sourceComponent);
|
||||
sourceRecord.launchedFromPackage);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ class TaskChangeNotificationController {
|
||||
};
|
||||
|
||||
private final TaskStackConsumer mNotifyPinnedActivityRestartAttempt = (l, m) -> {
|
||||
l.onPinnedActivityRestartAttempt((ComponentName) m.obj);
|
||||
l.onPinnedActivityRestartAttempt((String) m.obj);
|
||||
};
|
||||
|
||||
private final TaskStackConsumer mNotifyPinnedStackAnimationEnded = (l, m) -> {
|
||||
@@ -267,11 +267,11 @@ class TaskChangeNotificationController {
|
||||
* running in the pinned stack and the activity was not actually started, but the task is
|
||||
* either brought to the front or a new Intent is delivered to it.
|
||||
*/
|
||||
void notifyPinnedActivityRestartAttempt(ComponentName sourceComponent) {
|
||||
void notifyPinnedActivityRestartAttempt(String launchedFromPackage) {
|
||||
mHandler.removeMessages(NOTIFY_PINNED_ACTIVITY_RESTART_ATTEMPT_LISTENERS_MSG);
|
||||
final Message msg =
|
||||
mHandler.obtainMessage(NOTIFY_PINNED_ACTIVITY_RESTART_ATTEMPT_LISTENERS_MSG,
|
||||
sourceComponent);
|
||||
launchedFromPackage);
|
||||
forAllLocalListeners(mNotifyPinnedActivityRestartAttempt, msg);
|
||||
msg.sendToTarget();
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ class PinnedStackController {
|
||||
* @return the movement bounds for the given {@param stackBounds} and the current state of the
|
||||
* controller.
|
||||
*/
|
||||
Rect getMovementBounds(Rect stackBounds) {
|
||||
private Rect getMovementBounds(Rect stackBounds) {
|
||||
return getMovementBounds(stackBounds, true /* adjustForIme */);
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ class PinnedStackController {
|
||||
* @return the movement bounds for the given {@param stackBounds} and the current state of the
|
||||
* controller.
|
||||
*/
|
||||
Rect getMovementBounds(Rect stackBounds, boolean adjustForIme) {
|
||||
private Rect getMovementBounds(Rect stackBounds, boolean adjustForIme) {
|
||||
final Rect movementBounds = new Rect();
|
||||
getInsetBounds(movementBounds);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user