Skip to content

Commit 57b0988

Browse files
Daisuke MiyakawaAndroid (Google) Code Review
authored andcommitted
Merge "Have a new constant for "vibrate when ringing" setting" into jb-dev
2 parents d422ade + 3c60eeb commit 57b0988

File tree

2 files changed

+81
-40
lines changed

2 files changed

+81
-40
lines changed

core/java/android/provider/Settings.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,6 +1748,20 @@ public static void setShowGTalkServiceStatus(ContentResolver cr, boolean flag) {
17481748
*/
17491749
public static final String USER_ROTATION = "user_rotation";
17501750

1751+
/**
1752+
* Whether the phone vibrates when it is ringing due to an incoming call. This will
1753+
* be used by Phone and Setting apps; it shouldn't affect other apps.
1754+
* The value is boolean (1 or 0).
1755+
*
1756+
* Note: this is not same as "vibrate on ring", which had been available until ICS.
1757+
* It was about AudioManager's setting and thus affected all the applications which
1758+
* relied on the setting, while this is purely about the vibration setting for incoming
1759+
* calls.
1760+
*
1761+
* @hide
1762+
*/
1763+
public static final String VIBRATE_WHEN_RINGING = "vibrate_when_ringing";
1764+
17511765
/**
17521766
* Whether the audible DTMF tones are played by the dialer when dialing. The value is
17531767
* boolean (1 or 0).
@@ -2030,6 +2044,7 @@ public static void setShowGTalkServiceStatus(ContentResolver cr, boolean flag) {
20302044
SIP_CALL_OPTIONS,
20312045
SIP_RECEIVE_CALLS,
20322046
POINTER_SPEED,
2047+
VIBRATE_WHEN_RINGING
20332048
};
20342049

20352050
// Settings moved to Settings.Secure

packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java

Lines changed: 66 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
6363
// database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion'
6464
// is properly propagated through your change. Not doing so will result in a loss of user
6565
// settings.
66-
private static final int DATABASE_VERSION = 77;
66+
private static final int DATABASE_VERSION = 78;
6767

6868
private Context mContext;
6969

@@ -657,7 +657,7 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int currentVersion) {
657657

658658
upgradeVersion = 53;
659659
}
660-
660+
661661
if (upgradeVersion == 53) {
662662
/*
663663
* New settings for set install location UI no longer initiated here.
@@ -1047,6 +1047,12 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int currentVersion) {
10471047
upgradeVersion = 77;
10481048
}
10491049

1050+
if (upgradeVersion == 77) {
1051+
// Introduce "vibrate when ringing" setting
1052+
loadVibrateWhenRingingSetting(db);
1053+
1054+
upgradeVersion = 78;
1055+
}
10501056

10511057
// *** Remember to update DATABASE_VERSION above!
10521058

@@ -1141,7 +1147,7 @@ private void upgradeScreenTimeoutFromNever(SQLiteDatabase db) {
11411147
try {
11421148
stmt = db.compileStatement("INSERT OR REPLACE INTO system(name,value)"
11431149
+ " VALUES(?,?);");
1144-
1150+
11451151
// Set the timeout to 30 minutes in milliseconds
11461152
loadSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT,
11471153
Integer.toString(30 * 60 * 1000));
@@ -1303,7 +1309,7 @@ private void loadVolumeLevels(SQLiteDatabase db) {
13031309
try {
13041310
stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)"
13051311
+ " VALUES(?,?);");
1306-
1312+
13071313
loadSetting(stmt, Settings.System.VOLUME_MUSIC,
13081314
AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_MUSIC]);
13091315
loadSetting(stmt, Settings.System.VOLUME_RING,
@@ -1324,10 +1330,10 @@ private void loadVolumeLevels(SQLiteDatabase db) {
13241330
stmt,
13251331
Settings.System.VOLUME_BLUETOOTH_SCO,
13261332
AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_BLUETOOTH_SCO]);
1327-
1333+
13281334
loadSetting(stmt, Settings.System.MODE_RINGER,
13291335
AudioManager.RINGER_MODE_NORMAL);
1330-
1336+
13311337
// By default:
13321338
// - ringtones, notification, system and music streams are affected by ringer mode
13331339
// on non voice capable devices (tablets)
@@ -1352,6 +1358,8 @@ private void loadVolumeLevels(SQLiteDatabase db) {
13521358
} finally {
13531359
if (stmt != null) stmt.close();
13541360
}
1361+
1362+
loadVibrateWhenRingingSetting(db);
13551363
}
13561364

13571365
private void loadVibrateSetting(SQLiteDatabase db, boolean deleteOld) {
@@ -1363,7 +1371,7 @@ private void loadVibrateSetting(SQLiteDatabase db, boolean deleteOld) {
13631371
try {
13641372
stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)"
13651373
+ " VALUES(?,?);");
1366-
1374+
13671375
// Vibrate on by default for ringer, on for notification
13681376
int vibrate = 0;
13691377
vibrate = AudioService.getValueForVibrateSetting(vibrate,
@@ -1377,6 +1385,24 @@ private void loadVibrateSetting(SQLiteDatabase db, boolean deleteOld) {
13771385
}
13781386
}
13791387

1388+
private void loadVibrateWhenRingingSetting(SQLiteDatabase db) {
1389+
// The default should be off. VIBRATE_SETTING_ONLY_SILENT should also be ignored here.
1390+
// Phone app should separately check whether AudioManager#getRingerMode() returns
1391+
// RINGER_MODE_VIBRATE, with which the device should vibrate anyway.
1392+
int vibrateSetting = getIntValueFromSystem(db, Settings.System.VIBRATE_ON,
1393+
AudioManager.VIBRATE_SETTING_OFF);
1394+
boolean vibrateWhenRinging = ((vibrateSetting & 3) == AudioManager.VIBRATE_SETTING_ON);
1395+
1396+
SQLiteStatement stmt = null;
1397+
try {
1398+
stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)"
1399+
+ " VALUES(?,?);");
1400+
loadSetting(stmt, Settings.System.VIBRATE_WHEN_RINGING, vibrateWhenRinging ? 1 : 0);
1401+
} finally {
1402+
if (stmt != null) stmt.close();
1403+
}
1404+
}
1405+
13801406
private void loadSettings(SQLiteDatabase db) {
13811407
loadSystemSettings(db);
13821408
loadSecureSettings(db);
@@ -1387,7 +1413,7 @@ private void loadSystemSettings(SQLiteDatabase db) {
13871413
try {
13881414
stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)"
13891415
+ " VALUES(?,?);");
1390-
1416+
13911417
loadBooleanSetting(stmt, Settings.System.DIM_SCREEN,
13921418
R.bool.def_dim_screen);
13931419
loadSetting(stmt, Settings.System.STAY_ON_WHILE_PLUGGED_IN,
@@ -1396,31 +1422,31 @@ private void loadSystemSettings(SQLiteDatabase db) {
13961422
? 1 : 0);
13971423
loadIntegerSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT,
13981424
R.integer.def_screen_off_timeout);
1399-
1425+
14001426
// Set default cdma emergency tone
14011427
loadSetting(stmt, Settings.System.EMERGENCY_TONE, 0);
1402-
1428+
14031429
// Set default cdma call auto retry
14041430
loadSetting(stmt, Settings.System.CALL_AUTO_RETRY, 0);
1405-
1431+
14061432
// Set default cdma DTMF type
14071433
loadSetting(stmt, Settings.System.DTMF_TONE_TYPE_WHEN_DIALING, 0);
1408-
1434+
14091435
// Set default hearing aid
14101436
loadSetting(stmt, Settings.System.HEARING_AID, 0);
1411-
1437+
14121438
// Set default tty mode
14131439
loadSetting(stmt, Settings.System.TTY_MODE, 0);
1414-
1440+
14151441
loadBooleanSetting(stmt, Settings.System.AIRPLANE_MODE_ON,
14161442
R.bool.def_airplane_mode_on);
1417-
1443+
14181444
loadStringSetting(stmt, Settings.System.AIRPLANE_MODE_RADIOS,
14191445
R.string.def_airplane_mode_radios);
1420-
1446+
14211447
loadStringSetting(stmt, Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS,
14221448
R.string.airplane_mode_toggleable_radios);
1423-
1449+
14241450
loadBooleanSetting(stmt, Settings.System.AUTO_TIME,
14251451
R.bool.def_auto_time); // Sync time to NITZ
14261452

@@ -1429,17 +1455,17 @@ private void loadSystemSettings(SQLiteDatabase db) {
14291455

14301456
loadIntegerSetting(stmt, Settings.System.SCREEN_BRIGHTNESS,
14311457
R.integer.def_screen_brightness);
1432-
1458+
14331459
loadBooleanSetting(stmt, Settings.System.SCREEN_BRIGHTNESS_MODE,
14341460
R.bool.def_screen_brightness_automatic_mode);
1435-
1461+
14361462
loadDefaultAnimationSettings(stmt);
1437-
1463+
14381464
loadBooleanSetting(stmt, Settings.System.ACCELEROMETER_ROTATION,
14391465
R.bool.def_accelerometer_rotation);
1440-
1466+
14411467
loadDefaultHapticSettings(stmt);
1442-
1468+
14431469
loadBooleanSetting(stmt, Settings.System.NOTIFICATION_LIGHT_PULSE,
14441470
R.bool.def_notification_pulse);
14451471
loadSetting(stmt, Settings.Secure.SET_INSTALL_LOCATION, 0);
@@ -1504,41 +1530,41 @@ private void loadSecureSettings(SQLiteDatabase db) {
15041530
try {
15051531
stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)"
15061532
+ " VALUES(?,?);");
1507-
1533+
15081534
loadBooleanSetting(stmt, Settings.Secure.BLUETOOTH_ON,
15091535
R.bool.def_bluetooth_on);
1510-
1536+
15111537
// Data roaming default, based on build
15121538
loadSetting(stmt, Settings.Secure.DATA_ROAMING,
15131539
"true".equalsIgnoreCase(
15141540
SystemProperties.get("ro.com.android.dataroaming",
15151541
"false")) ? 1 : 0);
1516-
1542+
15171543
loadBooleanSetting(stmt, Settings.Secure.INSTALL_NON_MARKET_APPS,
15181544
R.bool.def_install_non_market_apps);
1519-
1545+
15201546
loadStringSetting(stmt, Settings.Secure.LOCATION_PROVIDERS_ALLOWED,
15211547
R.string.def_location_providers_allowed);
1522-
1548+
15231549
loadBooleanSetting(stmt, Settings.Secure.ASSISTED_GPS_ENABLED,
15241550
R.bool.assisted_gps_enabled);
1525-
1551+
15261552
loadIntegerSetting(stmt, Settings.Secure.NETWORK_PREFERENCE,
15271553
R.integer.def_network_preference);
1528-
1554+
15291555
loadBooleanSetting(stmt, Settings.Secure.USB_MASS_STORAGE_ENABLED,
15301556
R.bool.def_usb_mass_storage_enabled);
1531-
1557+
15321558
loadBooleanSetting(stmt, Settings.Secure.WIFI_ON,
15331559
R.bool.def_wifi_on);
15341560
loadBooleanSetting(stmt, Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
15351561
R.bool.def_networks_available_notification_on);
1536-
1562+
15371563
String wifiWatchList = SystemProperties.get("ro.com.android.wifi-watchlist");
15381564
if (!TextUtils.isEmpty(wifiWatchList)) {
15391565
loadSetting(stmt, Settings.Secure.WIFI_WATCHDOG_WATCH_LIST, wifiWatchList);
15401566
}
1541-
1567+
15421568
// Set the preferred network mode to 0 = Global, CDMA default
15431569
int type;
15441570
if (BaseCommands.getLteOnCdmaModeStatic() == Phone.LTE_ON_CDMA_TRUE) {
@@ -1548,30 +1574,30 @@ private void loadSecureSettings(SQLiteDatabase db) {
15481574
RILConstants.PREFERRED_NETWORK_MODE);
15491575
}
15501576
loadSetting(stmt, Settings.Secure.PREFERRED_NETWORK_MODE, type);
1551-
1577+
15521578
// Enable or disable Cell Broadcast SMS
15531579
loadSetting(stmt, Settings.Secure.CDMA_CELL_BROADCAST_SMS,
15541580
RILConstants.CDMA_CELL_BROADCAST_SMS_DISABLED);
1555-
1581+
15561582
// Don't do this. The SystemServer will initialize ADB_ENABLED from a
15571583
// persistent system property instead.
15581584
//loadSetting(stmt, Settings.Secure.ADB_ENABLED, 0);
1559-
1585+
15601586
// Allow mock locations default, based on build
15611587
loadSetting(stmt, Settings.Secure.ALLOW_MOCK_LOCATION,
15621588
"1".equals(SystemProperties.get("ro.allow.mock.location")) ? 1 : 0);
1563-
1589+
15641590
loadSecure35Settings(stmt);
1565-
1591+
15661592
loadBooleanSetting(stmt, Settings.Secure.MOUNT_PLAY_NOTIFICATION_SND,
15671593
R.bool.def_mount_play_notification_snd);
1568-
1594+
15691595
loadBooleanSetting(stmt, Settings.Secure.MOUNT_UMS_AUTOSTART,
15701596
R.bool.def_mount_ums_autostart);
1571-
1597+
15721598
loadBooleanSetting(stmt, Settings.Secure.MOUNT_UMS_PROMPT,
15731599
R.bool.def_mount_ums_prompt);
1574-
1600+
15751601
loadBooleanSetting(stmt, Settings.Secure.MOUNT_UMS_NOTIFY_ENABLED,
15761602
R.bool.def_mount_ums_notify_enabled);
15771603

0 commit comments

Comments
 (0)