am c8ade15d: Merge "Silent and Vibrate mode clean up" into jb-dev
* commit 'c8ade15dadd680c5e4b201f3b7b0823a13dedb3e': Silent and Vibrate mode clean up
This commit is contained in:
@@ -1557,6 +1557,9 @@ public final class Settings {
|
|||||||
* will likely be removed in a future release with support for
|
* will likely be removed in a future release with support for
|
||||||
* audio/vibe feedback profiles.
|
* audio/vibe feedback profiles.
|
||||||
*
|
*
|
||||||
|
* Not used anymore. On devices with vibrator, the user explicitly selects
|
||||||
|
* silent or vibrate mode.
|
||||||
|
* Kept for use by legacy database upgrade code in DatabaseHelper.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static final String VIBRATE_IN_SILENT = "vibrate_in_silent";
|
public static final String VIBRATE_IN_SILENT = "vibrate_in_silent";
|
||||||
@@ -1983,7 +1986,6 @@ public final class Settings {
|
|||||||
SCREEN_BRIGHTNESS,
|
SCREEN_BRIGHTNESS,
|
||||||
SCREEN_BRIGHTNESS_MODE,
|
SCREEN_BRIGHTNESS_MODE,
|
||||||
SCREEN_AUTO_BRIGHTNESS_ADJ,
|
SCREEN_AUTO_BRIGHTNESS_ADJ,
|
||||||
VIBRATE_ON,
|
|
||||||
VIBRATE_INPUT_DEVICES,
|
VIBRATE_INPUT_DEVICES,
|
||||||
MODE_RINGER,
|
MODE_RINGER,
|
||||||
MODE_RINGER_STREAMS_AFFECTED,
|
MODE_RINGER_STREAMS_AFFECTED,
|
||||||
@@ -2002,7 +2004,6 @@ public final class Settings {
|
|||||||
VOLUME_ALARM + APPEND_FOR_LAST_AUDIBLE,
|
VOLUME_ALARM + APPEND_FOR_LAST_AUDIBLE,
|
||||||
VOLUME_NOTIFICATION + APPEND_FOR_LAST_AUDIBLE,
|
VOLUME_NOTIFICATION + APPEND_FOR_LAST_AUDIBLE,
|
||||||
VOLUME_BLUETOOTH_SCO + APPEND_FOR_LAST_AUDIBLE,
|
VOLUME_BLUETOOTH_SCO + APPEND_FOR_LAST_AUDIBLE,
|
||||||
VIBRATE_IN_SILENT,
|
|
||||||
TEXT_AUTO_REPLACE,
|
TEXT_AUTO_REPLACE,
|
||||||
TEXT_AUTO_CAPS,
|
TEXT_AUTO_CAPS,
|
||||||
TEXT_AUTO_PUNCTUATE,
|
TEXT_AUTO_PUNCTUATE,
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ import android.os.PowerManager;
|
|||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
|
import android.os.Vibrator;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.provider.Settings.System;
|
import android.provider.Settings.System;
|
||||||
import android.telephony.PhoneStateListener;
|
import android.telephony.PhoneStateListener;
|
||||||
@@ -119,19 +120,18 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
|
|||||||
private static final int MSG_PERSIST_VOLUME = 1;
|
private static final int MSG_PERSIST_VOLUME = 1;
|
||||||
private static final int MSG_PERSIST_MASTER_VOLUME = 2;
|
private static final int MSG_PERSIST_MASTER_VOLUME = 2;
|
||||||
private static final int MSG_PERSIST_RINGER_MODE = 3;
|
private static final int MSG_PERSIST_RINGER_MODE = 3;
|
||||||
private static final int MSG_PERSIST_VIBRATE_SETTING = 4;
|
private static final int MSG_MEDIA_SERVER_DIED = 4;
|
||||||
private static final int MSG_MEDIA_SERVER_DIED = 5;
|
private static final int MSG_MEDIA_SERVER_STARTED = 5;
|
||||||
private static final int MSG_MEDIA_SERVER_STARTED = 6;
|
private static final int MSG_PLAY_SOUND_EFFECT = 6;
|
||||||
private static final int MSG_PLAY_SOUND_EFFECT = 7;
|
private static final int MSG_BTA2DP_DOCK_TIMEOUT = 7;
|
||||||
private static final int MSG_BTA2DP_DOCK_TIMEOUT = 8;
|
private static final int MSG_LOAD_SOUND_EFFECTS = 8;
|
||||||
private static final int MSG_LOAD_SOUND_EFFECTS = 9;
|
private static final int MSG_SET_FORCE_USE = 9;
|
||||||
private static final int MSG_SET_FORCE_USE = 10;
|
private static final int MSG_PERSIST_MEDIABUTTONRECEIVER = 10;
|
||||||
private static final int MSG_PERSIST_MEDIABUTTONRECEIVER = 11;
|
private static final int MSG_BT_HEADSET_CNCT_FAILED = 11;
|
||||||
private static final int MSG_BT_HEADSET_CNCT_FAILED = 12;
|
private static final int MSG_RCDISPLAY_CLEAR = 12;
|
||||||
private static final int MSG_RCDISPLAY_CLEAR = 13;
|
private static final int MSG_RCDISPLAY_UPDATE = 13;
|
||||||
private static final int MSG_RCDISPLAY_UPDATE = 14;
|
private static final int MSG_SET_ALL_VOLUMES = 14;
|
||||||
private static final int MSG_SET_ALL_VOLUMES = 15;
|
private static final int MSG_PERSIST_MASTER_VOLUME_MUTE = 15;
|
||||||
private static final int MSG_PERSIST_MASTER_VOLUME_MUTE = 16;
|
|
||||||
|
|
||||||
|
|
||||||
// flags for MSG_PERSIST_VOLUME indicating if current and/or last audible volume should be
|
// flags for MSG_PERSIST_VOLUME indicating if current and/or last audible volume should be
|
||||||
@@ -241,6 +241,20 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
|
|||||||
};
|
};
|
||||||
private int[] mStreamVolumeAlias;
|
private int[] mStreamVolumeAlias;
|
||||||
|
|
||||||
|
// stream names used by dumpStreamStates()
|
||||||
|
private final String[] STREAM_NAMES = new String[] {
|
||||||
|
"STREAM_VOICE_CALL",
|
||||||
|
"STREAM_SYSTEM",
|
||||||
|
"STREAM_RING",
|
||||||
|
"STREAM_MUSIC",
|
||||||
|
"STREAM_ALARM",
|
||||||
|
"STREAM_NOTIFICATION",
|
||||||
|
"STREAM_BLUETOOTH_SCO",
|
||||||
|
"STREAM_SYSTEM_ENFORCED",
|
||||||
|
"STREAM_DTMF",
|
||||||
|
"STREAM_TTS"
|
||||||
|
};
|
||||||
|
|
||||||
private final AudioSystem.ErrorCallback mAudioSystemCallback = new AudioSystem.ErrorCallback() {
|
private final AudioSystem.ErrorCallback mAudioSystemCallback = new AudioSystem.ErrorCallback() {
|
||||||
public void onError(int error) {
|
public void onError(int error) {
|
||||||
switch (error) {
|
switch (error) {
|
||||||
@@ -282,14 +296,15 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
|
|||||||
private int mMuteAffectedStreams;
|
private int mMuteAffectedStreams;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Has multiple bits per vibrate type to indicate the type's vibrate
|
* NOTE: setVibrateSetting(), getVibrateSetting(), shouldVibrate() are deprecated.
|
||||||
* setting. See {@link #setVibrateSetting(int, int)}.
|
* mVibrateSetting is just maintained during deprecation period but vibration policy is
|
||||||
* <p>
|
* now only controlled by mHasVibrator and mRingerMode
|
||||||
* NOTE: This is not the final decision of whether vibrate is on/off for the
|
|
||||||
* type since it depends on the ringer mode. See {@link #shouldVibrate(int)}.
|
|
||||||
*/
|
*/
|
||||||
private int mVibrateSetting;
|
private int mVibrateSetting;
|
||||||
|
|
||||||
|
// Is there a vibrator
|
||||||
|
private final boolean mHasVibrator;
|
||||||
|
|
||||||
// Broadcast receiver for device connections intent broadcasts
|
// Broadcast receiver for device connections intent broadcasts
|
||||||
private final BroadcastReceiver mReceiver = new AudioServiceBroadcastReceiver();
|
private final BroadcastReceiver mReceiver = new AudioServiceBroadcastReceiver();
|
||||||
|
|
||||||
@@ -388,6 +403,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
|
|||||||
PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
|
PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
|
||||||
mMediaEventWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "mediaKeyEvent");
|
mMediaEventWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "mediaKeyEvent");
|
||||||
|
|
||||||
|
Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
|
||||||
|
mHasVibrator = vibrator == null ? false : vibrator.hasVibrator();
|
||||||
|
|
||||||
// Intialized volume
|
// Intialized volume
|
||||||
MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL] = SystemProperties.getInt(
|
MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL] = SystemProperties.getInt(
|
||||||
"ro.config.vc_call_vol_steps",
|
"ro.config.vc_call_vol_steps",
|
||||||
@@ -507,6 +525,16 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void dumpStreamStates(PrintWriter pw) {
|
||||||
|
pw.println("\nStream volumes (device: index)");
|
||||||
|
int numStreamTypes = AudioSystem.getNumStreamTypes();
|
||||||
|
for (int i = 0; i < numStreamTypes; i++) {
|
||||||
|
pw.println("- "+STREAM_NAMES[i]+":");
|
||||||
|
mStreamStates[i].dump(pw);
|
||||||
|
pw.println("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void updateStreamVolumeAlias(boolean updateVolumes) {
|
private void updateStreamVolumeAlias(boolean updateVolumes) {
|
||||||
int dtmfStreamAlias;
|
int dtmfStreamAlias;
|
||||||
@@ -538,18 +566,34 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
|
|||||||
private void readPersistedSettings() {
|
private void readPersistedSettings() {
|
||||||
final ContentResolver cr = mContentResolver;
|
final ContentResolver cr = mContentResolver;
|
||||||
|
|
||||||
int ringerMode = System.getInt(cr, System.MODE_RINGER, AudioManager.RINGER_MODE_NORMAL);
|
int ringerModeFromSettings =
|
||||||
|
System.getInt(cr, System.MODE_RINGER, AudioManager.RINGER_MODE_NORMAL);
|
||||||
|
int ringerMode = ringerModeFromSettings;
|
||||||
// sanity check in case the settings are restored from a device with incompatible
|
// sanity check in case the settings are restored from a device with incompatible
|
||||||
// ringer modes
|
// ringer modes
|
||||||
if (!AudioManager.isValidRingerMode(ringerMode)) {
|
if (!AudioManager.isValidRingerMode(ringerMode)) {
|
||||||
ringerMode = AudioManager.RINGER_MODE_NORMAL;
|
ringerMode = AudioManager.RINGER_MODE_NORMAL;
|
||||||
|
}
|
||||||
|
if ((ringerMode == AudioManager.RINGER_MODE_VIBRATE) && !mHasVibrator) {
|
||||||
|
ringerMode = AudioManager.RINGER_MODE_SILENT;
|
||||||
|
}
|
||||||
|
if (ringerMode != ringerModeFromSettings) {
|
||||||
System.putInt(cr, System.MODE_RINGER, ringerMode);
|
System.putInt(cr, System.MODE_RINGER, ringerMode);
|
||||||
}
|
}
|
||||||
synchronized(mSettingsLock) {
|
synchronized(mSettingsLock) {
|
||||||
mRingerMode = ringerMode;
|
mRingerMode = ringerMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
mVibrateSetting = System.getInt(cr, System.VIBRATE_ON, 0);
|
// System.VIBRATE_ON is not used any more but defaults for mVibrateSetting
|
||||||
|
// are still needed while setVibrateSetting() and getVibrateSetting() are being deprecated.
|
||||||
|
mVibrateSetting = getValueForVibrateSetting(0,
|
||||||
|
AudioManager.VIBRATE_TYPE_NOTIFICATION,
|
||||||
|
mHasVibrator ? AudioManager.VIBRATE_SETTING_ONLY_SILENT
|
||||||
|
: AudioManager.VIBRATE_SETTING_OFF);
|
||||||
|
mVibrateSetting = getValueForVibrateSetting(mVibrateSetting,
|
||||||
|
AudioManager.VIBRATE_TYPE_RINGER,
|
||||||
|
mHasVibrator ? AudioManager.VIBRATE_SETTING_ONLY_SILENT
|
||||||
|
: AudioManager.VIBRATE_SETTING_OFF);
|
||||||
|
|
||||||
// make sure settings for ringer mode are consistent with device type: non voice capable
|
// make sure settings for ringer mode are consistent with device type: non voice capable
|
||||||
// devices (tablets) include media stream in silent mode whereas phones don't.
|
// devices (tablets) include media stream in silent mode whereas phones don't.
|
||||||
@@ -639,8 +683,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
|
|||||||
// If either the client forces allowing ringer modes for this adjustment,
|
// If either the client forces allowing ringer modes for this adjustment,
|
||||||
// or the stream type is one that is affected by ringer modes
|
// or the stream type is one that is affected by ringer modes
|
||||||
if (((flags & AudioManager.FLAG_ALLOW_RINGER_MODES) != 0) ||
|
if (((flags & AudioManager.FLAG_ALLOW_RINGER_MODES) != 0) ||
|
||||||
streamTypeAlias == AudioSystem.STREAM_RING ||
|
(streamTypeAlias == getMasterStreamType())) {
|
||||||
(!mVoiceCapable && streamTypeAlias == AudioSystem.STREAM_MUSIC)) {
|
|
||||||
int ringerMode = getRingerMode();
|
int ringerMode = getRingerMode();
|
||||||
// do not vibrate if already in vibrate mode
|
// do not vibrate if already in vibrate mode
|
||||||
if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) {
|
if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) {
|
||||||
@@ -648,7 +691,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
|
|||||||
}
|
}
|
||||||
// Check if the ringer mode changes with this volume adjustment. If
|
// Check if the ringer mode changes with this volume adjustment. If
|
||||||
// it does, it will handle adjusting the volume, so we won't below
|
// it does, it will handle adjusting the volume, so we won't below
|
||||||
adjustVolume = checkForRingerModeChange(oldIndex, direction, streamTypeAlias);
|
adjustVolume = checkForRingerModeChange(oldIndex, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If stream is muted, adjust last audible index only
|
// If stream is muted, adjust last audible index only
|
||||||
@@ -724,9 +767,8 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
|
|||||||
(mStreamVolumeAlias[streamType] == getMasterStreamType())) {
|
(mStreamVolumeAlias[streamType] == getMasterStreamType())) {
|
||||||
int newRingerMode;
|
int newRingerMode;
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
newRingerMode = System.getInt(mContentResolver, System.VIBRATE_IN_SILENT, 1) == 1
|
newRingerMode = mHasVibrator ? AudioManager.RINGER_MODE_VIBRATE
|
||||||
? AudioManager.RINGER_MODE_VIBRATE
|
: AudioManager.RINGER_MODE_SILENT;
|
||||||
: AudioManager.RINGER_MODE_SILENT;
|
|
||||||
setStreamVolumeInt(mStreamVolumeAlias[streamType],
|
setStreamVolumeInt(mStreamVolumeAlias[streamType],
|
||||||
index,
|
index,
|
||||||
device,
|
device,
|
||||||
@@ -1070,7 +1112,6 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
|
|||||||
// on voice capable devices
|
// on voice capable devices
|
||||||
if (mVoiceCapable &&
|
if (mVoiceCapable &&
|
||||||
mStreamVolumeAlias[streamType] == AudioSystem.STREAM_RING) {
|
mStreamVolumeAlias[streamType] == AudioSystem.STREAM_RING) {
|
||||||
|
|
||||||
Set set = mStreamStates[streamType].mLastAudibleIndex.entrySet();
|
Set set = mStreamStates[streamType].mLastAudibleIndex.entrySet();
|
||||||
Iterator i = set.iterator();
|
Iterator i = set.iterator();
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
@@ -1111,6 +1152,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
|
|||||||
|
|
||||||
/** @see AudioManager#shouldVibrate(int) */
|
/** @see AudioManager#shouldVibrate(int) */
|
||||||
public boolean shouldVibrate(int vibrateType) {
|
public boolean shouldVibrate(int vibrateType) {
|
||||||
|
if (!mHasVibrator) return false;
|
||||||
|
|
||||||
switch (getVibrateSetting(vibrateType)) {
|
switch (getVibrateSetting(vibrateType)) {
|
||||||
|
|
||||||
@@ -1131,21 +1173,20 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
|
|||||||
|
|
||||||
/** @see AudioManager#getVibrateSetting(int) */
|
/** @see AudioManager#getVibrateSetting(int) */
|
||||||
public int getVibrateSetting(int vibrateType) {
|
public int getVibrateSetting(int vibrateType) {
|
||||||
|
if (!mHasVibrator) return AudioManager.VIBRATE_SETTING_OFF;
|
||||||
return (mVibrateSetting >> (vibrateType * 2)) & 3;
|
return (mVibrateSetting >> (vibrateType * 2)) & 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see AudioManager#setVibrateSetting(int, int) */
|
/** @see AudioManager#setVibrateSetting(int, int) */
|
||||||
public void setVibrateSetting(int vibrateType, int vibrateSetting) {
|
public void setVibrateSetting(int vibrateType, int vibrateSetting) {
|
||||||
|
|
||||||
|
if (!mHasVibrator) return;
|
||||||
|
|
||||||
mVibrateSetting = getValueForVibrateSetting(mVibrateSetting, vibrateType, vibrateSetting);
|
mVibrateSetting = getValueForVibrateSetting(mVibrateSetting, vibrateType, vibrateSetting);
|
||||||
|
|
||||||
// Broadcast change
|
// Broadcast change
|
||||||
broadcastVibrateSetting(vibrateType);
|
broadcastVibrateSetting(vibrateType);
|
||||||
|
|
||||||
// Post message to set ringer mode (it in turn will post a message
|
|
||||||
// to persist)
|
|
||||||
sendMsg(mAudioHandler, MSG_PERSIST_VIBRATE_SETTING, SENDMSG_NOOP, 0, 0,
|
|
||||||
null, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1967,48 +2008,56 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
|
|||||||
* adjusting volume. If so, this will set the proper ringer mode and volume
|
* adjusting volume. If so, this will set the proper ringer mode and volume
|
||||||
* indices on the stream states.
|
* indices on the stream states.
|
||||||
*/
|
*/
|
||||||
private boolean checkForRingerModeChange(int oldIndex, int direction, int streamType) {
|
private boolean checkForRingerModeChange(int oldIndex, int direction) {
|
||||||
boolean adjustVolumeIndex = true;
|
boolean adjustVolumeIndex = true;
|
||||||
int ringerMode = getRingerMode();
|
int ringerMode = getRingerMode();
|
||||||
int newRingerMode = ringerMode;
|
|
||||||
int uiIndex = (oldIndex + 5) / 10;
|
int uiIndex = (oldIndex + 5) / 10;
|
||||||
boolean vibeInSilent = System.getInt(mContentResolver, System.VIBRATE_IN_SILENT, 1) == 1;
|
|
||||||
|
|
||||||
if (ringerMode == RINGER_MODE_NORMAL) {
|
switch (ringerMode) {
|
||||||
if ((direction == AudioManager.ADJUST_LOWER) && (uiIndex <= 1)) {
|
case RINGER_MODE_NORMAL:
|
||||||
// enter silent mode if current index is the last audible one and not repeating a
|
if (direction == AudioManager.ADJUST_LOWER) {
|
||||||
// volume key down
|
if (mHasVibrator) {
|
||||||
if (vibeInSilent || mPrevVolDirection != AudioManager.ADJUST_LOWER) {
|
if (uiIndex == 1) {
|
||||||
// "silent mode", but which one?
|
ringerMode = RINGER_MODE_VIBRATE;
|
||||||
newRingerMode = vibeInSilent ? RINGER_MODE_VIBRATE : RINGER_MODE_SILENT;
|
}
|
||||||
}
|
} else {
|
||||||
if (uiIndex == 0 ||
|
if (uiIndex == 0 && mPrevVolDirection != AudioManager.ADJUST_LOWER) {
|
||||||
(!vibeInSilent &&
|
ringerMode = RINGER_MODE_SILENT;
|
||||||
mPrevVolDirection == AudioManager.ADJUST_LOWER &&
|
}
|
||||||
mVoiceCapable && streamType == AudioSystem.STREAM_RING)) {
|
|
||||||
adjustVolumeIndex = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (ringerMode == RINGER_MODE_VIBRATE) {
|
break;
|
||||||
|
case RINGER_MODE_VIBRATE:
|
||||||
|
if (!mHasVibrator) {
|
||||||
|
Log.e(TAG, "checkForRingerModeChange() current ringer mode is vibrate" +
|
||||||
|
"but no vibrator is present");
|
||||||
|
break;
|
||||||
|
}
|
||||||
if ((direction == AudioManager.ADJUST_LOWER)) {
|
if ((direction == AudioManager.ADJUST_LOWER)) {
|
||||||
// Set it to silent, if it wasn't a long-press
|
|
||||||
if (mPrevVolDirection != AudioManager.ADJUST_LOWER) {
|
if (mPrevVolDirection != AudioManager.ADJUST_LOWER) {
|
||||||
newRingerMode = RINGER_MODE_SILENT;
|
ringerMode = RINGER_MODE_SILENT;
|
||||||
}
|
}
|
||||||
} else if (direction == AudioManager.ADJUST_RAISE) {
|
} else if (direction == AudioManager.ADJUST_RAISE) {
|
||||||
newRingerMode = RINGER_MODE_NORMAL;
|
ringerMode = RINGER_MODE_NORMAL;
|
||||||
}
|
}
|
||||||
adjustVolumeIndex = false;
|
adjustVolumeIndex = false;
|
||||||
} else {
|
break;
|
||||||
|
case RINGER_MODE_SILENT:
|
||||||
if (direction == AudioManager.ADJUST_RAISE) {
|
if (direction == AudioManager.ADJUST_RAISE) {
|
||||||
// exiting silent mode
|
if (mHasVibrator) {
|
||||||
// If VIBRATE_IN_SILENT, then go into vibrate mode
|
ringerMode = RINGER_MODE_VIBRATE;
|
||||||
newRingerMode = vibeInSilent ? RINGER_MODE_VIBRATE : RINGER_MODE_NORMAL;
|
} else {
|
||||||
|
ringerMode = RINGER_MODE_NORMAL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
adjustVolumeIndex = false;
|
adjustVolumeIndex = false;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Log.e(TAG, "checkForRingerModeChange() wrong ringer mode: "+ringerMode);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
setRingerMode(newRingerMode);
|
setRingerMode(ringerMode);
|
||||||
|
|
||||||
mPrevVolDirection = direction;
|
mPrevVolDirection = direction;
|
||||||
|
|
||||||
@@ -2217,9 +2266,6 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void readSettings() {
|
public void readSettings() {
|
||||||
boolean checkSilentVolume = (mRingerMode == AudioManager.RINGER_MODE_NORMAL) &&
|
|
||||||
isStreamAffectedByRingerMode(mStreamType);
|
|
||||||
|
|
||||||
int remainingDevices = AudioSystem.DEVICE_OUT_ALL;
|
int remainingDevices = AudioSystem.DEVICE_OUT_ALL;
|
||||||
|
|
||||||
for (int i = 0; remainingDevices != 0; i++) {
|
for (int i = 0; remainingDevices != 0; i++) {
|
||||||
@@ -2248,12 +2294,13 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
|
|||||||
index : AudioManager.DEFAULT_STREAM_VOLUME[mStreamType];
|
index : AudioManager.DEFAULT_STREAM_VOLUME[mStreamType];
|
||||||
int lastAudibleIndex = Settings.System.getInt(mContentResolver, name, defaultIndex);
|
int lastAudibleIndex = Settings.System.getInt(mContentResolver, name, defaultIndex);
|
||||||
|
|
||||||
// a last audible index of 0 is never stored, except on non-voice capable devices
|
// a last audible index of 0 should never be stored for ring and notification
|
||||||
// (e.g. tablets) for the music stream type, where the music stream volume can reach
|
// streams on phones (voice capable devices).
|
||||||
// 0 without the device being in silent mode
|
// same for system stream on phones and tablets
|
||||||
if ((lastAudibleIndex == 0) &&
|
if ((lastAudibleIndex == 0) &&
|
||||||
(mVoiceCapable ||
|
((mVoiceCapable &&
|
||||||
(mStreamVolumeAlias[mStreamType] != AudioSystem.STREAM_MUSIC))) {
|
(mStreamVolumeAlias[mStreamType] == AudioSystem.STREAM_RING)) ||
|
||||||
|
(mStreamVolumeAlias[mStreamType] == AudioSystem.STREAM_SYSTEM))) {
|
||||||
lastAudibleIndex = AudioManager.DEFAULT_STREAM_VOLUME[mStreamType];
|
lastAudibleIndex = AudioManager.DEFAULT_STREAM_VOLUME[mStreamType];
|
||||||
// Correct the data base
|
// Correct the data base
|
||||||
sendMsg(mAudioHandler,
|
sendMsg(mAudioHandler,
|
||||||
@@ -2265,12 +2312,13 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
|
|||||||
PERSIST_DELAY);
|
PERSIST_DELAY);
|
||||||
}
|
}
|
||||||
mLastAudibleIndex.put(device, getValidIndex(10 * lastAudibleIndex));
|
mLastAudibleIndex.put(device, getValidIndex(10 * lastAudibleIndex));
|
||||||
// the initial index should never be 0 for a stream affected by ringer mode if not
|
// the initial index should never be 0 for ring and notification streams on phones
|
||||||
// in silent or vibrate mode.
|
// (voice capable devices) if not in silent or vibrate mode.
|
||||||
// this is permitted on tablets for music stream type.
|
// same for system stream on phones and tablets
|
||||||
if (checkSilentVolume && (index == 0) &&
|
if ((index == 0) && (mRingerMode == AudioManager.RINGER_MODE_NORMAL) &&
|
||||||
(mVoiceCapable ||
|
((mVoiceCapable &&
|
||||||
(mStreamVolumeAlias[mStreamType] != AudioSystem.STREAM_MUSIC))) {
|
(mStreamVolumeAlias[mStreamType] == AudioSystem.STREAM_RING)) ||
|
||||||
|
(mStreamVolumeAlias[mStreamType] == AudioSystem.STREAM_SYSTEM))) {
|
||||||
index = lastAudibleIndex;
|
index = lastAudibleIndex;
|
||||||
// Correct the data base
|
// Correct the data base
|
||||||
sendMsg(mAudioHandler,
|
sendMsg(mAudioHandler,
|
||||||
@@ -2328,14 +2376,22 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
|
|||||||
mLastAudibleIndex.put(device, index);
|
mLastAudibleIndex.put(device, index);
|
||||||
}
|
}
|
||||||
// Apply change to all streams using this one as alias
|
// Apply change to all streams using this one as alias
|
||||||
|
// if changing volume of current device, also change volume of current
|
||||||
|
// device on aliased stream
|
||||||
|
boolean currentDevice = (device == getDeviceForStream(mStreamType));
|
||||||
int numStreamTypes = AudioSystem.getNumStreamTypes();
|
int numStreamTypes = AudioSystem.getNumStreamTypes();
|
||||||
for (int streamType = numStreamTypes - 1; streamType >= 0; streamType--) {
|
for (int streamType = numStreamTypes - 1; streamType >= 0; streamType--) {
|
||||||
if (streamType != mStreamType && mStreamVolumeAlias[streamType] == mStreamType) {
|
if (streamType != mStreamType &&
|
||||||
mStreamStates[streamType].setIndex(rescaleIndex(index,
|
mStreamVolumeAlias[streamType] == mStreamType) {
|
||||||
mStreamType,
|
int scaledIndex = rescaleIndex(index, mStreamType, streamType);
|
||||||
streamType),
|
mStreamStates[streamType].setIndex(scaledIndex,
|
||||||
getDeviceForStream(streamType),
|
device,
|
||||||
lastAudible);
|
lastAudible);
|
||||||
|
if (currentDevice) {
|
||||||
|
mStreamStates[streamType].setIndex(scaledIndex,
|
||||||
|
getDeviceForStream(streamType),
|
||||||
|
lastAudible);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -2544,6 +2600,25 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
|
|||||||
return handler;
|
return handler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void dump(PrintWriter pw) {
|
||||||
|
pw.print(" Current: ");
|
||||||
|
Set set = mIndex.entrySet();
|
||||||
|
Iterator i = set.iterator();
|
||||||
|
while (i.hasNext()) {
|
||||||
|
Map.Entry entry = (Map.Entry)i.next();
|
||||||
|
pw.print(Integer.toHexString(((Integer)entry.getKey()).intValue())
|
||||||
|
+ ": " + ((((Integer)entry.getValue()).intValue() + 5) / 10)+", ");
|
||||||
|
}
|
||||||
|
pw.print("\n Last audible: ");
|
||||||
|
set = mLastAudibleIndex.entrySet();
|
||||||
|
i = set.iterator();
|
||||||
|
while (i.hasNext()) {
|
||||||
|
Map.Entry entry = (Map.Entry)i.next();
|
||||||
|
pw.print(Integer.toHexString(((Integer)entry.getKey()).intValue())
|
||||||
|
+ ": " + ((((Integer)entry.getValue()).intValue() + 5) / 10)+", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Thread that handles native AudioSystem control. */
|
/** Thread that handles native AudioSystem control. */
|
||||||
@@ -2631,10 +2706,6 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
|
|||||||
System.putInt(mContentResolver, System.MODE_RINGER, ringerMode);
|
System.putInt(mContentResolver, System.MODE_RINGER, ringerMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void persistVibrateSetting() {
|
|
||||||
System.putInt(mContentResolver, System.VIBRATE_ON, mVibrateSetting);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void playSoundEffect(int effectType, int volume) {
|
private void playSoundEffect(int effectType, int volume) {
|
||||||
synchronized (mSoundEffectsLock) {
|
synchronized (mSoundEffectsLock) {
|
||||||
if (mSoundPool == null) {
|
if (mSoundPool == null) {
|
||||||
@@ -2734,10 +2805,6 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
|
|||||||
persistRingerMode(getRingerMode());
|
persistRingerMode(getRingerMode());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_PERSIST_VIBRATE_SETTING:
|
|
||||||
persistVibrateSetting();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MSG_MEDIA_SERVER_DIED:
|
case MSG_MEDIA_SERVER_DIED:
|
||||||
if (!mMediaServerOk) {
|
if (!mMediaServerOk) {
|
||||||
Log.e(TAG, "Media server died.");
|
Log.e(TAG, "Media server died.");
|
||||||
@@ -4366,5 +4433,6 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
|
|||||||
// TODO probably a lot more to do here than just the audio focus and remote control stacks
|
// TODO probably a lot more to do here than just the audio focus and remote control stacks
|
||||||
dumpFocusStack(pw);
|
dumpFocusStack(pw);
|
||||||
dumpRCStack(pw);
|
dumpRCStack(pw);
|
||||||
|
dumpStreamStates(pw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -260,6 +260,8 @@ public class AudioSystem
|
|||||||
public static final String DEVICE_OUT_AUX_DIGITAL_NAME = "aux_digital";
|
public static final String DEVICE_OUT_AUX_DIGITAL_NAME = "aux_digital";
|
||||||
public static final String DEVICE_OUT_ANLG_DOCK_HEADSET_NAME = "analog_dock";
|
public static final String DEVICE_OUT_ANLG_DOCK_HEADSET_NAME = "analog_dock";
|
||||||
public static final String DEVICE_OUT_DGTL_DOCK_HEADSET_NAME = "digital_dock";
|
public static final String DEVICE_OUT_DGTL_DOCK_HEADSET_NAME = "digital_dock";
|
||||||
|
public static final String DEVICE_OUT_USB_ACCESSORY_NAME = "usb_accessory";
|
||||||
|
public static final String DEVICE_OUT_USB_DEVICE_NAME = "usb_device";
|
||||||
|
|
||||||
public static String getDeviceName(int device)
|
public static String getDeviceName(int device)
|
||||||
{
|
{
|
||||||
@@ -290,6 +292,10 @@ public class AudioSystem
|
|||||||
return DEVICE_OUT_ANLG_DOCK_HEADSET_NAME;
|
return DEVICE_OUT_ANLG_DOCK_HEADSET_NAME;
|
||||||
case DEVICE_OUT_DGTL_DOCK_HEADSET:
|
case DEVICE_OUT_DGTL_DOCK_HEADSET:
|
||||||
return DEVICE_OUT_DGTL_DOCK_HEADSET_NAME;
|
return DEVICE_OUT_DGTL_DOCK_HEADSET_NAME;
|
||||||
|
case DEVICE_OUT_USB_ACCESSORY:
|
||||||
|
return DEVICE_OUT_USB_ACCESSORY_NAME;
|
||||||
|
case DEVICE_OUT_USB_DEVICE:
|
||||||
|
return DEVICE_OUT_USB_DEVICE_NAME;
|
||||||
case DEVICE_IN_DEFAULT:
|
case DEVICE_IN_DEFAULT:
|
||||||
default:
|
default:
|
||||||
return "";
|
return "";
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
|||||||
// database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion'
|
// database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion'
|
||||||
// is properly propagated through your change. Not doing so will result in a loss of user
|
// is properly propagated through your change. Not doing so will result in a loss of user
|
||||||
// settings.
|
// settings.
|
||||||
private static final int DATABASE_VERSION = 76;
|
private static final int DATABASE_VERSION = 77;
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
@@ -1031,6 +1031,23 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
|||||||
upgradeVersion = 76;
|
upgradeVersion = 76;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/************* The following are Jelly Bean changes ************/
|
||||||
|
|
||||||
|
if (upgradeVersion == 76) {
|
||||||
|
// Removed VIBRATE_IN_SILENT setting
|
||||||
|
db.beginTransaction();
|
||||||
|
try {
|
||||||
|
db.execSQL("DELETE FROM system WHERE name='"
|
||||||
|
+ Settings.System.VIBRATE_IN_SILENT + "'");
|
||||||
|
db.setTransactionSuccessful();
|
||||||
|
} finally {
|
||||||
|
db.endTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
upgradeVersion = 77;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// *** Remember to update DATABASE_VERSION above!
|
// *** Remember to update DATABASE_VERSION above!
|
||||||
|
|
||||||
if (upgradeVersion != currentVersion) {
|
if (upgradeVersion != currentVersion) {
|
||||||
@@ -1311,8 +1328,6 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
|||||||
loadSetting(stmt, Settings.System.MODE_RINGER,
|
loadSetting(stmt, Settings.System.MODE_RINGER,
|
||||||
AudioManager.RINGER_MODE_NORMAL);
|
AudioManager.RINGER_MODE_NORMAL);
|
||||||
|
|
||||||
loadVibrateSetting(db, false);
|
|
||||||
|
|
||||||
// By default:
|
// By default:
|
||||||
// - ringtones, notification, system and music streams are affected by ringer mode
|
// - ringtones, notification, system and music streams are affected by ringer mode
|
||||||
// on non voice capable devices (tablets)
|
// on non voice capable devices (tablets)
|
||||||
@@ -1433,9 +1448,6 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
|||||||
|
|
||||||
loadUISoundEffectsSettings(stmt);
|
loadUISoundEffectsSettings(stmt);
|
||||||
|
|
||||||
loadBooleanSetting(stmt, Settings.System.VIBRATE_IN_SILENT,
|
|
||||||
R.bool.def_vibrate_in_silent);
|
|
||||||
|
|
||||||
loadIntegerSetting(stmt, Settings.System.POINTER_SPEED,
|
loadIntegerSetting(stmt, Settings.System.POINTER_SPEED,
|
||||||
R.integer.def_pointer_speed);
|
R.integer.def_pointer_speed);
|
||||||
|
|
||||||
|
|||||||
@@ -43,9 +43,6 @@ public class SettingsHelper {
|
|||||||
private IContentService mContentService;
|
private IContentService mContentService;
|
||||||
private IPowerManager mPowerManager;
|
private IPowerManager mPowerManager;
|
||||||
|
|
||||||
private boolean mSilent;
|
|
||||||
private boolean mVibrate;
|
|
||||||
|
|
||||||
public SettingsHelper(Context context) {
|
public SettingsHelper(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mAudioManager = (AudioManager) context
|
mAudioManager = (AudioManager) context
|
||||||
@@ -119,18 +116,6 @@ public class SettingsHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setRingerMode() {
|
|
||||||
if (mSilent) {
|
|
||||||
mAudioManager.setRingerMode(mVibrate ? AudioManager.RINGER_MODE_VIBRATE :
|
|
||||||
AudioManager.RINGER_MODE_SILENT);
|
|
||||||
} else {
|
|
||||||
mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
|
|
||||||
mAudioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER,
|
|
||||||
mVibrate ? AudioManager.VIBRATE_SETTING_ON
|
|
||||||
: AudioManager.VIBRATE_SETTING_OFF);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] getLocaleData() {
|
byte[] getLocaleData() {
|
||||||
Configuration conf = mContext.getResources().getConfiguration();
|
Configuration conf = mContext.getResources().getConfiguration();
|
||||||
final Locale loc = conf.locale;
|
final Locale loc = conf.locale;
|
||||||
|
|||||||
@@ -122,8 +122,7 @@ public class PhoneStatusBarPolicy {
|
|||||||
action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) {
|
action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) {
|
||||||
updateBluetooth(intent);
|
updateBluetooth(intent);
|
||||||
}
|
}
|
||||||
else if (action.equals(AudioManager.RINGER_MODE_CHANGED_ACTION) ||
|
else if (action.equals(AudioManager.RINGER_MODE_CHANGED_ACTION)) {
|
||||||
action.equals(AudioManager.VIBRATE_SETTING_CHANGED_ACTION)) {
|
|
||||||
updateVolume();
|
updateVolume();
|
||||||
}
|
}
|
||||||
else if (action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) {
|
else if (action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) {
|
||||||
@@ -144,7 +143,6 @@ public class PhoneStatusBarPolicy {
|
|||||||
filter.addAction(Intent.ACTION_ALARM_CHANGED);
|
filter.addAction(Intent.ACTION_ALARM_CHANGED);
|
||||||
filter.addAction(Intent.ACTION_SYNC_STATE_CHANGED);
|
filter.addAction(Intent.ACTION_SYNC_STATE_CHANGED);
|
||||||
filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
|
filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
|
||||||
filter.addAction(AudioManager.VIBRATE_SETTING_CHANGED_ACTION);
|
|
||||||
filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
|
filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
|
||||||
filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
|
filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
|
||||||
filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
|
filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
|
||||||
@@ -238,7 +236,7 @@ public class PhoneStatusBarPolicy {
|
|||||||
|
|
||||||
final int iconId;
|
final int iconId;
|
||||||
String contentDescription = null;
|
String contentDescription = null;
|
||||||
if (audioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_RINGER)) {
|
if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) {
|
||||||
iconId = R.drawable.stat_sys_ringer_vibrate;
|
iconId = R.drawable.stat_sys_ringer_vibrate;
|
||||||
contentDescription = mContext.getString(R.string.accessibility_ringer_vibrate);
|
contentDescription = mContext.getString(R.string.accessibility_ringer_vibrate);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import android.content.ContentResolver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
|
import android.os.Vibrator;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
@@ -36,10 +37,16 @@ public class VolumeController implements ToggleSlider.Listener {
|
|||||||
|
|
||||||
private boolean mMute;
|
private boolean mMute;
|
||||||
private int mVolume;
|
private int mVolume;
|
||||||
|
// Is there a vibrator
|
||||||
|
private final boolean mHasVibrator;
|
||||||
|
|
||||||
public VolumeController(Context context, ToggleSlider control) {
|
public VolumeController(Context context, ToggleSlider control) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mControl = control;
|
mControl = control;
|
||||||
|
|
||||||
|
Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
|
||||||
|
mHasVibrator = vibrator == null ? false : vibrator.hasVibrator();
|
||||||
|
|
||||||
mAudioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
|
mAudioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
|
||||||
|
|
||||||
mMute = mAudioManager.getRingerMode() != AudioManager.RINGER_MODE_NORMAL;
|
mMute = mAudioManager.getRingerMode() != AudioManager.RINGER_MODE_NORMAL;
|
||||||
@@ -54,10 +61,8 @@ public class VolumeController implements ToggleSlider.Listener {
|
|||||||
public void onChanged(ToggleSlider view, boolean tracking, boolean mute, int level) {
|
public void onChanged(ToggleSlider view, boolean tracking, boolean mute, int level) {
|
||||||
if (!tracking) {
|
if (!tracking) {
|
||||||
if (mute) {
|
if (mute) {
|
||||||
boolean vibeInSilent = (1 == Settings.System.getInt(mContext.getContentResolver(),
|
|
||||||
Settings.System.VIBRATE_IN_SILENT, 1));
|
|
||||||
mAudioManager.setRingerMode(
|
mAudioManager.setRingerMode(
|
||||||
vibeInSilent ? AudioManager.RINGER_MODE_VIBRATE
|
mHasVibrator ? AudioManager.RINGER_MODE_VIBRATE
|
||||||
: AudioManager.RINGER_MODE_SILENT);
|
: AudioManager.RINGER_MODE_SILENT);
|
||||||
} else {
|
} else {
|
||||||
mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
|
mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.os.Vibrator;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -82,6 +83,8 @@ class LockScreen extends LinearLayout implements KeyguardScreen {
|
|||||||
private boolean mCameraDisabled;
|
private boolean mCameraDisabled;
|
||||||
private boolean mSearchDisabled;
|
private boolean mSearchDisabled;
|
||||||
private SearchManager mSearchManager;
|
private SearchManager mSearchManager;
|
||||||
|
// Is there a vibrator
|
||||||
|
private final boolean mHasVibrator;
|
||||||
|
|
||||||
InfoCallbackImpl mInfoCallback = new InfoCallbackImpl() {
|
InfoCallbackImpl mInfoCallback = new InfoCallbackImpl() {
|
||||||
|
|
||||||
@@ -385,11 +388,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen {
|
|||||||
// toggle silent mode
|
// toggle silent mode
|
||||||
mSilentMode = !mSilentMode;
|
mSilentMode = !mSilentMode;
|
||||||
if (mSilentMode) {
|
if (mSilentMode) {
|
||||||
final boolean vibe = (Settings.System.getInt(
|
mAudioManager.setRingerMode(mHasVibrator
|
||||||
mContext.getContentResolver(),
|
|
||||||
Settings.System.VIBRATE_IN_SILENT, 1) == 1);
|
|
||||||
|
|
||||||
mAudioManager.setRingerMode(vibe
|
|
||||||
? AudioManager.RINGER_MODE_VIBRATE
|
? AudioManager.RINGER_MODE_VIBRATE
|
||||||
: AudioManager.RINGER_MODE_SILENT);
|
: AudioManager.RINGER_MODE_SILENT);
|
||||||
} else {
|
} else {
|
||||||
@@ -451,6 +450,8 @@ class LockScreen extends LinearLayout implements KeyguardScreen {
|
|||||||
setFocusableInTouchMode(true);
|
setFocusableInTouchMode(true);
|
||||||
setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
|
setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
|
||||||
|
|
||||||
|
Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
|
||||||
|
mHasVibrator = vibrator == null ? false : vibrator.hasVibrator();
|
||||||
mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
||||||
mSilentMode = isSilentMode();
|
mSilentMode = isSilentMode();
|
||||||
mUnlockWidget = findViewById(R.id.unlock_widget);
|
mUnlockWidget = findViewById(R.id.unlock_widget);
|
||||||
|
|||||||
@@ -1046,7 +1046,7 @@ public class NotificationManagerService extends INotificationManager.Stub
|
|||||||
final boolean useDefaultVibrate =
|
final boolean useDefaultVibrate =
|
||||||
(notification.defaults & Notification.DEFAULT_VIBRATE) != 0;
|
(notification.defaults & Notification.DEFAULT_VIBRATE) != 0;
|
||||||
if ((useDefaultVibrate || notification.vibrate != null)
|
if ((useDefaultVibrate || notification.vibrate != null)
|
||||||
&& audioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_NOTIFICATION)) {
|
&& !(audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT)) {
|
||||||
mVibrateNotification = r;
|
mVibrateNotification = r;
|
||||||
|
|
||||||
mVibrator.vibrate(useDefaultVibrate ? DEFAULT_VIBRATE_PATTERN
|
mVibrator.vibrate(useDefaultVibrate ? DEFAULT_VIBRATE_PATTERN
|
||||||
|
|||||||
Reference in New Issue
Block a user