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

Commit b7cab6a1 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic 'bisto-request'

* changes:
  Allow privileged app to set media key event listener
  Allow privileged app to set volume key long-press listener
parents b0865576 6e2b01ce
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -425,10 +425,12 @@ LOCAL_SRC_FILES += \
	media/java/android/media/projection/IMediaProjectionManager.aidl \
	media/java/android/media/projection/IMediaProjectionWatcherCallback.aidl \
	media/java/android/media/session/IActiveSessionsListener.aidl \
	media/java/android/media/session/ISessionController.aidl \
	media/java/android/media/session/ISessionControllerCallback.aidl \
	media/java/android/media/session/IOnMediaKeyListener.aidl \
	media/java/android/media/session/IOnVolumeKeyLongPressListener.aidl \
	media/java/android/media/session/ISession.aidl \
	media/java/android/media/session/ISessionCallback.aidl \
	media/java/android/media/session/ISessionController.aidl \
	media/java/android/media/session/ISessionControllerCallback.aidl \
	media/java/android/media/session/ISessionManager.aidl \
	media/java/android/media/tv/ITvInputClient.aidl \
	media/java/android/media/tv/ITvInputHardware.aidl \
+12 −0
Original line number Diff line number Diff line
@@ -217,6 +217,7 @@ package android {
    field public static final java.lang.String SET_ALWAYS_FINISH = "android.permission.SET_ALWAYS_FINISH";
    field public static final java.lang.String SET_ANIMATION_SCALE = "android.permission.SET_ANIMATION_SCALE";
    field public static final java.lang.String SET_DEBUG_APP = "android.permission.SET_DEBUG_APP";
    field public static final java.lang.String SET_MEDIA_KEY_LISTENER = "android.permission.SET_MEDIA_KEY_LISTENER";
    field public static final java.lang.String SET_ORIENTATION = "android.permission.SET_ORIENTATION";
    field public static final java.lang.String SET_POINTER_SPEED = "android.permission.SET_POINTER_SPEED";
    field public static final deprecated java.lang.String SET_PREFERRED_APPLICATIONS = "android.permission.SET_PREFERRED_APPLICATIONS";
@@ -224,6 +225,7 @@ package android {
    field public static final java.lang.String SET_SCREEN_COMPATIBILITY = "android.permission.SET_SCREEN_COMPATIBILITY";
    field public static final java.lang.String SET_TIME = "android.permission.SET_TIME";
    field public static final java.lang.String SET_TIME_ZONE = "android.permission.SET_TIME_ZONE";
    field public static final java.lang.String SET_VOLUME_KEY_LONG_PRESS_LISTENER = "android.permission.SET_VOLUME_KEY_LONG_PRESS_LISTENER";
    field public static final java.lang.String SET_WALLPAPER = "android.permission.SET_WALLPAPER";
    field public static final java.lang.String SET_WALLPAPER_COMPONENT = "android.permission.SET_WALLPAPER_COMPONENT";
    field public static final java.lang.String SET_WALLPAPER_HINTS = "android.permission.SET_WALLPAPER_HINTS";
@@ -25205,12 +25207,22 @@ package android.media.session {
    method public void addOnActiveSessionsChangedListener(android.media.session.MediaSessionManager.OnActiveSessionsChangedListener, android.content.ComponentName, android.os.Handler);
    method public java.util.List<android.media.session.MediaController> getActiveSessions(android.content.ComponentName);
    method public void removeOnActiveSessionsChangedListener(android.media.session.MediaSessionManager.OnActiveSessionsChangedListener);
    method public void setOnMediaKeyListener(android.media.session.MediaSessionManager.OnMediaKeyListener, android.os.Handler);
    method public void setOnVolumeKeyLongPressListener(android.media.session.MediaSessionManager.OnVolumeKeyLongPressListener, android.os.Handler);
  }
  public static abstract interface MediaSessionManager.OnActiveSessionsChangedListener {
    method public abstract void onActiveSessionsChanged(java.util.List<android.media.session.MediaController>);
  }
  public static abstract interface MediaSessionManager.OnMediaKeyListener {
    method public abstract boolean onMediaKey(android.view.KeyEvent);
  }
  public static abstract interface MediaSessionManager.OnVolumeKeyLongPressListener {
    method public abstract void onVolumeKeyLongPress(android.view.KeyEvent);
  }
  public final class PlaybackState implements android.os.Parcelable {
    method public int describeContents();
    method public long getActions();
+4 −2
Original line number Diff line number Diff line
@@ -84,7 +84,8 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler {
            case KeyEvent.KEYCODE_VOLUME_UP:
            case KeyEvent.KEYCODE_VOLUME_DOWN:
            case KeyEvent.KEYCODE_VOLUME_MUTE: {
                MediaSessionLegacyHelper.getHelper(mContext).sendVolumeKeyEvent(event, false);
                MediaSessionLegacyHelper.getHelper(mContext).sendVolumeKeyEvent(
                        event, AudioManager.USE_DEFAULT_STREAM_TYPE, false);
                return true;
            }

@@ -215,7 +216,8 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler {
            case KeyEvent.KEYCODE_VOLUME_DOWN:
            case KeyEvent.KEYCODE_VOLUME_MUTE: {
                if (!event.isCanceled()) {
                    MediaSessionLegacyHelper.getHelper(mContext).sendVolumeKeyEvent(event, false);
                    MediaSessionLegacyHelper.getHelper(mContext).sendVolumeKeyEvent(
                            event, AudioManager.USE_DEFAULT_STREAM_TYPE, false);
                }
                return true;
            }
+20 −21
Original line number Diff line number Diff line
@@ -1856,6 +1856,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
            case KeyEvent.KEYCODE_VOLUME_UP:
            case KeyEvent.KEYCODE_VOLUME_DOWN:
            case KeyEvent.KEYCODE_VOLUME_MUTE: {
                // If we have a session send it the volume command, otherwise
                // use the suggested stream.
                if (mMediaController != null) {
                    int direction = 0;
                    switch (keyCode) {
                        case KeyEvent.KEYCODE_VOLUME_UP:
@@ -1868,15 +1871,10 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
                            direction = AudioManager.ADJUST_TOGGLE_MUTE;
                            break;
                    }
                // If we have a session send it the volume command, otherwise
                // use the suggested stream.
                if (mMediaController != null) {
                    mMediaController.adjustVolume(direction, AudioManager.FLAG_SHOW_UI);
                } else {
                    MediaSessionLegacyHelper.getHelper(getContext()).sendAdjustVolumeBy(
                            mVolumeControlStreamType, direction,
                            AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_VIBRATE
                                    | AudioManager.FLAG_FROM_KEY);
                    MediaSessionLegacyHelper.getHelper(getContext()).sendVolumeKeyEvent(
                            event, mVolumeControlStreamType, false);
                }
                return true;
            }
@@ -1954,15 +1952,15 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
        switch (keyCode) {
            case KeyEvent.KEYCODE_VOLUME_UP:
            case KeyEvent.KEYCODE_VOLUME_DOWN: {
                final int flags = AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_VIBRATE
                        | AudioManager.FLAG_FROM_KEY;
                // If we have a session send it the volume command, otherwise
                // use the suggested stream.
                if (mMediaController != null) {
                    final int flags = AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_VIBRATE
                            | AudioManager.FLAG_FROM_KEY;
                    mMediaController.adjustVolume(0, flags);
                } else {
                    MediaSessionLegacyHelper.getHelper(getContext()).sendAdjustVolumeBy(
                            mVolumeControlStreamType, 0, flags);
                    MediaSessionLegacyHelper.getHelper(getContext()).sendVolumeKeyEvent(
                            event, mVolumeControlStreamType, false);
                }
                return true;
            }
@@ -1971,7 +1969,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
                // doesn't have one of these.  In this case, we execute it here and
                // eat the event instead, because we have mVolumeControlStreamType
                // and they don't.
                getAudioManager().handleKeyUp(event, mVolumeControlStreamType);
                MediaSessionLegacyHelper.getHelper(getContext()).sendVolumeKeyEvent(
                        event, AudioManager.USE_DEFAULT_STREAM_TYPE, false);
                return true;
            }
            // These are all the recognized media key codes in
+15 −0
Original line number Diff line number Diff line
@@ -2645,6 +2645,21 @@
    <permission android:name="android.permission.MEDIA_CONTENT_CONTROL"
        android:protectionLevel="signature|privileged" />

    <!-- @SystemApi @hide Allows an application to set the volume key long-press listener.
         <p>When it's set, the application will receive the volume key long-press event
         instead of changing volume.</p>
         <p>Not for use by third-party applications</p> -->
    <permission android:name="android.permission.SET_VOLUME_KEY_LONG_PRESS_LISTENER"
        android:protectionLevel="signature|privileged|development" />

    <!-- @SystemApi @hide Allows an application to set media key event listener.
         <p>When it's set, the application will receive the media key event before
         any other media sessions. If the event is handled by the listener, other sessions
         cannot get the event.</p>
         <p>Not for use by third-party applications</p> -->
    <permission android:name="android.permission.SET_MEDIA_KEY_LISTENER"
        android:protectionLevel="signature|privileged|development" />

    <!-- @SystemApi Required to be able to disable the device (very dangerous!).
         <p>Not for use by third-party applications.
         @hide
Loading