am 57b09882: Merge "Have a new constant for "vibrate when ringing" setting" into jb-dev

* commit '57b098829f5960bc2fd29f0b0917189911b18338':
  Have a new constant for "vibrate when ringing" setting
This commit is contained in:
Daisuke Miyakawa
2012-05-09 10:17:54 -07:00
committed by Android Git Automerger
2 changed files with 81 additions and 40 deletions

View File

@@ -1748,6 +1748,20 @@ public final class Settings {
*/ */
public static final String USER_ROTATION = "user_rotation"; public static final String USER_ROTATION = "user_rotation";
/**
* Whether the phone vibrates when it is ringing due to an incoming call. This will
* be used by Phone and Setting apps; it shouldn't affect other apps.
* The value is boolean (1 or 0).
*
* Note: this is not same as "vibrate on ring", which had been available until ICS.
* It was about AudioManager's setting and thus affected all the applications which
* relied on the setting, while this is purely about the vibration setting for incoming
* calls.
*
* @hide
*/
public static final String VIBRATE_WHEN_RINGING = "vibrate_when_ringing";
/** /**
* Whether the audible DTMF tones are played by the dialer when dialing. The value is * Whether the audible DTMF tones are played by the dialer when dialing. The value is
* boolean (1 or 0). * boolean (1 or 0).
@@ -2030,6 +2044,7 @@ public final class Settings {
SIP_CALL_OPTIONS, SIP_CALL_OPTIONS,
SIP_RECEIVE_CALLS, SIP_RECEIVE_CALLS,
POINTER_SPEED, POINTER_SPEED,
VIBRATE_WHEN_RINGING
}; };
// Settings moved to Settings.Secure // Settings moved to Settings.Secure

View File

@@ -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 = 77; private static final int DATABASE_VERSION = 78;
private Context mContext; private Context mContext;
@@ -657,7 +657,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
upgradeVersion = 53; upgradeVersion = 53;
} }
if (upgradeVersion == 53) { if (upgradeVersion == 53) {
/* /*
* New settings for set install location UI no longer initiated here. * New settings for set install location UI no longer initiated here.
@@ -1047,6 +1047,12 @@ public class DatabaseHelper extends SQLiteOpenHelper {
upgradeVersion = 77; upgradeVersion = 77;
} }
if (upgradeVersion == 77) {
// Introduce "vibrate when ringing" setting
loadVibrateWhenRingingSetting(db);
upgradeVersion = 78;
}
// *** Remember to update DATABASE_VERSION above! // *** Remember to update DATABASE_VERSION above!
@@ -1141,7 +1147,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
try { try {
stmt = db.compileStatement("INSERT OR REPLACE INTO system(name,value)" stmt = db.compileStatement("INSERT OR REPLACE INTO system(name,value)"
+ " VALUES(?,?);"); + " VALUES(?,?);");
// Set the timeout to 30 minutes in milliseconds // Set the timeout to 30 minutes in milliseconds
loadSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT, loadSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT,
Integer.toString(30 * 60 * 1000)); Integer.toString(30 * 60 * 1000));
@@ -1303,7 +1309,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
try { try {
stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)" stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)"
+ " VALUES(?,?);"); + " VALUES(?,?);");
loadSetting(stmt, Settings.System.VOLUME_MUSIC, loadSetting(stmt, Settings.System.VOLUME_MUSIC,
AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_MUSIC]); AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_MUSIC]);
loadSetting(stmt, Settings.System.VOLUME_RING, loadSetting(stmt, Settings.System.VOLUME_RING,
@@ -1324,10 +1330,10 @@ public class DatabaseHelper extends SQLiteOpenHelper {
stmt, stmt,
Settings.System.VOLUME_BLUETOOTH_SCO, Settings.System.VOLUME_BLUETOOTH_SCO,
AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_BLUETOOTH_SCO]); AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_BLUETOOTH_SCO]);
loadSetting(stmt, Settings.System.MODE_RINGER, loadSetting(stmt, Settings.System.MODE_RINGER,
AudioManager.RINGER_MODE_NORMAL); AudioManager.RINGER_MODE_NORMAL);
// 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)
@@ -1352,6 +1358,8 @@ public class DatabaseHelper extends SQLiteOpenHelper {
} finally { } finally {
if (stmt != null) stmt.close(); if (stmt != null) stmt.close();
} }
loadVibrateWhenRingingSetting(db);
} }
private void loadVibrateSetting(SQLiteDatabase db, boolean deleteOld) { private void loadVibrateSetting(SQLiteDatabase db, boolean deleteOld) {
@@ -1363,7 +1371,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
try { try {
stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)" stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)"
+ " VALUES(?,?);"); + " VALUES(?,?);");
// Vibrate on by default for ringer, on for notification // Vibrate on by default for ringer, on for notification
int vibrate = 0; int vibrate = 0;
vibrate = AudioService.getValueForVibrateSetting(vibrate, vibrate = AudioService.getValueForVibrateSetting(vibrate,
@@ -1377,6 +1385,24 @@ public class DatabaseHelper extends SQLiteOpenHelper {
} }
} }
private void loadVibrateWhenRingingSetting(SQLiteDatabase db) {
// The default should be off. VIBRATE_SETTING_ONLY_SILENT should also be ignored here.
// Phone app should separately check whether AudioManager#getRingerMode() returns
// RINGER_MODE_VIBRATE, with which the device should vibrate anyway.
int vibrateSetting = getIntValueFromSystem(db, Settings.System.VIBRATE_ON,
AudioManager.VIBRATE_SETTING_OFF);
boolean vibrateWhenRinging = ((vibrateSetting & 3) == AudioManager.VIBRATE_SETTING_ON);
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)"
+ " VALUES(?,?);");
loadSetting(stmt, Settings.System.VIBRATE_WHEN_RINGING, vibrateWhenRinging ? 1 : 0);
} finally {
if (stmt != null) stmt.close();
}
}
private void loadSettings(SQLiteDatabase db) { private void loadSettings(SQLiteDatabase db) {
loadSystemSettings(db); loadSystemSettings(db);
loadSecureSettings(db); loadSecureSettings(db);
@@ -1387,7 +1413,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
try { try {
stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)" stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)"
+ " VALUES(?,?);"); + " VALUES(?,?);");
loadBooleanSetting(stmt, Settings.System.DIM_SCREEN, loadBooleanSetting(stmt, Settings.System.DIM_SCREEN,
R.bool.def_dim_screen); R.bool.def_dim_screen);
loadSetting(stmt, Settings.System.STAY_ON_WHILE_PLUGGED_IN, loadSetting(stmt, Settings.System.STAY_ON_WHILE_PLUGGED_IN,
@@ -1396,31 +1422,31 @@ public class DatabaseHelper extends SQLiteOpenHelper {
? 1 : 0); ? 1 : 0);
loadIntegerSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT, loadIntegerSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT,
R.integer.def_screen_off_timeout); R.integer.def_screen_off_timeout);
// Set default cdma emergency tone // Set default cdma emergency tone
loadSetting(stmt, Settings.System.EMERGENCY_TONE, 0); loadSetting(stmt, Settings.System.EMERGENCY_TONE, 0);
// Set default cdma call auto retry // Set default cdma call auto retry
loadSetting(stmt, Settings.System.CALL_AUTO_RETRY, 0); loadSetting(stmt, Settings.System.CALL_AUTO_RETRY, 0);
// Set default cdma DTMF type // Set default cdma DTMF type
loadSetting(stmt, Settings.System.DTMF_TONE_TYPE_WHEN_DIALING, 0); loadSetting(stmt, Settings.System.DTMF_TONE_TYPE_WHEN_DIALING, 0);
// Set default hearing aid // Set default hearing aid
loadSetting(stmt, Settings.System.HEARING_AID, 0); loadSetting(stmt, Settings.System.HEARING_AID, 0);
// Set default tty mode // Set default tty mode
loadSetting(stmt, Settings.System.TTY_MODE, 0); loadSetting(stmt, Settings.System.TTY_MODE, 0);
loadBooleanSetting(stmt, Settings.System.AIRPLANE_MODE_ON, loadBooleanSetting(stmt, Settings.System.AIRPLANE_MODE_ON,
R.bool.def_airplane_mode_on); R.bool.def_airplane_mode_on);
loadStringSetting(stmt, Settings.System.AIRPLANE_MODE_RADIOS, loadStringSetting(stmt, Settings.System.AIRPLANE_MODE_RADIOS,
R.string.def_airplane_mode_radios); R.string.def_airplane_mode_radios);
loadStringSetting(stmt, Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS, loadStringSetting(stmt, Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS,
R.string.airplane_mode_toggleable_radios); R.string.airplane_mode_toggleable_radios);
loadBooleanSetting(stmt, Settings.System.AUTO_TIME, loadBooleanSetting(stmt, Settings.System.AUTO_TIME,
R.bool.def_auto_time); // Sync time to NITZ R.bool.def_auto_time); // Sync time to NITZ
@@ -1429,17 +1455,17 @@ public class DatabaseHelper extends SQLiteOpenHelper {
loadIntegerSetting(stmt, Settings.System.SCREEN_BRIGHTNESS, loadIntegerSetting(stmt, Settings.System.SCREEN_BRIGHTNESS,
R.integer.def_screen_brightness); R.integer.def_screen_brightness);
loadBooleanSetting(stmt, Settings.System.SCREEN_BRIGHTNESS_MODE, loadBooleanSetting(stmt, Settings.System.SCREEN_BRIGHTNESS_MODE,
R.bool.def_screen_brightness_automatic_mode); R.bool.def_screen_brightness_automatic_mode);
loadDefaultAnimationSettings(stmt); loadDefaultAnimationSettings(stmt);
loadBooleanSetting(stmt, Settings.System.ACCELEROMETER_ROTATION, loadBooleanSetting(stmt, Settings.System.ACCELEROMETER_ROTATION,
R.bool.def_accelerometer_rotation); R.bool.def_accelerometer_rotation);
loadDefaultHapticSettings(stmt); loadDefaultHapticSettings(stmt);
loadBooleanSetting(stmt, Settings.System.NOTIFICATION_LIGHT_PULSE, loadBooleanSetting(stmt, Settings.System.NOTIFICATION_LIGHT_PULSE,
R.bool.def_notification_pulse); R.bool.def_notification_pulse);
loadSetting(stmt, Settings.Secure.SET_INSTALL_LOCATION, 0); loadSetting(stmt, Settings.Secure.SET_INSTALL_LOCATION, 0);
@@ -1504,41 +1530,41 @@ public class DatabaseHelper extends SQLiteOpenHelper {
try { try {
stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)" stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)"
+ " VALUES(?,?);"); + " VALUES(?,?);");
loadBooleanSetting(stmt, Settings.Secure.BLUETOOTH_ON, loadBooleanSetting(stmt, Settings.Secure.BLUETOOTH_ON,
R.bool.def_bluetooth_on); R.bool.def_bluetooth_on);
// Data roaming default, based on build // Data roaming default, based on build
loadSetting(stmt, Settings.Secure.DATA_ROAMING, loadSetting(stmt, Settings.Secure.DATA_ROAMING,
"true".equalsIgnoreCase( "true".equalsIgnoreCase(
SystemProperties.get("ro.com.android.dataroaming", SystemProperties.get("ro.com.android.dataroaming",
"false")) ? 1 : 0); "false")) ? 1 : 0);
loadBooleanSetting(stmt, Settings.Secure.INSTALL_NON_MARKET_APPS, loadBooleanSetting(stmt, Settings.Secure.INSTALL_NON_MARKET_APPS,
R.bool.def_install_non_market_apps); R.bool.def_install_non_market_apps);
loadStringSetting(stmt, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, loadStringSetting(stmt, Settings.Secure.LOCATION_PROVIDERS_ALLOWED,
R.string.def_location_providers_allowed); R.string.def_location_providers_allowed);
loadBooleanSetting(stmt, Settings.Secure.ASSISTED_GPS_ENABLED, loadBooleanSetting(stmt, Settings.Secure.ASSISTED_GPS_ENABLED,
R.bool.assisted_gps_enabled); R.bool.assisted_gps_enabled);
loadIntegerSetting(stmt, Settings.Secure.NETWORK_PREFERENCE, loadIntegerSetting(stmt, Settings.Secure.NETWORK_PREFERENCE,
R.integer.def_network_preference); R.integer.def_network_preference);
loadBooleanSetting(stmt, Settings.Secure.USB_MASS_STORAGE_ENABLED, loadBooleanSetting(stmt, Settings.Secure.USB_MASS_STORAGE_ENABLED,
R.bool.def_usb_mass_storage_enabled); R.bool.def_usb_mass_storage_enabled);
loadBooleanSetting(stmt, Settings.Secure.WIFI_ON, loadBooleanSetting(stmt, Settings.Secure.WIFI_ON,
R.bool.def_wifi_on); R.bool.def_wifi_on);
loadBooleanSetting(stmt, Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, loadBooleanSetting(stmt, Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
R.bool.def_networks_available_notification_on); R.bool.def_networks_available_notification_on);
String wifiWatchList = SystemProperties.get("ro.com.android.wifi-watchlist"); String wifiWatchList = SystemProperties.get("ro.com.android.wifi-watchlist");
if (!TextUtils.isEmpty(wifiWatchList)) { if (!TextUtils.isEmpty(wifiWatchList)) {
loadSetting(stmt, Settings.Secure.WIFI_WATCHDOG_WATCH_LIST, wifiWatchList); loadSetting(stmt, Settings.Secure.WIFI_WATCHDOG_WATCH_LIST, wifiWatchList);
} }
// Set the preferred network mode to 0 = Global, CDMA default // Set the preferred network mode to 0 = Global, CDMA default
int type; int type;
if (BaseCommands.getLteOnCdmaModeStatic() == Phone.LTE_ON_CDMA_TRUE) { if (BaseCommands.getLteOnCdmaModeStatic() == Phone.LTE_ON_CDMA_TRUE) {
@@ -1548,30 +1574,30 @@ public class DatabaseHelper extends SQLiteOpenHelper {
RILConstants.PREFERRED_NETWORK_MODE); RILConstants.PREFERRED_NETWORK_MODE);
} }
loadSetting(stmt, Settings.Secure.PREFERRED_NETWORK_MODE, type); loadSetting(stmt, Settings.Secure.PREFERRED_NETWORK_MODE, type);
// Enable or disable Cell Broadcast SMS // Enable or disable Cell Broadcast SMS
loadSetting(stmt, Settings.Secure.CDMA_CELL_BROADCAST_SMS, loadSetting(stmt, Settings.Secure.CDMA_CELL_BROADCAST_SMS,
RILConstants.CDMA_CELL_BROADCAST_SMS_DISABLED); RILConstants.CDMA_CELL_BROADCAST_SMS_DISABLED);
// Don't do this. The SystemServer will initialize ADB_ENABLED from a // Don't do this. The SystemServer will initialize ADB_ENABLED from a
// persistent system property instead. // persistent system property instead.
//loadSetting(stmt, Settings.Secure.ADB_ENABLED, 0); //loadSetting(stmt, Settings.Secure.ADB_ENABLED, 0);
// Allow mock locations default, based on build // Allow mock locations default, based on build
loadSetting(stmt, Settings.Secure.ALLOW_MOCK_LOCATION, loadSetting(stmt, Settings.Secure.ALLOW_MOCK_LOCATION,
"1".equals(SystemProperties.get("ro.allow.mock.location")) ? 1 : 0); "1".equals(SystemProperties.get("ro.allow.mock.location")) ? 1 : 0);
loadSecure35Settings(stmt); loadSecure35Settings(stmt);
loadBooleanSetting(stmt, Settings.Secure.MOUNT_PLAY_NOTIFICATION_SND, loadBooleanSetting(stmt, Settings.Secure.MOUNT_PLAY_NOTIFICATION_SND,
R.bool.def_mount_play_notification_snd); R.bool.def_mount_play_notification_snd);
loadBooleanSetting(stmt, Settings.Secure.MOUNT_UMS_AUTOSTART, loadBooleanSetting(stmt, Settings.Secure.MOUNT_UMS_AUTOSTART,
R.bool.def_mount_ums_autostart); R.bool.def_mount_ums_autostart);
loadBooleanSetting(stmt, Settings.Secure.MOUNT_UMS_PROMPT, loadBooleanSetting(stmt, Settings.Secure.MOUNT_UMS_PROMPT,
R.bool.def_mount_ums_prompt); R.bool.def_mount_ums_prompt);
loadBooleanSetting(stmt, Settings.Secure.MOUNT_UMS_NOTIFY_ENABLED, loadBooleanSetting(stmt, Settings.Secure.MOUNT_UMS_NOTIFY_ENABLED,
R.bool.def_mount_ums_notify_enabled); R.bool.def_mount_ums_notify_enabled);