diff options
author | Jeff Brown <jeffbrown@google.com> | 2015-03-20 22:10:54 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-03-20 22:10:54 +0000 |
commit | 619ce1ce534775ab0ff4d591a69dafd53c04a315 (patch) | |
tree | 6f72baf867d4c97746fe3c8fe2baa73bd470924f | |
parent | 104a29b6b5fe6e454787053ca72950dbbc4d424b (diff) | |
parent | d62163055f983b95a954f1a6c2cbc8e0085a7ab5 (diff) | |
download | frameworks_base-619ce1ce534775ab0ff4d591a69dafd53c04a315.zip frameworks_base-619ce1ce534775ab0ff4d591a69dafd53c04a315.tar.gz frameworks_base-619ce1ce534775ab0ff4d591a69dafd53c04a315.tar.bz2 |
am d6216305: Merge "Disable more hotkeys while in setup." into lmp-mr1-dev
* commit 'd62163055f983b95a954f1a6c2cbc8e0085a7ab5':
Disable more hotkeys while in setup.
-rw-r--r-- | policy/src/com/android/internal/policy/impl/PhoneFallbackEventHandler.java | 95 | ||||
-rw-r--r-- | services/core/java/com/android/server/media/MediaSessionService.java | 16 |
2 files changed, 75 insertions, 36 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneFallbackEventHandler.java b/policy/src/com/android/internal/policy/impl/PhoneFallbackEventHandler.java index f291e89..5e37241 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneFallbackEventHandler.java +++ b/policy/src/com/android/internal/policy/impl/PhoneFallbackEventHandler.java @@ -28,9 +28,9 @@ import android.media.session.MediaSessionLegacyHelper; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; +import android.provider.Settings; import android.telephony.TelephonyManager; import android.util.Log; -import android.util.Slog; import android.view.View; import android.view.HapticFeedbackConstants; import android.view.FallbackEventHandler; @@ -117,15 +117,20 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { dispatcher.startTracking(event, this); } else if (event.isLongPress() && dispatcher.isTracking(event)) { dispatcher.performedLongPress(event); - mView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); - // launch the VoiceDialer - Intent intent = new Intent(Intent.ACTION_VOICE_COMMAND); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - try { - sendCloseSystemWindows(); - mContext.startActivity(intent); - } catch (ActivityNotFoundException e) { - startCallActivity(); + if (isUserSetupComplete()) { + mView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); + // launch the VoiceDialer + Intent intent = new Intent(Intent.ACTION_VOICE_COMMAND); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + try { + sendCloseSystemWindows(); + mContext.startActivity(intent); + } catch (ActivityNotFoundException e) { + startCallActivity(); + } + } else { + Log.i(TAG, "Not starting call activity because user " + + "setup is in progress."); } } return true; @@ -139,13 +144,18 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { dispatcher.startTracking(event, this); } else if (event.isLongPress() && dispatcher.isTracking(event)) { dispatcher.performedLongPress(event); - mView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); - sendCloseSystemWindows(); - // Broadcast an intent that the Camera button was longpressed - Intent intent = new Intent(Intent.ACTION_CAMERA_BUTTON, null); - intent.putExtra(Intent.EXTRA_KEY_EVENT, event); - mContext.sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT_OR_SELF, - null, null, null, 0, null, null); + if (isUserSetupComplete()) { + mView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); + sendCloseSystemWindows(); + // Broadcast an intent that the Camera button was longpressed + Intent intent = new Intent(Intent.ACTION_CAMERA_BUTTON, null); + 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; } @@ -160,21 +170,26 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { Configuration config = mContext.getResources().getConfiguration(); if (config.keyboard == Configuration.KEYBOARD_NOKEYS || config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) { - // launch the search activity - Intent intent = new Intent(Intent.ACTION_SEARCH_LONG_PRESS); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - try { - mView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); - sendCloseSystemWindows(); - getSearchManager().stopSearch(); - mContext.startActivity(intent); - // Only clear this if we successfully start the - // activity; otherwise we will allow the normal short - // press action to be performed. - dispatcher.performedLongPress(event); - return true; - } catch (ActivityNotFoundException e) { - // Ignore + if (isUserSetupComplete()) { + // launch the search activity + Intent intent = new Intent(Intent.ACTION_SEARCH_LONG_PRESS); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + try { + mView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); + sendCloseSystemWindows(); + getSearchManager().stopSearch(); + mContext.startActivity(intent); + // Only clear this if we successfully start the + // activity; otherwise we will allow the normal short + // press action to be performed. + dispatcher.performedLongPress(event); + return true; + } catch (ActivityNotFoundException e) { + // Ignore + } + } else { + Log.i(TAG, "Not dispatching SEARCH long press because user " + + "setup is in progress."); } } } @@ -186,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) { @@ -234,7 +249,12 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { break; } if (event.isTracking() && !event.isCanceled()) { - startCallActivity(); + if (isUserSetupComplete()) { + startCallActivity(); + } else { + Log.i(TAG, "Not starting call activity because user " + + "setup is in progress."); + } } return true; } @@ -249,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."); } } @@ -289,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; + } } diff --git a/services/core/java/com/android/server/media/MediaSessionService.java b/services/core/java/com/android/server/media/MediaSessionService.java index 77a1fa9..72e4b4b 100644 --- a/services/core/java/com/android/server/media/MediaSessionService.java +++ b/services/core/java/com/android/server/media/MediaSessionService.java @@ -56,6 +56,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; @@ -715,11 +716,19 @@ 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 (!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; + } + synchronized (mLock) { // If we don't have a media button receiver to fall back on // include non-playing sessions for dispatching @@ -1007,6 +1016,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 |