summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com/android
diff options
context:
space:
mode:
authorAdrian Roos <roosa@google.com>2014-08-13 17:14:51 +0200
committerAdrian Roos <roosa@google.com>2014-08-18 16:53:27 +0000
commit49e057d7eedb44f5397781254acab4e0ef08a9cf (patch)
tree5ba51bd4faf957aa4848c8ecd3b7fbecd7ab5723 /packages/SystemUI/src/com/android
parent9eee9dca63dfd596197b58011b85d9daa6f39f06 (diff)
downloadframeworks_base-49e057d7eedb44f5397781254acab4e0ef08a9cf.zip
frameworks_base-49e057d7eedb44f5397781254acab4e0ef08a9cf.tar.gz
frameworks_base-49e057d7eedb44f5397781254acab4e0ef08a9cf.tar.bz2
Play "device trusted" sound when onTrustInitiatedByUser fires
Bug: 16840500 Change-Id: I73fbe5c2cff665ccb637abb9039d57f377d9df53
Diffstat (limited to 'packages/SystemUI/src/com/android')
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java32
1 files changed, 28 insertions, 4 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index be11220..ad568b8 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -262,6 +262,7 @@ public class KeyguardViewMediator extends SystemUI {
private SoundPool mLockSounds;
private int mLockSoundId;
private int mUnlockSoundId;
+ private int mTrustedSoundId;
private int mLockSoundStreamId;
/**
@@ -451,6 +452,11 @@ public class KeyguardViewMediator extends SystemUI {
KeyguardViewMediator.this.keyguardDone(true /* authenticated */, true /* wakeUp */);
}
}
+
+ @Override
+ public void playTrustedSound() {
+ KeyguardViewMediator.this.playTrustedSound();
+ }
};
public void userActivity() {
@@ -500,6 +506,14 @@ public class KeyguardViewMediator extends SystemUI {
if (soundPath == null || mUnlockSoundId == 0) {
Log.w(TAG, "failed to load unlock sound from " + soundPath);
}
+ soundPath = Settings.Global.getString(cr, Settings.Global.TRUSTED_SOUND);
+ if (soundPath != null) {
+ mTrustedSoundId = mLockSounds.load(soundPath, 1);
+ }
+ if (soundPath == null || mTrustedSoundId == 0) {
+ Log.w(TAG, "failed to load trusted sound from " + soundPath);
+ }
+
int lockSoundDefaultAttenuation = mContext.getResources().getInteger(
com.android.internal.R.integer.config_lockSoundVolumeDb);
mLockSoundVolume = (float)Math.pow(10, (float)lockSoundDefaultAttenuation/20);
@@ -1155,11 +1169,14 @@ public class KeyguardViewMediator extends SystemUI {
return;
}
+ playSound(locked ? mLockSoundId : mUnlockSoundId);
+ }
+
+ private void playSound(int soundId) {
+ if (soundId == 0) return;
final ContentResolver cr = mContext.getContentResolver();
if (Settings.System.getInt(cr, Settings.System.LOCKSCREEN_SOUNDS_ENABLED, 1) == 1) {
- final int whichSound = locked
- ? mLockSoundId
- : mUnlockSoundId;
+
mLockSounds.stop(mLockSoundStreamId);
// Init mAudioManager
if (mAudioManager == null) {
@@ -1170,11 +1187,18 @@ public class KeyguardViewMediator extends SystemUI {
// If the stream is muted, don't play the sound
if (mAudioManager.isStreamMute(mMasterStreamType)) return;
- mLockSoundStreamId = mLockSounds.play(whichSound,
+ mLockSoundStreamId = mLockSounds.play(soundId,
mLockSoundVolume, mLockSoundVolume, 1/*priortiy*/, 0/*loop*/, 1.0f/*rate*/);
}
}
+ private void playTrustedSound() {
+ if (mSuppressNextLockSound) {
+ return;
+ }
+ playSound(mTrustedSoundId);
+ }
+
private void updateActivityLockScreenState() {
try {
ActivityManagerNative.getDefault().setLockScreenShown(mShowing && !mOccluded);