Skip to content

Commit f336408

Browse files
Amith YamasaniAndroid (Google) Code Review
authored andcommitted
Merge "New and improved silent mode on lockscreen." into ics-mr1
2 parents 720efc4 + 6243edd commit f336408

File tree

7 files changed

+267
-71
lines changed

7 files changed

+267
-71
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright (C) 2011 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
18+
<item android:state_selected="false" android:drawable="@android:color/transparent" />
19+
<item android:state_selected="true" android:drawable="@drawable/tab_selected_holo" />
20+
</selector>

core/res/res/layout/global_actions_item.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222
android:minHeight="?android:attr/listPreferredItemHeight"
2323
android:orientation="horizontal"
2424

25-
android:paddingLeft="11dip"
25+
android:paddingLeft="16dip"
2626
android:paddingTop="6dip"
2727
android:paddingBottom="6dip"
2828
>
2929
<ImageView android:id="@+id/icon"
3030
android:layout_width="wrap_content"
3131
android:layout_height="match_parent"
3232
android:layout_gravity="center"
33-
android:layout_marginRight="9dip"
33+
android:layout_marginRight="16dip"
3434
/>
3535

3636
<LinearLayout
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright (C) 2011 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:layout_width="wrap_content"
19+
android:layout_height="wrap_content"
20+
android:minHeight="?android:attr/listPreferredItemHeight"
21+
android:orientation="horizontal"
22+
>
23+
24+
<LinearLayout
25+
android:id="@+id/option1"
26+
android:layout_width="64dp"
27+
android:layout_height="match_parent"
28+
android:background="?android:attr/actionBarItemBackground"
29+
>
30+
<ImageView
31+
android:layout_width="48dp"
32+
android:layout_height="match_parent"
33+
android:layout_gravity="center"
34+
android:layout_marginLeft="8dp"
35+
android:layout_marginRight="8dp"
36+
android:layout_marginTop="6dp"
37+
android:layout_marginBottom="6dp"
38+
android:src="@drawable/ic_audio_vol_mute"
39+
android:scaleType="center"
40+
android:duplicateParentState="true"
41+
android:background="@drawable/silent_mode_indicator"
42+
/>
43+
</LinearLayout>
44+
<!-- Spacer -->
45+
<View android:layout_width="0dp"
46+
android:layout_height="match_parent"
47+
android:layout_weight="1"
48+
android:visibility="invisible"/>
49+
50+
<LinearLayout
51+
android:id="@+id/option2"
52+
android:layout_width="64dp"
53+
android:layout_height="match_parent"
54+
android:background="?android:attr/actionBarItemBackground"
55+
>
56+
<ImageView
57+
android:layout_width="48dp"
58+
android:layout_height="match_parent"
59+
android:layout_gravity="center"
60+
android:layout_marginLeft="8dp"
61+
android:layout_marginRight="8dp"
62+
android:layout_marginTop="6dp"
63+
android:layout_marginBottom="6dp"
64+
android:src="@drawable/ic_audio_ring_notif_vibrate"
65+
android:scaleType="center"
66+
android:duplicateParentState="true"
67+
android:background="@drawable/silent_mode_indicator"
68+
/>
69+
</LinearLayout>
70+
71+
<!-- Spacer -->
72+
<View android:layout_width="0dp"
73+
android:layout_height="match_parent"
74+
android:layout_weight="1"
75+
android:visibility="invisible"/>
76+
77+
<LinearLayout
78+
android:id="@+id/option3"
79+
android:layout_width="64dp"
80+
android:layout_height="match_parent"
81+
android:background="?android:attr/actionBarItemBackground"
82+
>
83+
<ImageView
84+
android:layout_width="48dp"
85+
android:layout_height="match_parent"
86+
android:layout_gravity="center"
87+
android:layout_marginLeft="8dp"
88+
android:layout_marginRight="8dp"
89+
android:layout_marginTop="6dp"
90+
android:layout_marginBottom="6dp"
91+
android:src="@drawable/ic_audio_vol"
92+
android:scaleType="center"
93+
android:duplicateParentState="true"
94+
android:background="@drawable/silent_mode_indicator"
95+
/>
96+
</LinearLayout>
97+
</LinearLayout>

media/java/android/media/AudioService.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import static android.media.AudioManager.RINGER_MODE_VIBRATE;
2222

2323
import android.app.ActivityManagerNative;
24+
import android.app.KeyguardManager;
2425
import android.app.PendingIntent;
2526
import android.app.PendingIntent.CanceledException;
2627
import android.bluetooth.BluetoothA2dp;
@@ -319,6 +320,8 @@ public void onError(int error) {
319320
private static final int NOTIFICATION_VOLUME_DELAY_MS = 5000;
320321
// previous volume adjustment direction received by checkForRingerModeChange()
321322
private int mPrevVolDirection = AudioManager.ADJUST_SAME;
323+
// Keyguard manager proxy
324+
private KeyguardManager mKeyguardManager;
322325

323326
///////////////////////////////////////////////////////////////////////////
324327
// Construction
@@ -503,9 +506,10 @@ public void adjustSuggestedStreamVolume(int direction, int suggestedStreamType,
503506
streamType = getActiveStreamType(suggestedStreamType);
504507
}
505508

506-
// Play sounds on STREAM_RING only.
509+
// Play sounds on STREAM_RING only and if lock screen is not on.
507510
if ((flags & AudioManager.FLAG_PLAY_SOUND) != 0 &&
508-
((STREAM_VOLUME_ALIAS[streamType] != AudioSystem.STREAM_RING))) {
511+
((STREAM_VOLUME_ALIAS[streamType] != AudioSystem.STREAM_RING)
512+
|| (mKeyguardManager != null && mKeyguardManager.isKeyguardLocked()))) {
509513
flags &= ~AudioManager.FLAG_PLAY_SOUND;
510514
}
511515

@@ -2665,6 +2669,8 @@ public void onReceive(Context context, Intent intent) {
26652669
sendMsg(mAudioHandler, MSG_LOAD_SOUND_EFFECTS, SHARED_MSG, SENDMSG_NOOP,
26662670
0, 0, null, 0);
26672671

2672+
mKeyguardManager =
2673+
(KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
26682674
mScoConnectionState = AudioManager.SCO_AUDIO_STATE_ERROR;
26692675
resetBluetoothSco();
26702676
getBluetoothHeadset();

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

Lines changed: 19 additions & 1 deletion
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 = 72;
66+
private static final int DATABASE_VERSION = 73;
6767

6868
private Context mContext;
6969

@@ -961,13 +961,31 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int currentVersion) {
961961
+ " VALUES(?,?);");
962962
loadBooleanSetting(stmt, Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD,
963963
R.bool.def_accessibility_speak_password);
964+
db.setTransactionSuccessful();
964965
} finally {
965966
db.endTransaction();
966967
if (stmt != null) stmt.close();
967968
}
968969
upgradeVersion = 72;
969970
}
970971

972+
if (upgradeVersion == 72) {
973+
// update vibration settings
974+
db.beginTransaction();
975+
SQLiteStatement stmt = null;
976+
try {
977+
stmt = db.compileStatement("INSERT OR REPLACE INTO system(name,value)"
978+
+ " VALUES(?,?);");
979+
loadBooleanSetting(stmt, Settings.System.VIBRATE_IN_SILENT,
980+
R.bool.def_vibrate_in_silent);
981+
db.setTransactionSuccessful();
982+
} finally {
983+
db.endTransaction();
984+
if (stmt != null) stmt.close();
985+
}
986+
upgradeVersion = 73;
987+
}
988+
971989
// *** Remember to update DATABASE_VERSION above!
972990

973991
if (upgradeVersion != currentVersion) {

0 commit comments

Comments
 (0)