Loading core/res/res/values/config.xml +5 −0 Original line number Diff line number Diff line Loading @@ -1043,4 +1043,9 @@ <!-- Apps that are authorized to access shared accounts, overridden by product overlays --> <string name="config_appsAuthorizedForSharedAccounts"></string> <!-- Flag indicating that the media framework should not allow changes or mute on any stream or master volumes. --> <bool name="config_useFixedVolume">false</bool> </resources> core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -277,6 +277,7 @@ <java-symbol type="bool" name="config_camera_sound_forced" /> <java-symbol type="bool" name="config_dontPreferApn" /> <java-symbol type="bool" name="config_speed_up_audio_on_mt_calls" /> <java-symbol type="bool" name="config_useFixedVolume" /> <java-symbol type="integer" name="config_cursorWindowSize" /> <java-symbol type="integer" name="config_longPressOnPowerBehavior" /> Loading media/java/android/media/AudioService.java +70 −6 Original line number Diff line number Diff line Loading @@ -257,6 +257,8 @@ public class AudioService extends IAudioService.Stub implements OnFinished { }; private int[] mStreamVolumeAlias; private final boolean mUseFixedVolume; // stream names used by dumpStreamStates() private final String[] STREAM_NAMES = new String[] { "STREAM_VOICE_CALL", Loading Loading @@ -487,6 +489,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished { mSafeMediaVolumeIndex = mContext.getResources().getInteger( com.android.internal.R.integer.config_safe_media_volume_index) * 10; mUseFixedVolume = mContext.getResources().getBoolean( com.android.internal.R.bool.config_useFixedVolume); readPersistedSettings(); mSettingsObserver = new SettingsObserver(); updateStreamVolumeAlias(false /*updateVolumes*/); Loading Loading @@ -678,6 +683,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished { if (ringerMode != ringerModeFromSettings) { Settings.Global.putInt(cr, Settings.Global.MODE_RINGER, ringerMode); } if (mUseFixedVolume) { ringerMode = AudioManager.RINGER_MODE_NORMAL; } synchronized(mSettingsLock) { mRingerMode = ringerMode; Loading Loading @@ -736,6 +744,10 @@ public class AudioService extends IAudioService.Stub implements OnFinished { boolean masterMute = System.getIntForUser(cr, System.VOLUME_MASTER_MUTE, 0, UserHandle.USER_CURRENT) == 1; if (mUseFixedVolume) { masterMute = false; AudioSystem.setMasterVolume(1.0f); } AudioSystem.setMasterMute(masterMute); broadcastMasterMuteStatus(masterMute); Loading Loading @@ -806,6 +818,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished { /** @see AudioManager#adjustStreamVolume(int, int, int) */ public void adjustStreamVolume(int streamType, int direction, int flags) { if (mUseFixedVolume) { return; } if (DEBUG_VOL) Log.d(TAG, "adjustStreamVolume() stream="+streamType+", dir="+direction); ensureValidDirection(direction); Loading Loading @@ -918,6 +933,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished { /** @see AudioManager#adjustMasterVolume(int, int) */ public void adjustMasterVolume(int steps, int flags) { if (mUseFixedVolume) { return; } ensureValidSteps(steps); int volume = Math.round(AudioSystem.getMasterVolume() * MAX_MASTER_VOLUME); int delta = 0; Loading Loading @@ -972,6 +990,10 @@ public class AudioService extends IAudioService.Stub implements OnFinished { /** @see AudioManager#setStreamVolume(int, int, int) */ public void setStreamVolume(int streamType, int index, int flags) { if (mUseFixedVolume) { return; } ensureValidStreamType(streamType); VolumeStreamState streamState = mStreamStates[mStreamVolumeAlias[streamType]]; Loading Loading @@ -1214,6 +1236,10 @@ public class AudioService extends IAudioService.Stub implements OnFinished { /** @see AudioManager#setStreamSolo(int, boolean) */ public void setStreamSolo(int streamType, boolean state, IBinder cb) { if (mUseFixedVolume) { return; } for (int stream = 0; stream < mStreamStates.length; stream++) { if (!isStreamAffectedByMute(stream) || stream == streamType) continue; // Bring back last audible volume Loading @@ -1223,6 +1249,10 @@ public class AudioService extends IAudioService.Stub implements OnFinished { /** @see AudioManager#setStreamMute(int, boolean) */ public void setStreamMute(int streamType, boolean state, IBinder cb) { if (mUseFixedVolume) { return; } if (isStreamAffectedByMute(streamType)) { mStreamStates[streamType].mute(cb, state); } Loading @@ -1235,6 +1265,10 @@ public class AudioService extends IAudioService.Stub implements OnFinished { /** @see AudioManager#setMasterMute(boolean, int) */ public void setMasterMute(boolean state, int flags, IBinder cb) { if (mUseFixedVolume) { return; } if (state != AudioSystem.getMasterMute()) { AudioSystem.setMasterMute(state); // Post a persist master volume msg Loading Loading @@ -1268,6 +1302,10 @@ public class AudioService extends IAudioService.Stub implements OnFinished { } public void setMasterVolume(int volume, int flags) { if (mUseFixedVolume) { return; } if (volume < 0) { volume = 0; } else if (volume > MAX_MASTER_VOLUME) { Loading Loading @@ -1339,6 +1377,10 @@ public class AudioService extends IAudioService.Stub implements OnFinished { /** @see AudioManager#setRingerMode(int) */ public void setRingerMode(int ringerMode) { if (mUseFixedVolume) { return; } if ((ringerMode == AudioManager.RINGER_MODE_VIBRATE) && !mHasVibrator) { ringerMode = AudioManager.RINGER_MODE_SILENT; } Loading Loading @@ -1398,6 +1440,10 @@ public class AudioService extends IAudioService.Stub implements OnFinished { } private void restoreMasterVolume() { if (mUseFixedVolume) { AudioSystem.setMasterVolume(1.0f); return; } if (mUseMasterVolume) { float volume = Settings.System.getFloatForUser(mContentResolver, Settings.System.VOLUME_MASTER, -1.0f, UserHandle.USER_CURRENT); Loading Loading @@ -1951,8 +1997,8 @@ public class AudioService extends IAudioService.Stub implements OnFinished { streamState.readSettings(); // unmute stream that was muted but is not affect by mute anymore if (streamState.muteCount() != 0 && !isStreamAffectedByMute(streamType) && !isStreamMutedByRingerMode(streamType)) { if (streamState.muteCount() != 0 && ((!isStreamAffectedByMute(streamType) && !isStreamMutedByRingerMode(streamType)) || mUseFixedVolume)) { int size = streamState.mDeathHandlers.size(); for (int i = 0; i < size; i++) { streamState.mDeathHandlers.get(i).mMuteCount = 1; Loading Loading @@ -2833,8 +2879,12 @@ public class AudioService extends IAudioService.Stub implements OnFinished { } public synchronized void readSettings() { int remainingDevices = AudioSystem.DEVICE_OUT_ALL; // force maximum volume on all streams if fixed volume property is set if (mUseFixedVolume) { mIndex.put(AudioSystem.DEVICE_OUT_DEFAULT, mIndexMax); mLastAudibleIndex.put(AudioSystem.DEVICE_OUT_DEFAULT, mIndexMax); return; } // do not read system stream volume from settings: this stream is always aliased // to another stream type and its volume is never persisted. Values in settings can // only be stale values Loading @@ -2855,6 +2905,8 @@ public class AudioService extends IAudioService.Stub implements OnFinished { return; } int remainingDevices = AudioSystem.DEVICE_OUT_ALL; for (int i = 0; remainingDevices != 0; i++) { int device = (1 << i); if ((device & remainingDevices) == 0) { Loading Loading @@ -2972,7 +3024,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished { index = mIndexMax; } } mIndex.put(device, getValidIndex(index)); mIndex.put(device, index); if (oldIndex != index) { if (lastAudible) { Loading Loading @@ -3106,7 +3158,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished { private int getValidIndex(int index) { if (index < 0) { return 0; } else if (index > mIndexMax) { } else if (mUseFixedVolume || index > mIndexMax) { return mIndexMax; } Loading Loading @@ -3328,6 +3380,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished { private void persistVolume(VolumeStreamState streamState, int persistType, int device) { if (mUseFixedVolume) { return; } if ((persistType & PERSIST_CURRENT) != 0) { System.putIntForUser(mContentResolver, streamState.getSettingNameForDevice(false /* lastAudible */, device), Loading @@ -3343,6 +3398,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished { } private void persistRingerMode(int ringerMode) { if (mUseFixedVolume) { return; } Settings.Global.putInt(mContentResolver, Settings.Global.MODE_RINGER, ringerMode); } Loading Loading @@ -3439,6 +3497,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished { break; case MSG_PERSIST_MASTER_VOLUME: if (mUseFixedVolume) { return; } Settings.System.putFloatForUser(mContentResolver, Settings.System.VOLUME_MASTER, (float)msg.arg1 / (float)1000.0, Loading @@ -3446,6 +3507,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished { break; case MSG_PERSIST_MASTER_VOLUME_MUTE: if (mUseFixedVolume) { return; } Settings.System.putIntForUser(mContentResolver, Settings.System.VOLUME_MASTER_MUTE, msg.arg1, Loading media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/audio/MediaAudioManagerTest.java +11 −4 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ public class MediaAudioManagerTest extends ActivityInstrumentationTestCase2<Medi private final static int WAIT_FOR_LOOPER_TO_INITIALIZE_MS = 60000; // 60s private int[] ringtoneMode = {AudioManager.RINGER_MODE_NORMAL, AudioManager.RINGER_MODE_SILENT, AudioManager.RINGER_MODE_VIBRATE}; private boolean mUseFixedVolume; public MediaAudioManagerTest() { super("com.android.mediaframeworktest", MediaFrameworkTest.class); Loading @@ -65,6 +66,10 @@ public class MediaAudioManagerTest extends ActivityInstrumentationTestCase2<Medi @Override protected void setUp() throws Exception { super.setUp(); mUseFixedVolume = getActivity().getResources().getBoolean( com.android.internal.R.bool.config_useFixedVolume); synchronized(mLooperLock) { initializeAudioManagerWithLooper(); try { Loading @@ -91,10 +96,12 @@ public class MediaAudioManagerTest extends ActivityInstrumentationTestCase2<Medi public boolean validateSetRingTone(int i) { int getRingtone = mAudioManager.getRingerMode(); if (i != getRingtone) return false; else return true; if (mUseFixedVolume) { return (getRingtone == AudioManager.RINGER_MODE_NORMAL); } else { return (getRingtone == i); } } // Test case 1: Simple test case to validate the set ringtone mode Loading policy/src/com/android/internal/policy/impl/GlobalActions.java +7 −3 Original line number Diff line number Diff line Loading @@ -102,6 +102,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac private boolean mIsWaitingForEcmExit = false; private boolean mHasTelephony; private boolean mHasVibrator; private final boolean mShowSilentToggle; /** * @param context everything needs a context :( Loading Loading @@ -132,6 +133,9 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac mAirplaneModeObserver); Vibrator vibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); mHasVibrator = vibrator != null && vibrator.hasVibrator(); mShowSilentToggle = SHOW_SILENT_TOGGLE && !mContext.getResources().getBoolean( com.android.internal.R.bool.config_useFixedVolume); } /** Loading Loading @@ -309,7 +313,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac } // last: silent mode if (SHOW_SILENT_TOGGLE) { if (mShowSilentToggle) { mItems.add(mSilentModeAction); } Loading Loading @@ -390,7 +394,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac mAirplaneModeOn.updateState(mAirplaneState); mAdapter.notifyDataSetChanged(); mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG); if (SHOW_SILENT_TOGGLE) { if (mShowSilentToggle) { IntentFilter filter = new IntentFilter(AudioManager.RINGER_MODE_CHANGED_ACTION); mContext.registerReceiver(mRingerModeReceiver, filter); } Loading @@ -407,7 +411,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac /** {@inheritDoc} */ public void onDismiss(DialogInterface dialog) { if (SHOW_SILENT_TOGGLE) { if (mShowSilentToggle) { try { mContext.unregisterReceiver(mRingerModeReceiver); } catch (IllegalArgumentException ie) { Loading Loading
core/res/res/values/config.xml +5 −0 Original line number Diff line number Diff line Loading @@ -1043,4 +1043,9 @@ <!-- Apps that are authorized to access shared accounts, overridden by product overlays --> <string name="config_appsAuthorizedForSharedAccounts"></string> <!-- Flag indicating that the media framework should not allow changes or mute on any stream or master volumes. --> <bool name="config_useFixedVolume">false</bool> </resources>
core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -277,6 +277,7 @@ <java-symbol type="bool" name="config_camera_sound_forced" /> <java-symbol type="bool" name="config_dontPreferApn" /> <java-symbol type="bool" name="config_speed_up_audio_on_mt_calls" /> <java-symbol type="bool" name="config_useFixedVolume" /> <java-symbol type="integer" name="config_cursorWindowSize" /> <java-symbol type="integer" name="config_longPressOnPowerBehavior" /> Loading
media/java/android/media/AudioService.java +70 −6 Original line number Diff line number Diff line Loading @@ -257,6 +257,8 @@ public class AudioService extends IAudioService.Stub implements OnFinished { }; private int[] mStreamVolumeAlias; private final boolean mUseFixedVolume; // stream names used by dumpStreamStates() private final String[] STREAM_NAMES = new String[] { "STREAM_VOICE_CALL", Loading Loading @@ -487,6 +489,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished { mSafeMediaVolumeIndex = mContext.getResources().getInteger( com.android.internal.R.integer.config_safe_media_volume_index) * 10; mUseFixedVolume = mContext.getResources().getBoolean( com.android.internal.R.bool.config_useFixedVolume); readPersistedSettings(); mSettingsObserver = new SettingsObserver(); updateStreamVolumeAlias(false /*updateVolumes*/); Loading Loading @@ -678,6 +683,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished { if (ringerMode != ringerModeFromSettings) { Settings.Global.putInt(cr, Settings.Global.MODE_RINGER, ringerMode); } if (mUseFixedVolume) { ringerMode = AudioManager.RINGER_MODE_NORMAL; } synchronized(mSettingsLock) { mRingerMode = ringerMode; Loading Loading @@ -736,6 +744,10 @@ public class AudioService extends IAudioService.Stub implements OnFinished { boolean masterMute = System.getIntForUser(cr, System.VOLUME_MASTER_MUTE, 0, UserHandle.USER_CURRENT) == 1; if (mUseFixedVolume) { masterMute = false; AudioSystem.setMasterVolume(1.0f); } AudioSystem.setMasterMute(masterMute); broadcastMasterMuteStatus(masterMute); Loading Loading @@ -806,6 +818,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished { /** @see AudioManager#adjustStreamVolume(int, int, int) */ public void adjustStreamVolume(int streamType, int direction, int flags) { if (mUseFixedVolume) { return; } if (DEBUG_VOL) Log.d(TAG, "adjustStreamVolume() stream="+streamType+", dir="+direction); ensureValidDirection(direction); Loading Loading @@ -918,6 +933,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished { /** @see AudioManager#adjustMasterVolume(int, int) */ public void adjustMasterVolume(int steps, int flags) { if (mUseFixedVolume) { return; } ensureValidSteps(steps); int volume = Math.round(AudioSystem.getMasterVolume() * MAX_MASTER_VOLUME); int delta = 0; Loading Loading @@ -972,6 +990,10 @@ public class AudioService extends IAudioService.Stub implements OnFinished { /** @see AudioManager#setStreamVolume(int, int, int) */ public void setStreamVolume(int streamType, int index, int flags) { if (mUseFixedVolume) { return; } ensureValidStreamType(streamType); VolumeStreamState streamState = mStreamStates[mStreamVolumeAlias[streamType]]; Loading Loading @@ -1214,6 +1236,10 @@ public class AudioService extends IAudioService.Stub implements OnFinished { /** @see AudioManager#setStreamSolo(int, boolean) */ public void setStreamSolo(int streamType, boolean state, IBinder cb) { if (mUseFixedVolume) { return; } for (int stream = 0; stream < mStreamStates.length; stream++) { if (!isStreamAffectedByMute(stream) || stream == streamType) continue; // Bring back last audible volume Loading @@ -1223,6 +1249,10 @@ public class AudioService extends IAudioService.Stub implements OnFinished { /** @see AudioManager#setStreamMute(int, boolean) */ public void setStreamMute(int streamType, boolean state, IBinder cb) { if (mUseFixedVolume) { return; } if (isStreamAffectedByMute(streamType)) { mStreamStates[streamType].mute(cb, state); } Loading @@ -1235,6 +1265,10 @@ public class AudioService extends IAudioService.Stub implements OnFinished { /** @see AudioManager#setMasterMute(boolean, int) */ public void setMasterMute(boolean state, int flags, IBinder cb) { if (mUseFixedVolume) { return; } if (state != AudioSystem.getMasterMute()) { AudioSystem.setMasterMute(state); // Post a persist master volume msg Loading Loading @@ -1268,6 +1302,10 @@ public class AudioService extends IAudioService.Stub implements OnFinished { } public void setMasterVolume(int volume, int flags) { if (mUseFixedVolume) { return; } if (volume < 0) { volume = 0; } else if (volume > MAX_MASTER_VOLUME) { Loading Loading @@ -1339,6 +1377,10 @@ public class AudioService extends IAudioService.Stub implements OnFinished { /** @see AudioManager#setRingerMode(int) */ public void setRingerMode(int ringerMode) { if (mUseFixedVolume) { return; } if ((ringerMode == AudioManager.RINGER_MODE_VIBRATE) && !mHasVibrator) { ringerMode = AudioManager.RINGER_MODE_SILENT; } Loading Loading @@ -1398,6 +1440,10 @@ public class AudioService extends IAudioService.Stub implements OnFinished { } private void restoreMasterVolume() { if (mUseFixedVolume) { AudioSystem.setMasterVolume(1.0f); return; } if (mUseMasterVolume) { float volume = Settings.System.getFloatForUser(mContentResolver, Settings.System.VOLUME_MASTER, -1.0f, UserHandle.USER_CURRENT); Loading Loading @@ -1951,8 +1997,8 @@ public class AudioService extends IAudioService.Stub implements OnFinished { streamState.readSettings(); // unmute stream that was muted but is not affect by mute anymore if (streamState.muteCount() != 0 && !isStreamAffectedByMute(streamType) && !isStreamMutedByRingerMode(streamType)) { if (streamState.muteCount() != 0 && ((!isStreamAffectedByMute(streamType) && !isStreamMutedByRingerMode(streamType)) || mUseFixedVolume)) { int size = streamState.mDeathHandlers.size(); for (int i = 0; i < size; i++) { streamState.mDeathHandlers.get(i).mMuteCount = 1; Loading Loading @@ -2833,8 +2879,12 @@ public class AudioService extends IAudioService.Stub implements OnFinished { } public synchronized void readSettings() { int remainingDevices = AudioSystem.DEVICE_OUT_ALL; // force maximum volume on all streams if fixed volume property is set if (mUseFixedVolume) { mIndex.put(AudioSystem.DEVICE_OUT_DEFAULT, mIndexMax); mLastAudibleIndex.put(AudioSystem.DEVICE_OUT_DEFAULT, mIndexMax); return; } // do not read system stream volume from settings: this stream is always aliased // to another stream type and its volume is never persisted. Values in settings can // only be stale values Loading @@ -2855,6 +2905,8 @@ public class AudioService extends IAudioService.Stub implements OnFinished { return; } int remainingDevices = AudioSystem.DEVICE_OUT_ALL; for (int i = 0; remainingDevices != 0; i++) { int device = (1 << i); if ((device & remainingDevices) == 0) { Loading Loading @@ -2972,7 +3024,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished { index = mIndexMax; } } mIndex.put(device, getValidIndex(index)); mIndex.put(device, index); if (oldIndex != index) { if (lastAudible) { Loading Loading @@ -3106,7 +3158,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished { private int getValidIndex(int index) { if (index < 0) { return 0; } else if (index > mIndexMax) { } else if (mUseFixedVolume || index > mIndexMax) { return mIndexMax; } Loading Loading @@ -3328,6 +3380,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished { private void persistVolume(VolumeStreamState streamState, int persistType, int device) { if (mUseFixedVolume) { return; } if ((persistType & PERSIST_CURRENT) != 0) { System.putIntForUser(mContentResolver, streamState.getSettingNameForDevice(false /* lastAudible */, device), Loading @@ -3343,6 +3398,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished { } private void persistRingerMode(int ringerMode) { if (mUseFixedVolume) { return; } Settings.Global.putInt(mContentResolver, Settings.Global.MODE_RINGER, ringerMode); } Loading Loading @@ -3439,6 +3497,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished { break; case MSG_PERSIST_MASTER_VOLUME: if (mUseFixedVolume) { return; } Settings.System.putFloatForUser(mContentResolver, Settings.System.VOLUME_MASTER, (float)msg.arg1 / (float)1000.0, Loading @@ -3446,6 +3507,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished { break; case MSG_PERSIST_MASTER_VOLUME_MUTE: if (mUseFixedVolume) { return; } Settings.System.putIntForUser(mContentResolver, Settings.System.VOLUME_MASTER_MUTE, msg.arg1, Loading
media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/audio/MediaAudioManagerTest.java +11 −4 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ public class MediaAudioManagerTest extends ActivityInstrumentationTestCase2<Medi private final static int WAIT_FOR_LOOPER_TO_INITIALIZE_MS = 60000; // 60s private int[] ringtoneMode = {AudioManager.RINGER_MODE_NORMAL, AudioManager.RINGER_MODE_SILENT, AudioManager.RINGER_MODE_VIBRATE}; private boolean mUseFixedVolume; public MediaAudioManagerTest() { super("com.android.mediaframeworktest", MediaFrameworkTest.class); Loading @@ -65,6 +66,10 @@ public class MediaAudioManagerTest extends ActivityInstrumentationTestCase2<Medi @Override protected void setUp() throws Exception { super.setUp(); mUseFixedVolume = getActivity().getResources().getBoolean( com.android.internal.R.bool.config_useFixedVolume); synchronized(mLooperLock) { initializeAudioManagerWithLooper(); try { Loading @@ -91,10 +96,12 @@ public class MediaAudioManagerTest extends ActivityInstrumentationTestCase2<Medi public boolean validateSetRingTone(int i) { int getRingtone = mAudioManager.getRingerMode(); if (i != getRingtone) return false; else return true; if (mUseFixedVolume) { return (getRingtone == AudioManager.RINGER_MODE_NORMAL); } else { return (getRingtone == i); } } // Test case 1: Simple test case to validate the set ringtone mode Loading
policy/src/com/android/internal/policy/impl/GlobalActions.java +7 −3 Original line number Diff line number Diff line Loading @@ -102,6 +102,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac private boolean mIsWaitingForEcmExit = false; private boolean mHasTelephony; private boolean mHasVibrator; private final boolean mShowSilentToggle; /** * @param context everything needs a context :( Loading Loading @@ -132,6 +133,9 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac mAirplaneModeObserver); Vibrator vibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); mHasVibrator = vibrator != null && vibrator.hasVibrator(); mShowSilentToggle = SHOW_SILENT_TOGGLE && !mContext.getResources().getBoolean( com.android.internal.R.bool.config_useFixedVolume); } /** Loading Loading @@ -309,7 +313,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac } // last: silent mode if (SHOW_SILENT_TOGGLE) { if (mShowSilentToggle) { mItems.add(mSilentModeAction); } Loading Loading @@ -390,7 +394,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac mAirplaneModeOn.updateState(mAirplaneState); mAdapter.notifyDataSetChanged(); mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG); if (SHOW_SILENT_TOGGLE) { if (mShowSilentToggle) { IntentFilter filter = new IntentFilter(AudioManager.RINGER_MODE_CHANGED_ACTION); mContext.registerReceiver(mRingerModeReceiver, filter); } Loading @@ -407,7 +411,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac /** {@inheritDoc} */ public void onDismiss(DialogInterface dialog) { if (SHOW_SILENT_TOGGLE) { if (mShowSilentToggle) { try { mContext.unregisterReceiver(mRingerModeReceiver); } catch (IllegalArgumentException ie) { Loading