开启静音模式并关闭静音后,插入充电器手机振动
grep -nr “Charging sounds and vibration” res/
res/values-en-rXC/strings.xml:3199: <string name="charging_sounds_title" msgid="3379885700913955599">"Charging sounds and vibration"</string>
res/values/strings.xml:7817: <string name="charging_sounds_title">Charging sounds and vibration</string>
grep -nr “charging_sounds_title” res/
res/xml/other_sound_settings.xml:35: android:title="@string/charging_sounds_title" />
32 <!-- Charging sounds -->
33 <SwitchPreference
find src/ -name Charging*.java
src/com/android/settings/notification/ChargingSoundPreferenceController.java
32 public ChargingSoundPreferenceController(Context context, SettingsPreferenceFragment parent,
33 Lifecycle lifecycle) {
34 super(context, parent, lifecycle);
35 mPreference = new SettingPref(
36 TYPE_SECURE, KEY_CHARGING_SOUNDS, Secure.CHARGING_SOUNDS_ENABLED, DEFAULT_ON);
37 }
grep -nr “CHARGING_SOUNDS_ENABLED” frameworks/base/
frameworks/base/services/core/java/com/android/server/power/Notifier.java
794 /**
795 * If enabled, plays a sound and/or vibration when wireless or non-wireless charging has started
796 */
797 private void playChargingStartedFeedback(@UserIdInt int userId) {
798 playChargingStartedVibration(userId);
799 final String soundPath = Settings.Global.getString(mContext.getContentResolver(),
800 Settings.Global.CHARGING_STARTED_SOUND);
801 if (isChargingFeedbackEnabled(userId) && soundPath != null) {
802 final Uri soundUri = Uri.parse("file://" + soundPath);
803 if (soundUri != null) {
804 final Ringtone sfx = RingtoneManager.getRingtone(mContext, soundUri);
805 if (sfx != null) {
806 sfx.setStreamType(AudioManager.STREAM_SYSTEM);
807 sfx.play();
808 }
809 }
810 }
811 }
......
830 private void playChargingStartedVibration(@UserIdInt int userId) {
831 final boolean vibrateEnabled = Settings.Secure.getIntForUser(mContext.getContentResolver(),
832 Settings.Secure.CHARGING_VIBRATION_ENABLED, 1, userId) != 0;
833 if (vibrateEnabled && isChargingFeedbackEnabled(userId)) {
834 mVibrator.vibrate(WIRELESS_CHARGING_VIBRATION_EFFECT, VIBRATION_ATTRIBUTES);
835 }
836 }
837
838 private boolean isChargingFeedbackEnabled(@UserIdInt int userId) {
839 final boolean enabled = Settings.Secure.getIntForUser(mContext.getContentResolver(),
840 Settings.Secure.CHARGING_SOUNDS_ENABLED, 1, userId) != 0;
841 final boolean dndOff = Settings.Global.getInt(mContext.getContentResolver(),
842 Settings.Global.ZEN_MODE, Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS)
843 == Settings.Global.ZEN_MODE_OFF;
844 return enabled && dndOff;
845 }
wifi 抓取log:
设备端端口:
adb tcpip 5555
pc adb connect 设备端ip
注意: pc和设备链接到同一个wifi上。
模拟低电模式,灭屏播放音乐,音乐出现卡顿。
1、adb root;
2、切换手机电池为非充电状态: adb shell dumpsys battery set status 1
3、让手机电量显示1: adb shell dumpsys battery set level 1