* commit '3781523becbb2d576761c2701763ff3588294a97': Play a tone when wireless charging begins.
This commit is contained in:
@ -4295,6 +4295,13 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public static final String POWER_SOUNDS_ENABLED = "power_sounds_enabled";
|
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.
|
* Whether we keep the device on while the device is plugged in.
|
||||||
* Supported values are:
|
* Supported values are:
|
||||||
|
@ -1818,5 +1818,4 @@
|
|||||||
|
|
||||||
<!-- From PinyinIME(!!!) -->
|
<!-- From PinyinIME(!!!) -->
|
||||||
<java-symbol type="string" name="inputMethod" />
|
<java-symbol type="string" name="inputMethod" />
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -29,6 +29,7 @@ PRODUCT_COPY_FILES += \
|
|||||||
$(LOCAL_PATH)/effects/ogg/Undock.ogg:system/media/audio/ui/Undock.ogg \
|
$(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/Lock.ogg:system/media/audio/ui/Lock.ogg \
|
||||||
$(LOCAL_PATH)/effects/ogg/Unlock.ogg:system/media/audio/ui/Unlock.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/Adara.ogg:system/media/audio/notifications/Adara.ogg \
|
||||||
$(LOCAL_PATH)/notifications/ogg/Alya.ogg:system/media/audio/notifications/Alya.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 \
|
$(LOCAL_PATH)/notifications/ogg/Arcturus.ogg:system/media/audio/notifications/Arcturus.ogg \
|
||||||
|
Binary file not shown.
BIN
data/sounds/effects/ogg/WirelessChargingStarted.ogg
Normal file
BIN
data/sounds/effects/ogg/WirelessChargingStarted.ogg
Normal file
Binary file not shown.
@ -75,6 +75,8 @@
|
|||||||
<integer name="def_lockscreen_sounds_enabled">1</integer>
|
<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_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_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_lockscreen_disabled">false</bool>
|
||||||
<bool name="def_device_provisioned">false</bool>
|
<bool name="def_device_provisioned">false</bool>
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
|||||||
// database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion'
|
// 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
|
// is properly propagated through your change. Not doing so will result in a loss of user
|
||||||
// settings.
|
// settings.
|
||||||
private static final int DATABASE_VERSION = 94;
|
private static final int DATABASE_VERSION = 95;
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private int mUserHandle;
|
private int mUserHandle;
|
||||||
@ -1505,6 +1505,23 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
|||||||
upgradeVersion = 94;
|
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!
|
// *** Remember to update DATABASE_VERSION above!
|
||||||
|
|
||||||
if (upgradeVersion != currentVersion) {
|
if (upgradeVersion != currentVersion) {
|
||||||
@ -2191,6 +2208,8 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
|||||||
R.string.def_car_dock_sound);
|
R.string.def_car_dock_sound);
|
||||||
loadStringSetting(stmt, Settings.Global.CAR_UNDOCK_SOUND,
|
loadStringSetting(stmt, Settings.Global.CAR_UNDOCK_SOUND,
|
||||||
R.string.def_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.SET_INSTALL_LOCATION, 0);
|
||||||
loadSetting(stmt, Settings.Global.DEFAULT_INSTALL_LOCATION,
|
loadSetting(stmt, Settings.Global.DEFAULT_INSTALL_LOCATION,
|
||||||
|
@ -23,6 +23,10 @@ import android.app.ActivityManagerNative;
|
|||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
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.BatteryStats;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
@ -32,6 +36,7 @@ import android.os.RemoteException;
|
|||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.WorkSource;
|
import android.os.WorkSource;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.util.EventLog;
|
import android.util.EventLog;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
import android.view.WindowManagerPolicy;
|
import android.view.WindowManagerPolicy;
|
||||||
@ -64,6 +69,7 @@ final class Notifier {
|
|||||||
|
|
||||||
private static final int MSG_USER_ACTIVITY = 1;
|
private static final int MSG_USER_ACTIVITY = 1;
|
||||||
private static final int MSG_BROADCAST = 2;
|
private static final int MSG_BROADCAST = 2;
|
||||||
|
private static final int MSG_WIRELESS_CHARGING_STARTED = 3;
|
||||||
|
|
||||||
private final Object mLock = new Object();
|
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() {
|
private void updatePendingBroadcastLocked() {
|
||||||
if (!mBroadcastInProgress
|
if (!mBroadcastInProgress
|
||||||
&& mActualPowerState != POWER_STATE_UNKNOWN
|
&& 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 {
|
private final class NotifierHandler extends Handler {
|
||||||
public NotifierHandler(Looper looper) {
|
public NotifierHandler(Looper looper) {
|
||||||
super(looper, null, true /*async*/);
|
super(looper, null, true /*async*/);
|
||||||
@ -488,6 +525,10 @@ final class Notifier {
|
|||||||
case MSG_BROADCAST:
|
case MSG_BROADCAST:
|
||||||
sendNextBroadcast();
|
sendNextBroadcast();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MSG_WIRELESS_CHARGING_STARTED:
|
||||||
|
playWirelessChargingStartedSound();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1150,6 +1150,16 @@ public final class PowerManagerService extends IPowerManager.Stub
|
|||||||
}
|
}
|
||||||
userActivityNoUpdateLocked(
|
userActivityNoUpdateLocked(
|
||||||
now, PowerManager.USER_ACTIVITY_EVENT_OTHER, 0, Process.SYSTEM_UID);
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user