Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.server.power; |
| 18 | |
Andrew Zeng | 6d07baf | 2018-04-20 14:13:16 -0700 | [diff] [blame] | 19 | import android.annotation.Nullable; |
Pavel Grafov | 2893998 | 2017-10-03 15:11:52 +0100 | [diff] [blame] | 20 | import android.annotation.UserIdInt; |
Jeff Brown | 13014b5 | 2014-04-07 19:45:27 -0700 | [diff] [blame] | 21 | import android.app.ActivityManagerInternal; |
Dianne Hackborn | 713df15 | 2013-05-17 11:27:57 -0700 | [diff] [blame] | 22 | import android.app.AppOpsManager; |
Pavel Grafov | 2893998 | 2017-10-03 15:11:52 +0100 | [diff] [blame] | 23 | import android.app.trust.TrustManager; |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 24 | import android.content.BroadcastReceiver; |
| 25 | import android.content.Context; |
| 26 | import android.content.Intent; |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 27 | import android.hardware.input.InputManagerInternal; |
Beverly | 69721d6 | 2018-05-09 17:41:44 -0400 | [diff] [blame] | 28 | import android.media.AudioAttributes; |
Jeff Brown | 84e2756 | 2012-12-07 13:56:34 -0800 | [diff] [blame] | 29 | import android.media.AudioManager; |
| 30 | import android.media.Ringtone; |
| 31 | import android.media.RingtoneManager; |
Alison Cichowlas | 5c38fc2 | 2017-01-25 17:11:06 -0500 | [diff] [blame] | 32 | import android.metrics.LogMaker; |
Jeff Brown | 84e2756 | 2012-12-07 13:56:34 -0800 | [diff] [blame] | 33 | import android.net.Uri; |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 34 | import android.os.BatteryStats; |
| 35 | import android.os.Handler; |
| 36 | import android.os.Looper; |
| 37 | import android.os.Message; |
| 38 | import android.os.PowerManager; |
Michael Wright | e300104 | 2019-02-05 00:13:14 +0000 | [diff] [blame] | 39 | import android.os.PowerManager.WakeReason; |
Jeff Brown | fbe9670 | 2014-11-19 18:30:58 -0800 | [diff] [blame] | 40 | import android.os.PowerManagerInternal; |
Dianne Hackborn | 3d658bf | 2014-02-05 13:38:56 -0800 | [diff] [blame] | 41 | import android.os.Process; |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 42 | import android.os.RemoteException; |
| 43 | import android.os.SystemClock; |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 44 | import android.os.UserHandle; |
Beverly | 69721d6 | 2018-05-09 17:41:44 -0400 | [diff] [blame] | 45 | import android.os.VibrationEffect; |
| 46 | import android.os.Vibrator; |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 47 | import android.os.WorkSource; |
Jeff Brown | 84e2756 | 2012-12-07 13:56:34 -0800 | [diff] [blame] | 48 | import android.provider.Settings; |
Peter Wang | 6a92dd4 | 2020-01-15 14:11:25 -0800 | [diff] [blame] | 49 | import android.telephony.TelephonyManager; |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 50 | import android.util.EventLog; |
| 51 | import android.util.Slog; |
Michael Wright | e300104 | 2019-02-05 00:13:14 +0000 | [diff] [blame] | 52 | import android.view.WindowManagerPolicyConstants.OnReason; |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 53 | |
Santos Cordon | 64a6e61 | 2018-08-22 19:27:04 +0100 | [diff] [blame] | 54 | import com.android.internal.annotations.VisibleForTesting; |
Beverly | ae79ab9 | 2017-12-11 09:20:02 -0500 | [diff] [blame] | 55 | import com.android.internal.app.IBatteryStats; |
| 56 | import com.android.internal.logging.MetricsLogger; |
| 57 | import com.android.internal.logging.nano.MetricsProto.MetricsEvent; |
Muhammad Qureshi | 4116630 | 2020-01-28 10:23:36 -0800 | [diff] [blame] | 58 | import com.android.internal.util.FrameworkStatsLog; |
Beverly | ae79ab9 | 2017-12-11 09:20:02 -0500 | [diff] [blame] | 59 | import com.android.server.EventLogTags; |
| 60 | import com.android.server.LocalServices; |
Yohei Yukawa | c3de83e | 2018-08-28 16:09:34 -0700 | [diff] [blame] | 61 | import com.android.server.inputmethod.InputMethodManagerInternal; |
Beverly | ae79ab9 | 2017-12-11 09:20:02 -0500 | [diff] [blame] | 62 | import com.android.server.policy.WindowManagerPolicy; |
Beverly | 69721d6 | 2018-05-09 17:41:44 -0400 | [diff] [blame] | 63 | import com.android.server.statusbar.StatusBarManagerInternal; |
Beverly | ae79ab9 | 2017-12-11 09:20:02 -0500 | [diff] [blame] | 64 | |
Santos Cordon | 9204cc8 | 2019-11-21 11:45:28 +0000 | [diff] [blame] | 65 | import java.io.PrintWriter; |
| 66 | |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 67 | /** |
| 68 | * Sends broadcasts about important power state changes. |
Jeff Brown | 5430835 | 2012-10-04 17:59:58 -0700 | [diff] [blame] | 69 | * <p> |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 70 | * This methods of this class may be called by the power manager service while |
| 71 | * its lock is being held. Internally it takes care of sending broadcasts to |
| 72 | * notify other components of the system or applications asynchronously. |
Jeff Brown | 5430835 | 2012-10-04 17:59:58 -0700 | [diff] [blame] | 73 | * </p><p> |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 74 | * The notifier is designed to collapse unnecessary broadcasts when it is not |
| 75 | * possible for the system to have observed an intermediate state. |
Jeff Brown | 5430835 | 2012-10-04 17:59:58 -0700 | [diff] [blame] | 76 | * </p><p> |
| 77 | * For example, if the device wakes up, goes to sleep, wakes up again and goes to |
| 78 | * sleep again before the wake up notification is sent, then the system will |
| 79 | * be told about only one wake up and sleep. However, we always notify the |
| 80 | * fact that at least one transition occurred. It is especially important to |
| 81 | * tell the system when we go to sleep so that it can lock the keyguard if needed. |
| 82 | * </p> |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 83 | */ |
Santos Cordon | 64a6e61 | 2018-08-22 19:27:04 +0100 | [diff] [blame] | 84 | @VisibleForTesting |
| 85 | public class Notifier { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 86 | private static final String TAG = "PowerManagerNotifier"; |
| 87 | |
| 88 | private static final boolean DEBUG = false; |
| 89 | |
Jeff Brown | fbe9670 | 2014-11-19 18:30:58 -0800 | [diff] [blame] | 90 | private static final int INTERACTIVE_STATE_UNKNOWN = 0; |
| 91 | private static final int INTERACTIVE_STATE_AWAKE = 1; |
| 92 | private static final int INTERACTIVE_STATE_ASLEEP = 2; |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 93 | |
| 94 | private static final int MSG_USER_ACTIVITY = 1; |
| 95 | private static final int MSG_BROADCAST = 2; |
Jeff Brown | 84e2756 | 2012-12-07 13:56:34 -0800 | [diff] [blame] | 96 | private static final int MSG_WIRELESS_CHARGING_STARTED = 3; |
Pavel Grafov | 2893998 | 2017-10-03 15:11:52 +0100 | [diff] [blame] | 97 | private static final int MSG_PROFILE_TIMED_OUT = 5; |
Beverly | c1313eb | 2018-01-31 18:07:21 -0500 | [diff] [blame] | 98 | private static final int MSG_WIRED_CHARGING_STARTED = 6; |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 99 | |
Beverly | f364d7c | 2019-10-10 16:44:43 -0400 | [diff] [blame] | 100 | private static final long[] CHARGING_VIBRATION_TIME = { |
Beverly | 69721d6 | 2018-05-09 17:41:44 -0400 | [diff] [blame] | 101 | 40, 40, 40, 40, 40, 40, 40, 40, 40, // ramp-up sampling rate = 40ms |
| 102 | 40, 40, 40, 40, 40, 40, 40 // ramp-down sampling rate = 40ms |
| 103 | }; |
Beverly | f364d7c | 2019-10-10 16:44:43 -0400 | [diff] [blame] | 104 | private static final int[] CHARGING_VIBRATION_AMPLITUDE = { |
Beverly | 69721d6 | 2018-05-09 17:41:44 -0400 | [diff] [blame] | 105 | 1, 4, 11, 25, 44, 67, 91, 114, 123, // ramp-up amplitude (from 0 to 50%) |
| 106 | 103, 79, 55, 34, 17, 7, 2 // ramp-up amplitude |
| 107 | }; |
Beverly | f364d7c | 2019-10-10 16:44:43 -0400 | [diff] [blame] | 108 | private static final VibrationEffect CHARGING_VIBRATION_EFFECT = |
| 109 | VibrationEffect.createWaveform(CHARGING_VIBRATION_TIME, CHARGING_VIBRATION_AMPLITUDE, |
Beverly | 69721d6 | 2018-05-09 17:41:44 -0400 | [diff] [blame] | 110 | -1); |
| 111 | private static final AudioAttributes VIBRATION_ATTRIBUTES = new AudioAttributes.Builder() |
| 112 | .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) |
| 113 | .build(); |
| 114 | |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 115 | private final Object mLock = new Object(); |
| 116 | |
| 117 | private final Context mContext; |
| 118 | private final IBatteryStats mBatteryStats; |
Svet Ganov | f7b4725 | 2018-02-26 11:11:27 -0800 | [diff] [blame] | 119 | private final AppOpsManager mAppOps; |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 120 | private final SuspendBlocker mSuspendBlocker; |
| 121 | private final WindowManagerPolicy mPolicy; |
Jeff Brown | 13014b5 | 2014-04-07 19:45:27 -0700 | [diff] [blame] | 122 | private final ActivityManagerInternal mActivityManagerInternal; |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 123 | private final InputManagerInternal mInputManagerInternal; |
Yohei Yukawa | fa6e0a8 | 2015-07-23 15:08:59 -0700 | [diff] [blame] | 124 | private final InputMethodManagerInternal mInputMethodManagerInternal; |
Andrew Zeng | 6d07baf | 2018-04-20 14:13:16 -0700 | [diff] [blame] | 125 | @Nullable private final StatusBarManagerInternal mStatusBarManagerInternal; |
Pavel Grafov | 2893998 | 2017-10-03 15:11:52 +0100 | [diff] [blame] | 126 | private final TrustManager mTrustManager; |
Beverly | 69721d6 | 2018-05-09 17:41:44 -0400 | [diff] [blame] | 127 | private final Vibrator mVibrator; |
Santos Cordon | 9204cc8 | 2019-11-21 11:45:28 +0000 | [diff] [blame] | 128 | private final WakeLockLog mWakeLockLog; |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 129 | |
| 130 | private final NotifierHandler mHandler; |
| 131 | private final Intent mScreenOnIntent; |
| 132 | private final Intent mScreenOffIntent; |
| 133 | |
Jeff Brown | c4bd42c | 2015-06-12 18:00:11 -0700 | [diff] [blame] | 134 | // True if the device should suspend when the screen is off due to proximity. |
| 135 | private final boolean mSuspendWhenScreenOffDueToProximityConfig; |
| 136 | |
Beverly | f364d7c | 2019-10-10 16:44:43 -0400 | [diff] [blame] | 137 | // True if the device should show the wireless charging animation when the device |
| 138 | // begins charging wirelessly |
| 139 | private final boolean mShowWirelessChargingAnimationConfig; |
| 140 | |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 141 | // The current interactive state. This is set as soon as an interactive state |
| 142 | // transition begins so as to capture the reason that it happened. At some point |
| 143 | // this state will propagate to the pending state then eventually to the |
| 144 | // broadcasted state over the course of reporting the transition asynchronously. |
| 145 | private boolean mInteractive = true; |
| 146 | private int mInteractiveChangeReason; |
Michael Wright | e300104 | 2019-02-05 00:13:14 +0000 | [diff] [blame] | 147 | private long mInteractiveChangeStartTime; // In SystemClock.uptimeMillis() |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 148 | private boolean mInteractiveChanging; |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 149 | |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 150 | // The pending interactive state that we will eventually want to broadcast. |
| 151 | // This is designed so that we can collapse redundant sequences of awake/sleep |
| 152 | // transition pairs while still guaranteeing that at least one transition is observed |
| 153 | // whenever this happens. |
| 154 | private int mPendingInteractiveState; |
Jeff Brown | 5430835 | 2012-10-04 17:59:58 -0700 | [diff] [blame] | 155 | private boolean mPendingWakeUpBroadcast; |
| 156 | private boolean mPendingGoToSleepBroadcast; |
| 157 | |
Jeff Brown | fbe9670 | 2014-11-19 18:30:58 -0800 | [diff] [blame] | 158 | // The currently broadcasted interactive state. This reflects what other parts of the |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 159 | // system have observed. |
Jeff Brown | fbe9670 | 2014-11-19 18:30:58 -0800 | [diff] [blame] | 160 | private int mBroadcastedInteractiveState; |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 161 | private boolean mBroadcastInProgress; |
| 162 | private long mBroadcastStartTime; |
| 163 | |
| 164 | // True if a user activity message should be sent. |
| 165 | private boolean mUserActivityPending; |
| 166 | |
| 167 | public Notifier(Looper looper, Context context, IBatteryStats batteryStats, |
Svet Ganov | f7b4725 | 2018-02-26 11:11:27 -0800 | [diff] [blame] | 168 | SuspendBlocker suspendBlocker, WindowManagerPolicy policy) { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 169 | mContext = context; |
| 170 | mBatteryStats = batteryStats; |
Svet Ganov | f7b4725 | 2018-02-26 11:11:27 -0800 | [diff] [blame] | 171 | mAppOps = mContext.getSystemService(AppOpsManager.class); |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 172 | mSuspendBlocker = suspendBlocker; |
| 173 | mPolicy = policy; |
Jeff Brown | 13014b5 | 2014-04-07 19:45:27 -0700 | [diff] [blame] | 174 | mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.class); |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 175 | mInputManagerInternal = LocalServices.getService(InputManagerInternal.class); |
Yohei Yukawa | fa6e0a8 | 2015-07-23 15:08:59 -0700 | [diff] [blame] | 176 | mInputMethodManagerInternal = LocalServices.getService(InputMethodManagerInternal.class); |
Beverly | ae79ab9 | 2017-12-11 09:20:02 -0500 | [diff] [blame] | 177 | mStatusBarManagerInternal = LocalServices.getService(StatusBarManagerInternal.class); |
Pavel Grafov | 2893998 | 2017-10-03 15:11:52 +0100 | [diff] [blame] | 178 | mTrustManager = mContext.getSystemService(TrustManager.class); |
Beverly | 69721d6 | 2018-05-09 17:41:44 -0400 | [diff] [blame] | 179 | mVibrator = mContext.getSystemService(Vibrator.class); |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 180 | |
| 181 | mHandler = new NotifierHandler(looper); |
| 182 | mScreenOnIntent = new Intent(Intent.ACTION_SCREEN_ON); |
| 183 | mScreenOnIntent.addFlags( |
Chad Brubaker | 291df4f | 2017-03-14 10:23:02 -0700 | [diff] [blame] | 184 | Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND |
| 185 | | Intent.FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS); |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 186 | mScreenOffIntent = new Intent(Intent.ACTION_SCREEN_OFF); |
| 187 | mScreenOffIntent.addFlags( |
Chad Brubaker | 291df4f | 2017-03-14 10:23:02 -0700 | [diff] [blame] | 188 | Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND |
| 189 | | Intent.FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS); |
Jeff Brown | e95c3cd | 2014-05-02 16:59:26 -0700 | [diff] [blame] | 190 | |
Jeff Brown | c4bd42c | 2015-06-12 18:00:11 -0700 | [diff] [blame] | 191 | mSuspendWhenScreenOffDueToProximityConfig = context.getResources().getBoolean( |
| 192 | com.android.internal.R.bool.config_suspendWhenScreenOffDueToProximity); |
Beverly | f364d7c | 2019-10-10 16:44:43 -0400 | [diff] [blame] | 193 | mShowWirelessChargingAnimationConfig = context.getResources().getBoolean( |
| 194 | com.android.internal.R.bool.config_showBuiltinWirelessChargingAnim); |
Jeff Brown | c4bd42c | 2015-06-12 18:00:11 -0700 | [diff] [blame] | 195 | |
Santos Cordon | 9204cc8 | 2019-11-21 11:45:28 +0000 | [diff] [blame] | 196 | mWakeLockLog = new WakeLockLog(); |
| 197 | |
Jeff Brown | e95c3cd | 2014-05-02 16:59:26 -0700 | [diff] [blame] | 198 | // Initialize interactive state for battery stats. |
| 199 | try { |
| 200 | mBatteryStats.noteInteractive(true); |
| 201 | } catch (RemoteException ex) { } |
Muhammad Qureshi | 4116630 | 2020-01-28 10:23:36 -0800 | [diff] [blame] | 202 | FrameworkStatsLog.write(FrameworkStatsLog.INTERACTIVE_STATE_CHANGED, |
| 203 | FrameworkStatsLog.INTERACTIVE_STATE_CHANGED__STATE__ON); |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | /** |
| 207 | * Called when a wake lock is acquired. |
| 208 | */ |
Dianne Hackborn | 713df15 | 2013-05-17 11:27:57 -0700 | [diff] [blame] | 209 | public void onWakeLockAcquired(int flags, String tag, String packageName, |
Dianne Hackborn | a1f1a3c | 2014-02-24 18:12:28 -0800 | [diff] [blame] | 210 | int ownerUid, int ownerPid, WorkSource workSource, String historyTag) { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 211 | if (DEBUG) { |
| 212 | Slog.d(TAG, "onWakeLockAcquired: flags=" + flags + ", tag=\"" + tag |
Dianne Hackborn | 713df15 | 2013-05-17 11:27:57 -0700 | [diff] [blame] | 213 | + "\", packageName=" + packageName |
| 214 | + ", ownerUid=" + ownerUid + ", ownerPid=" + ownerPid |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 215 | + ", workSource=" + workSource); |
| 216 | } |
| 217 | |
Jeff Brown | c4bd42c | 2015-06-12 18:00:11 -0700 | [diff] [blame] | 218 | final int monitorType = getBatteryStatsWakeLockMonitorType(flags); |
| 219 | if (monitorType >= 0) { |
| 220 | try { |
| 221 | final boolean unimportantForLogging = ownerUid == Process.SYSTEM_UID |
| 222 | && (flags & PowerManager.UNIMPORTANT_FOR_LOGGING) != 0; |
| 223 | if (workSource != null) { |
| 224 | mBatteryStats.noteStartWakelockFromSource(workSource, ownerPid, tag, |
| 225 | historyTag, monitorType, unimportantForLogging); |
| 226 | } else { |
| 227 | mBatteryStats.noteStartWakelock(ownerUid, ownerPid, tag, historyTag, |
| 228 | monitorType, unimportantForLogging); |
| 229 | // XXX need to deal with disabled operations. |
Svet Ganov | f7b4725 | 2018-02-26 11:11:27 -0800 | [diff] [blame] | 230 | mAppOps.startOpNoThrow(AppOpsManager.OP_WAKE_LOCK, ownerUid, packageName); |
Jeff Brown | c4bd42c | 2015-06-12 18:00:11 -0700 | [diff] [blame] | 231 | } |
| 232 | } catch (RemoteException ex) { |
| 233 | // Ignore |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 234 | } |
| 235 | } |
Santos Cordon | 9204cc8 | 2019-11-21 11:45:28 +0000 | [diff] [blame] | 236 | |
| 237 | mWakeLockLog.onWakeLockAcquired(tag, ownerUid, flags); |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 238 | } |
| 239 | |
Dianne Hackborn | d0db6f0 | 2016-07-18 14:14:20 -0700 | [diff] [blame] | 240 | public void onLongPartialWakeLockStart(String tag, int ownerUid, WorkSource workSource, |
| 241 | String historyTag) { |
| 242 | if (DEBUG) { |
| 243 | Slog.d(TAG, "onLongPartialWakeLockStart: ownerUid=" + ownerUid |
| 244 | + ", workSource=" + workSource); |
| 245 | } |
| 246 | |
| 247 | try { |
| 248 | if (workSource != null) { |
Narayan Kamath | 96a9256 | 2018-01-02 18:57:17 +0000 | [diff] [blame] | 249 | mBatteryStats.noteLongPartialWakelockStartFromSource(tag, historyTag, workSource); |
Muhammad Qureshi | 4116630 | 2020-01-28 10:23:36 -0800 | [diff] [blame] | 250 | FrameworkStatsLog.write(FrameworkStatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, |
| 251 | workSource, tag, historyTag, |
| 252 | FrameworkStatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED__STATE__ON); |
Dianne Hackborn | d0db6f0 | 2016-07-18 14:14:20 -0700 | [diff] [blame] | 253 | } else { |
| 254 | mBatteryStats.noteLongPartialWakelockStart(tag, historyTag, ownerUid); |
Muhammad Qureshi | 4116630 | 2020-01-28 10:23:36 -0800 | [diff] [blame] | 255 | FrameworkStatsLog.write_non_chained( |
| 256 | FrameworkStatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, ownerUid, null, tag, |
| 257 | historyTag, |
| 258 | FrameworkStatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED__STATE__ON); |
Dianne Hackborn | d0db6f0 | 2016-07-18 14:14:20 -0700 | [diff] [blame] | 259 | } |
| 260 | } catch (RemoteException ex) { |
| 261 | // Ignore |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | public void onLongPartialWakeLockFinish(String tag, int ownerUid, WorkSource workSource, |
| 266 | String historyTag) { |
| 267 | if (DEBUG) { |
| 268 | Slog.d(TAG, "onLongPartialWakeLockFinish: ownerUid=" + ownerUid |
| 269 | + ", workSource=" + workSource); |
| 270 | } |
| 271 | |
| 272 | try { |
| 273 | if (workSource != null) { |
Narayan Kamath | 96a9256 | 2018-01-02 18:57:17 +0000 | [diff] [blame] | 274 | mBatteryStats.noteLongPartialWakelockFinishFromSource(tag, historyTag, workSource); |
Muhammad Qureshi | 4116630 | 2020-01-28 10:23:36 -0800 | [diff] [blame] | 275 | FrameworkStatsLog.write(FrameworkStatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, |
| 276 | workSource, tag, historyTag, |
| 277 | FrameworkStatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED__STATE__OFF); |
Dianne Hackborn | d0db6f0 | 2016-07-18 14:14:20 -0700 | [diff] [blame] | 278 | } else { |
| 279 | mBatteryStats.noteLongPartialWakelockFinish(tag, historyTag, ownerUid); |
Muhammad Qureshi | 4116630 | 2020-01-28 10:23:36 -0800 | [diff] [blame] | 280 | FrameworkStatsLog.write_non_chained( |
| 281 | FrameworkStatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, ownerUid, null, tag, |
| 282 | historyTag, |
| 283 | FrameworkStatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED__STATE__OFF); |
Dianne Hackborn | d0db6f0 | 2016-07-18 14:14:20 -0700 | [diff] [blame] | 284 | } |
| 285 | } catch (RemoteException ex) { |
| 286 | // Ignore |
| 287 | } |
| 288 | } |
| 289 | |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 290 | /** |
Dianne Hackborn | e5167ca | 2014-03-08 14:39:10 -0800 | [diff] [blame] | 291 | * Called when a wake lock is changing. |
| 292 | */ |
| 293 | public void onWakeLockChanging(int flags, String tag, String packageName, |
| 294 | int ownerUid, int ownerPid, WorkSource workSource, String historyTag, |
| 295 | int newFlags, String newTag, String newPackageName, int newOwnerUid, |
| 296 | int newOwnerPid, WorkSource newWorkSource, String newHistoryTag) { |
| 297 | |
Jeff Brown | c4bd42c | 2015-06-12 18:00:11 -0700 | [diff] [blame] | 298 | final int monitorType = getBatteryStatsWakeLockMonitorType(flags); |
| 299 | final int newMonitorType = getBatteryStatsWakeLockMonitorType(newFlags); |
| 300 | if (workSource != null && newWorkSource != null |
| 301 | && monitorType >= 0 && newMonitorType >= 0) { |
Dianne Hackborn | e5167ca | 2014-03-08 14:39:10 -0800 | [diff] [blame] | 302 | if (DEBUG) { |
| 303 | Slog.d(TAG, "onWakeLockChanging: flags=" + newFlags + ", tag=\"" + newTag |
| 304 | + "\", packageName=" + newPackageName |
| 305 | + ", ownerUid=" + newOwnerUid + ", ownerPid=" + newOwnerPid |
| 306 | + ", workSource=" + newWorkSource); |
| 307 | } |
Jeff Brown | c4bd42c | 2015-06-12 18:00:11 -0700 | [diff] [blame] | 308 | |
| 309 | final boolean unimportantForLogging = newOwnerUid == Process.SYSTEM_UID |
| 310 | && (newFlags & PowerManager.UNIMPORTANT_FOR_LOGGING) != 0; |
Dianne Hackborn | e5167ca | 2014-03-08 14:39:10 -0800 | [diff] [blame] | 311 | try { |
Dianne Hackborn | cbefd8d | 2014-05-14 11:42:00 -0700 | [diff] [blame] | 312 | mBatteryStats.noteChangeWakelockFromSource(workSource, ownerPid, tag, historyTag, |
| 313 | monitorType, newWorkSource, newOwnerPid, newTag, newHistoryTag, |
Dianne Hackborn | e5167ca | 2014-03-08 14:39:10 -0800 | [diff] [blame] | 314 | newMonitorType, unimportantForLogging); |
| 315 | } catch (RemoteException ex) { |
| 316 | // Ignore |
| 317 | } |
| 318 | } else { |
Dianne Hackborn | cbefd8d | 2014-05-14 11:42:00 -0700 | [diff] [blame] | 319 | onWakeLockReleased(flags, tag, packageName, ownerUid, ownerPid, workSource, historyTag); |
Dianne Hackborn | e5167ca | 2014-03-08 14:39:10 -0800 | [diff] [blame] | 320 | onWakeLockAcquired(newFlags, newTag, newPackageName, newOwnerUid, newOwnerPid, |
| 321 | newWorkSource, newHistoryTag); |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | /** |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 326 | * Called when a wake lock is released. |
| 327 | */ |
Dianne Hackborn | 713df15 | 2013-05-17 11:27:57 -0700 | [diff] [blame] | 328 | public void onWakeLockReleased(int flags, String tag, String packageName, |
Dianne Hackborn | cbefd8d | 2014-05-14 11:42:00 -0700 | [diff] [blame] | 329 | int ownerUid, int ownerPid, WorkSource workSource, String historyTag) { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 330 | if (DEBUG) { |
| 331 | Slog.d(TAG, "onWakeLockReleased: flags=" + flags + ", tag=\"" + tag |
Dianne Hackborn | 713df15 | 2013-05-17 11:27:57 -0700 | [diff] [blame] | 332 | + "\", packageName=" + packageName |
| 333 | + ", ownerUid=" + ownerUid + ", ownerPid=" + ownerPid |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 334 | + ", workSource=" + workSource); |
| 335 | } |
| 336 | |
Jeff Brown | c4bd42c | 2015-06-12 18:00:11 -0700 | [diff] [blame] | 337 | final int monitorType = getBatteryStatsWakeLockMonitorType(flags); |
| 338 | if (monitorType >= 0) { |
| 339 | try { |
| 340 | if (workSource != null) { |
| 341 | mBatteryStats.noteStopWakelockFromSource(workSource, ownerPid, tag, |
| 342 | historyTag, monitorType); |
| 343 | } else { |
| 344 | mBatteryStats.noteStopWakelock(ownerUid, ownerPid, tag, |
| 345 | historyTag, monitorType); |
Svet Ganov | f7b4725 | 2018-02-26 11:11:27 -0800 | [diff] [blame] | 346 | mAppOps.finishOp(AppOpsManager.OP_WAKE_LOCK, ownerUid, packageName); |
Jeff Brown | c4bd42c | 2015-06-12 18:00:11 -0700 | [diff] [blame] | 347 | } |
| 348 | } catch (RemoteException ex) { |
| 349 | // Ignore |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 350 | } |
| 351 | } |
Santos Cordon | 9204cc8 | 2019-11-21 11:45:28 +0000 | [diff] [blame] | 352 | mWakeLockLog.onWakeLockReleased(tag, ownerUid); |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 353 | } |
| 354 | |
Jeff Brown | c4bd42c | 2015-06-12 18:00:11 -0700 | [diff] [blame] | 355 | private int getBatteryStatsWakeLockMonitorType(int flags) { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 356 | switch (flags & PowerManager.WAKE_LOCK_LEVEL_MASK) { |
| 357 | case PowerManager.PARTIAL_WAKE_LOCK: |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 358 | return BatteryStats.WAKE_TYPE_PARTIAL; |
Jeff Brown | c4bd42c | 2015-06-12 18:00:11 -0700 | [diff] [blame] | 359 | |
| 360 | case PowerManager.SCREEN_DIM_WAKE_LOCK: |
| 361 | case PowerManager.SCREEN_BRIGHT_WAKE_LOCK: |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 362 | return BatteryStats.WAKE_TYPE_FULL; |
Jeff Brown | c4bd42c | 2015-06-12 18:00:11 -0700 | [diff] [blame] | 363 | |
| 364 | case PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK: |
| 365 | if (mSuspendWhenScreenOffDueToProximityConfig) { |
| 366 | return -1; |
| 367 | } |
| 368 | return BatteryStats.WAKE_TYPE_PARTIAL; |
| 369 | |
| 370 | case PowerManager.DRAW_WAKE_LOCK: |
| 371 | return BatteryStats.WAKE_TYPE_DRAW; |
| 372 | |
| 373 | case PowerManager.DOZE_WAKE_LOCK: |
| 374 | // Doze wake locks are an internal implementation detail of the |
| 375 | // communication between dream manager service and power manager |
| 376 | // service. They have no additive battery impact. |
| 377 | return -1; |
| 378 | |
| 379 | default: |
| 380 | return -1; |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 381 | } |
| 382 | } |
| 383 | |
| 384 | /** |
Jeff Brown | fbe9670 | 2014-11-19 18:30:58 -0800 | [diff] [blame] | 385 | * Notifies that the device is changing wakefulness. |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 386 | * This function may be called even if the previous change hasn't finished in |
| 387 | * which case it will assume that the state did not fully converge before the |
| 388 | * next transition began and will recover accordingly. |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 389 | */ |
Michael Wright | e300104 | 2019-02-05 00:13:14 +0000 | [diff] [blame] | 390 | public void onWakefulnessChangeStarted(final int wakefulness, int reason, long eventTime) { |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 391 | final boolean interactive = PowerManagerInternal.isInteractive(wakefulness); |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 392 | if (DEBUG) { |
Jeff Brown | fbe9670 | 2014-11-19 18:30:58 -0800 | [diff] [blame] | 393 | Slog.d(TAG, "onWakefulnessChangeStarted: wakefulness=" + wakefulness |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 394 | + ", reason=" + reason + ", interactive=" + interactive); |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 395 | } |
| 396 | |
Jeff Brown | fbe9670 | 2014-11-19 18:30:58 -0800 | [diff] [blame] | 397 | // Tell the activity manager about changes in wakefulness, not just interactivity. |
| 398 | // It needs more granularity than other components. |
| 399 | mHandler.post(new Runnable() { |
| 400 | @Override |
| 401 | public void run() { |
| 402 | mActivityManagerInternal.onWakefulnessChanged(wakefulness); |
| 403 | } |
| 404 | }); |
| 405 | |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 406 | // Handle any early interactive state changes. |
| 407 | // Finish pending incomplete ones from a previous cycle. |
| 408 | if (mInteractive != interactive) { |
| 409 | // Finish up late behaviors if needed. |
| 410 | if (mInteractiveChanging) { |
| 411 | handleLateInteractiveChange(); |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 412 | } |
Jeff Brown | e95c3cd | 2014-05-02 16:59:26 -0700 | [diff] [blame] | 413 | |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 414 | // Start input as soon as we start waking up or going to sleep. |
| 415 | mInputManagerInternal.setInteractive(interactive); |
| 416 | |
| 417 | // Notify battery stats. |
Jeff Brown | e95c3cd | 2014-05-02 16:59:26 -0700 | [diff] [blame] | 418 | try { |
Jeff Brown | fbe9670 | 2014-11-19 18:30:58 -0800 | [diff] [blame] | 419 | mBatteryStats.noteInteractive(interactive); |
Jeff Brown | e95c3cd | 2014-05-02 16:59:26 -0700 | [diff] [blame] | 420 | } catch (RemoteException ex) { } |
Muhammad Qureshi | 4116630 | 2020-01-28 10:23:36 -0800 | [diff] [blame] | 421 | FrameworkStatsLog.write(FrameworkStatsLog.INTERACTIVE_STATE_CHANGED, |
| 422 | interactive ? FrameworkStatsLog.INTERACTIVE_STATE_CHANGED__STATE__ON : |
| 423 | FrameworkStatsLog.INTERACTIVE_STATE_CHANGED__STATE__OFF); |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 424 | |
| 425 | // Handle early behaviors. |
| 426 | mInteractive = interactive; |
| 427 | mInteractiveChangeReason = reason; |
Michael Wright | e300104 | 2019-02-05 00:13:14 +0000 | [diff] [blame] | 428 | mInteractiveChangeStartTime = eventTime; |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 429 | mInteractiveChanging = true; |
| 430 | handleEarlyInteractiveChange(); |
| 431 | } |
| 432 | } |
| 433 | |
| 434 | /** |
| 435 | * Notifies that the device has finished changing wakefulness. |
| 436 | */ |
| 437 | public void onWakefulnessChangeFinished() { |
| 438 | if (DEBUG) { |
| 439 | Slog.d(TAG, "onWakefulnessChangeFinished"); |
| 440 | } |
| 441 | |
| 442 | if (mInteractiveChanging) { |
| 443 | mInteractiveChanging = false; |
| 444 | handleLateInteractiveChange(); |
| 445 | } |
| 446 | } |
| 447 | |
| 448 | /** |
| 449 | * Handle early interactive state changes such as getting applications or the lock |
| 450 | * screen running and ready for the user to see (such as when turning on the screen). |
| 451 | */ |
| 452 | private void handleEarlyInteractiveChange() { |
| 453 | synchronized (mLock) { |
| 454 | if (mInteractive) { |
| 455 | // Waking up... |
| 456 | mHandler.post(new Runnable() { |
| 457 | @Override |
| 458 | public void run() { |
Michael Wright | e300104 | 2019-02-05 00:13:14 +0000 | [diff] [blame] | 459 | final int why = translateOnReason(mInteractiveChangeReason); |
| 460 | mPolicy.startedWakingUp(why); |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 461 | } |
| 462 | }); |
| 463 | |
| 464 | // Send interactive broadcast. |
| 465 | mPendingInteractiveState = INTERACTIVE_STATE_AWAKE; |
| 466 | mPendingWakeUpBroadcast = true; |
| 467 | updatePendingBroadcastLocked(); |
| 468 | } else { |
| 469 | // Going to sleep... |
| 470 | // Tell the policy that we started going to sleep. |
| 471 | final int why = translateOffReason(mInteractiveChangeReason); |
| 472 | mHandler.post(new Runnable() { |
| 473 | @Override |
| 474 | public void run() { |
| 475 | mPolicy.startedGoingToSleep(why); |
| 476 | } |
| 477 | }); |
| 478 | } |
| 479 | } |
| 480 | } |
| 481 | |
| 482 | /** |
| 483 | * Handle late interactive state changes once they are finished so that the system can |
| 484 | * finish pending transitions (such as turning the screen off) before causing |
| 485 | * applications to change state visibly. |
| 486 | */ |
| 487 | private void handleLateInteractiveChange() { |
| 488 | synchronized (mLock) { |
Michael Wright | e300104 | 2019-02-05 00:13:14 +0000 | [diff] [blame] | 489 | final int interactiveChangeLatency = |
| 490 | (int) (SystemClock.uptimeMillis() - mInteractiveChangeStartTime); |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 491 | if (mInteractive) { |
| 492 | // Finished waking up... |
Michael Wright | e300104 | 2019-02-05 00:13:14 +0000 | [diff] [blame] | 493 | final int why = translateOnReason(mInteractiveChangeReason); |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 494 | mHandler.post(new Runnable() { |
| 495 | @Override |
| 496 | public void run() { |
Michael Wright | e300104 | 2019-02-05 00:13:14 +0000 | [diff] [blame] | 497 | LogMaker log = new LogMaker(MetricsEvent.SCREEN); |
| 498 | log.setType(MetricsEvent.TYPE_OPEN); |
| 499 | log.setSubtype(why); |
| 500 | log.setLatency(interactiveChangeLatency); |
Steven Wu | 0e6e5de | 2019-03-12 17:13:14 -0400 | [diff] [blame] | 501 | log.addTaggedData( |
| 502 | MetricsEvent.FIELD_SCREEN_WAKE_REASON, mInteractiveChangeReason); |
Michael Wright | e300104 | 2019-02-05 00:13:14 +0000 | [diff] [blame] | 503 | MetricsLogger.action(log); |
| 504 | EventLogTags.writePowerScreenState(1, 0, 0, 0, interactiveChangeLatency); |
| 505 | mPolicy.finishedWakingUp(why); |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 506 | } |
| 507 | }); |
| 508 | } else { |
| 509 | // Finished going to sleep... |
| 510 | // This is a good time to make transitions that we don't want the user to see, |
| 511 | // such as bringing the key guard to focus. There's no guarantee for this |
| 512 | // however because the user could turn the device on again at any time. |
| 513 | // Some things may need to be protected by other mechanisms that defer screen on. |
| 514 | |
| 515 | // Cancel pending user activity. |
| 516 | if (mUserActivityPending) { |
| 517 | mUserActivityPending = false; |
| 518 | mHandler.removeMessages(MSG_USER_ACTIVITY); |
| 519 | } |
| 520 | |
| 521 | // Tell the policy we finished going to sleep. |
| 522 | final int why = translateOffReason(mInteractiveChangeReason); |
| 523 | mHandler.post(new Runnable() { |
| 524 | @Override |
| 525 | public void run() { |
Alison Cichowlas | 5c38fc2 | 2017-01-25 17:11:06 -0500 | [diff] [blame] | 526 | LogMaker log = new LogMaker(MetricsEvent.SCREEN); |
| 527 | log.setType(MetricsEvent.TYPE_CLOSE); |
| 528 | log.setSubtype(why); |
Michael Wright | e300104 | 2019-02-05 00:13:14 +0000 | [diff] [blame] | 529 | log.setLatency(interactiveChangeLatency); |
Steven Wu | 0e6e5de | 2019-03-12 17:13:14 -0400 | [diff] [blame] | 530 | log.addTaggedData( |
| 531 | MetricsEvent.FIELD_SCREEN_SLEEP_REASON, mInteractiveChangeReason); |
Alison Cichowlas | 5c38fc2 | 2017-01-25 17:11:06 -0500 | [diff] [blame] | 532 | MetricsLogger.action(log); |
Michael Wright | e300104 | 2019-02-05 00:13:14 +0000 | [diff] [blame] | 533 | EventLogTags.writePowerScreenState(0, why, 0, 0, interactiveChangeLatency); |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 534 | mPolicy.finishedGoingToSleep(why); |
| 535 | } |
| 536 | }); |
| 537 | |
| 538 | // Send non-interactive broadcast. |
| 539 | mPendingInteractiveState = INTERACTIVE_STATE_ASLEEP; |
| 540 | mPendingGoToSleepBroadcast = true; |
| 541 | updatePendingBroadcastLocked(); |
| 542 | } |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | private static int translateOffReason(int reason) { |
| 547 | switch (reason) { |
| 548 | case PowerManager.GO_TO_SLEEP_REASON_DEVICE_ADMIN: |
| 549 | return WindowManagerPolicy.OFF_BECAUSE_OF_ADMIN; |
| 550 | case PowerManager.GO_TO_SLEEP_REASON_TIMEOUT: |
Robert Horvath | 5560f38 | 2019-07-10 10:46:38 +0200 | [diff] [blame] | 551 | case PowerManager.GO_TO_SLEEP_REASON_INATTENTIVE: |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 552 | return WindowManagerPolicy.OFF_BECAUSE_OF_TIMEOUT; |
| 553 | default: |
| 554 | return WindowManagerPolicy.OFF_BECAUSE_OF_USER; |
Jeff Brown | e95c3cd | 2014-05-02 16:59:26 -0700 | [diff] [blame] | 555 | } |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 556 | } |
| 557 | |
Michael Wright | e300104 | 2019-02-05 00:13:14 +0000 | [diff] [blame] | 558 | private static @OnReason int translateOnReason(@WakeReason int reason) { |
| 559 | switch (reason) { |
| 560 | case PowerManager.WAKE_REASON_POWER_BUTTON: |
| 561 | case PowerManager.WAKE_REASON_PLUGGED_IN: |
| 562 | case PowerManager.WAKE_REASON_GESTURE: |
| 563 | case PowerManager.WAKE_REASON_CAMERA_LAUNCH: |
| 564 | case PowerManager.WAKE_REASON_WAKE_KEY: |
| 565 | case PowerManager.WAKE_REASON_WAKE_MOTION: |
| 566 | case PowerManager.WAKE_REASON_LID: |
| 567 | return WindowManagerPolicy.ON_BECAUSE_OF_USER; |
| 568 | case PowerManager.WAKE_REASON_APPLICATION: |
| 569 | return WindowManagerPolicy.ON_BECAUSE_OF_APPLICATION; |
| 570 | default: |
| 571 | return WindowManagerPolicy.ON_BECAUSE_OF_UNKNOWN; |
| 572 | } |
| 573 | } |
| 574 | |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 575 | /** |
| 576 | * Called when there has been user activity. |
| 577 | */ |
| 578 | public void onUserActivity(int event, int uid) { |
| 579 | if (DEBUG) { |
| 580 | Slog.d(TAG, "onUserActivity: event=" + event + ", uid=" + uid); |
| 581 | } |
| 582 | |
| 583 | try { |
| 584 | mBatteryStats.noteUserActivity(uid, event); |
| 585 | } catch (RemoteException ex) { |
| 586 | // Ignore |
| 587 | } |
| 588 | |
| 589 | synchronized (mLock) { |
| 590 | if (!mUserActivityPending) { |
| 591 | mUserActivityPending = true; |
| 592 | Message msg = mHandler.obtainMessage(MSG_USER_ACTIVITY); |
| 593 | msg.setAsynchronous(true); |
| 594 | mHandler.sendMessage(msg); |
| 595 | } |
| 596 | } |
| 597 | } |
| 598 | |
Jeff Brown | 84e2756 | 2012-12-07 13:56:34 -0800 | [diff] [blame] | 599 | /** |
Dianne Hackborn | 280a64e | 2015-07-13 14:48:08 -0700 | [diff] [blame] | 600 | * Called when the screen has turned on. |
| 601 | */ |
Michael Wright | e300104 | 2019-02-05 00:13:14 +0000 | [diff] [blame] | 602 | public void onWakeUp(int reason, String details, int reasonUid, String opPackageName, |
| 603 | int opUid) { |
Dianne Hackborn | 280a64e | 2015-07-13 14:48:08 -0700 | [diff] [blame] | 604 | if (DEBUG) { |
Michael Wright | e300104 | 2019-02-05 00:13:14 +0000 | [diff] [blame] | 605 | Slog.d(TAG, "onWakeUp: reason=" + PowerManager.wakeReasonToString(reason) |
| 606 | + ", details=" + details + ", reasonUid=" + reasonUid |
Dianne Hackborn | 280a64e | 2015-07-13 14:48:08 -0700 | [diff] [blame] | 607 | + " opPackageName=" + opPackageName + " opUid=" + opUid); |
| 608 | } |
| 609 | |
| 610 | try { |
Michael Wright | e300104 | 2019-02-05 00:13:14 +0000 | [diff] [blame] | 611 | mBatteryStats.noteWakeUp(details, reasonUid); |
Dianne Hackborn | 280a64e | 2015-07-13 14:48:08 -0700 | [diff] [blame] | 612 | if (opPackageName != null) { |
Svet Ganov | f7b4725 | 2018-02-26 11:11:27 -0800 | [diff] [blame] | 613 | mAppOps.noteOpNoThrow(AppOpsManager.OP_TURN_SCREEN_ON, opUid, opPackageName); |
Dianne Hackborn | 280a64e | 2015-07-13 14:48:08 -0700 | [diff] [blame] | 614 | } |
| 615 | } catch (RemoteException ex) { |
| 616 | // Ignore |
| 617 | } |
Dianne Hackborn | 280a64e | 2015-07-13 14:48:08 -0700 | [diff] [blame] | 618 | } |
| 619 | |
| 620 | /** |
Beverly | ae79ab9 | 2017-12-11 09:20:02 -0500 | [diff] [blame] | 621 | * Called when profile screen lock timeout has expired. |
Jeff Brown | 84e2756 | 2012-12-07 13:56:34 -0800 | [diff] [blame] | 622 | */ |
Beverly | ae79ab9 | 2017-12-11 09:20:02 -0500 | [diff] [blame] | 623 | public void onProfileTimeout(@UserIdInt int userId) { |
| 624 | final Message msg = mHandler.obtainMessage(MSG_PROFILE_TIMED_OUT); |
| 625 | msg.setAsynchronous(true); |
| 626 | msg.arg1 = userId; |
| 627 | mHandler.sendMessage(msg); |
| 628 | } |
| 629 | |
| 630 | /** |
Beverly | 91d0a63 | 2018-07-02 16:45:00 -0400 | [diff] [blame] | 631 | * Called when wireless charging has started - to provide user feedback (sound and visual). |
Beverly | ae79ab9 | 2017-12-11 09:20:02 -0500 | [diff] [blame] | 632 | */ |
Beverly | 91d0a63 | 2018-07-02 16:45:00 -0400 | [diff] [blame] | 633 | public void onWirelessChargingStarted(int batteryLevel, @UserIdInt int userId) { |
Jeff Brown | 84e2756 | 2012-12-07 13:56:34 -0800 | [diff] [blame] | 634 | if (DEBUG) { |
| 635 | Slog.d(TAG, "onWirelessChargingStarted"); |
| 636 | } |
| 637 | |
| 638 | mSuspendBlocker.acquire(); |
| 639 | Message msg = mHandler.obtainMessage(MSG_WIRELESS_CHARGING_STARTED); |
| 640 | msg.setAsynchronous(true); |
Beverly | ae79ab9 | 2017-12-11 09:20:02 -0500 | [diff] [blame] | 641 | msg.arg1 = batteryLevel; |
Beverly | 91d0a63 | 2018-07-02 16:45:00 -0400 | [diff] [blame] | 642 | msg.arg2 = userId; |
Pavel Grafov | 2893998 | 2017-10-03 15:11:52 +0100 | [diff] [blame] | 643 | mHandler.sendMessage(msg); |
| 644 | } |
| 645 | |
Beverly | c1313eb | 2018-01-31 18:07:21 -0500 | [diff] [blame] | 646 | /** |
Beverly | 91d0a63 | 2018-07-02 16:45:00 -0400 | [diff] [blame] | 647 | * Called when wired charging has started - to provide user feedback |
Beverly | c1313eb | 2018-01-31 18:07:21 -0500 | [diff] [blame] | 648 | */ |
Beverly | 91d0a63 | 2018-07-02 16:45:00 -0400 | [diff] [blame] | 649 | public void onWiredChargingStarted(@UserIdInt int userId) { |
Beverly | c1313eb | 2018-01-31 18:07:21 -0500 | [diff] [blame] | 650 | if (DEBUG) { |
| 651 | Slog.d(TAG, "onWiredChargingStarted"); |
| 652 | } |
| 653 | |
| 654 | mSuspendBlocker.acquire(); |
| 655 | Message msg = mHandler.obtainMessage(MSG_WIRED_CHARGING_STARTED); |
| 656 | msg.setAsynchronous(true); |
Beverly | 91d0a63 | 2018-07-02 16:45:00 -0400 | [diff] [blame] | 657 | msg.arg1 = userId; |
Beverly | c1313eb | 2018-01-31 18:07:21 -0500 | [diff] [blame] | 658 | mHandler.sendMessage(msg); |
| 659 | } |
| 660 | |
Santos Cordon | 9204cc8 | 2019-11-21 11:45:28 +0000 | [diff] [blame] | 661 | /** |
| 662 | * Dumps data for bugreports. |
| 663 | * |
| 664 | * @param pw The stream to print to. |
| 665 | */ |
| 666 | public void dump(PrintWriter pw) { |
| 667 | if (mWakeLockLog != null) { |
| 668 | mWakeLockLog.dump(pw); |
| 669 | } |
| 670 | } |
| 671 | |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 672 | private void updatePendingBroadcastLocked() { |
| 673 | if (!mBroadcastInProgress |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 674 | && mPendingInteractiveState != INTERACTIVE_STATE_UNKNOWN |
Jeff Brown | 5430835 | 2012-10-04 17:59:58 -0700 | [diff] [blame] | 675 | && (mPendingWakeUpBroadcast || mPendingGoToSleepBroadcast |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 676 | || mPendingInteractiveState != mBroadcastedInteractiveState)) { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 677 | mBroadcastInProgress = true; |
| 678 | mSuspendBlocker.acquire(); |
| 679 | Message msg = mHandler.obtainMessage(MSG_BROADCAST); |
| 680 | msg.setAsynchronous(true); |
| 681 | mHandler.sendMessage(msg); |
| 682 | } |
| 683 | } |
| 684 | |
Jeff Brown | 5430835 | 2012-10-04 17:59:58 -0700 | [diff] [blame] | 685 | private void finishPendingBroadcastLocked() { |
| 686 | mBroadcastInProgress = false; |
| 687 | mSuspendBlocker.release(); |
| 688 | } |
| 689 | |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 690 | private void sendUserActivity() { |
| 691 | synchronized (mLock) { |
| 692 | if (!mUserActivityPending) { |
| 693 | return; |
| 694 | } |
| 695 | mUserActivityPending = false; |
| 696 | } |
Peter Wang | 6a92dd4 | 2020-01-15 14:11:25 -0800 | [diff] [blame] | 697 | TelephonyManager tm = mContext.getSystemService(TelephonyManager.class); |
| 698 | tm.notifyUserActivity(); |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 699 | mPolicy.userActivity(); |
| 700 | } |
| 701 | |
| 702 | private void sendNextBroadcast() { |
| 703 | final int powerState; |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 704 | synchronized (mLock) { |
Jeff Brown | fbe9670 | 2014-11-19 18:30:58 -0800 | [diff] [blame] | 705 | if (mBroadcastedInteractiveState == INTERACTIVE_STATE_UNKNOWN) { |
Robert Horvath | 4fbab20 | 2019-11-29 15:36:39 +0100 | [diff] [blame] | 706 | // Broadcasted power state is unknown. |
| 707 | // Send wake up or go to sleep. |
| 708 | switch (mPendingInteractiveState) { |
| 709 | case INTERACTIVE_STATE_ASLEEP: |
| 710 | mPendingGoToSleepBroadcast = false; |
| 711 | mBroadcastedInteractiveState = INTERACTIVE_STATE_ASLEEP; |
| 712 | break; |
| 713 | |
| 714 | case INTERACTIVE_STATE_AWAKE: |
| 715 | default: |
| 716 | mPendingWakeUpBroadcast = false; |
| 717 | mBroadcastedInteractiveState = INTERACTIVE_STATE_AWAKE; |
| 718 | break; |
| 719 | } |
Jeff Brown | fbe9670 | 2014-11-19 18:30:58 -0800 | [diff] [blame] | 720 | } else if (mBroadcastedInteractiveState == INTERACTIVE_STATE_AWAKE) { |
Jeff Brown | 5430835 | 2012-10-04 17:59:58 -0700 | [diff] [blame] | 721 | // Broadcasted power state is awake. Send asleep if needed. |
| 722 | if (mPendingWakeUpBroadcast || mPendingGoToSleepBroadcast |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 723 | || mPendingInteractiveState == INTERACTIVE_STATE_ASLEEP) { |
Jeff Brown | 5430835 | 2012-10-04 17:59:58 -0700 | [diff] [blame] | 724 | mPendingGoToSleepBroadcast = false; |
Jeff Brown | fbe9670 | 2014-11-19 18:30:58 -0800 | [diff] [blame] | 725 | mBroadcastedInteractiveState = INTERACTIVE_STATE_ASLEEP; |
Jeff Brown | 5430835 | 2012-10-04 17:59:58 -0700 | [diff] [blame] | 726 | } else { |
| 727 | finishPendingBroadcastLocked(); |
| 728 | return; |
| 729 | } |
| 730 | } else { |
| 731 | // Broadcasted power state is asleep. Send awake if needed. |
| 732 | if (mPendingWakeUpBroadcast || mPendingGoToSleepBroadcast |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 733 | || mPendingInteractiveState == INTERACTIVE_STATE_AWAKE) { |
Jeff Brown | 5430835 | 2012-10-04 17:59:58 -0700 | [diff] [blame] | 734 | mPendingWakeUpBroadcast = false; |
Jeff Brown | fbe9670 | 2014-11-19 18:30:58 -0800 | [diff] [blame] | 735 | mBroadcastedInteractiveState = INTERACTIVE_STATE_AWAKE; |
Jeff Brown | 5430835 | 2012-10-04 17:59:58 -0700 | [diff] [blame] | 736 | } else { |
| 737 | finishPendingBroadcastLocked(); |
| 738 | return; |
| 739 | } |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 740 | } |
| 741 | |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 742 | mBroadcastStartTime = SystemClock.uptimeMillis(); |
Jeff Brown | fbe9670 | 2014-11-19 18:30:58 -0800 | [diff] [blame] | 743 | powerState = mBroadcastedInteractiveState; |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 744 | } |
| 745 | |
| 746 | EventLog.writeEvent(EventLogTags.POWER_SCREEN_BROADCAST_SEND, 1); |
| 747 | |
Jeff Brown | fbe9670 | 2014-11-19 18:30:58 -0800 | [diff] [blame] | 748 | if (powerState == INTERACTIVE_STATE_AWAKE) { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 749 | sendWakeUpBroadcast(); |
| 750 | } else { |
Jim Miller | c522d16 | 2014-07-01 17:10:21 -0700 | [diff] [blame] | 751 | sendGoToSleepBroadcast(); |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 752 | } |
| 753 | } |
| 754 | |
| 755 | private void sendWakeUpBroadcast() { |
| 756 | if (DEBUG) { |
| 757 | Slog.d(TAG, "Sending wake up broadcast."); |
| 758 | } |
| 759 | |
Sudheer Shanka | fc46e9b | 2016-10-21 17:55:27 -0700 | [diff] [blame] | 760 | if (mActivityManagerInternal.isSystemReady()) { |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 761 | mContext.sendOrderedBroadcastAsUser(mScreenOnIntent, UserHandle.ALL, null, |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 762 | mWakeUpBroadcastDone, mHandler, 0, null, null); |
| 763 | } else { |
| 764 | EventLog.writeEvent(EventLogTags.POWER_SCREEN_BROADCAST_STOP, 2, 1); |
| 765 | sendNextBroadcast(); |
| 766 | } |
| 767 | } |
| 768 | |
| 769 | private final BroadcastReceiver mWakeUpBroadcastDone = new BroadcastReceiver() { |
| 770 | @Override |
| 771 | public void onReceive(Context context, Intent intent) { |
| 772 | EventLog.writeEvent(EventLogTags.POWER_SCREEN_BROADCAST_DONE, 1, |
| 773 | SystemClock.uptimeMillis() - mBroadcastStartTime, 1); |
| 774 | sendNextBroadcast(); |
| 775 | } |
| 776 | }; |
| 777 | |
Jim Miller | c522d16 | 2014-07-01 17:10:21 -0700 | [diff] [blame] | 778 | private void sendGoToSleepBroadcast() { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 779 | if (DEBUG) { |
| 780 | Slog.d(TAG, "Sending go to sleep broadcast."); |
| 781 | } |
| 782 | |
Sudheer Shanka | fc46e9b | 2016-10-21 17:55:27 -0700 | [diff] [blame] | 783 | if (mActivityManagerInternal.isSystemReady()) { |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 784 | mContext.sendOrderedBroadcastAsUser(mScreenOffIntent, UserHandle.ALL, null, |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 785 | mGoToSleepBroadcastDone, mHandler, 0, null, null); |
| 786 | } else { |
| 787 | EventLog.writeEvent(EventLogTags.POWER_SCREEN_BROADCAST_STOP, 3, 1); |
| 788 | sendNextBroadcast(); |
| 789 | } |
| 790 | } |
| 791 | |
| 792 | private final BroadcastReceiver mGoToSleepBroadcastDone = new BroadcastReceiver() { |
| 793 | @Override |
| 794 | public void onReceive(Context context, Intent intent) { |
| 795 | EventLog.writeEvent(EventLogTags.POWER_SCREEN_BROADCAST_DONE, 0, |
| 796 | SystemClock.uptimeMillis() - mBroadcastStartTime, 1); |
| 797 | sendNextBroadcast(); |
| 798 | } |
| 799 | }; |
| 800 | |
Beverly | f364d7c | 2019-10-10 16:44:43 -0400 | [diff] [blame] | 801 | private void playChargingStartedFeedback(@UserIdInt int userId, boolean wireless) { |
| 802 | if (!isChargingFeedbackEnabled(userId)) { |
| 803 | return; |
| 804 | } |
| 805 | |
| 806 | // vibrate |
| 807 | final boolean vibrate = Settings.Secure.getIntForUser(mContext.getContentResolver(), |
| 808 | Settings.Secure.CHARGING_VIBRATION_ENABLED, 1, userId) != 0; |
| 809 | if (vibrate) { |
| 810 | mVibrator.vibrate(CHARGING_VIBRATION_EFFECT, VIBRATION_ATTRIBUTES); |
| 811 | } |
| 812 | |
| 813 | // play sound |
Jeff Brown | 84e2756 | 2012-12-07 13:56:34 -0800 | [diff] [blame] | 814 | final String soundPath = Settings.Global.getString(mContext.getContentResolver(), |
Beverly | f364d7c | 2019-10-10 16:44:43 -0400 | [diff] [blame] | 815 | wireless ? Settings.Global.WIRELESS_CHARGING_STARTED_SOUND |
| 816 | : Settings.Global.CHARGING_STARTED_SOUND); |
| 817 | final Uri soundUri = Uri.parse("file://" + soundPath); |
| 818 | if (soundUri != null) { |
| 819 | final Ringtone sfx = RingtoneManager.getRingtone(mContext, soundUri); |
| 820 | if (sfx != null) { |
| 821 | sfx.setStreamType(AudioManager.STREAM_SYSTEM); |
| 822 | sfx.play(); |
Jeff Brown | 84e2756 | 2012-12-07 13:56:34 -0800 | [diff] [blame] | 823 | } |
| 824 | } |
Beverly | ae79ab9 | 2017-12-11 09:20:02 -0500 | [diff] [blame] | 825 | } |
Jeff Brown | 84e2756 | 2012-12-07 13:56:34 -0800 | [diff] [blame] | 826 | |
Beverly | 91d0a63 | 2018-07-02 16:45:00 -0400 | [diff] [blame] | 827 | private void showWirelessChargingStarted(int batteryLevel, @UserIdInt int userId) { |
Beverly | f364d7c | 2019-10-10 16:44:43 -0400 | [diff] [blame] | 828 | // play sounds + haptics |
| 829 | playChargingStartedFeedback(userId, true /* wireless */); |
| 830 | |
| 831 | // show animation |
| 832 | if (mShowWirelessChargingAnimationConfig && mStatusBarManagerInternal != null) { |
Andrew Zeng | 6d07baf | 2018-04-20 14:13:16 -0700 | [diff] [blame] | 833 | mStatusBarManagerInternal.showChargingAnimation(batteryLevel); |
| 834 | } |
Jeff Brown | 84e2756 | 2012-12-07 13:56:34 -0800 | [diff] [blame] | 835 | mSuspendBlocker.release(); |
| 836 | } |
| 837 | |
Beverly | 91d0a63 | 2018-07-02 16:45:00 -0400 | [diff] [blame] | 838 | private void showWiredChargingStarted(@UserIdInt int userId) { |
Beverly | f364d7c | 2019-10-10 16:44:43 -0400 | [diff] [blame] | 839 | playChargingStartedFeedback(userId, false /* wireless */); |
Beverly | c1313eb | 2018-01-31 18:07:21 -0500 | [diff] [blame] | 840 | mSuspendBlocker.release(); |
| 841 | } |
| 842 | |
Pavel Grafov | 2893998 | 2017-10-03 15:11:52 +0100 | [diff] [blame] | 843 | private void lockProfile(@UserIdInt int userId) { |
| 844 | mTrustManager.setDeviceLockedForUser(userId, true /*locked*/); |
| 845 | } |
| 846 | |
Beverly | 91d0a63 | 2018-07-02 16:45:00 -0400 | [diff] [blame] | 847 | private boolean isChargingFeedbackEnabled(@UserIdInt int userId) { |
| 848 | final boolean enabled = Settings.Secure.getIntForUser(mContext.getContentResolver(), |
| 849 | Settings.Secure.CHARGING_SOUNDS_ENABLED, 1, userId) != 0; |
Beverly | 69721d6 | 2018-05-09 17:41:44 -0400 | [diff] [blame] | 850 | final boolean dndOff = Settings.Global.getInt(mContext.getContentResolver(), |
| 851 | Settings.Global.ZEN_MODE, Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS) |
| 852 | == Settings.Global.ZEN_MODE_OFF; |
| 853 | return enabled && dndOff; |
| 854 | } |
| 855 | |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 856 | private final class NotifierHandler extends Handler { |
Pavel Grafov | 2893998 | 2017-10-03 15:11:52 +0100 | [diff] [blame] | 857 | |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 858 | public NotifierHandler(Looper looper) { |
Jeff Brown | a2910d0 | 2012-08-25 12:29:46 -0700 | [diff] [blame] | 859 | super(looper, null, true /*async*/); |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 860 | } |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 861 | @Override |
| 862 | public void handleMessage(Message msg) { |
| 863 | switch (msg.what) { |
| 864 | case MSG_USER_ACTIVITY: |
| 865 | sendUserActivity(); |
| 866 | break; |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 867 | case MSG_BROADCAST: |
| 868 | sendNextBroadcast(); |
| 869 | break; |
Jeff Brown | 84e2756 | 2012-12-07 13:56:34 -0800 | [diff] [blame] | 870 | case MSG_WIRELESS_CHARGING_STARTED: |
Beverly | 91d0a63 | 2018-07-02 16:45:00 -0400 | [diff] [blame] | 871 | showWirelessChargingStarted(msg.arg1, msg.arg2); |
Jeff Brown | 84e2756 | 2012-12-07 13:56:34 -0800 | [diff] [blame] | 872 | break; |
Pavel Grafov | 2893998 | 2017-10-03 15:11:52 +0100 | [diff] [blame] | 873 | case MSG_PROFILE_TIMED_OUT: |
| 874 | lockProfile(msg.arg1); |
| 875 | break; |
Beverly | c1313eb | 2018-01-31 18:07:21 -0500 | [diff] [blame] | 876 | case MSG_WIRED_CHARGING_STARTED: |
Beverly | 91d0a63 | 2018-07-02 16:45:00 -0400 | [diff] [blame] | 877 | showWiredChargingStarted(msg.arg1); |
Beverly | 69721d6 | 2018-05-09 17:41:44 -0400 | [diff] [blame] | 878 | break; |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 879 | } |
| 880 | } |
| 881 | } |
| 882 | } |