summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Eric Laurent <elaurent@google.com> 2012-05-08 15:15:49 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2012-05-08 15:15:49 -0700
commitc8ade15dadd680c5e4b201f3b7b0823a13dedb3e (patch)
tree9bdbedce9405c522224b1921e0b54694d131fdf8
parent2e999d12743edf329b6991d7168099cec9f1c24f (diff)
parentbffc3d1bd33eb2d8e00a9f8b6261d815db503311 (diff)
Merge "Silent and Vibrate mode clean up" into jb-dev
-rw-r--r--core/java/android/provider/Settings.java5
-rw-r--r--media/java/android/media/AudioService.java236
-rw-r--r--media/java/android/media/AudioSystem.java6
-rw-r--r--packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java24
-rw-r--r--packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java15
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/VolumeController.java11
-rw-r--r--policy/src/com/android/internal/policy/impl/LockScreen.java11
-rwxr-xr-xservices/java/com/android/server/NotificationManagerService.java2
9 files changed, 196 insertions, 120 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 2c49bd2a335f..2f7a9ec9967e 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -1557,6 +1557,9 @@ public final class Settings {
* will likely be removed in a future release with support for
* 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
*/
public static final String VIBRATE_IN_SILENT = "vibrate_in_silent";
@@ -1983,7 +1986,6 @@ public final class Settings {
SCREEN_BRIGHTNESS,
SCREEN_BRIGHTNESS_MODE,
SCREEN_AUTO_BRIGHTNESS_ADJ,
- VIBRATE_ON,
VIBRATE_INPUT_DEVICES,
MODE_RINGER,
MODE_RINGER_STREAMS_AFFECTED,
@@ -2002,7 +2004,6 @@ public final class Settings {
VOLUME_ALARM + APPEND_FOR_LAST_AUDIBLE,
VOLUME_NOTIFICATION + APPEND_FOR_LAST_AUDIBLE,
VOLUME_BLUETOOTH_SCO + APPEND_FOR_LAST_AUDIBLE,
- VIBRATE_IN_SILENT,
TEXT_AUTO_REPLACE,
TEXT_AUTO_CAPS,
TEXT_AUTO_PUNCTUATE,
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index 2174d0653bba..1892fce5dbcb 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -55,6 +55,7 @@ import android.os.PowerManager;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
+import android.os.Vibrator;
import android.provider.Settings;
import android.provider.Settings.System;
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_MASTER_VOLUME = 2;
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 = 5;
- private static final int MSG_MEDIA_SERVER_STARTED = 6;
- private static final int MSG_PLAY_SOUND_EFFECT = 7;
- private static final int MSG_BTA2DP_DOCK_TIMEOUT = 8;
- private static final int MSG_LOAD_SOUND_EFFECTS = 9;
- private static final int MSG_SET_FORCE_USE = 10;
- private static final int MSG_PERSIST_MEDIABUTTONRECEIVER = 11;
- private static final int MSG_BT_HEADSET_CNCT_FAILED = 12;
- private static final int MSG_RCDISPLAY_CLEAR = 13;
- private static final int MSG_RCDISPLAY_UPDATE = 14;
- private static final int MSG_SET_ALL_VOLUMES = 15;
- private static final int MSG_PERSIST_MASTER_VOLUME_MUTE = 16;
+ private static final int MSG_MEDIA_SERVER_DIED = 4;
+ private static final int MSG_MEDIA_SERVER_STARTED = 5;
+ private static final int MSG_PLAY_SOUND_EFFECT = 6;
+ private static final int MSG_BTA2DP_DOCK_TIMEOUT = 7;
+ private static final int MSG_LOAD_SOUND_EFFECTS = 8;
+ private static final int MSG_SET_FORCE_USE = 9;
+ private static final int MSG_PERSIST_MEDIABUTTONRECEIVER = 10;
+ private static final int MSG_BT_HEADSET_CNCT_FAILED = 11;
+ private static final int MSG_RCDISPLAY_CLEAR = 12;
+ private static final int MSG_RCDISPLAY_UPDATE = 13;
+ private static final int MSG_SET_ALL_VOLUMES = 14;
+ private static final int MSG_PERSIST_MASTER_VOLUME_MUTE = 15;
// 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;
+ // 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() {
public void onError(int error) {
switch (error) {
@@ -282,14 +296,15 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
private int mMuteAffectedStreams;
/**
- * Has multiple bits per vibrate type to indicate the type's vibrate
- * setting. See {@link #setVibrateSetting(int, int)}.
- * <p>
- * 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)}.
+ * NOTE: setVibrateSetting(), getVibrateSetting(), shouldVibrate() are deprecated.
+ * mVibrateSetting is just maintained during deprecation period but vibration policy is
+ * now only controlled by mHasVibrator and mRingerMode
*/
private int mVibrateSetting;
+ // Is there a vibrator
+ private final boolean mHasVibrator;
+
// Broadcast receiver for device connections intent broadcasts
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);
mMediaEventWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "mediaKeyEvent");
+ Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
+ mHasVibrator = vibrator == null ? false : vibrator.hasVibrator();
+
// Intialized volume
MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL] = SystemProperties.getInt(
"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) {
int dtmfStreamAlias;
@@ -538,18 +566,34 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
private void readPersistedSettings() {
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
// ringer modes
if (!AudioManager.isValidRingerMode(ringerMode)) {
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);
}
synchronized(mSettingsLock) {
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
// 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,
// or the stream type is one that is affected by ringer modes
if (((flags & AudioManager.FLAG_ALLOW_RINGER_MODES) != 0) ||
- streamTypeAlias == AudioSystem.STREAM_RING ||
- (!mVoiceCapable && streamTypeAlias == AudioSystem.STREAM_MUSIC)) {
+ (streamTypeAlias == getMasterStreamType())) {
int ringerMode = getRingerMode();
// do not vibrate if already in vibrate mode
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
// 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
@@ -724,9 +767,8 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
(mStreamVolumeAlias[streamType] == getMasterStreamType())) {
int newRingerMode;
if (index == 0) {
- newRingerMode = System.getInt(mContentResolver, System.VIBRATE_IN_SILENT, 1) == 1
- ? AudioManager.RINGER_MODE_VIBRATE
- : AudioManager.RINGER_MODE_SILENT;
+ newRingerMode = mHasVibrator ? AudioManager.RINGER_MODE_VIBRATE
+ : AudioManager.RINGER_MODE_SILENT;
setStreamVolumeInt(mStreamVolumeAlias[streamType],
index,
device,
@@ -1070,7 +1112,6 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
// on voice capable devices
if (mVoiceCapable &&
mStreamVolumeAlias[streamType] == AudioSystem.STREAM_RING) {
-
Set set = mStreamStates[streamType].mLastAudibleIndex.entrySet();
Iterator i = set.iterator();
while (i.hasNext()) {
@@ -1111,6 +1152,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
/** @see AudioManager#shouldVibrate(int) */
public boolean shouldVibrate(int vibrateType) {
+ if (!mHasVibrator) return false;
switch (getVibrateSetting(vibrateType)) {
@@ -1131,21 +1173,20 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
/** @see AudioManager#getVibrateSetting(int) */
public int getVibrateSetting(int vibrateType) {
+ if (!mHasVibrator) return AudioManager.VIBRATE_SETTING_OFF;
return (mVibrateSetting >> (vibrateType * 2)) & 3;
}
/** @see AudioManager#setVibrateSetting(int, int) */
public void setVibrateSetting(int vibrateType, int vibrateSetting) {
+ if (!mHasVibrator) return;
+
mVibrateSetting = getValueForVibrateSetting(mVibrateSetting, vibrateType, vibrateSetting);
// Broadcast change
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
* indices on the stream states.
*/
- private boolean checkForRingerModeChange(int oldIndex, int direction, int streamType) {
+ private boolean checkForRingerModeChange(int oldIndex, int direction) {
boolean adjustVolumeIndex = true;
int ringerMode = getRingerMode();
- int newRingerMode = ringerMode;
int uiIndex = (oldIndex + 5) / 10;
- boolean vibeInSilent = System.getInt(mContentResolver, System.VIBRATE_IN_SILENT, 1) == 1;
-
- if (ringerMode == RINGER_MODE_NORMAL) {
- if ((direction == AudioManager.ADJUST_LOWER) && (uiIndex <= 1)) {
- // enter silent mode if current index is the last audible one and not repeating a
- // volume key down
- if (vibeInSilent || mPrevVolDirection != AudioManager.ADJUST_LOWER) {
- // "silent mode", but which one?
- newRingerMode = vibeInSilent ? RINGER_MODE_VIBRATE : RINGER_MODE_SILENT;
- }
- if (uiIndex == 0 ||
- (!vibeInSilent &&
- mPrevVolDirection == AudioManager.ADJUST_LOWER &&
- mVoiceCapable && streamType == AudioSystem.STREAM_RING)) {
- adjustVolumeIndex = false;
+
+ switch (ringerMode) {
+ case RINGER_MODE_NORMAL:
+ if (direction == AudioManager.ADJUST_LOWER) {
+ if (mHasVibrator) {
+ if (uiIndex == 1) {
+ ringerMode = RINGER_MODE_VIBRATE;
+ }
+ } else {
+ if (uiIndex == 0 && mPrevVolDirection != AudioManager.ADJUST_LOWER) {
+ ringerMode = RINGER_MODE_SILENT;
+ }
}
}
- } 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)) {
- // Set it to silent, if it wasn't a long-press
if (mPrevVolDirection != AudioManager.ADJUST_LOWER) {
- newRingerMode = RINGER_MODE_SILENT;
+ ringerMode = RINGER_MODE_SILENT;
}
} else if (direction == AudioManager.ADJUST_RAISE) {
- newRingerMode = RINGER_MODE_NORMAL;
+ ringerMode = RINGER_MODE_NORMAL;
}
adjustVolumeIndex = false;
- } else {
+ break;
+ case RINGER_MODE_SILENT:
if (direction == AudioManager.ADJUST_RAISE) {
- // exiting silent mode
- // If VIBRATE_IN_SILENT, then go into vibrate mode
- newRingerMode = vibeInSilent ? RINGER_MODE_VIBRATE : RINGER_MODE_NORMAL;
+ if (mHasVibrator) {
+ ringerMode = RINGER_MODE_VIBRATE;
+ } else {
+ ringerMode = RINGER_MODE_NORMAL;
+ }
}
adjustVolumeIndex = false;
+ break;
+ default:
+ Log.e(TAG, "checkForRingerModeChange() wrong ringer mode: "+ringerMode);
+ break;
}
- setRingerMode(newRingerMode);
+ setRingerMode(ringerMode);
mPrevVolDirection = direction;
@@ -2217,9 +2266,6 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
}
public void readSettings() {
- boolean checkSilentVolume = (mRingerMode == AudioManager.RINGER_MODE_NORMAL) &&
- isStreamAffectedByRingerMode(mStreamType);
-
int remainingDevices = AudioSystem.DEVICE_OUT_ALL;
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];
int lastAudibleIndex = Settings.System.getInt(mContentResolver, name, defaultIndex);
- // a last audible index of 0 is never stored, except on non-voice capable devices
- // (e.g. tablets) for the music stream type, where the music stream volume can reach
- // 0 without the device being in silent mode
+ // a last audible index of 0 should never be stored for ring and notification
+ // streams on phones (voice capable devices).
+ // same for system stream on phones and tablets
if ((lastAudibleIndex == 0) &&
- (mVoiceCapable ||
- (mStreamVolumeAlias[mStreamType] != AudioSystem.STREAM_MUSIC))) {
+ ((mVoiceCapable &&
+ (mStreamVolumeAlias[mStreamType] == AudioSystem.STREAM_RING)) ||
+ (mStreamVolumeAlias[mStreamType] == AudioSystem.STREAM_SYSTEM))) {
lastAudibleIndex = AudioManager.DEFAULT_STREAM_VOLUME[mStreamType];
// Correct the data base
sendMsg(mAudioHandler,
@@ -2265,12 +2312,13 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
PERSIST_DELAY);
}
mLastAudibleIndex.put(device, getValidIndex(10 * lastAudibleIndex));
- // the initial index should never be 0 for a stream affected by ringer mode if not
- // in silent or vibrate mode.
- // this is permitted on tablets for music stream type.
- if (checkSilentVolume && (index == 0) &&
- (mVoiceCapable ||
- (mStreamVolumeAlias[mStreamType] != AudioSystem.STREAM_MUSIC))) {
+ // the initial index should never be 0 for ring and notification streams on phones
+ // (voice capable devices) if not in silent or vibrate mode.
+ // same for system stream on phones and tablets
+ if ((index == 0) && (mRingerMode == AudioManager.RINGER_MODE_NORMAL) &&
+ ((mVoiceCapable &&
+ (mStreamVolumeAlias[mStreamType] == AudioSystem.STREAM_RING)) ||
+ (mStreamVolumeAlias[mStreamType] == AudioSystem.STREAM_SYSTEM))) {
index = lastAudibleIndex;
// Correct the data base
sendMsg(mAudioHandler,
@@ -2328,14 +2376,22 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
mLastAudibleIndex.put(device, index);
}
// 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();
for (int streamType = numStreamTypes - 1; streamType >= 0; streamType--) {
- if (streamType != mStreamType && mStreamVolumeAlias[streamType] == mStreamType) {
- mStreamStates[streamType].setIndex(rescaleIndex(index,
- mStreamType,
- streamType),
- getDeviceForStream(streamType),
+ if (streamType != mStreamType &&
+ mStreamVolumeAlias[streamType] == mStreamType) {
+ int scaledIndex = rescaleIndex(index, mStreamType, streamType);
+ mStreamStates[streamType].setIndex(scaledIndex,
+ device,
lastAudible);
+ if (currentDevice) {
+ mStreamStates[streamType].setIndex(scaledIndex,
+ getDeviceForStream(streamType),
+ lastAudible);
+ }
}
}
return true;
@@ -2544,6 +2600,25 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
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. */
@@ -2631,10 +2706,6 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
System.putInt(mContentResolver, System.MODE_RINGER, ringerMode);
}
- private void persistVibrateSetting() {
- System.putInt(mContentResolver, System.VIBRATE_ON, mVibrateSetting);
- }
-
private void playSoundEffect(int effectType, int volume) {
synchronized (mSoundEffectsLock) {
if (mSoundPool == null) {
@@ -2734,10 +2805,6 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
persistRingerMode(getRingerMode());
break;
- case MSG_PERSIST_VIBRATE_SETTING:
- persistVibrateSetting();
- break;
-
case MSG_MEDIA_SERVER_DIED:
if (!mMediaServerOk) {
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
dumpFocusStack(pw);
dumpRCStack(pw);
+ dumpStreamStates(pw);
}
}
diff --git a/media/java/android/media/AudioSystem.java b/media/java/android/media/AudioSystem.java
index 9bafa5ca8d0f..55071ec04380 100644
--- a/media/java/android/media/AudioSystem.java
+++ b/media/java/android/media/AudioSystem.java
@@ -260,6 +260,8 @@ public class AudioSystem
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_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)
{
@@ -290,6 +292,10 @@ public class AudioSystem
return DEVICE_OUT_ANLG_DOCK_HEADSET_NAME;
case DEVICE_OUT_DGTL_DOCK_HEADSET:
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:
default:
return "";
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index abf713bf63c8..ee3b53fd9af5 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -63,7 +63,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
// 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
// settings.
- private static final int DATABASE_VERSION = 76;
+ private static final int DATABASE_VERSION = 77;
private Context mContext;
@@ -1031,6 +1031,23 @@ public class DatabaseHelper extends SQLiteOpenHelper {
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!
if (upgradeVersion != currentVersion) {
@@ -1311,8 +1328,6 @@ public class DatabaseHelper extends SQLiteOpenHelper {
loadSetting(stmt, Settings.System.MODE_RINGER,
AudioManager.RINGER_MODE_NORMAL);
- loadVibrateSetting(db, false);
-
// By default:
// - ringtones, notification, system and music streams are affected by ringer mode
// on non voice capable devices (tablets)
@@ -1433,9 +1448,6 @@ public class DatabaseHelper extends SQLiteOpenHelper {
loadUISoundEffectsSettings(stmt);
- loadBooleanSetting(stmt, Settings.System.VIBRATE_IN_SILENT,
- R.bool.def_vibrate_in_silent);
-
loadIntegerSetting(stmt, Settings.System.POINTER_SPEED,
R.integer.def_pointer_speed);
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java
index 3e7d86a38bd1..18e7faa95fe6 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java
@@ -43,9 +43,6 @@ public class SettingsHelper {
private IContentService mContentService;
private IPowerManager mPowerManager;
- private boolean mSilent;
- private boolean mVibrate;
-
public SettingsHelper(Context context) {
mContext = 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() {
Configuration conf = mContext.getResources().getConfiguration();
final Locale loc = conf.locale;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
index 5f18b5dfe8ab..374226d3a536 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
@@ -122,8 +122,7 @@ public class PhoneStatusBarPolicy {
action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) {
updateBluetooth(intent);
}
- else if (action.equals(AudioManager.RINGER_MODE_CHANGED_ACTION) ||
- action.equals(AudioManager.VIBRATE_SETTING_CHANGED_ACTION)) {
+ else if (action.equals(AudioManager.RINGER_MODE_CHANGED_ACTION)) {
updateVolume();
}
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_SYNC_STATE_CHANGED);
filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
- filter.addAction(AudioManager.VIBRATE_SETTING_CHANGED_ACTION);
filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
@@ -238,7 +236,7 @@ public class PhoneStatusBarPolicy {
final int iconId;
String contentDescription = null;
- if (audioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_RINGER)) {
+ if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) {
iconId = R.drawable.stat_sys_ringer_vibrate;
contentDescription = mContext.getString(R.string.accessibility_ringer_vibrate);
} else {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/VolumeController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/VolumeController.java
index c9da01aa73d2..43cb85ea3a56 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/VolumeController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/VolumeController.java
@@ -20,6 +20,7 @@ import android.content.ContentResolver;
import android.content.Context;
import android.os.RemoteException;
import android.os.ServiceManager;
+import android.os.Vibrator;
import android.media.AudioManager;
import android.provider.Settings;
import android.util.Slog;
@@ -36,10 +37,16 @@ public class VolumeController implements ToggleSlider.Listener {
private boolean mMute;
private int mVolume;
+ // Is there a vibrator
+ private final boolean mHasVibrator;
public VolumeController(Context context, ToggleSlider control) {
mContext = context;
mControl = control;
+
+ Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
+ mHasVibrator = vibrator == null ? false : vibrator.hasVibrator();
+
mAudioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
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) {
if (!tracking) {
if (mute) {
- boolean vibeInSilent = (1 == Settings.System.getInt(mContext.getContentResolver(),
- Settings.System.VIBRATE_IN_SILENT, 1));
mAudioManager.setRingerMode(
- vibeInSilent ? AudioManager.RINGER_MODE_VIBRATE
+ mHasVibrator ? AudioManager.RINGER_MODE_VIBRATE
: AudioManager.RINGER_MODE_SILENT);
} else {
mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
diff --git a/policy/src/com/android/internal/policy/impl/LockScreen.java b/policy/src/com/android/internal/policy/impl/LockScreen.java
index 8b0d858823b3..c7a30e291b3f 100644
--- a/policy/src/com/android/internal/policy/impl/LockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/LockScreen.java
@@ -34,6 +34,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
+import android.os.Vibrator;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
@@ -82,6 +83,8 @@ class LockScreen extends LinearLayout implements KeyguardScreen {
private boolean mCameraDisabled;
private boolean mSearchDisabled;
private SearchManager mSearchManager;
+ // Is there a vibrator
+ private final boolean mHasVibrator;
InfoCallbackImpl mInfoCallback = new InfoCallbackImpl() {
@@ -385,11 +388,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen {
// toggle silent mode
mSilentMode = !mSilentMode;
if (mSilentMode) {
- final boolean vibe = (Settings.System.getInt(
- mContext.getContentResolver(),
- Settings.System.VIBRATE_IN_SILENT, 1) == 1);
-
- mAudioManager.setRingerMode(vibe
+ mAudioManager.setRingerMode(mHasVibrator
? AudioManager.RINGER_MODE_VIBRATE
: AudioManager.RINGER_MODE_SILENT);
} else {
@@ -451,6 +450,8 @@ class LockScreen extends LinearLayout implements KeyguardScreen {
setFocusableInTouchMode(true);
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);
mSilentMode = isSilentMode();
mUnlockWidget = findViewById(R.id.unlock_widget);
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java
index 663a0316dbee..52ba665aea61 100755
--- a/services/java/com/android/server/NotificationManagerService.java
+++ b/services/java/com/android/server/NotificationManagerService.java
@@ -1046,7 +1046,7 @@ public class NotificationManagerService extends INotificationManager.Stub
final boolean useDefaultVibrate =
(notification.defaults & Notification.DEFAULT_VIBRATE) != 0;
if ((useDefaultVibrate || notification.vibrate != null)
- && audioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_NOTIFICATION)) {
+ && !(audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT)) {
mVibrateNotification = r;
mVibrator.vibrate(useDefaultVibrate ? DEFAULT_VIBRATE_PATTERN