diff options
Diffstat (limited to 'services/java/com/android/server/power/Notifier.java')
-rw-r--r-- | services/java/com/android/server/power/Notifier.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/services/java/com/android/server/power/Notifier.java b/services/java/com/android/server/power/Notifier.java index 5e05693..d99d523 100644 --- a/services/java/com/android/server/power/Notifier.java +++ b/services/java/com/android/server/power/Notifier.java @@ -23,6 +23,10 @@ import android.app.ActivityManagerNative; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import android.media.AudioManager; +import android.media.Ringtone; +import android.media.RingtoneManager; +import android.net.Uri; import android.os.BatteryStats; import android.os.Handler; import android.os.Looper; @@ -32,6 +36,7 @@ import android.os.RemoteException; import android.os.SystemClock; import android.os.UserHandle; import android.os.WorkSource; +import android.provider.Settings; import android.util.EventLog; import android.util.Slog; import android.view.WindowManagerPolicy; @@ -64,6 +69,7 @@ final class Notifier { private static final int MSG_USER_ACTIVITY = 1; private static final int MSG_BROADCAST = 2; + private static final int MSG_WIRELESS_CHARGING_STARTED = 3; private final Object mLock = new Object(); @@ -312,6 +318,20 @@ final class Notifier { } } + /** + * Called when wireless charging has started so as to provide user feedback. + */ + public void onWirelessChargingStarted() { + if (DEBUG) { + Slog.d(TAG, "onWirelessChargingStarted"); + } + + mSuspendBlocker.acquire(); + Message msg = mHandler.obtainMessage(MSG_WIRELESS_CHARGING_STARTED); + msg.setAsynchronous(true); + mHandler.sendMessage(msg); + } + private void updatePendingBroadcastLocked() { if (!mBroadcastInProgress && mActualPowerState != POWER_STATE_UNKNOWN @@ -473,6 +493,23 @@ final class Notifier { } }; + private void playWirelessChargingStartedSound() { + final String soundPath = Settings.Global.getString(mContext.getContentResolver(), + Settings.Global.WIRELESS_CHARGING_STARTED_SOUND); + if (soundPath != null) { + final Uri soundUri = Uri.parse("file://" + soundPath); + if (soundUri != null) { + final Ringtone sfx = RingtoneManager.getRingtone(mContext, soundUri); + if (sfx != null) { + sfx.setStreamType(AudioManager.STREAM_SYSTEM); + sfx.play(); + } + } + } + + mSuspendBlocker.release(); + } + private final class NotifierHandler extends Handler { public NotifierHandler(Looper looper) { super(looper, null, true /*async*/); @@ -488,6 +525,10 @@ final class Notifier { case MSG_BROADCAST: sendNextBroadcast(); break; + + case MSG_WIRELESS_CHARGING_STARTED: + playWirelessChargingStartedSound(); + break; } } } |