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

Commit 6e2b01ce authored by Jaewan Kim's avatar Jaewan Kim
Browse files

Allow privileged app to set media key event listener

If the media key listener is set, the listener will receive the media key
events before any other sessions, but after the global priority session.
If the event is handled by the listener, other sessions cannot get the event.

Privileged app needs permission android.permission.SET_MEDIA_KEY_LISTENER
to set the listener.

Bug: 30125811
Change-Id: I2b2cf4ac7873b70899194701c6921990dcb9de02
parent 5026936e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -423,6 +423,7 @@ 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/IOnMediaKeyListener.aidl \
	media/java/android/media/session/IOnVolumeKeyLongPressListener.aidl \
	media/java/android/media/session/ISession.aidl \
	media/java/android/media/session/ISessionCallback.aidl \
+6 −0
Original line number Diff line number Diff line
@@ -215,6 +215,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";
@@ -24820,6 +24821,7 @@ 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);
  }
@@ -24827,6 +24829,10 @@ package android.media.session {
    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);
  }
+8 −0
Original line number Diff line number Diff line
@@ -2632,6 +2632,14 @@
    <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
+28 −0
Original line number Diff line number Diff line
/* Copyright (C) 2016 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 android.media.session;

import android.os.ResultReceiver;
import android.view.KeyEvent;

/**
 * Listener to handle media key.
 * @hide
 */
interface IOnMediaKeyListener {
    void onMediaKey(in KeyEvent event, in ResultReceiver result);
}
+2 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import android.content.ComponentName;
import android.media.IRemoteVolumeController;
import android.media.session.IActiveSessionsListener;
import android.media.session.IOnVolumeKeyLongPressListener;
import android.media.session.IOnMediaKeyListener;
import android.media.session.ISession;
import android.media.session.ISessionCallback;
import android.os.Bundle;
@@ -45,5 +46,6 @@ interface ISessionManager {
    boolean isGlobalPriorityActive();

    void setOnVolumeKeyLongPressListener(in IOnVolumeKeyLongPressListener listener);
    void setOnMediaKeyListener(in IOnMediaKeyListener listener);
}
Loading