summaryrefslogtreecommitdiffstats
path: root/policy
diff options
context:
space:
mode:
authorRoboErik <epastern@google.com>2014-05-16 11:19:38 -0700
committerRoboErik <epastern@google.com>2014-05-16 15:10:27 -0700
commit8a2cfc309ab9126e90022916967c65a793c034f0 (patch)
treebfd40410ca43540902de565432b057ee5a5206d8 /policy
parent62cb534edb2cef23bdc71254294bd63fa03b38b3 (diff)
downloadframeworks_base-8a2cfc309ab9126e90022916967c65a793c034f0.zip
frameworks_base-8a2cfc309ab9126e90022916967c65a793c034f0.tar.gz
frameworks_base-8a2cfc309ab9126e90022916967c65a793c034f0.tar.bz2
Move media key processing to sessions
Send all media key events over to the MediaSessionService instead of AudioManager. This does not affect volume handling yet, so it is possible to get into a state where volume will be handled by a different thing than media buttons. Except for corner cases this shouldn't be noticable. Change-Id: I00a576175d9c82937f0836e509b9a98d5cb77b83
Diffstat (limited to 'policy')
-rw-r--r--policy/src/com/android/internal/policy/impl/PhoneWindowManager.java42
1 files changed, 25 insertions, 17 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 8eed414..276d55eb 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -46,6 +46,7 @@ import android.media.AudioSystem;
import android.media.IAudioService;
import android.media.Ringtone;
import android.media.RingtoneManager;
+import android.media.session.MediaSessionLegacyHelper;
import android.os.Bundle;
import android.os.FactoryTest;
import android.os.Handler;
@@ -137,6 +138,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
static final boolean ENABLE_CAR_DOCK_HOME_CAPTURE = true;
static final boolean ENABLE_DESK_DOCK_HOME_CAPTURE = false;
+ // Whether to use the new Session APIs
+ static final boolean USE_SESSIONS = true;
+
static final int LONG_PRESS_POWER_NOTHING = 0;
static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1;
static final int LONG_PRESS_POWER_SHUT_OFF = 2;
@@ -1377,11 +1381,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
}
}
-
+
void readLidState() {
mLidState = mWindowManagerFuncs.getLidState();
}
-
+
private boolean isHidden(int accessibilityMode) {
switch (accessibilityMode) {
case 1:
@@ -1728,16 +1732,16 @@ public class PhoneWindowManager implements WindowManagerPolicy {
/**
* Preflight adding a window to the system.
- *
+ *
* Currently enforces that three window types are singletons:
* <ul>
* <li>STATUS_BAR_TYPE</li>
* <li>KEYGUARD_TYPE</li>
* </ul>
- *
+ *
* @param win The window to be added
* @param attrs Information about the window to be added
- *
+ *
* @return If ok, WindowManagerImpl.ADD_OKAY. If too many singletons,
* WindowManagerImpl.ADD_MULTIPLE_SINGLETON
*/
@@ -1810,7 +1814,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
static final boolean PRINT_ANIM = false;
-
+
/** {@inheritDoc} */
@Override
public int selectAnimationLw(WindowState win, int transit) {
@@ -2390,7 +2394,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
Intent intent = new Intent(Intent.ACTION_SEARCH_LONG_PRESS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
- // TODO: This only stops the factory-installed search manager.
+ // TODO: This only stops the factory-installed search manager.
// Need to formalize an API to handle others
SearchManager searchManager = getSearchManager();
if (searchManager != null) {
@@ -3058,7 +3062,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if ((fl & (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR))
== (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) {
- if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle()
+ if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle()
+ "): IN_SCREEN, INSET_DECOR");
// This is the case for a normal activity window: we want it
// to cover all of the screen space, and it can take care of
@@ -3342,7 +3346,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (DEBUG_LAYOUT) Slog.v(TAG, "Compute frame " + attrs.getTitle()
+ ": sim=#" + Integer.toHexString(sim)
- + " attach=" + attached + " type=" + attrs.type
+ + " attach=" + attached + " type=" + attrs.type
+ String.format(" flags=0x%08x", fl)
+ " pf=" + pf.toShortString() + " df=" + df.toShortString()
+ " of=" + of.toShortString()
@@ -3391,7 +3395,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mForceStatusBarFromKeyguard = false;
mForcingShowNavBar = false;
mForcingShowNavBarLayer = -1;
-
+
mHideLockScreen = false;
mAllowLockscreenWhenOn = false;
mDismissKeyguard = DISMISS_KEYGUARD_NONE;
@@ -4235,12 +4239,16 @@ public class PhoneWindowManager implements WindowManagerPolicy {
void dispatchMediaKeyWithWakeLockToAudioService(KeyEvent event) {
if (ActivityManagerNative.isSystemReady()) {
- IAudioService audioService = getAudioService();
- if (audioService != null) {
- try {
- audioService.dispatchMediaKeyEventUnderWakelock(event);
- } catch (RemoteException e) {
- Log.e(TAG, "dispatchMediaKeyEvent threw exception " + e);
+ if (USE_SESSIONS) {
+ MediaSessionLegacyHelper.getHelper(mContext).sendMediaButtonEvent(event, true);
+ } else {
+ IAudioService audioService = getAudioService();
+ if (audioService != null) {
+ try {
+ audioService.dispatchMediaKeyEventUnderWakelock(event);
+ } catch (RemoteException e) {
+ Log.e(TAG, "dispatchMediaKeyEvent threw exception " + e);
+ }
}
}
}
@@ -4466,7 +4474,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
public void dismissKeyguardLw() {
- if (mKeyguardDelegate != null && mKeyguardDelegate.isShowing()) {
+ if (mKeyguardDelegate != null && mKeyguardDelegate.isShowing()) {
mHandler.post(new Runnable() {
public void run() {
if (mKeyguardDelegate.isDismissable()) {