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

Commit 2a35e6db authored by Winson Chung's avatar Winson Chung
Browse files

Fix a couple PIP related issues.

- Only show settings button when in the full PIP menu (71709327)
- Fix issue with PIP not moving with keyboard due to new callback order
  (71584422)
- Make home button consistent with recents button when in an activity
  over the lockscreen (64137485).  When you tap home, it will now prompt
  you to unlock before going home (and auto-entering PIP if the app
  supports it)

Bug: 71709327
Bug: 71584422
Bug: 64137485

Test: Manual, ensure that pip shifts with keyboard and verify that it
      launches into PIP from show-over-lockscreen activity

Change-Id: I9122b7e20a5bfe82b32c8b576bd4fa11b5659c31
parent 49c3ef9e
Loading
Loading
Loading
Loading
+41 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.internal.policy;

import android.os.RemoteException;
import com.android.internal.policy.IKeyguardDismissCallback;

/**
 * @hide
 */
public class KeyguardDismissCallback extends IKeyguardDismissCallback.Stub {

    @Override
    public void onDismissError() throws RemoteException {
        // To be overidden
    }

    @Override
    public void onDismissSucceeded() throws RemoteException {
        // To be overidden
    }

    @Override
    public void onDismissCancelled() throws RemoteException {
        // To be overidden
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -373,7 +373,7 @@ public class PipMenuActivity extends Activity {
            if (menuState == MENU_STATE_FULL) {
                mMenuContainerAnimator.playTogether(menuAnim, settingsAnim, dismissAnim);
            } else {
                mMenuContainerAnimator.playTogether(settingsAnim, dismissAnim);
                mMenuContainerAnimator.playTogether(dismissAnim);
            }
            mMenuContainerAnimator.setInterpolator(Interpolators.ALPHA_IN);
            mMenuContainerAnimator.setDuration(MENU_FADE_DURATION);
+2 −11
Original line number Diff line number Diff line
@@ -397,6 +397,7 @@ import com.android.internal.os.ProcessCpuTracker;
import com.android.internal.os.TransferPipe;
import com.android.internal.os.Zygote;
import com.android.internal.policy.IKeyguardDismissCallback;
import com.android.internal.policy.KeyguardDismissCallback;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.DumpUtils;
@@ -8386,21 +8387,11 @@ public class ActivityManagerService extends IActivityManager.Stub
                    // entering picture-in-picture (this will prompt the user to authenticate if the
                    // device is currently locked).
                    try {
                        dismissKeyguard(token, new IKeyguardDismissCallback.Stub() {
                            @Override
                            public void onDismissError() throws RemoteException {
                                // Do nothing
                            }
                        dismissKeyguard(token, new KeyguardDismissCallback() {
                            @Override
                            public void onDismissSucceeded() throws RemoteException {
                                mHandler.post(enterPipRunnable);
                            }
                            @Override
                            public void onDismissCancelled() throws RemoteException {
                                // Do nothing
                            }
                        }, null /* message */);
                    } catch (RemoteException e) {
                        // Local call
+21 −18
Original line number Diff line number Diff line
@@ -266,6 +266,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.policy.IKeyguardDismissCallback;
import com.android.internal.policy.IShortcutService;
import com.android.internal.policy.KeyguardDismissCallback;
import com.android.internal.policy.PhoneWindow;
import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.util.ArrayUtils;
@@ -4203,20 +4204,23 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            if (isKeyguardShowingAndNotOccluded()) {
                // don't launch home if keyguard showing
                return;
            } else if (mKeyguardOccluded && mKeyguardDelegate.isShowing()) {
                mKeyguardDelegate.dismiss(new KeyguardDismissCallback() {
                    @Override
                    public void onDismissSucceeded() throws RemoteException {
                        mHandler.post(() -> {
                            startDockOrHome(true /*fromHomeKey*/, awakenFromDreams);
                        });
                    }

            if (!mKeyguardOccluded && mKeyguardDelegate.isInputRestricted()) {
                }, null /* message */);
                return;
            } else if (!mKeyguardOccluded && mKeyguardDelegate.isInputRestricted()) {
                // when in keyguard restricted mode, must first verify unlock
                // before launching home
                mKeyguardDelegate.verifyUnlock(new OnKeyguardExitResult() {
                    @Override
                    public void onKeyguardExitResult(boolean success) {
                        if (success) {
                            try {
                                ActivityManager.getService().stopAppSwitches();
                            } catch (RemoteException e) {
                            }
                            sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
                            startDockOrHome(true /*fromHomeKey*/, awakenFromDreams);
                        }
                    }
@@ -4226,11 +4230,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }

        // no keyguard stuff to worry about, just launch home!
        if (mRecentsVisible) {
            try {
                ActivityManager.getService().stopAppSwitches();
        } catch (RemoteException e) {
        }
        if (mRecentsVisible) {
            } catch (RemoteException e) {}

            // Hide Recents and notify it to launch Home
            if (awakenFromDreams) {
                awakenDreams();
@@ -4238,7 +4242,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            hideRecentApps(false, true);
        } else {
            // Otherwise, just launch Home
            sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
            startDockOrHome(true /*fromHomeKey*/, awakenFromDreams);
        }
    }
@@ -7631,6 +7634,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    }

    void startDockOrHome(boolean fromHomeKey, boolean awakenFromDreams) {
        try {
            ActivityManager.getService().stopAppSwitches();
        } catch (RemoteException e) {}
        sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);

        if (awakenFromDreams) {
            awakenDreams();
        }
@@ -7670,11 +7678,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }
        if (false) {
            // This code always brings home to the front.
            try {
                ActivityManager.getService().stopAppSwitches();
            } catch (RemoteException e) {
            }
            sendCloseSystemWindows();
            startDockOrHome(false /*fromHomeKey*/, true /* awakenFromDreams */);
        } else {
            // This code brings home to the front or, if it is already
+9 −4
Original line number Diff line number Diff line
@@ -360,14 +360,19 @@ class PinnedStackController {
     * Sets the Ime state and height.
     */
    void setAdjustedForIme(boolean adjustedForIme, int imeHeight) {
        // Return early if there is no state change
        if (mIsImeShowing == adjustedForIme && mImeHeight == imeHeight) {
        // Due to the order of callbacks from the system, we may receive an ime height even when
        // {@param adjustedForIme} is false, and also a zero height when {@param adjustedForIme}
        // is true.  Instead, ensure that the ime state changes with the height and if the ime is
        // showing, then the height is non-zero.
        final boolean imeShowing = adjustedForIme && imeHeight > 0;
        imeHeight = imeShowing ? imeHeight : 0;
        if (imeShowing == mIsImeShowing && imeHeight == mImeHeight) {
            return;
        }

        mIsImeShowing = adjustedForIme;
        mIsImeShowing = imeShowing;
        mImeHeight = imeHeight;
        notifyImeVisibilityChanged(adjustedForIme, imeHeight);
        notifyImeVisibilityChanged(imeShowing, imeHeight);
        notifyMovementBoundsChanged(true /* fromImeAdjustment */);
    }