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

Commit bee89155 authored by RoboErik's avatar RoboErik Committed by Android Git Automerger
Browse files

am 065b605c: am 55ecb483: Merge "Don\'t forward media keys to the app if the...

am 065b605c: am 55ecb483: Merge "Don\'t forward media keys to the app if the phone session is active" into lmp-dev

* commit '065b605c02e52d76dcd1df211b64f94fc4a18604':
  Don't forward media keys to the app if the phone session is active
parents 3f1c8a08 507cee74
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -38,4 +38,7 @@ interface ISessionManager {

    // This is for the system volume UI only
    void setRemoteVolumeController(in IRemoteVolumeController rvc);

    // For PhoneWindowManager to precheck media keys
    boolean isGlobalPriorityActive();
}
 No newline at end of file
+4 −0
Original line number Diff line number Diff line
@@ -232,6 +232,10 @@ public class MediaSessionLegacyHelper {
        }
    }

    public boolean isGlobalPriorityActive() {
        return mSessionManager.isGlobalPriorityActive();
    }

    public void addRccListener(PendingIntent pi, MediaSession.Callback listener) {
        if (pi == null) {
            Log.w(TAG, "Pending intent was null, can't add rcc listener.");
+15 −0
Original line number Diff line number Diff line
@@ -295,6 +295,21 @@ public final class MediaSessionManager {
        }
    }

    /**
     * Check if the global priority session is currently active. This can be
     * used to decide if media keys should be sent to the session or to the app.
     *
     * @hide
     */
    public boolean isGlobalPriorityActive() {
        try {
            return mService.isGlobalPriorityActive();
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to check if the global priority is active.", e);
        }
        return false;
    }

    /**
     * Listens for changes to the list of active sessions. This can be added
     * using {@link #addOnActiveSessionsChangedListener}.
+7 −12
Original line number Diff line number Diff line
@@ -4248,8 +4248,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        boolean isWakeKey = (policyFlags & WindowManagerPolicy.FLAG_WAKE) != 0
                || event.isWakeKey();
        if (interactive || (isInjected && !isWakeKey)) {
            // When the device is interactive or the key is injected pass the key to the
            // application.
            // When the device is interactive or the key is injected pass the
            // key to the application.
            result = ACTION_PASS_TO_USER;
            isWakeKey = false;
        } else if (!interactive && shouldDispatchInputWhenNonInteractive()) {
@@ -4449,16 +4449,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            case KeyEvent.KEYCODE_MEDIA_PLAY:
            case KeyEvent.KEYCODE_MEDIA_PAUSE:
            case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
                if (down) {
                    TelecomManager telecomManager = getTelecommService();
                    if (telecomManager != null) {
                        if (telecomManager.isInCall()) {
                            // Suppress PLAY/PAUSE toggle when phone is ringing or in-call
                            // to avoid music playback.
                            break;
                        }
                    }
                }
            case KeyEvent.KEYCODE_HEADSETHOOK:
            case KeyEvent.KEYCODE_MUTE:
            case KeyEvent.KEYCODE_MEDIA_STOP:
@@ -4468,6 +4458,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            case KeyEvent.KEYCODE_MEDIA_RECORD:
            case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
            case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK: {
                if (MediaSessionLegacyHelper.getHelper(mContext).isGlobalPriorityActive()) {
                    // If the global session is active pass all media keys to it
                    // instead of the active window.
                    result &= ~ACTION_PASS_TO_USER;
                }
                if ((result & ACTION_PASS_TO_USER) == 0) {
                    // Only do this if we would otherwise not pass it to the user. In that
                    // case, the PhoneWindow class will do the same thing, except it will
+5 −0
Original line number Diff line number Diff line
@@ -742,6 +742,11 @@ public class MediaSessionService extends SystemService implements Monitor {
            }
        }

        @Override
        public boolean isGlobalPriorityActive() {
            return mPriorityStack.isGlobalPriorityActive();
        }

        @Override
        public void dump(FileDescriptor fd, final PrintWriter pw, String[] args) {
            if (getContext().checkCallingOrSelfPermission(Manifest.permission.DUMP)
Loading