diff options
author | Jeff Brown <jeffbrown@google.com> | 2012-12-11 15:21:02 -0800 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2012-12-11 15:21:02 -0800 |
commit | ace7404de8b9a5bd7566027a8a90d36d099a46f4 (patch) | |
tree | c01fc20897525d49aecd56c4fc6a672fceed3089 | |
parent | fba73030d674b3cd29ffe8519aa41738b54ae827 (diff) | |
parent | d7337fb97aab0b28c6ca60f6553d03feb1000991 (diff) | |
download | frameworks_base-ace7404de8b9a5bd7566027a8a90d36d099a46f4.zip frameworks_base-ace7404de8b9a5bd7566027a8a90d36d099a46f4.tar.gz frameworks_base-ace7404de8b9a5bd7566027a8a90d36d099a46f4.tar.bz2 |
resolved conflicts for merge of d7337fb9 to master
Change-Id: I51dedcc5ee521e62ad6101c0b09e4f881b8c4bf0
-rw-r--r-- | core/java/android/provider/Settings.java | 7 | ||||
-rwxr-xr-x | data/sounds/AudioPackage10.mk | 1 | ||||
-rw-r--r-- | data/sounds/effects/ogg/LowBattery.ogg | bin | 17786 -> 12401 bytes | |||
-rw-r--r-- | data/sounds/effects/ogg/WirelessChargingStarted.ogg | bin | 0 -> 12025 bytes | |||
-rw-r--r-- | packages/SettingsProvider/res/values/defaults.xml | 2 | ||||
-rw-r--r-- | packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java | 21 | ||||
-rw-r--r-- | services/java/com/android/server/power/Notifier.java | 41 | ||||
-rw-r--r-- | services/java/com/android/server/power/PowerManagerService.java | 10 |
8 files changed, 81 insertions, 1 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index dc089bd..4dbc4b4 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -4296,6 +4296,13 @@ public final class Settings { public static final String POWER_SOUNDS_ENABLED = "power_sounds_enabled"; /** + * URI for the "wireless charging started" sound. + * @hide + */ + public static final String WIRELESS_CHARGING_STARTED_SOUND = + "wireless_charging_started_sound"; + + /** * Whether we keep the device on while the device is plugged in. * Supported values are: * <ul> diff --git a/data/sounds/AudioPackage10.mk b/data/sounds/AudioPackage10.mk index a930a54..90d8eaa 100755 --- a/data/sounds/AudioPackage10.mk +++ b/data/sounds/AudioPackage10.mk @@ -29,6 +29,7 @@ PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/effects/ogg/Undock.ogg:system/media/audio/ui/Undock.ogg \ $(LOCAL_PATH)/effects/ogg/Lock.ogg:system/media/audio/ui/Lock.ogg \ $(LOCAL_PATH)/effects/ogg/Unlock.ogg:system/media/audio/ui/Unlock.ogg \ + $(LOCAL_PATH)/effects/ogg/WirelessChargingStarted.ogg:system/media/audio/ui/WirelessChargingStarted.ogg \ $(LOCAL_PATH)/notifications/ogg/Adara.ogg:system/media/audio/notifications/Adara.ogg \ $(LOCAL_PATH)/notifications/ogg/Alya.ogg:system/media/audio/notifications/Alya.ogg \ $(LOCAL_PATH)/notifications/ogg/Arcturus.ogg:system/media/audio/notifications/Arcturus.ogg \ diff --git a/data/sounds/effects/ogg/LowBattery.ogg b/data/sounds/effects/ogg/LowBattery.ogg Binary files differindex 710e385..ab9eba3 100644 --- a/data/sounds/effects/ogg/LowBattery.ogg +++ b/data/sounds/effects/ogg/LowBattery.ogg diff --git a/data/sounds/effects/ogg/WirelessChargingStarted.ogg b/data/sounds/effects/ogg/WirelessChargingStarted.ogg Binary files differnew file mode 100644 index 0000000..66f6cd2 --- /dev/null +++ b/data/sounds/effects/ogg/WirelessChargingStarted.ogg diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml index 282ea8a..82627c0 100644 --- a/packages/SettingsProvider/res/values/defaults.xml +++ b/packages/SettingsProvider/res/values/defaults.xml @@ -73,6 +73,8 @@ <integer name="def_lockscreen_sounds_enabled">1</integer> <string name="def_lock_sound" translatable="false">/system/media/audio/ui/Lock.ogg</string> <string name="def_unlock_sound" translatable="false">/system/media/audio/ui/Unlock.ogg</string> + <string name="def_wireless_charging_started_sound" translatable="false">/system/media/audio/ui/WirelessChargingStarted.ogg</string> + <bool name="def_lockscreen_disabled">false</bool> <bool name="def_device_provisioned">false</bool> diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java index 2c8c4a2..b2f1d3f 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java @@ -71,7 +71,7 @@ public class DatabaseHelper extends SQLiteOpenHelper { // 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 // settings. - private static final int DATABASE_VERSION = 94; + private static final int DATABASE_VERSION = 95; private Context mContext; private int mUserHandle; @@ -1505,6 +1505,23 @@ public class DatabaseHelper extends SQLiteOpenHelper { upgradeVersion = 94; } + if (upgradeVersion == 94) { + // Add wireless charging started sound setting + db.beginTransaction(); + SQLiteStatement stmt = null; + try { + stmt = db.compileStatement("INSERT OR REPLACE INTO global(name,value)" + + " VALUES(?,?);"); + loadStringSetting(stmt, Settings.Global.WIRELESS_CHARGING_STARTED_SOUND, + R.string.def_wireless_charging_started_sound); + db.setTransactionSuccessful(); + } finally { + db.endTransaction(); + if (stmt != null) stmt.close(); + } + upgradeVersion = 95; + } + // *** Remember to update DATABASE_VERSION above! if (upgradeVersion != currentVersion) { @@ -2188,6 +2205,8 @@ public class DatabaseHelper extends SQLiteOpenHelper { R.string.def_car_dock_sound); loadStringSetting(stmt, Settings.Global.CAR_UNDOCK_SOUND, R.string.def_car_undock_sound); + loadStringSetting(stmt, Settings.Global.WIRELESS_CHARGING_STARTED_SOUND, + R.string.def_wireless_charging_started_sound); loadSetting(stmt, Settings.Global.SET_INSTALL_LOCATION, 0); loadSetting(stmt, Settings.Global.DEFAULT_INSTALL_LOCATION, 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; } } } diff --git a/services/java/com/android/server/power/PowerManagerService.java b/services/java/com/android/server/power/PowerManagerService.java index 7f83c17..5a5d910 100644 --- a/services/java/com/android/server/power/PowerManagerService.java +++ b/services/java/com/android/server/power/PowerManagerService.java @@ -1150,6 +1150,16 @@ public final class PowerManagerService extends IPowerManager.Stub } userActivityNoUpdateLocked( now, PowerManager.USER_ACTIVITY_EVENT_OTHER, 0, Process.SYSTEM_UID); + + // Tell the notifier whether wireless charging has started so that + // it can provide feedback to the user. Refer to + // shouldWakeUpWhenPluggedOrUnpluggedLocked for justification of the + // heuristics used here. + if (!wasPowered && mIsPowered + && mPlugType == BatteryManager.BATTERY_PLUGGED_WIRELESS + && mBatteryLevel < WIRELESS_CHARGER_TURN_ON_BATTERY_LEVEL_LIMIT) { + mNotifier.onWirelessChargingStarted(); + } } } } |