Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 734c9c05 authored by Winson Chung's avatar Winson Chung
Browse files

Fixing error calculating the top pinned activity.

- When the menu was open, we were not calculating the correct
  top-activity to determine whether to relaunch fullscreen or to show
  media controller actions for.  Also fixes a bad condition check
  where we were setting the expand to fullscreen flag incorrectly.

Bug: 33754261
Test: Open a PIP activity, try to launch it again from launcher while the menu is visible
Change-Id: I3fd3dfe83a017c76cca9709f29c08621b16fb088
parent 655f908a
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -86,9 +86,12 @@ public class PipManager {
            // another package than the top activity in the stack
            boolean expandPipToFullscreen = true;
            if (sourceComponent != null) {
                ComponentName topActivity = PipUtils.getTopPinnedActivity(mActivityManager);
                expandPipToFullscreen = topActivity != null && topActivity.getPackageName().equals(
                        sourceComponent.getPackageName());
                ComponentName topActivity = PipUtils.getTopPinnedActivity(mContext,
                        mActivityManager);
                if (topActivity != null && topActivity.getPackageName().equals(
                        sourceComponent.getPackageName())) {
                    expandPipToFullscreen = false;
                }
            }
            if (expandPipToFullscreen) {
                mTouchHandler.expandPinnedStackToFullscreen();
+2 −1
Original line number Diff line number Diff line
@@ -148,7 +148,8 @@ public class PipMediaController {
     */
    private void resolveActiveMediaController(List<MediaController> controllers) {
        if (controllers != null) {
            final ComponentName topActivity = PipUtils.getTopPinnedActivity(mActivityManager);
            final ComponentName topActivity = PipUtils.getTopPinnedActivity(mContext,
                    mActivityManager);
            if (topActivity != null) {
                for (int i = 0; i < controllers.size(); i++) {
                    final MediaController controller = controllers.get(i);
+14 −4
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.app.ActivityManager.StackId.PINNED_STACK_ID;
import android.app.ActivityManager.StackInfo;
import android.app.IActivityManager;
import android.content.ComponentName;
import android.content.Context;
import android.os.RemoteException;
import android.util.Log;

@@ -29,14 +30,23 @@ public class PipUtils {
    private static final String TAG = "PipUtils";

    /**
     * @return the ComponentName of the top activity in the pinned stack, or null if none exists.
     * @return the ComponentName of the top non-SystemUI activity in the pinned stack, or null if
     *         none exists.
     */
    public static ComponentName getTopPinnedActivity(IActivityManager activityManager) {
    public static ComponentName getTopPinnedActivity(Context context,
            IActivityManager activityManager) {
        try {
            StackInfo pinnedStackInfo = activityManager.getStackInfo(PINNED_STACK_ID);
            final String sysUiPackageName = context.getPackageName();
            final StackInfo pinnedStackInfo = activityManager.getStackInfo(PINNED_STACK_ID);
            if (pinnedStackInfo != null && pinnedStackInfo.taskIds != null &&
                    pinnedStackInfo.taskIds.length > 0) {
                return pinnedStackInfo.topActivity;
                for (int i = pinnedStackInfo.taskNames.length - 1; i >= 0; i--) {
                    ComponentName cn = ComponentName.unflattenFromString(
                            pinnedStackInfo.taskNames[i]);
                    if (cn != null && !cn.getPackageName().equals(sysUiPackageName)) {
                        return cn;
                    }
                }
            }
        } catch (RemoteException e) {
            Log.w(TAG, "Unable to get pinned stack.");