Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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 | package com.android.server.stats; |
| 17 | |
Chenjie Yu | 05013b3 | 2017-11-21 10:21:41 -0800 | [diff] [blame] | 18 | import android.annotation.Nullable; |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 19 | import android.app.AlarmManager; |
| 20 | import android.app.PendingIntent; |
Bookatz | c697797 | 2018-01-16 16:55:05 -0800 | [diff] [blame] | 21 | import android.app.StatsManager; |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 22 | import android.bluetooth.BluetoothActivityEnergyInfo; |
| 23 | import android.bluetooth.BluetoothAdapter; |
| 24 | import android.bluetooth.UidTraffic; |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 25 | import android.content.BroadcastReceiver; |
| 26 | import android.content.Context; |
| 27 | import android.content.Intent; |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 28 | import android.content.IntentFilter; |
Bookatz | c697797 | 2018-01-16 16:55:05 -0800 | [diff] [blame] | 29 | import android.content.IntentSender; |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 30 | import android.content.pm.PackageInfo; |
| 31 | import android.content.pm.PackageManager; |
| 32 | import android.content.pm.UserInfo; |
David Chen | c8a4324 | 2017-10-17 16:23:28 -0700 | [diff] [blame] | 33 | import android.net.NetworkStats; |
Chenjie Yu | 05013b3 | 2017-11-21 10:21:41 -0800 | [diff] [blame] | 34 | import android.net.wifi.IWifiManager; |
| 35 | import android.net.wifi.WifiActivityEnergyInfo; |
David Chen | c8a4324 | 2017-10-17 16:23:28 -0700 | [diff] [blame] | 36 | import android.os.BatteryStatsInternal; |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 37 | import android.os.Binder; |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 38 | import android.os.Bundle; |
Chenjie Yu | 937d742 | 2018-01-10 16:37:53 -0800 | [diff] [blame] | 39 | import android.os.Environment; |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 40 | import android.os.IBinder; |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 41 | import android.os.IStatsCompanionService; |
| 42 | import android.os.IStatsManager; |
Chenjie Yu | 05013b3 | 2017-11-21 10:21:41 -0800 | [diff] [blame] | 43 | import android.os.Parcelable; |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 44 | import android.os.Process; |
Bookatz | 1b0b114 | 2017-09-08 11:58:42 -0700 | [diff] [blame] | 45 | import android.os.RemoteException; |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 46 | import android.os.ServiceManager; |
Chenjie Yu | 937d742 | 2018-01-10 16:37:53 -0800 | [diff] [blame] | 47 | import android.os.StatFs; |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 48 | import android.os.StatsDimensionsValue; |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame] | 49 | import android.os.StatsLogEventWrapper; |
Chenjie Yu | 05013b3 | 2017-11-21 10:21:41 -0800 | [diff] [blame] | 50 | import android.os.SynchronousResultReceiver; |
Chenjie Yu | 937d742 | 2018-01-10 16:37:53 -0800 | [diff] [blame] | 51 | import android.os.SystemClock; |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 52 | import android.os.UserHandle; |
| 53 | import android.os.UserManager; |
Chenjie Yu | 937d742 | 2018-01-10 16:37:53 -0800 | [diff] [blame] | 54 | import android.telephony.ModemActivityInfo; |
| 55 | import android.telephony.TelephonyManager; |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 56 | import android.util.Slog; |
David Chen | c8a4324 | 2017-10-17 16:23:28 -0700 | [diff] [blame] | 57 | import android.util.StatsLog; |
| 58 | |
| 59 | import com.android.internal.annotations.GuardedBy; |
| 60 | import com.android.internal.net.NetworkStatsFactory; |
Chenjie Yu | 937d742 | 2018-01-10 16:37:53 -0800 | [diff] [blame] | 61 | import com.android.internal.os.KernelCpuSpeedReader; |
David Chen | c8a4324 | 2017-10-17 16:23:28 -0700 | [diff] [blame] | 62 | import com.android.internal.os.KernelWakelockReader; |
| 63 | import com.android.internal.os.KernelWakelockStats; |
Chenjie Yu | 7f8def9 | 2017-11-03 09:33:15 -0700 | [diff] [blame] | 64 | import com.android.internal.os.PowerProfile; |
David Chen | c8a4324 | 2017-10-17 16:23:28 -0700 | [diff] [blame] | 65 | import com.android.server.LocalServices; |
| 66 | import com.android.server.SystemService; |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 67 | |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 68 | import java.util.ArrayList; |
| 69 | import java.util.List; |
Bookatz | c68a9d2 | 2017-09-27 14:09:55 -0700 | [diff] [blame] | 70 | import java.util.Map; |
Chenjie Yu | 05013b3 | 2017-11-21 10:21:41 -0800 | [diff] [blame] | 71 | import java.util.concurrent.TimeoutException; |
Bookatz | c68a9d2 | 2017-09-27 14:09:55 -0700 | [diff] [blame] | 72 | |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 73 | /** |
| 74 | * Helper service for statsd (the native stats management service in cmds/statsd/). |
| 75 | * Used for registering and receiving alarms on behalf of statsd. |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame] | 76 | * |
Bookatz | 6bc51d7 | 2017-09-28 16:43:40 -0700 | [diff] [blame] | 77 | * @hide |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 78 | */ |
| 79 | public class StatsCompanionService extends IStatsCompanionService.Stub { |
Chenjie Yu | 05013b3 | 2017-11-21 10:21:41 -0800 | [diff] [blame] | 80 | /** |
| 81 | * How long to wait on an individual subsystem to return its stats. |
| 82 | */ |
| 83 | private static final long EXTERNAL_STATS_SYNC_TIMEOUT_MILLIS = 2000; |
| 84 | |
| 85 | public static final String RESULT_RECEIVER_CONTROLLER_KEY = "controller_activity"; |
| 86 | |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 87 | static final String TAG = "StatsCompanionService"; |
| 88 | static final boolean DEBUG = true; |
Bookatz | c697797 | 2018-01-16 16:55:05 -0800 | [diff] [blame] | 89 | |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 90 | public static final int CODE_DATA_BROADCAST = 1; |
Bookatz | c697797 | 2018-01-16 16:55:05 -0800 | [diff] [blame] | 91 | public static final int CODE_SUBSCRIBER_BROADCAST = 1; |
| 92 | |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 93 | private final Context mContext; |
| 94 | private final AlarmManager mAlarmManager; |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 95 | @GuardedBy("sStatsdLock") |
Bookatz | 1b0b114 | 2017-09-08 11:58:42 -0700 | [diff] [blame] | 96 | private static IStatsManager sStatsd; |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 97 | private static final Object sStatsdLock = new Object(); |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 98 | |
| 99 | private final PendingIntent mAnomalyAlarmIntent; |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 100 | private final PendingIntent mPullingAlarmIntent; |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 101 | private final BroadcastReceiver mAppUpdateReceiver; |
David Chen | 47e8f4d | 2017-10-11 15:34:13 -0700 | [diff] [blame] | 102 | private final BroadcastReceiver mUserUpdateReceiver; |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 103 | private final ShutdownEventReceiver mShutdownEventReceiver; |
Chenjie Yu | 7f8def9 | 2017-11-03 09:33:15 -0700 | [diff] [blame] | 104 | private final KernelWakelockReader mKernelWakelockReader = new KernelWakelockReader(); |
| 105 | private final KernelWakelockStats mTmpWakelockStats = new KernelWakelockStats(); |
| 106 | private final KernelCpuSpeedReader[] mKernelCpuSpeedReaders; |
Chenjie Yu | 05013b3 | 2017-11-21 10:21:41 -0800 | [diff] [blame] | 107 | private IWifiManager mWifiManager = null; |
| 108 | private TelephonyManager mTelephony = null; |
Chenjie Yu | 937d742 | 2018-01-10 16:37:53 -0800 | [diff] [blame] | 109 | private final StatFs mStatFsData = new StatFs(Environment.getDataDirectory().getAbsolutePath()); |
| 110 | private final StatFs mStatFsSystem = |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 111 | new StatFs(Environment.getRootDirectory().getAbsolutePath()); |
Chenjie Yu | 937d742 | 2018-01-10 16:37:53 -0800 | [diff] [blame] | 112 | private final StatFs mStatFsTemp = |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 113 | new StatFs(Environment.getDownloadCacheDirectory().getAbsolutePath()); |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 114 | |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 115 | public StatsCompanionService(Context context) { |
| 116 | super(); |
| 117 | mContext = context; |
| 118 | mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); |
| 119 | |
| 120 | mAnomalyAlarmIntent = PendingIntent.getBroadcast(mContext, 0, |
| 121 | new Intent(mContext, AnomalyAlarmReceiver.class), 0); |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 122 | mPullingAlarmIntent = PendingIntent.getBroadcast( |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 123 | mContext, 0, new Intent(mContext, PullingAlarmReceiver.class), 0); |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 124 | mAppUpdateReceiver = new AppUpdateReceiver(); |
David Chen | 47e8f4d | 2017-10-11 15:34:13 -0700 | [diff] [blame] | 125 | mUserUpdateReceiver = new BroadcastReceiver() { |
| 126 | @Override |
| 127 | public void onReceive(Context context, Intent intent) { |
| 128 | synchronized (sStatsdLock) { |
| 129 | sStatsd = fetchStatsdService(); |
| 130 | if (sStatsd == null) { |
| 131 | Slog.w(TAG, "Could not access statsd"); |
| 132 | return; |
| 133 | } |
| 134 | try { |
| 135 | // Pull the latest state of UID->app name, version mapping. |
| 136 | // Needed since the new user basically has a version of every app. |
| 137 | informAllUidsLocked(context); |
| 138 | } catch (RemoteException e) { |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame] | 139 | Slog.e(TAG, "Failed to inform statsd latest update of all apps", e); |
David Chen | 47e8f4d | 2017-10-11 15:34:13 -0700 | [diff] [blame] | 140 | forgetEverything(); |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | }; |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 145 | mShutdownEventReceiver = new ShutdownEventReceiver(); |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 146 | Slog.w(TAG, "Registered receiver for ACTION_PACKAGE_REPLACE AND ADDED."); |
Chenjie Yu | 7f8def9 | 2017-11-03 09:33:15 -0700 | [diff] [blame] | 147 | PowerProfile powerProfile = new PowerProfile(context); |
| 148 | final int numClusters = powerProfile.getNumCpuClusters(); |
| 149 | mKernelCpuSpeedReaders = new KernelCpuSpeedReader[numClusters]; |
| 150 | int firstCpuOfCluster = 0; |
| 151 | for (int i = 0; i < numClusters; i++) { |
| 152 | final int numSpeedSteps = powerProfile.getNumSpeedStepsInCpuCluster(i); |
| 153 | mKernelCpuSpeedReaders[i] = new KernelCpuSpeedReader(firstCpuOfCluster, |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 154 | numSpeedSteps); |
Chenjie Yu | 7f8def9 | 2017-11-03 09:33:15 -0700 | [diff] [blame] | 155 | firstCpuOfCluster += powerProfile.getNumCoresInCpuCluster(i); |
| 156 | } |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 157 | } |
| 158 | |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 159 | @Override |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 160 | public void sendDataBroadcast(IBinder intentSenderBinder) { |
Bookatz | 3692082 | 2018-01-26 09:18:07 -0800 | [diff] [blame] | 161 | enforceCallingPermission(); |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 162 | IntentSender intentSender = new IntentSender(intentSenderBinder); |
| 163 | Intent intent = new Intent(); |
| 164 | try { |
| 165 | intentSender.sendIntent(mContext, CODE_DATA_BROADCAST, intent, null, null); |
| 166 | } catch (IntentSender.SendIntentException e) { |
| 167 | Slog.w(TAG, "Unable to send using IntentSender"); |
| 168 | } |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 169 | } |
| 170 | |
Bookatz | c697797 | 2018-01-16 16:55:05 -0800 | [diff] [blame] | 171 | @Override |
| 172 | public void sendSubscriberBroadcast(IBinder intentSenderBinder, long configUid, long configKey, |
| 173 | long subscriptionId, long subscriptionRuleId, |
| 174 | StatsDimensionsValue dimensionsValue) { |
| 175 | if (DEBUG) Slog.d(TAG, "Statsd requested to sendSubscriberBroadcast."); |
| 176 | enforceCallingPermission(); |
| 177 | IntentSender intentSender = new IntentSender(intentSenderBinder); |
| 178 | Intent intent = new Intent() |
| 179 | .putExtra(StatsManager.EXTRA_STATS_CONFIG_UID, configUid) |
| 180 | .putExtra(StatsManager.EXTRA_STATS_CONFIG_KEY, configKey) |
| 181 | .putExtra(StatsManager.EXTRA_STATS_SUBSCRIPTION_ID, subscriptionId) |
| 182 | .putExtra(StatsManager.EXTRA_STATS_SUBSCRIPTION_RULE_ID, subscriptionRuleId) |
| 183 | .putExtra(StatsManager.EXTRA_STATS_DIMENSIONS_VALUE, dimensionsValue); |
| 184 | try { |
| 185 | intentSender.sendIntent(mContext, CODE_SUBSCRIBER_BROADCAST, intent, null, null); |
| 186 | } catch (IntentSender.SendIntentException e) { |
| 187 | Slog.w(TAG, "Unable to send using IntentSender from uid " + configUid |
| 188 | + "; presumably it had been cancelled."); |
| 189 | if (DEBUG) { |
| 190 | Slog.d(TAG, String.format("SubscriberBroadcast params {%d %d %d %d %s}", |
| 191 | configUid, configKey, subscriptionId, |
| 192 | subscriptionRuleId, dimensionsValue)); |
| 193 | } |
| 194 | } |
| 195 | } |
| 196 | |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame] | 197 | private final static int[] toIntArray(List<Integer> list) { |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 198 | int[] ret = new int[list.size()]; |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame] | 199 | for (int i = 0; i < ret.length; i++) { |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 200 | ret[i] = list.get(i); |
| 201 | } |
| 202 | return ret; |
| 203 | } |
| 204 | |
Dianne Hackborn | 3accca0 | 2013-09-20 09:32:11 -0700 | [diff] [blame] | 205 | private final static long[] toLongArray(List<Long> list) { |
| 206 | long[] ret = new long[list.size()]; |
| 207 | for (int i = 0; i < ret.length; i++) { |
| 208 | ret[i] = list.get(i); |
| 209 | } |
| 210 | return ret; |
| 211 | } |
| 212 | |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 213 | // Assumes that sStatsdLock is held. |
| 214 | private final void informAllUidsLocked(Context context) throws RemoteException { |
| 215 | UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE); |
| 216 | PackageManager pm = context.getPackageManager(); |
| 217 | final List<UserInfo> users = um.getUsers(true); |
| 218 | if (DEBUG) { |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame] | 219 | Slog.w(TAG, "Iterating over " + users.size() + " profiles."); |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | List<Integer> uids = new ArrayList(); |
Dianne Hackborn | 3accca0 | 2013-09-20 09:32:11 -0700 | [diff] [blame] | 223 | List<Long> versions = new ArrayList(); |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 224 | List<String> apps = new ArrayList(); |
| 225 | |
| 226 | // Add in all the apps for every user/profile. |
| 227 | for (UserInfo profile : users) { |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame] | 228 | List<PackageInfo> pi = pm.getInstalledPackagesAsUser(0, profile.id); |
| 229 | for (int j = 0; j < pi.size(); j++) { |
| 230 | if (pi.get(j).applicationInfo != null) { |
| 231 | uids.add(pi.get(j).applicationInfo.uid); |
Dianne Hackborn | 3accca0 | 2013-09-20 09:32:11 -0700 | [diff] [blame] | 232 | versions.add(pi.get(j).getLongVersionCode()); |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame] | 233 | apps.add(pi.get(j).packageName); |
| 234 | } |
| 235 | } |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 236 | } |
Dianne Hackborn | 3accca0 | 2013-09-20 09:32:11 -0700 | [diff] [blame] | 237 | sStatsd.informAllUidData(toIntArray(uids), toLongArray(versions), apps.toArray(new |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame] | 238 | String[apps.size()])); |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 239 | if (DEBUG) { |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame] | 240 | Slog.w(TAG, "Sent data for " + uids.size() + " apps"); |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 241 | } |
| 242 | } |
| 243 | |
Bookatz | 3692082 | 2018-01-26 09:18:07 -0800 | [diff] [blame] | 244 | private final static class AppUpdateReceiver extends BroadcastReceiver { |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 245 | @Override |
| 246 | public void onReceive(Context context, Intent intent) { |
David Chen | 47e8f4d | 2017-10-11 15:34:13 -0700 | [diff] [blame] | 247 | /** |
| 248 | * App updates actually consist of REMOVE, ADD, and then REPLACE broadcasts. To avoid |
| 249 | * waste, we ignore the REMOVE and ADD broadcasts that contain the replacing flag. |
David Chen | d689689 | 2017-10-25 11:49:03 -0700 | [diff] [blame] | 250 | * If we can't find the value for EXTRA_REPLACING, we default to false. |
David Chen | 47e8f4d | 2017-10-11 15:34:13 -0700 | [diff] [blame] | 251 | */ |
David Chen | d689689 | 2017-10-25 11:49:03 -0700 | [diff] [blame] | 252 | if (!intent.getAction().equals(Intent.ACTION_PACKAGE_REPLACED) |
| 253 | && intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) { |
David Chen | 47e8f4d | 2017-10-11 15:34:13 -0700 | [diff] [blame] | 254 | return; // Keep only replacing or normal add and remove. |
| 255 | } |
David Chen | d689689 | 2017-10-25 11:49:03 -0700 | [diff] [blame] | 256 | Slog.i(TAG, "StatsCompanionService noticed an app was updated."); |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 257 | synchronized (sStatsdLock) { |
| 258 | if (sStatsd == null) { |
yro | f6d1ca5 | 2017-11-15 15:38:34 -0800 | [diff] [blame] | 259 | Slog.w(TAG, "Could not access statsd to inform it of an app update"); |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 260 | return; |
| 261 | } |
| 262 | try { |
| 263 | if (intent.getAction().equals(Intent.ACTION_PACKAGE_REMOVED)) { |
| 264 | Bundle b = intent.getExtras(); |
| 265 | int uid = b.getInt(Intent.EXTRA_UID); |
| 266 | boolean replacing = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false); |
| 267 | if (!replacing) { |
| 268 | // Don't bother sending an update if we're right about to get another |
| 269 | // intent for the new version that's added. |
| 270 | PackageManager pm = context.getPackageManager(); |
| 271 | String app = intent.getData().getSchemeSpecificPart(); |
| 272 | sStatsd.informOnePackageRemoved(app, uid); |
| 273 | } |
| 274 | } else { |
| 275 | PackageManager pm = context.getPackageManager(); |
| 276 | Bundle b = intent.getExtras(); |
| 277 | int uid = b.getInt(Intent.EXTRA_UID); |
| 278 | String app = intent.getData().getSchemeSpecificPart(); |
| 279 | PackageInfo pi = pm.getPackageInfo(app, PackageManager.MATCH_ANY_USER); |
Dianne Hackborn | 3accca0 | 2013-09-20 09:32:11 -0700 | [diff] [blame] | 280 | sStatsd.informOnePackage(app, uid, pi.getLongVersionCode()); |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 281 | } |
| 282 | } catch (Exception e) { |
| 283 | Slog.w(TAG, "Failed to inform statsd of an app update", e); |
| 284 | } |
| 285 | } |
| 286 | } |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame] | 287 | } |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 288 | |
Bookatz | 582870e | 2018-02-06 14:24:49 -0800 | [diff] [blame] | 289 | public final static class AnomalyAlarmReceiver extends BroadcastReceiver { |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 290 | @Override |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 291 | public void onReceive(Context context, Intent intent) { |
| 292 | Slog.i(TAG, "StatsCompanionService believes an anomaly has occurred."); |
| 293 | synchronized (sStatsdLock) { |
| 294 | if (sStatsd == null) { |
| 295 | Slog.w(TAG, "Could not access statsd to inform it of anomaly alarm firing"); |
| 296 | return; |
| 297 | } |
| 298 | try { |
| 299 | // Two-way call to statsd to retain AlarmManager wakelock |
| 300 | sStatsd.informAnomalyAlarmFired(); |
| 301 | } catch (RemoteException e) { |
| 302 | Slog.w(TAG, "Failed to inform statsd of anomaly alarm firing", e); |
| 303 | } |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 304 | } |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 305 | // AlarmManager releases its own wakelock here. |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 306 | } |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame] | 307 | } |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 308 | |
Bookatz | 582870e | 2018-02-06 14:24:49 -0800 | [diff] [blame] | 309 | public final static class PullingAlarmReceiver extends BroadcastReceiver { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 310 | @Override |
| 311 | public void onReceive(Context context, Intent intent) { |
| 312 | if (DEBUG) |
| 313 | Slog.d(TAG, "Time to poll something."); |
| 314 | synchronized (sStatsdLock) { |
| 315 | if (sStatsd == null) { |
| 316 | Slog.w(TAG, "Could not access statsd to inform it of pulling alarm firing."); |
| 317 | return; |
| 318 | } |
| 319 | try { |
| 320 | // Two-way call to statsd to retain AlarmManager wakelock |
| 321 | sStatsd.informPollAlarmFired(); |
| 322 | } catch (RemoteException e) { |
| 323 | Slog.w(TAG, "Failed to inform statsd of pulling alarm firing.", e); |
| 324 | } |
| 325 | } |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 326 | } |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame] | 327 | } |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 328 | |
Bookatz | 3692082 | 2018-01-26 09:18:07 -0800 | [diff] [blame] | 329 | private final static class ShutdownEventReceiver extends BroadcastReceiver { |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 330 | @Override |
| 331 | public void onReceive(Context context, Intent intent) { |
| 332 | /** |
| 333 | * Skip immediately if intent is not relevant to device shutdown. |
| 334 | */ |
| 335 | if (!intent.getAction().equals(Intent.ACTION_REBOOT) |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 336 | && !(intent.getAction().equals(Intent.ACTION_SHUTDOWN) |
| 337 | && (intent.getFlags() & Intent.FLAG_RECEIVER_FOREGROUND) != 0)) { |
| 338 | return; |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 339 | } |
yro | f7a3bcb | 2018-01-24 17:18:55 -0800 | [diff] [blame] | 340 | |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 341 | Slog.i(TAG, "StatsCompanionService noticed a shutdown."); |
| 342 | synchronized (sStatsdLock) { |
| 343 | if (sStatsd == null) { |
| 344 | Slog.w(TAG, "Could not access statsd to inform it of a shutdown event."); |
| 345 | return; |
| 346 | } |
| 347 | try { |
| 348 | sStatsd.writeDataToDisk(); |
| 349 | } catch (Exception e) { |
| 350 | Slog.w(TAG, "Failed to inform statsd of a shutdown event.", e); |
| 351 | } |
| 352 | } |
| 353 | } |
| 354 | } |
| 355 | |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 356 | @Override // Binder call |
| 357 | public void setAnomalyAlarm(long timestampMs) { |
| 358 | enforceCallingPermission(); |
| 359 | if (DEBUG) Slog.d(TAG, "Setting anomaly alarm for " + timestampMs); |
| 360 | final long callingToken = Binder.clearCallingIdentity(); |
| 361 | try { |
| 362 | // using RTC, not RTC_WAKEUP, so if device is asleep, will only fire when it awakens. |
| 363 | // This alarm is inexact, leaving its exactness completely up to the OS optimizations. |
| 364 | // AlarmManager will automatically cancel any previous mAnomalyAlarmIntent alarm. |
| 365 | mAlarmManager.set(AlarmManager.RTC, timestampMs, mAnomalyAlarmIntent); |
| 366 | } finally { |
| 367 | Binder.restoreCallingIdentity(callingToken); |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | @Override // Binder call |
| 372 | public void cancelAnomalyAlarm() { |
| 373 | enforceCallingPermission(); |
| 374 | if (DEBUG) Slog.d(TAG, "Cancelling anomaly alarm"); |
| 375 | final long callingToken = Binder.clearCallingIdentity(); |
| 376 | try { |
| 377 | mAlarmManager.cancel(mAnomalyAlarmIntent); |
| 378 | } finally { |
| 379 | Binder.restoreCallingIdentity(callingToken); |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | @Override // Binder call |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 384 | public void setPullingAlarms(long timestampMs, long intervalMs) { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 385 | enforceCallingPermission(); |
| 386 | if (DEBUG) |
| 387 | Slog.d(TAG, "Setting pulling alarm for " + timestampMs + " every " + intervalMs + "ms"); |
| 388 | final long callingToken = Binder.clearCallingIdentity(); |
| 389 | try { |
| 390 | // using RTC, not RTC_WAKEUP, so if device is asleep, will only fire when it awakens. |
| 391 | // This alarm is inexact, leaving its exactness completely up to the OS optimizations. |
| 392 | // TODO: totally inexact means that stats per bucket could be quite off. Is this okay? |
| 393 | mAlarmManager.setRepeating(AlarmManager.RTC, timestampMs, intervalMs, mPullingAlarmIntent); |
| 394 | } finally { |
| 395 | Binder.restoreCallingIdentity(callingToken); |
| 396 | } |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 397 | } |
| 398 | |
| 399 | @Override // Binder call |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 400 | public void cancelPullingAlarms() { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 401 | enforceCallingPermission(); |
| 402 | if (DEBUG) |
| 403 | Slog.d(TAG, "Cancelling pulling alarm"); |
| 404 | final long callingToken = Binder.clearCallingIdentity(); |
| 405 | try { |
| 406 | mAlarmManager.cancel(mPullingAlarmIntent); |
| 407 | } finally { |
| 408 | Binder.restoreCallingIdentity(callingToken); |
| 409 | } |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 410 | } |
| 411 | |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 412 | private void addNetworkStats( |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 413 | int tag, List<StatsLogEventWrapper> ret, NetworkStats stats, boolean withFGBG) { |
| 414 | int size = stats.size(); |
| 415 | NetworkStats.Entry entry = new NetworkStats.Entry(); // For recycling |
| 416 | for (int j = 0; j < size; j++) { |
| 417 | stats.getValues(j, entry); |
| 418 | StatsLogEventWrapper e = new StatsLogEventWrapper(tag, withFGBG ? 6 : 5); |
| 419 | e.writeInt(entry.uid); |
| 420 | if (withFGBG) { |
| 421 | e.writeInt(entry.set); |
| 422 | } |
| 423 | e.writeLong(entry.rxBytes); |
| 424 | e.writeLong(entry.rxPackets); |
| 425 | e.writeLong(entry.txBytes); |
| 426 | e.writeLong(entry.txPackets); |
| 427 | ret.add(e); |
David Chen | c8a4324 | 2017-10-17 16:23:28 -0700 | [diff] [blame] | 428 | } |
David Chen | c8a4324 | 2017-10-17 16:23:28 -0700 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | /** |
| 432 | * Allows rollups per UID but keeping the set (foreground/background) slicing. |
| 433 | * Adapted from groupedByUid in frameworks/base/core/java/android/net/NetworkStats.java |
| 434 | */ |
| 435 | private NetworkStats rollupNetworkStatsByFGBG(NetworkStats stats) { |
| 436 | final NetworkStats ret = new NetworkStats(stats.getElapsedRealtime(), 1); |
| 437 | |
| 438 | final NetworkStats.Entry entry = new NetworkStats.Entry(); |
| 439 | entry.iface = NetworkStats.IFACE_ALL; |
| 440 | entry.tag = NetworkStats.TAG_NONE; |
| 441 | entry.metered = NetworkStats.METERED_ALL; |
| 442 | entry.roaming = NetworkStats.ROAMING_ALL; |
| 443 | |
| 444 | int size = stats.size(); |
| 445 | NetworkStats.Entry recycle = new NetworkStats.Entry(); // Used for retrieving values |
| 446 | for (int i = 0; i < size; i++) { |
| 447 | stats.getValues(i, recycle); |
| 448 | |
| 449 | // Skip specific tags, since already counted in TAG_NONE |
| 450 | if (recycle.tag != NetworkStats.TAG_NONE) continue; |
| 451 | |
| 452 | entry.set = recycle.set; // Allows slicing by background/foreground |
| 453 | entry.uid = recycle.uid; |
| 454 | entry.rxBytes = recycle.rxBytes; |
| 455 | entry.rxPackets = recycle.rxPackets; |
| 456 | entry.txBytes = recycle.txBytes; |
| 457 | entry.txPackets = recycle.txPackets; |
| 458 | // Operations purposefully omitted since we don't use them for statsd. |
| 459 | ret.combineValues(entry); |
| 460 | } |
| 461 | return ret; |
| 462 | } |
| 463 | |
Chenjie Yu | 05013b3 | 2017-11-21 10:21:41 -0800 | [diff] [blame] | 464 | /** |
| 465 | * Helper method to extract the Parcelable controller info from a |
| 466 | * SynchronousResultReceiver. |
| 467 | */ |
| 468 | private static <T extends Parcelable> T awaitControllerInfo( |
| 469 | @Nullable SynchronousResultReceiver receiver) { |
| 470 | if (receiver == null) { |
| 471 | return null; |
| 472 | } |
| 473 | |
| 474 | try { |
| 475 | final SynchronousResultReceiver.Result result = |
| 476 | receiver.awaitResult(EXTERNAL_STATS_SYNC_TIMEOUT_MILLIS); |
| 477 | if (result.bundle != null) { |
| 478 | // This is the final destination for the Bundle. |
| 479 | result.bundle.setDefusable(true); |
| 480 | |
| 481 | final T data = result.bundle.getParcelable( |
| 482 | RESULT_RECEIVER_CONTROLLER_KEY); |
| 483 | if (data != null) { |
| 484 | return data; |
| 485 | } |
| 486 | } |
| 487 | Slog.e(TAG, "no controller energy info supplied for " + receiver.getName()); |
| 488 | } catch (TimeoutException e) { |
| 489 | Slog.w(TAG, "timeout reading " + receiver.getName() + " stats"); |
| 490 | } |
| 491 | return null; |
| 492 | } |
| 493 | |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 494 | private void pullKernelWakelock(int tagId, List<StatsLogEventWrapper> pulledData) { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 495 | final KernelWakelockStats wakelockStats = |
| 496 | mKernelWakelockReader.readKernelWakelockStats(mTmpWakelockStats); |
| 497 | for (Map.Entry<String, KernelWakelockStats.Entry> ent : wakelockStats.entrySet()) { |
| 498 | String name = ent.getKey(); |
| 499 | KernelWakelockStats.Entry kws = ent.getValue(); |
| 500 | StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, 4); |
| 501 | e.writeString(name); |
| 502 | e.writeInt(kws.mCount); |
| 503 | e.writeInt(kws.mVersion); |
| 504 | e.writeLong(kws.mTotalTime); |
| 505 | pulledData.add(e); |
| 506 | } |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 507 | } |
| 508 | |
| 509 | private void pullWifiBytesTransfer(int tagId, List<StatsLogEventWrapper> pulledData) { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 510 | long token = Binder.clearCallingIdentity(); |
| 511 | try { |
| 512 | // TODO: Consider caching the following call to get BatteryStatsInternal. |
| 513 | BatteryStatsInternal bs = LocalServices.getService(BatteryStatsInternal.class); |
| 514 | String[] ifaces = bs.getWifiIfaces(); |
| 515 | if (ifaces.length == 0) { |
| 516 | return; |
| 517 | } |
| 518 | NetworkStatsFactory nsf = new NetworkStatsFactory(); |
| 519 | // Combine all the metrics per Uid into one record. |
| 520 | NetworkStats stats = |
| 521 | nsf.readNetworkStatsDetail(NetworkStats.UID_ALL, ifaces, NetworkStats.TAG_NONE, null) |
| 522 | .groupedByUid(); |
| 523 | addNetworkStats(tagId, pulledData, stats, false); |
| 524 | } catch (java.io.IOException e) { |
| 525 | Slog.e(TAG, "Pulling netstats for wifi bytes has error", e); |
| 526 | } finally { |
| 527 | Binder.restoreCallingIdentity(token); |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 528 | } |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 529 | } |
| 530 | |
| 531 | private void pullWifiBytesTransferByFgBg(int tagId, List<StatsLogEventWrapper> pulledData) { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 532 | long token = Binder.clearCallingIdentity(); |
| 533 | try { |
| 534 | BatteryStatsInternal bs = LocalServices.getService(BatteryStatsInternal.class); |
| 535 | String[] ifaces = bs.getWifiIfaces(); |
| 536 | if (ifaces.length == 0) { |
| 537 | return; |
| 538 | } |
| 539 | NetworkStatsFactory nsf = new NetworkStatsFactory(); |
| 540 | NetworkStats stats = rollupNetworkStatsByFGBG( |
| 541 | nsf.readNetworkStatsDetail(NetworkStats.UID_ALL, ifaces, NetworkStats.TAG_NONE, null)); |
| 542 | addNetworkStats(tagId, pulledData, stats, true); |
| 543 | } catch (java.io.IOException e) { |
| 544 | Slog.e(TAG, "Pulling netstats for wifi bytes w/ fg/bg has error", e); |
| 545 | } finally { |
| 546 | Binder.restoreCallingIdentity(token); |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 547 | } |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 548 | } |
| 549 | |
| 550 | private void pullMobileBytesTransfer(int tagId, List<StatsLogEventWrapper> pulledData) { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 551 | long token = Binder.clearCallingIdentity(); |
| 552 | try { |
| 553 | BatteryStatsInternal bs = LocalServices.getService(BatteryStatsInternal.class); |
| 554 | String[] ifaces = bs.getMobileIfaces(); |
| 555 | if (ifaces.length == 0) { |
| 556 | return; |
| 557 | } |
| 558 | NetworkStatsFactory nsf = new NetworkStatsFactory(); |
| 559 | // Combine all the metrics per Uid into one record. |
| 560 | NetworkStats stats = |
| 561 | nsf.readNetworkStatsDetail(NetworkStats.UID_ALL, ifaces, NetworkStats.TAG_NONE, null) |
| 562 | .groupedByUid(); |
| 563 | addNetworkStats(tagId, pulledData, stats, false); |
| 564 | } catch (java.io.IOException e) { |
| 565 | Slog.e(TAG, "Pulling netstats for mobile bytes has error", e); |
| 566 | } finally { |
| 567 | Binder.restoreCallingIdentity(token); |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 568 | } |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 569 | } |
| 570 | |
| 571 | private void pullBluetoothBytesTransfer(int tagId, List<StatsLogEventWrapper> pulledData) { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 572 | BluetoothActivityEnergyInfo info = pullBluetoothData(); |
| 573 | for (UidTraffic traffic : info.getUidTraffic()) { |
| 574 | StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, 3); |
| 575 | e.writeInt(traffic.getUid()); |
| 576 | e.writeLong(traffic.getRxBytes()); |
| 577 | e.writeLong(traffic.getTxBytes()); |
| 578 | pulledData.add(e); |
| 579 | } |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 580 | } |
| 581 | |
| 582 | private void pullMobileBytesTransferByFgBg(int tagId, List<StatsLogEventWrapper> pulledData) { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 583 | long token = Binder.clearCallingIdentity(); |
| 584 | try { |
| 585 | BatteryStatsInternal bs = LocalServices.getService(BatteryStatsInternal.class); |
| 586 | String[] ifaces = bs.getMobileIfaces(); |
| 587 | if (ifaces.length == 0) { |
| 588 | return; |
| 589 | } |
| 590 | NetworkStatsFactory nsf = new NetworkStatsFactory(); |
| 591 | NetworkStats stats = rollupNetworkStatsByFGBG( |
| 592 | nsf.readNetworkStatsDetail(NetworkStats.UID_ALL, ifaces, NetworkStats.TAG_NONE, null)); |
| 593 | addNetworkStats(tagId, pulledData, stats, true); |
| 594 | } catch (java.io.IOException e) { |
| 595 | Slog.e(TAG, "Pulling netstats for mobile bytes w/ fg/bg has error", e); |
| 596 | } finally { |
| 597 | Binder.restoreCallingIdentity(token); |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 598 | } |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | private void pullCpuTimePerFreq(int tagId, List<StatsLogEventWrapper> pulledData) { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 602 | for (int cluster = 0; cluster < mKernelCpuSpeedReaders.length; cluster++) { |
| 603 | long[] clusterTimeMs = mKernelCpuSpeedReaders[cluster].readAbsolute(); |
| 604 | if (clusterTimeMs != null) { |
| 605 | for (int speed = clusterTimeMs.length - 1; speed >= 0; --speed) { |
| 606 | StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, 3); |
| 607 | e.writeInt(cluster); |
| 608 | e.writeInt(speed); |
| 609 | e.writeLong(clusterTimeMs[speed]); |
| 610 | pulledData.add(e); |
| 611 | } |
| 612 | } |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 613 | } |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 614 | } |
| 615 | |
| 616 | private void pullWifiActivityEnergyInfo(int tagId, List<StatsLogEventWrapper> pulledData) { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 617 | long token = Binder.clearCallingIdentity(); |
| 618 | if (mWifiManager == null) { |
| 619 | mWifiManager = |
| 620 | IWifiManager.Stub.asInterface(ServiceManager.getService(Context.WIFI_SERVICE)); |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 621 | } |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 622 | if (mWifiManager != null) { |
| 623 | try { |
| 624 | SynchronousResultReceiver wifiReceiver = new SynchronousResultReceiver("wifi"); |
| 625 | mWifiManager.requestActivityInfo(wifiReceiver); |
| 626 | final WifiActivityEnergyInfo wifiInfo = awaitControllerInfo(wifiReceiver); |
| 627 | StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, 6); |
| 628 | e.writeLong(wifiInfo.getTimeStamp()); |
| 629 | e.writeInt(wifiInfo.getStackState()); |
| 630 | e.writeLong(wifiInfo.getControllerTxTimeMillis()); |
| 631 | e.writeLong(wifiInfo.getControllerRxTimeMillis()); |
| 632 | e.writeLong(wifiInfo.getControllerIdleTimeMillis()); |
| 633 | e.writeLong(wifiInfo.getControllerEnergyUsed()); |
| 634 | pulledData.add(e); |
| 635 | } catch (RemoteException e) { |
| 636 | Slog.e(TAG, "Pulling wifiManager for wifi controller activity energy info has error", e); |
| 637 | } finally { |
| 638 | Binder.restoreCallingIdentity(token); |
| 639 | } |
| 640 | } |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 641 | } |
| 642 | |
| 643 | private void pullModemActivityInfo(int tagId, List<StatsLogEventWrapper> pulledData) { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 644 | long token = Binder.clearCallingIdentity(); |
| 645 | if (mTelephony == null) { |
| 646 | mTelephony = TelephonyManager.from(mContext); |
| 647 | } |
| 648 | if (mTelephony != null) { |
| 649 | SynchronousResultReceiver modemReceiver = new SynchronousResultReceiver("telephony"); |
| 650 | mTelephony.requestModemActivityInfo(modemReceiver); |
| 651 | final ModemActivityInfo modemInfo = awaitControllerInfo(modemReceiver); |
| 652 | StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, 6); |
| 653 | e.writeLong(modemInfo.getTimestamp()); |
| 654 | e.writeLong(modemInfo.getSleepTimeMillis()); |
| 655 | e.writeLong(modemInfo.getIdleTimeMillis()); |
| 656 | e.writeLong(modemInfo.getTxTimeMillis()[0]); |
| 657 | e.writeLong(modemInfo.getTxTimeMillis()[1]); |
| 658 | e.writeLong(modemInfo.getTxTimeMillis()[2]); |
| 659 | e.writeLong(modemInfo.getTxTimeMillis()[3]); |
| 660 | e.writeLong(modemInfo.getTxTimeMillis()[4]); |
| 661 | e.writeLong(modemInfo.getRxTimeMillis()); |
| 662 | e.writeLong(modemInfo.getEnergyUsed()); |
| 663 | pulledData.add(e); |
| 664 | } |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 665 | } |
| 666 | |
| 667 | private void pullBluetoothActivityInfo(int tagId, List<StatsLogEventWrapper> pulledData) { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 668 | BluetoothActivityEnergyInfo info = pullBluetoothData(); |
| 669 | StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, 6); |
| 670 | e.writeLong(info.getTimeStamp()); |
| 671 | e.writeInt(info.getBluetoothStackState()); |
| 672 | e.writeLong(info.getControllerTxTimeMillis()); |
| 673 | e.writeLong(info.getControllerRxTimeMillis()); |
| 674 | e.writeLong(info.getControllerIdleTimeMillis()); |
| 675 | e.writeLong(info.getControllerEnergyUsed()); |
| 676 | pulledData.add(e); |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 677 | } |
| 678 | |
| 679 | private synchronized BluetoothActivityEnergyInfo pullBluetoothData() { |
Chenjie Yu | c2d6544 | 2018-02-01 22:27:17 -0800 | [diff] [blame] | 680 | final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 681 | if (adapter != null) { |
| 682 | SynchronousResultReceiver bluetoothReceiver = new SynchronousResultReceiver("bluetooth"); |
| 683 | adapter.requestControllerActivityEnergyInfo(bluetoothReceiver); |
| 684 | return awaitControllerInfo(bluetoothReceiver); |
| 685 | } else { |
| 686 | Slog.e(TAG, "Failed to get bluetooth adapter!"); |
| 687 | return null; |
| 688 | } |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 689 | } |
| 690 | |
| 691 | private void pullSystemElapsedRealtime(int tagId, List<StatsLogEventWrapper> pulledData) { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 692 | StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, 1); |
| 693 | e.writeLong(SystemClock.elapsedRealtime()); |
| 694 | pulledData.add(e); |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 695 | } |
| 696 | |
| 697 | private void pullDiskSpace(int tagId, List<StatsLogEventWrapper> pulledData) { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 698 | StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, 3); |
| 699 | e.writeLong(mStatFsData.getAvailableBytes()); |
| 700 | e.writeLong(mStatFsSystem.getAvailableBytes()); |
| 701 | e.writeLong(mStatFsTemp.getAvailableBytes()); |
| 702 | pulledData.add(e); |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 703 | } |
| 704 | |
| 705 | private void pullSystemUpTime(int tagId, List<StatsLogEventWrapper> pulledData) { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 706 | StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, 1); |
| 707 | e.writeLong(SystemClock.uptimeMillis()); |
| 708 | pulledData.add(e); |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 709 | } |
| 710 | |
Chenjie Yu | 05013b3 | 2017-11-21 10:21:41 -0800 | [diff] [blame] | 711 | /** |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 712 | * Pulls various data. |
Chenjie Yu | 05013b3 | 2017-11-21 10:21:41 -0800 | [diff] [blame] | 713 | */ |
Bookatz | c68a9d2 | 2017-09-27 14:09:55 -0700 | [diff] [blame] | 714 | @Override // Binder call |
Chenjie Yu | 5305e1d | 2017-10-31 13:49:36 -0700 | [diff] [blame] | 715 | public StatsLogEventWrapper[] pullData(int tagId) { |
Bookatz | c68a9d2 | 2017-09-27 14:09:55 -0700 | [diff] [blame] | 716 | enforceCallingPermission(); |
David Chen | c8a4324 | 2017-10-17 16:23:28 -0700 | [diff] [blame] | 717 | if (DEBUG) |
Chenjie Yu | 5305e1d | 2017-10-31 13:49:36 -0700 | [diff] [blame] | 718 | Slog.d(TAG, "Pulling " + tagId); |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 719 | List<StatsLogEventWrapper> ret = new ArrayList(); |
Chenjie Yu | 5305e1d | 2017-10-31 13:49:36 -0700 | [diff] [blame] | 720 | switch (tagId) { |
Chenjie Yu | 31d14d7 | 2017-12-12 17:54:33 -0800 | [diff] [blame] | 721 | case StatsLog.WIFI_BYTES_TRANSFER: { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 722 | pullWifiBytesTransfer(tagId, ret); |
| 723 | break; |
David Chen | c8a4324 | 2017-10-17 16:23:28 -0700 | [diff] [blame] | 724 | } |
Chenjie Yu | 31d14d7 | 2017-12-12 17:54:33 -0800 | [diff] [blame] | 725 | case StatsLog.MOBILE_BYTES_TRANSFER: { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 726 | pullMobileBytesTransfer(tagId, ret); |
| 727 | break; |
David Chen | c8a4324 | 2017-10-17 16:23:28 -0700 | [diff] [blame] | 728 | } |
Chenjie Yu | 31d14d7 | 2017-12-12 17:54:33 -0800 | [diff] [blame] | 729 | case StatsLog.WIFI_BYTES_TRANSFER_BY_FG_BG: { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 730 | pullWifiBytesTransferByFgBg(tagId, ret); |
| 731 | break; |
David Chen | c8a4324 | 2017-10-17 16:23:28 -0700 | [diff] [blame] | 732 | } |
Chenjie Yu | 31d14d7 | 2017-12-12 17:54:33 -0800 | [diff] [blame] | 733 | case StatsLog.MOBILE_BYTES_TRANSFER_BY_FG_BG: { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 734 | pullMobileBytesTransferByFgBg(tagId, ret); |
| 735 | break; |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 736 | } |
| 737 | case StatsLog.BLUETOOTH_BYTES_TRANSFER: { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 738 | pullBluetoothBytesTransfer(tagId, ret); |
| 739 | break; |
David Chen | c8a4324 | 2017-10-17 16:23:28 -0700 | [diff] [blame] | 740 | } |
Chenjie Yu | 31d14d7 | 2017-12-12 17:54:33 -0800 | [diff] [blame] | 741 | case StatsLog.KERNEL_WAKELOCK: { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 742 | pullKernelWakelock(tagId, ret); |
| 743 | break; |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame] | 744 | } |
Chenjie Yu | 31d14d7 | 2017-12-12 17:54:33 -0800 | [diff] [blame] | 745 | case StatsLog.CPU_TIME_PER_FREQ: { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 746 | pullCpuTimePerFreq(tagId, ret); |
| 747 | break; |
Chenjie Yu | 7f8def9 | 2017-11-03 09:33:15 -0700 | [diff] [blame] | 748 | } |
Chenjie Yu | 31d14d7 | 2017-12-12 17:54:33 -0800 | [diff] [blame] | 749 | case StatsLog.WIFI_ACTIVITY_ENERGY_INFO: { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 750 | pullWifiActivityEnergyInfo(tagId, ret); |
| 751 | break; |
Chenjie Yu | 05013b3 | 2017-11-21 10:21:41 -0800 | [diff] [blame] | 752 | } |
Chenjie Yu | 31d14d7 | 2017-12-12 17:54:33 -0800 | [diff] [blame] | 753 | case StatsLog.MODEM_ACTIVITY_INFO: { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 754 | pullModemActivityInfo(tagId, ret); |
| 755 | break; |
Chenjie Yu | 05013b3 | 2017-11-21 10:21:41 -0800 | [diff] [blame] | 756 | } |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 757 | case StatsLog.BLUETOOTH_ACTIVITY_INFO: { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 758 | pullBluetoothActivityInfo(tagId, ret); |
| 759 | break; |
Chenjie Yu | 937d742 | 2018-01-10 16:37:53 -0800 | [diff] [blame] | 760 | } |
| 761 | case StatsLog.SYSTEM_UPTIME: { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 762 | pullSystemUpTime(tagId, ret); |
| 763 | break; |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 764 | } |
| 765 | case StatsLog.SYSTEM_ELAPSED_REALTIME: { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 766 | pullSystemElapsedRealtime(tagId, ret); |
| 767 | break; |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 768 | } |
| 769 | case StatsLog.DISK_SPACE: { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 770 | pullDiskSpace(tagId, ret); |
| 771 | break; |
Chenjie Yu | 9da105b | 2018-01-13 12:41:08 -0800 | [diff] [blame] | 772 | } |
Bookatz | c68a9d2 | 2017-09-27 14:09:55 -0700 | [diff] [blame] | 773 | default: |
Chenjie Yu | 5305e1d | 2017-10-31 13:49:36 -0700 | [diff] [blame] | 774 | Slog.w(TAG, "No such tagId data as " + tagId); |
Bookatz | c68a9d2 | 2017-09-27 14:09:55 -0700 | [diff] [blame] | 775 | return null; |
| 776 | } |
Chenjie Yu | 9d7720b | 2018-01-24 10:34:48 -0800 | [diff] [blame] | 777 | return ret.toArray(new StatsLogEventWrapper[ret.size()]); |
Bookatz | c68a9d2 | 2017-09-27 14:09:55 -0700 | [diff] [blame] | 778 | } |
| 779 | |
| 780 | @Override // Binder call |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 781 | public void statsdReady() { |
| 782 | enforceCallingPermission(); |
| 783 | if (DEBUG) Slog.d(TAG, "learned that statsdReady"); |
| 784 | sayHiToStatsd(); // tell statsd that we're ready too and link to it |
Bookatz | 0eb58ae39 | 2018-01-25 15:49:26 -0800 | [diff] [blame] | 785 | mContext.sendBroadcastAsUser(new Intent(StatsManager.ACTION_STATSD_STARTED), |
| 786 | UserHandle.SYSTEM, |
Bookatz | 5c800e3 | 2018-01-24 14:59:52 -0800 | [diff] [blame] | 787 | android.Manifest.permission.DUMP); |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 788 | } |
| 789 | |
David Chen | c136f45a | 2017-11-27 11:52:26 -0800 | [diff] [blame] | 790 | @Override |
| 791 | public void triggerUidSnapshot() { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 792 | enforceCallingPermission(); |
| 793 | synchronized (sStatsdLock) { |
| 794 | try { |
| 795 | informAllUidsLocked(mContext); |
| 796 | } catch (RemoteException e) { |
| 797 | Slog.e(TAG, "Failed to trigger uid snapshot.", e); |
| 798 | } |
David Chen | c136f45a | 2017-11-27 11:52:26 -0800 | [diff] [blame] | 799 | } |
David Chen | c136f45a | 2017-11-27 11:52:26 -0800 | [diff] [blame] | 800 | } |
| 801 | |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 802 | private void enforceCallingPermission() { |
| 803 | if (Binder.getCallingPid() == Process.myPid()) { |
| 804 | return; |
| 805 | } |
| 806 | mContext.enforceCallingPermission(android.Manifest.permission.STATSCOMPANION, null); |
| 807 | } |
| 808 | |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 809 | // Lifecycle and related code |
| 810 | |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame] | 811 | /** |
| 812 | * Fetches the statsd IBinder service |
| 813 | */ |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 814 | private static IStatsManager fetchStatsdService() { |
| 815 | return IStatsManager.Stub.asInterface(ServiceManager.getService("stats")); |
| 816 | } |
| 817 | |
| 818 | public static final class Lifecycle extends SystemService { |
| 819 | private StatsCompanionService mStatsCompanionService; |
| 820 | |
| 821 | public Lifecycle(Context context) { |
| 822 | super(context); |
| 823 | } |
| 824 | |
| 825 | @Override |
| 826 | public void onStart() { |
| 827 | mStatsCompanionService = new StatsCompanionService(getContext()); |
| 828 | try { |
| 829 | publishBinderService(Context.STATS_COMPANION_SERVICE, mStatsCompanionService); |
| 830 | if (DEBUG) Slog.d(TAG, "Published " + Context.STATS_COMPANION_SERVICE); |
| 831 | } catch (Exception e) { |
| 832 | Slog.e(TAG, "Failed to publishBinderService", e); |
| 833 | } |
| 834 | } |
| 835 | |
| 836 | @Override |
| 837 | public void onBootPhase(int phase) { |
| 838 | super.onBootPhase(phase); |
| 839 | if (phase == PHASE_THIRD_PARTY_APPS_CAN_START) { |
| 840 | mStatsCompanionService.systemReady(); |
| 841 | } |
| 842 | } |
| 843 | } |
| 844 | |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame] | 845 | /** |
| 846 | * Now that the android system is ready, StatsCompanion is ready too, so inform statsd. |
| 847 | */ |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 848 | private void systemReady() { |
| 849 | if (DEBUG) Slog.d(TAG, "Learned that systemReady"); |
| 850 | sayHiToStatsd(); |
| 851 | } |
| 852 | |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame] | 853 | /** |
| 854 | * Tells statsd that statscompanion is ready. If the binder call returns, link to statsd. |
| 855 | */ |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 856 | private void sayHiToStatsd() { |
| 857 | synchronized (sStatsdLock) { |
| 858 | if (sStatsd != null) { |
| 859 | Slog.e(TAG, "Trying to fetch statsd, but it was already fetched", |
| 860 | new IllegalStateException("sStatsd is not null when being fetched")); |
| 861 | return; |
| 862 | } |
| 863 | sStatsd = fetchStatsdService(); |
| 864 | if (sStatsd == null) { |
| 865 | Slog.w(TAG, "Could not access statsd"); |
| 866 | return; |
| 867 | } |
| 868 | if (DEBUG) Slog.d(TAG, "Saying hi to statsd"); |
| 869 | try { |
| 870 | sStatsd.statsCompanionReady(); |
| 871 | // If the statsCompanionReady two-way binder call returns, link to statsd. |
| 872 | try { |
| 873 | sStatsd.asBinder().linkToDeath(new StatsdDeathRecipient(), 0); |
| 874 | } catch (RemoteException e) { |
| 875 | Slog.e(TAG, "linkToDeath(StatsdDeathRecipient) failed", e); |
| 876 | forgetEverything(); |
| 877 | } |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 878 | // Setup broadcast receiver for updates. |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 879 | IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_REPLACED); |
| 880 | filter.addAction(Intent.ACTION_PACKAGE_ADDED); |
| 881 | filter.addAction(Intent.ACTION_PACKAGE_REMOVED); |
| 882 | filter.addDataScheme("package"); |
| 883 | mContext.registerReceiverAsUser(mAppUpdateReceiver, UserHandle.ALL, filter, null, |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame] | 884 | null); |
David Chen | 47e8f4d | 2017-10-11 15:34:13 -0700 | [diff] [blame] | 885 | |
| 886 | // Setup receiver for user initialize (which happens once for a new user) and |
| 887 | // if a user is removed. |
| 888 | filter = new IntentFilter(Intent.ACTION_USER_INITIALIZE); |
| 889 | filter.addAction(Intent.ACTION_USER_REMOVED); |
| 890 | mContext.registerReceiverAsUser(mUserUpdateReceiver, UserHandle.ALL, |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame] | 891 | filter, null, null); |
David Chen | 47e8f4d | 2017-10-11 15:34:13 -0700 | [diff] [blame] | 892 | |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 893 | // Setup receiver for device reboots or shutdowns. |
| 894 | filter = new IntentFilter(Intent.ACTION_REBOOT); |
| 895 | filter.addAction(Intent.ACTION_SHUTDOWN); |
| 896 | mContext.registerReceiverAsUser( |
| 897 | mShutdownEventReceiver, UserHandle.ALL, filter, null, null); |
Yao Chen | 0f21710 | 2018-01-09 10:33:15 -0800 | [diff] [blame] | 898 | final long token = Binder.clearCallingIdentity(); |
| 899 | try { |
| 900 | // Pull the latest state of UID->app name, version mapping when statsd starts. |
| 901 | informAllUidsLocked(mContext); |
| 902 | } finally { |
| 903 | restoreCallingIdentity(token); |
| 904 | } |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 905 | } catch (RemoteException e) { |
| 906 | Slog.e(TAG, "Failed to inform statsd that statscompanion is ready", e); |
| 907 | forgetEverything(); |
| 908 | } |
| 909 | } |
| 910 | } |
| 911 | |
| 912 | private class StatsdDeathRecipient implements IBinder.DeathRecipient { |
| 913 | @Override |
| 914 | public void binderDied() { |
| 915 | Slog.i(TAG, "Statsd is dead - erase all my knowledge."); |
| 916 | forgetEverything(); |
| 917 | } |
| 918 | } |
| 919 | |
| 920 | private void forgetEverything() { |
| 921 | synchronized (sStatsdLock) { |
| 922 | sStatsd = null; |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 923 | mContext.unregisterReceiver(mAppUpdateReceiver); |
David Chen | 47e8f4d | 2017-10-11 15:34:13 -0700 | [diff] [blame] | 924 | mContext.unregisterReceiver(mUserUpdateReceiver); |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 925 | mContext.unregisterReceiver(mShutdownEventReceiver); |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 926 | cancelAnomalyAlarm(); |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 927 | cancelPullingAlarms(); |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 928 | } |
| 929 | } |
| 930 | |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 931 | } |