Loading policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +31 −47 Original line number Original line Diff line number Diff line Loading @@ -241,8 +241,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { int mPointerLocationMode = 0; int mPointerLocationMode = 0; PointerLocationView mPointerLocationView = null; PointerLocationView mPointerLocationView = null; InputChannel mPointerLocationInputChannel; InputChannel mPointerLocationInputChannel; boolean mVolumeUpPressed; boolean mVolumeDownPressed; boolean mCameraKeyPressable = false; boolean mCameraKeyPressable = false; static final long NEXT_DURATION = 400; static final long NEXT_DURATION = 400; Loading Loading @@ -308,6 +306,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { boolean mVolBtnMusicControls; boolean mVolBtnMusicControls; // Behavior of cambtn music controls // Behavior of cambtn music controls boolean mCamBtnMusicControls; boolean mCamBtnMusicControls; // keeps track about max volume state boolean mIsMaxVolume; // Behavior of POWER button while in-call and screen on. // Behavior of POWER button while in-call and screen on. // (See Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR.) // (See Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR.) Loading Loading @@ -588,11 +588,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { */ */ Runnable mVolumeUpLongPress = new Runnable() { Runnable mVolumeUpLongPress = new Runnable() { public void run() { public void run() { /* // we got one tick of volume change for the long press * Eat the longpress so it won't dismiss the recent apps dialog when // cancel this by adjusting volume to the other direction * the user lets go of the volume key // except we were on max volume before */ if(!mIsMaxVolume) mVolumeUpPressed = false; handleVolumeKey(AudioManager.STREAM_MUSIC, KeyEvent.KEYCODE_VOLUME_DOWN); // Shamelessly copied from Kmobs LockScreen controls, works for Pandora, etc... // Shamelessly copied from Kmobs LockScreen controls, works for Pandora, etc... sendMediaButtonEvent(KeyEvent.KEYCODE_MEDIA_NEXT); sendMediaButtonEvent(KeyEvent.KEYCODE_MEDIA_NEXT); Loading @@ -604,11 +604,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { */ */ Runnable mVolumeDownLongPress = new Runnable() { Runnable mVolumeDownLongPress = new Runnable() { public void run() { public void run() { /* // we got one tick of volume change for the long press * Eat the longpress so it won't dismiss the recent apps dialog when // cancel this by adjusting volume to the other direction * the user lets go of the volume key handleVolumeKey(AudioManager.STREAM_MUSIC, KeyEvent.KEYCODE_VOLUME_UP); */ mVolumeDownPressed = false; // Shamelessly copied from Kmobs LockScreen controls, works for Pandora, etc... // Shamelessly copied from Kmobs LockScreen controls, works for Pandora, etc... sendMediaButtonEvent(KeyEvent.KEYCODE_MEDIA_PREVIOUS); sendMediaButtonEvent(KeyEvent.KEYCODE_MEDIA_PREVIOUS); Loading Loading @@ -1930,6 +1928,12 @@ public class PhoneWindowManager implements WindowManagerPolicy { // during the call, but we do it as a precaution for the rare possibility // during the call, but we do it as a precaution for the rare possibility // that the music stops right before we call this // that the music stops right before we call this mBroadcastWakeLock.acquire(); mBroadcastWakeLock.acquire(); //check if we are at max volume for long press volume up to skip track mIsMaxVolume=false; if(audioService.getStreamVolume(stream) == audioService.getStreamMaxVolume(stream)) mIsMaxVolume=true; audioService.adjustStreamVolume(stream, audioService.adjustStreamVolume(stream, keycode == KeyEvent.KEYCODE_VOLUME_UP keycode == KeyEvent.KEYCODE_VOLUME_UP ? AudioManager.ADJUST_RAISE ? AudioManager.ADJUST_RAISE Loading @@ -1942,45 +1946,20 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } } } void handleVolumeKeyDown(int keycode) { void handleVolumeLongPress(int keycode) { // when keyguard is showing and screen off, we need // to handle the volume key for calls and music here // FIXME FIXME FIXME /* if (isInCall()) { handleVolumeKey(AudioManager.STREAM_VOICE_CALL, keycode); } // Take an initial hit time so we can decide for skip or volume adjust else if (isMusicActive()) { Runnable btnHandler; Runnable btnHandler; if (keycode == KeyEvent.KEYCODE_VOLUME_UP) { if (keycode == KeyEvent.KEYCODE_VOLUME_UP) mVolumeUpPressed = true; btnHandler = mVolumeUpLongPress; btnHandler = mVolumeUpLongPress; } else else { mVolumeDownPressed = true; btnHandler = mVolumeDownLongPress; btnHandler = mVolumeDownLongPress; } if (mVolBtnMusicControls) { mHandler.postDelayed(btnHandler, ViewConfiguration.getLongPressTimeout()); mHandler.postDelayed(btnHandler, ViewConfiguration.getLongPressTimeout()); } } } */ } void handleVolumeKeyUp(int keycode) { void handleVolumeLongPressAbort() { if (isMusicActive()) { if (keycode == KeyEvent.KEYCODE_VOLUME_UP) mHandler.removeCallbacks(mVolumeUpLongPress); mHandler.removeCallbacks(mVolumeUpLongPress); else mHandler.removeCallbacks(mVolumeDownLongPress); mHandler.removeCallbacks(mVolumeDownLongPress); // Normal volume change - not consumed be long press already if (mVolumeUpPressed || mVolumeDownPressed) handleVolumeKey(AudioManager.STREAM_MUSIC, keycode); } } } void handleCameraKeyDown() { void handleCameraKeyDown() { Loading Loading @@ -2064,6 +2043,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { switch (keyCode) { switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_UP: { case KeyEvent.KEYCODE_VOLUME_UP: { if(mVolBtnMusicControls && !down) handleVolumeLongPressAbort(); if (down) { if (down) { ITelephony telephonyService = getTelephonyService(); ITelephony telephonyService = getTelephonyService(); if (telephonyService != null) { if (telephonyService != null) { Loading Loading @@ -2100,6 +2081,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } if (isMusicActive() && (result & ACTION_PASS_TO_USER) == 0) { if (isMusicActive() && (result & ACTION_PASS_TO_USER) == 0) { // Care for long-press actions to skip tracks if(mVolBtnMusicControls) handleVolumeLongPress(keyCode); // If music is playing but we decided not to pass the key to the // If music is playing but we decided not to pass the key to the // application, handle the volume change here. // application, handle the volume change here. handleVolumeKey(AudioManager.STREAM_MUSIC, keyCode); handleVolumeKey(AudioManager.STREAM_MUSIC, keyCode); Loading Loading
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +31 −47 Original line number Original line Diff line number Diff line Loading @@ -241,8 +241,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { int mPointerLocationMode = 0; int mPointerLocationMode = 0; PointerLocationView mPointerLocationView = null; PointerLocationView mPointerLocationView = null; InputChannel mPointerLocationInputChannel; InputChannel mPointerLocationInputChannel; boolean mVolumeUpPressed; boolean mVolumeDownPressed; boolean mCameraKeyPressable = false; boolean mCameraKeyPressable = false; static final long NEXT_DURATION = 400; static final long NEXT_DURATION = 400; Loading Loading @@ -308,6 +306,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { boolean mVolBtnMusicControls; boolean mVolBtnMusicControls; // Behavior of cambtn music controls // Behavior of cambtn music controls boolean mCamBtnMusicControls; boolean mCamBtnMusicControls; // keeps track about max volume state boolean mIsMaxVolume; // Behavior of POWER button while in-call and screen on. // Behavior of POWER button while in-call and screen on. // (See Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR.) // (See Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR.) Loading Loading @@ -588,11 +588,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { */ */ Runnable mVolumeUpLongPress = new Runnable() { Runnable mVolumeUpLongPress = new Runnable() { public void run() { public void run() { /* // we got one tick of volume change for the long press * Eat the longpress so it won't dismiss the recent apps dialog when // cancel this by adjusting volume to the other direction * the user lets go of the volume key // except we were on max volume before */ if(!mIsMaxVolume) mVolumeUpPressed = false; handleVolumeKey(AudioManager.STREAM_MUSIC, KeyEvent.KEYCODE_VOLUME_DOWN); // Shamelessly copied from Kmobs LockScreen controls, works for Pandora, etc... // Shamelessly copied from Kmobs LockScreen controls, works for Pandora, etc... sendMediaButtonEvent(KeyEvent.KEYCODE_MEDIA_NEXT); sendMediaButtonEvent(KeyEvent.KEYCODE_MEDIA_NEXT); Loading @@ -604,11 +604,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { */ */ Runnable mVolumeDownLongPress = new Runnable() { Runnable mVolumeDownLongPress = new Runnable() { public void run() { public void run() { /* // we got one tick of volume change for the long press * Eat the longpress so it won't dismiss the recent apps dialog when // cancel this by adjusting volume to the other direction * the user lets go of the volume key handleVolumeKey(AudioManager.STREAM_MUSIC, KeyEvent.KEYCODE_VOLUME_UP); */ mVolumeDownPressed = false; // Shamelessly copied from Kmobs LockScreen controls, works for Pandora, etc... // Shamelessly copied from Kmobs LockScreen controls, works for Pandora, etc... sendMediaButtonEvent(KeyEvent.KEYCODE_MEDIA_PREVIOUS); sendMediaButtonEvent(KeyEvent.KEYCODE_MEDIA_PREVIOUS); Loading Loading @@ -1930,6 +1928,12 @@ public class PhoneWindowManager implements WindowManagerPolicy { // during the call, but we do it as a precaution for the rare possibility // during the call, but we do it as a precaution for the rare possibility // that the music stops right before we call this // that the music stops right before we call this mBroadcastWakeLock.acquire(); mBroadcastWakeLock.acquire(); //check if we are at max volume for long press volume up to skip track mIsMaxVolume=false; if(audioService.getStreamVolume(stream) == audioService.getStreamMaxVolume(stream)) mIsMaxVolume=true; audioService.adjustStreamVolume(stream, audioService.adjustStreamVolume(stream, keycode == KeyEvent.KEYCODE_VOLUME_UP keycode == KeyEvent.KEYCODE_VOLUME_UP ? AudioManager.ADJUST_RAISE ? AudioManager.ADJUST_RAISE Loading @@ -1942,45 +1946,20 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } } } void handleVolumeKeyDown(int keycode) { void handleVolumeLongPress(int keycode) { // when keyguard is showing and screen off, we need // to handle the volume key for calls and music here // FIXME FIXME FIXME /* if (isInCall()) { handleVolumeKey(AudioManager.STREAM_VOICE_CALL, keycode); } // Take an initial hit time so we can decide for skip or volume adjust else if (isMusicActive()) { Runnable btnHandler; Runnable btnHandler; if (keycode == KeyEvent.KEYCODE_VOLUME_UP) { if (keycode == KeyEvent.KEYCODE_VOLUME_UP) mVolumeUpPressed = true; btnHandler = mVolumeUpLongPress; btnHandler = mVolumeUpLongPress; } else else { mVolumeDownPressed = true; btnHandler = mVolumeDownLongPress; btnHandler = mVolumeDownLongPress; } if (mVolBtnMusicControls) { mHandler.postDelayed(btnHandler, ViewConfiguration.getLongPressTimeout()); mHandler.postDelayed(btnHandler, ViewConfiguration.getLongPressTimeout()); } } } */ } void handleVolumeKeyUp(int keycode) { void handleVolumeLongPressAbort() { if (isMusicActive()) { if (keycode == KeyEvent.KEYCODE_VOLUME_UP) mHandler.removeCallbacks(mVolumeUpLongPress); mHandler.removeCallbacks(mVolumeUpLongPress); else mHandler.removeCallbacks(mVolumeDownLongPress); mHandler.removeCallbacks(mVolumeDownLongPress); // Normal volume change - not consumed be long press already if (mVolumeUpPressed || mVolumeDownPressed) handleVolumeKey(AudioManager.STREAM_MUSIC, keycode); } } } void handleCameraKeyDown() { void handleCameraKeyDown() { Loading Loading @@ -2064,6 +2043,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { switch (keyCode) { switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_UP: { case KeyEvent.KEYCODE_VOLUME_UP: { if(mVolBtnMusicControls && !down) handleVolumeLongPressAbort(); if (down) { if (down) { ITelephony telephonyService = getTelephonyService(); ITelephony telephonyService = getTelephonyService(); if (telephonyService != null) { if (telephonyService != null) { Loading Loading @@ -2100,6 +2081,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } if (isMusicActive() && (result & ACTION_PASS_TO_USER) == 0) { if (isMusicActive() && (result & ACTION_PASS_TO_USER) == 0) { // Care for long-press actions to skip tracks if(mVolBtnMusicControls) handleVolumeLongPress(keyCode); // If music is playing but we decided not to pass the key to the // If music is playing but we decided not to pass the key to the // application, handle the volume change here. // application, handle the volume change here. handleVolumeKey(AudioManager.STREAM_MUSIC, keyCode); handleVolumeKey(AudioManager.STREAM_MUSIC, keyCode); Loading