Loading core/java/android/view/PhoneFallbackEventHandler.java +65 −35 Original line number Diff line number Diff line Loading @@ -25,8 +25,13 @@ import android.content.res.Configuration; import android.media.AudioManager; import android.media.session.MediaSessionLegacyHelper; import android.os.UserHandle; import android.provider.Settings; import android.telephony.TelephonyManager; import android.util.Slog; import android.util.Log; import android.view.View; import android.view.HapticFeedbackConstants; import android.view.FallbackEventHandler; import android.view.KeyEvent; /** * @hide Loading Loading @@ -112,6 +117,7 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { dispatcher.startTracking(event, this); } else if (event.isLongPress() && dispatcher.isTracking(event)) { dispatcher.performedLongPress(event); if (isUserSetupComplete()) { mView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); // launch the VoiceDialer Intent intent = new Intent(Intent.ACTION_VOICE_COMMAND); Loading @@ -122,6 +128,10 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { } catch (ActivityNotFoundException e) { startCallActivity(); } } else { Log.i(TAG, "Not starting call activity because user " + "setup is in progress."); } } return true; } Loading @@ -134,6 +144,7 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { dispatcher.startTracking(event, this); } else if (event.isLongPress() && dispatcher.isTracking(event)) { dispatcher.performedLongPress(event); if (isUserSetupComplete()) { mView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); sendCloseSystemWindows(); // Broadcast an intent that the Camera button was longpressed Loading @@ -141,6 +152,10 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { intent.putExtra(Intent.EXTRA_KEY_EVENT, event); mContext.sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT_OR_SELF, null, null, null, 0, null, null); } else { Log.i(TAG, "Not dispatching CAMERA long press because user " + "setup is in progress."); } } return true; } Loading @@ -155,6 +170,7 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { Configuration config = mContext.getResources().getConfiguration(); if (config.keyboard == Configuration.KEYBOARD_NOKEYS || config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) { if (isUserSetupComplete()) { // launch the search activity Intent intent = new Intent(Intent.ACTION_SEARCH_LONG_PRESS); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Loading @@ -171,6 +187,10 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { } catch (ActivityNotFoundException e) { // Ignore } } else { Log.i(TAG, "Not dispatching SEARCH long press because user " + "setup is in progress."); } } } break; Loading @@ -181,7 +201,7 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { boolean onKeyUp(int keyCode, KeyEvent event) { if (DEBUG) { Slog.d(TAG, "up " + keyCode); Log.d(TAG, "up " + keyCode); } final KeyEvent.DispatcherState dispatcher = mView.getKeyDispatcherState(); if (dispatcher != null) { Loading Loading @@ -229,7 +249,12 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { break; } if (event.isTracking() && !event.isCanceled()) { if (isUserSetupComplete()) { startCallActivity(); } else { Log.i(TAG, "Not starting call activity because user " + "setup is in progress."); } } return true; } Loading @@ -244,7 +269,7 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { try { mContext.startActivity(intent); } catch (ActivityNotFoundException e) { Slog.w(TAG, "No activity found for android.intent.action.CALL_BUTTON."); Log.w(TAG, "No activity found for android.intent.action.CALL_BUTTON."); } } Loading Loading @@ -284,5 +309,10 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { private void handleMediaKeyEvent(KeyEvent keyEvent) { MediaSessionLegacyHelper.getHelper(mContext).sendMediaButtonEvent(keyEvent, false); } private boolean isUserSetupComplete() { return Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 0) != 0; } } services/core/java/com/android/server/media/MediaSessionService.java +19 −5 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ import android.provider.Settings; import android.speech.RecognizerIntent; import android.text.TextUtils; import android.util.Log; import android.util.Slog; import android.util.SparseArray; import android.view.KeyEvent; Loading Loading @@ -743,15 +744,23 @@ public class MediaSessionService extends SystemService implements Monitor { Log.w(TAG, "Attempted to dispatch null or non-media key event."); return; } final int pid = Binder.getCallingPid(); final int uid = Binder.getCallingUid(); final long token = Binder.clearCallingIdentity(); try { if (DEBUG) { Log.d(TAG, "dispatchMediaKeyEvent, pid=" + pid + ", uid=" + uid + ", event=" + keyEvent); } if (!isUserSetupComplete()) { // Global media key handling can have the side-effect of starting new // activities which is undesirable while setup is in progress. Slog.i(TAG, "Not dispatching media key event because user " + "setup is in progress."); return; } try { synchronized (mLock) { // If we don't have a media button receiver to fall back on // include non-playing sessions for dispatching Loading Loading @@ -1025,6 +1034,11 @@ public class MediaSessionService extends SystemService implements Monitor { return keyCode == KeyEvent.KEYCODE_HEADSETHOOK; } private boolean isUserSetupComplete() { return Settings.Secure.getIntForUser(getContext().getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 0, UserHandle.USER_CURRENT) != 0; } // we only handle public stream types, which are 0-5 private boolean isValidLocalStreamType(int streamType) { return streamType >= AudioManager.STREAM_VOICE_CALL Loading Loading
core/java/android/view/PhoneFallbackEventHandler.java +65 −35 Original line number Diff line number Diff line Loading @@ -25,8 +25,13 @@ import android.content.res.Configuration; import android.media.AudioManager; import android.media.session.MediaSessionLegacyHelper; import android.os.UserHandle; import android.provider.Settings; import android.telephony.TelephonyManager; import android.util.Slog; import android.util.Log; import android.view.View; import android.view.HapticFeedbackConstants; import android.view.FallbackEventHandler; import android.view.KeyEvent; /** * @hide Loading Loading @@ -112,6 +117,7 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { dispatcher.startTracking(event, this); } else if (event.isLongPress() && dispatcher.isTracking(event)) { dispatcher.performedLongPress(event); if (isUserSetupComplete()) { mView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); // launch the VoiceDialer Intent intent = new Intent(Intent.ACTION_VOICE_COMMAND); Loading @@ -122,6 +128,10 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { } catch (ActivityNotFoundException e) { startCallActivity(); } } else { Log.i(TAG, "Not starting call activity because user " + "setup is in progress."); } } return true; } Loading @@ -134,6 +144,7 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { dispatcher.startTracking(event, this); } else if (event.isLongPress() && dispatcher.isTracking(event)) { dispatcher.performedLongPress(event); if (isUserSetupComplete()) { mView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); sendCloseSystemWindows(); // Broadcast an intent that the Camera button was longpressed Loading @@ -141,6 +152,10 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { intent.putExtra(Intent.EXTRA_KEY_EVENT, event); mContext.sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT_OR_SELF, null, null, null, 0, null, null); } else { Log.i(TAG, "Not dispatching CAMERA long press because user " + "setup is in progress."); } } return true; } Loading @@ -155,6 +170,7 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { Configuration config = mContext.getResources().getConfiguration(); if (config.keyboard == Configuration.KEYBOARD_NOKEYS || config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) { if (isUserSetupComplete()) { // launch the search activity Intent intent = new Intent(Intent.ACTION_SEARCH_LONG_PRESS); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Loading @@ -171,6 +187,10 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { } catch (ActivityNotFoundException e) { // Ignore } } else { Log.i(TAG, "Not dispatching SEARCH long press because user " + "setup is in progress."); } } } break; Loading @@ -181,7 +201,7 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { boolean onKeyUp(int keyCode, KeyEvent event) { if (DEBUG) { Slog.d(TAG, "up " + keyCode); Log.d(TAG, "up " + keyCode); } final KeyEvent.DispatcherState dispatcher = mView.getKeyDispatcherState(); if (dispatcher != null) { Loading Loading @@ -229,7 +249,12 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { break; } if (event.isTracking() && !event.isCanceled()) { if (isUserSetupComplete()) { startCallActivity(); } else { Log.i(TAG, "Not starting call activity because user " + "setup is in progress."); } } return true; } Loading @@ -244,7 +269,7 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { try { mContext.startActivity(intent); } catch (ActivityNotFoundException e) { Slog.w(TAG, "No activity found for android.intent.action.CALL_BUTTON."); Log.w(TAG, "No activity found for android.intent.action.CALL_BUTTON."); } } Loading Loading @@ -284,5 +309,10 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { private void handleMediaKeyEvent(KeyEvent keyEvent) { MediaSessionLegacyHelper.getHelper(mContext).sendMediaButtonEvent(keyEvent, false); } private boolean isUserSetupComplete() { return Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 0) != 0; } }
services/core/java/com/android/server/media/MediaSessionService.java +19 −5 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ import android.provider.Settings; import android.speech.RecognizerIntent; import android.text.TextUtils; import android.util.Log; import android.util.Slog; import android.util.SparseArray; import android.view.KeyEvent; Loading Loading @@ -743,15 +744,23 @@ public class MediaSessionService extends SystemService implements Monitor { Log.w(TAG, "Attempted to dispatch null or non-media key event."); return; } final int pid = Binder.getCallingPid(); final int uid = Binder.getCallingUid(); final long token = Binder.clearCallingIdentity(); try { if (DEBUG) { Log.d(TAG, "dispatchMediaKeyEvent, pid=" + pid + ", uid=" + uid + ", event=" + keyEvent); } if (!isUserSetupComplete()) { // Global media key handling can have the side-effect of starting new // activities which is undesirable while setup is in progress. Slog.i(TAG, "Not dispatching media key event because user " + "setup is in progress."); return; } try { synchronized (mLock) { // If we don't have a media button receiver to fall back on // include non-playing sessions for dispatching Loading Loading @@ -1025,6 +1034,11 @@ public class MediaSessionService extends SystemService implements Monitor { return keyCode == KeyEvent.KEYCODE_HEADSETHOOK; } private boolean isUserSetupComplete() { return Settings.Secure.getIntForUser(getContext().getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 0, UserHandle.USER_CURRENT) != 0; } // we only handle public stream types, which are 0-5 private boolean isValidLocalStreamType(int streamType) { return streamType >= AudioManager.STREAM_VOICE_CALL Loading