Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -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 | |
| 17 | #include "config/ConfigManager.h" |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 18 | #include "storage/StorageManager.h" |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 19 | |
| 20 | #include "stats_util.h" |
| 21 | |
yro | 87d983c | 2017-11-14 21:31:43 -0800 | [diff] [blame] | 22 | #include <android-base/file.h> |
| 23 | #include <dirent.h> |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 24 | #include <stdio.h> |
yro | 87d983c | 2017-11-14 21:31:43 -0800 | [diff] [blame] | 25 | #include <vector> |
| 26 | #include "android-base/stringprintf.h" |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 27 | |
| 28 | namespace android { |
| 29 | namespace os { |
| 30 | namespace statsd { |
| 31 | |
Yao Chen | f09569f | 2017-12-13 17:00:51 -0800 | [diff] [blame] | 32 | using std::map; |
| 33 | using std::pair; |
| 34 | using std::set; |
| 35 | using std::string; |
| 36 | using std::vector; |
| 37 | |
yro | 03faf09 | 2017-12-12 00:17:50 -0800 | [diff] [blame] | 38 | #define STATS_SERVICE_DIR "/data/misc/stats-service" |
yro | 87d983c | 2017-11-14 21:31:43 -0800 | [diff] [blame] | 39 | |
yro | 87d983c | 2017-11-14 21:31:43 -0800 | [diff] [blame] | 40 | using android::base::StringPrintf; |
| 41 | using std::unique_ptr; |
| 42 | |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 43 | ConfigManager::ConfigManager() { |
| 44 | } |
| 45 | |
| 46 | ConfigManager::~ConfigManager() { |
| 47 | } |
| 48 | |
| 49 | void ConfigManager::Startup() { |
Yao Chen | f09569f | 2017-12-13 17:00:51 -0800 | [diff] [blame] | 50 | map<ConfigKey, StatsdConfig> configsFromDisk; |
| 51 | StorageManager::readConfigFromDisk(configsFromDisk); |
| 52 | // TODO(b/70667694): Make the configs from disk be used. And remove the fake config, |
| 53 | // and tests shouldn't call this Startup(), maybe call StartupForTest() so we don't read |
| 54 | // configs from disk for tests. |
| 55 | // for (const auto& pair : configsFromDisk) { |
| 56 | // UpdateConfig(pair.first, pair.second); |
| 57 | //} |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 58 | // this should be called from StatsService when it receives a statsd_config |
Yao Chen | 7ee9415 | 2017-11-17 09:44:40 -0800 | [diff] [blame] | 59 | UpdateConfig(ConfigKey(1000, "fake"), build_fake_config()); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | void ConfigManager::AddListener(const sp<ConfigListener>& listener) { |
| 63 | mListeners.push_back(listener); |
| 64 | } |
| 65 | |
| 66 | void ConfigManager::UpdateConfig(const ConfigKey& key, const StatsdConfig& config) { |
Yao Chen | f09569f | 2017-12-13 17:00:51 -0800 | [diff] [blame] | 67 | // Add to set |
| 68 | mConfigs.insert(key); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 69 | |
| 70 | // Save to disk |
yro | 87d983c | 2017-11-14 21:31:43 -0800 | [diff] [blame] | 71 | update_saved_configs(key, config); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 72 | |
| 73 | // Tell everyone |
| 74 | for (auto& listener : mListeners) { |
| 75 | listener->OnConfigUpdated(key, config); |
| 76 | } |
| 77 | } |
| 78 | |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 79 | void ConfigManager::SetConfigReceiver(const ConfigKey& key, const string& pkg, const string& cls) { |
| 80 | mConfigReceivers[key] = pair<string, string>(pkg, cls); |
| 81 | } |
| 82 | |
| 83 | void ConfigManager::RemoveConfigReceiver(const ConfigKey& key) { |
| 84 | mConfigReceivers.erase(key); |
| 85 | } |
| 86 | |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 87 | void ConfigManager::RemoveConfig(const ConfigKey& key) { |
Yao Chen | f09569f | 2017-12-13 17:00:51 -0800 | [diff] [blame] | 88 | auto it = mConfigs.find(key); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 89 | if (it != mConfigs.end()) { |
| 90 | // Remove from map |
| 91 | mConfigs.erase(it); |
| 92 | |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 93 | // Tell everyone |
| 94 | for (auto& listener : mListeners) { |
| 95 | listener->OnConfigRemoved(key); |
| 96 | } |
| 97 | } |
yro | 9c98c05 | 2017-11-19 14:33:56 -0800 | [diff] [blame] | 98 | |
| 99 | // Remove from disk. There can still be a lingering file on disk so we check |
| 100 | // whether or not the config was on memory. |
| 101 | remove_saved_configs(key); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 102 | } |
| 103 | |
yro | 87d983c | 2017-11-14 21:31:43 -0800 | [diff] [blame] | 104 | void ConfigManager::remove_saved_configs(const ConfigKey& key) { |
yro | 87d983c | 2017-11-14 21:31:43 -0800 | [diff] [blame] | 105 | string prefix = StringPrintf("%d-%s", key.GetUid(), key.GetName().c_str()); |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 106 | StorageManager::deletePrefixedFiles(STATS_SERVICE_DIR, prefix.c_str()); |
yro | 87d983c | 2017-11-14 21:31:43 -0800 | [diff] [blame] | 107 | } |
| 108 | |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 109 | void ConfigManager::RemoveConfigs(int uid) { |
| 110 | vector<ConfigKey> removed; |
| 111 | |
| 112 | for (auto it = mConfigs.begin(); it != mConfigs.end();) { |
| 113 | // Remove from map |
Yao Chen | f09569f | 2017-12-13 17:00:51 -0800 | [diff] [blame] | 114 | if (it->GetUid() == uid) { |
| 115 | removed.push_back(*it); |
| 116 | mConfigReceivers.erase(*it); |
yro | 74fed97 | 2017-11-27 14:42:42 -0800 | [diff] [blame] | 117 | it = mConfigs.erase(it); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 118 | } else { |
| 119 | it++; |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | // Remove separately so if they do anything in the callback they can't mess up our iteration. |
| 124 | for (auto& key : removed) { |
| 125 | // Tell everyone |
| 126 | for (auto& listener : mListeners) { |
| 127 | listener->OnConfigRemoved(key); |
| 128 | } |
| 129 | } |
| 130 | } |
| 131 | |
yro | 74fed97 | 2017-11-27 14:42:42 -0800 | [diff] [blame] | 132 | void ConfigManager::RemoveAllConfigs() { |
| 133 | vector<ConfigKey> removed; |
| 134 | |
| 135 | for (auto it = mConfigs.begin(); it != mConfigs.end();) { |
| 136 | // Remove from map |
Yao Chen | f09569f | 2017-12-13 17:00:51 -0800 | [diff] [blame] | 137 | removed.push_back(*it); |
| 138 | auto receiverIt = mConfigReceivers.find(*it); |
yro | 74fed97 | 2017-11-27 14:42:42 -0800 | [diff] [blame] | 139 | if (receiverIt != mConfigReceivers.end()) { |
Yao Chen | f09569f | 2017-12-13 17:00:51 -0800 | [diff] [blame] | 140 | mConfigReceivers.erase(*it); |
yro | 74fed97 | 2017-11-27 14:42:42 -0800 | [diff] [blame] | 141 | } |
| 142 | it = mConfigs.erase(it); |
| 143 | } |
| 144 | |
| 145 | // Remove separately so if they do anything in the callback they can't mess up our iteration. |
| 146 | for (auto& key : removed) { |
| 147 | // Tell everyone |
| 148 | for (auto& listener : mListeners) { |
| 149 | listener->OnConfigRemoved(key); |
| 150 | } |
| 151 | } |
| 152 | } |
| 153 | |
Yangster | 7c334a1 | 2017-11-22 14:24:24 -0800 | [diff] [blame] | 154 | vector<ConfigKey> ConfigManager::GetAllConfigKeys() const { |
David Chen | 1d7b0cd | 2017-11-15 14:20:04 -0800 | [diff] [blame] | 155 | vector<ConfigKey> ret; |
| 156 | for (auto it = mConfigs.cbegin(); it != mConfigs.cend(); ++it) { |
Yao Chen | f09569f | 2017-12-13 17:00:51 -0800 | [diff] [blame] | 157 | ret.push_back(*it); |
David Chen | 1d7b0cd | 2017-11-15 14:20:04 -0800 | [diff] [blame] | 158 | } |
| 159 | return ret; |
| 160 | } |
| 161 | |
Yangster | 7c334a1 | 2017-11-22 14:24:24 -0800 | [diff] [blame] | 162 | const pair<string, string> ConfigManager::GetConfigReceiver(const ConfigKey& key) const { |
David Chen | 1d7b0cd | 2017-11-15 14:20:04 -0800 | [diff] [blame] | 163 | auto it = mConfigReceivers.find(key); |
| 164 | if (it == mConfigReceivers.end()) { |
| 165 | return pair<string,string>(); |
| 166 | } else { |
| 167 | return it->second; |
| 168 | } |
| 169 | } |
| 170 | |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 171 | void ConfigManager::Dump(FILE* out) { |
| 172 | fprintf(out, "CONFIGURATIONS (%d)\n", (int)mConfigs.size()); |
| 173 | fprintf(out, " uid name\n"); |
Yao Chen | f09569f | 2017-12-13 17:00:51 -0800 | [diff] [blame] | 174 | for (const auto& key : mConfigs) { |
| 175 | fprintf(out, " %6d %s\n", key.GetUid(), key.GetName().c_str()); |
| 176 | auto receiverIt = mConfigReceivers.find(key); |
David Chen | 1d7b0cd | 2017-11-15 14:20:04 -0800 | [diff] [blame] | 177 | if (receiverIt != mConfigReceivers.end()) { |
| 178 | fprintf(out, " -> received by %s, %s\n", receiverIt->second.first.c_str(), |
| 179 | receiverIt->second.second.c_str()); |
| 180 | } |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 181 | } |
| 182 | } |
| 183 | |
yro | 87d983c | 2017-11-14 21:31:43 -0800 | [diff] [blame] | 184 | void ConfigManager::update_saved_configs(const ConfigKey& key, const StatsdConfig& config) { |
| 185 | mkdir(STATS_SERVICE_DIR, S_IRWXU); |
yro | 9c98c05 | 2017-11-19 14:33:56 -0800 | [diff] [blame] | 186 | |
| 187 | // If there is a pre-existing config with same key we should first delete it. |
| 188 | remove_saved_configs(key); |
| 189 | |
| 190 | // Then we save the latest config. |
yro | 87d983c | 2017-11-14 21:31:43 -0800 | [diff] [blame] | 191 | string file_name = StringPrintf("%s/%d-%s-%ld", STATS_SERVICE_DIR, key.GetUid(), |
| 192 | key.GetName().c_str(), time(nullptr)); |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 193 | const int numBytes = config.ByteSize(); |
| 194 | vector<uint8_t> buffer(numBytes); |
| 195 | config.SerializeToArray(&buffer[0], numBytes); |
| 196 | StorageManager::writeFile(file_name.c_str(), &buffer[0], numBytes); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 197 | } |
| 198 | |
Yangster-mac | 756cd48 | 2017-11-21 21:58:44 -0800 | [diff] [blame] | 199 | StatsdConfig build_fake_config() { |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 200 | // HACK: Hard code a test metric for counting screen on events... |
| 201 | StatsdConfig config; |
Stefan Lafon | 7c8f0a5 | 2017-11-21 14:49:09 -0800 | [diff] [blame] | 202 | config.set_name("CONFIG_12345"); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 203 | |
Yao Chen | 5154a379 | 2017-10-30 22:57:06 -0700 | [diff] [blame] | 204 | int WAKE_LOCK_TAG_ID = 1111; // put a fake id here to make testing easier. |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 205 | int WAKE_LOCK_UID_KEY_ID = 1; |
Yao Chen | 5154a379 | 2017-10-30 22:57:06 -0700 | [diff] [blame] | 206 | int WAKE_LOCK_NAME_KEY = 3; |
| 207 | int WAKE_LOCK_STATE_KEY = 4; |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 208 | int WAKE_LOCK_ACQUIRE_VALUE = 1; |
| 209 | int WAKE_LOCK_RELEASE_VALUE = 0; |
| 210 | |
| 211 | int APP_USAGE_ID = 12345; |
| 212 | int APP_USAGE_UID_KEY_ID = 1; |
| 213 | int APP_USAGE_STATE_KEY = 2; |
| 214 | int APP_USAGE_FOREGROUND = 1; |
| 215 | int APP_USAGE_BACKGROUND = 0; |
| 216 | |
Bookatz | c1a050a | 2017-10-10 15:49:28 -0700 | [diff] [blame] | 217 | int SCREEN_EVENT_TAG_ID = 29; |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 218 | int SCREEN_EVENT_STATE_KEY = 1; |
| 219 | int SCREEN_EVENT_ON_VALUE = 2; |
| 220 | int SCREEN_EVENT_OFF_VALUE = 1; |
| 221 | |
Bookatz | c1a050a | 2017-10-10 15:49:28 -0700 | [diff] [blame] | 222 | int UID_PROCESS_STATE_TAG_ID = 27; |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 223 | int UID_PROCESS_STATE_UID_KEY = 1; |
| 224 | |
Chenjie Yu | 5305e1d | 2017-10-31 13:49:36 -0700 | [diff] [blame] | 225 | int KERNEL_WAKELOCK_TAG_ID = 1004; |
Chenjie Yu | 6842a8c | 2017-12-05 22:34:34 -0800 | [diff] [blame] | 226 | int KERNEL_WAKELOCK_COUNT_KEY = 2; |
| 227 | int KERNEL_WAKELOCK_NAME_KEY = 1; |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 228 | |
Yangster | 1d4d686 | 2017-10-31 12:58:51 -0700 | [diff] [blame] | 229 | int DEVICE_TEMPERATURE_TAG_ID = 33; |
| 230 | int DEVICE_TEMPERATURE_KEY = 1; |
| 231 | |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 232 | // Count Screen ON events. |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 233 | CountMetric* metric = config.add_count_metric(); |
Stefan Lafon | 7c8f0a5 | 2017-11-21 14:49:09 -0800 | [diff] [blame] | 234 | metric->set_name("METRIC_1"); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 235 | metric->set_what("SCREEN_TURNED_ON"); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 236 | metric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); |
| 237 | |
Bookatz | d3606c7 | 2017-10-19 10:13:49 -0700 | [diff] [blame] | 238 | // Anomaly threshold for screen-on count. |
Yao Chen | f09569f | 2017-12-13 17:00:51 -0800 | [diff] [blame] | 239 | // TODO(b/70627390): Uncomment once the bug is fixed. |
| 240 | /*Alert* alert = config.add_alert(); |
Stefan Lafon | 7c8f0a5 | 2017-11-21 14:49:09 -0800 | [diff] [blame] | 241 | alert->set_name("ALERT_1"); |
| 242 | alert->set_metric_name("METRIC_1"); |
Bookatz | d3606c7 | 2017-10-19 10:13:49 -0700 | [diff] [blame] | 243 | alert->set_number_of_buckets(6); |
| 244 | alert->set_trigger_if_sum_gt(10); |
| 245 | alert->set_refractory_period_secs(30); |
Bookatz | d1fd242 | 2017-11-22 15:21:03 -0800 | [diff] [blame] | 246 | Alert::IncidentdDetails* details = alert->mutable_incidentd_details(); |
| 247 | details->add_section(12); |
Yao Chen | f09569f | 2017-12-13 17:00:51 -0800 | [diff] [blame] | 248 | details->add_section(13);*/ |
Bookatz | d3606c7 | 2017-10-19 10:13:49 -0700 | [diff] [blame] | 249 | |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 250 | // Count process state changes, slice by uid. |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 251 | metric = config.add_count_metric(); |
Stefan Lafon | 7c8f0a5 | 2017-11-21 14:49:09 -0800 | [diff] [blame] | 252 | metric->set_name("METRIC_2"); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 253 | metric->set_what("PROCESS_STATE_CHANGE"); |
| 254 | metric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); |
| 255 | KeyMatcher* keyMatcher = metric->add_dimension(); |
| 256 | keyMatcher->set_key(UID_PROCESS_STATE_UID_KEY); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 257 | |
Yang Lu | 3eba621 | 2017-10-25 19:54:45 -0700 | [diff] [blame] | 258 | // Anomaly threshold for background count. |
Yao Chen | f09569f | 2017-12-13 17:00:51 -0800 | [diff] [blame] | 259 | // TODO(b/70627390): Uncomment once the bug is fixed. |
| 260 | /* |
Stefan Lafon | cfed20b | 2017-11-18 09:26:53 -0800 | [diff] [blame] | 261 | alert = config.add_alert(); |
Stefan Lafon | 7c8f0a5 | 2017-11-21 14:49:09 -0800 | [diff] [blame] | 262 | alert->set_name("ALERT_2"); |
| 263 | alert->set_metric_name("METRIC_2"); |
Yang Lu | 3eba621 | 2017-10-25 19:54:45 -0700 | [diff] [blame] | 264 | alert->set_number_of_buckets(4); |
| 265 | alert->set_trigger_if_sum_gt(30); |
| 266 | alert->set_refractory_period_secs(20); |
Bookatz | d1fd242 | 2017-11-22 15:21:03 -0800 | [diff] [blame] | 267 | details = alert->mutable_incidentd_details(); |
| 268 | details->add_section(14); |
Yao Chen | f09569f | 2017-12-13 17:00:51 -0800 | [diff] [blame] | 269 | details->add_section(15);*/ |
Yang Lu | 3eba621 | 2017-10-25 19:54:45 -0700 | [diff] [blame] | 270 | |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 271 | // Count process state changes, slice by uid, while SCREEN_IS_OFF |
| 272 | metric = config.add_count_metric(); |
Stefan Lafon | 7c8f0a5 | 2017-11-21 14:49:09 -0800 | [diff] [blame] | 273 | metric->set_name("METRIC_3"); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 274 | metric->set_what("PROCESS_STATE_CHANGE"); |
| 275 | metric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); |
| 276 | keyMatcher = metric->add_dimension(); |
| 277 | keyMatcher->set_key(UID_PROCESS_STATE_UID_KEY); |
| 278 | metric->set_condition("SCREEN_IS_OFF"); |
| 279 | |
Yao Chen | 5110bed | 2017-10-23 12:50:02 -0700 | [diff] [blame] | 280 | // Count wake lock, slice by uid, while SCREEN_IS_ON and app in background |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 281 | metric = config.add_count_metric(); |
Stefan Lafon | 7c8f0a5 | 2017-11-21 14:49:09 -0800 | [diff] [blame] | 282 | metric->set_name("METRIC_4"); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 283 | metric->set_what("APP_GET_WL"); |
| 284 | metric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); |
| 285 | keyMatcher = metric->add_dimension(); |
| 286 | keyMatcher->set_key(WAKE_LOCK_UID_KEY_ID); |
| 287 | metric->set_condition("APP_IS_BACKGROUND_AND_SCREEN_ON"); |
Stefan Lafon | a5b5191 | 2017-12-05 21:43:52 -0800 | [diff] [blame] | 288 | MetricConditionLink* link = metric->add_links(); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 289 | link->set_condition("APP_IS_BACKGROUND"); |
Stefan Lafon | a5b5191 | 2017-12-05 21:43:52 -0800 | [diff] [blame] | 290 | link->add_key_in_what()->set_key(WAKE_LOCK_UID_KEY_ID); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 291 | link->add_key_in_condition()->set_key(APP_USAGE_UID_KEY_ID); |
| 292 | |
Yao Chen | 5154a379 | 2017-10-30 22:57:06 -0700 | [diff] [blame] | 293 | // Duration of an app holding any wl, while screen on and app in background, slice by uid |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 294 | DurationMetric* durationMetric = config.add_duration_metric(); |
Stefan Lafon | 7c8f0a5 | 2017-11-21 14:49:09 -0800 | [diff] [blame] | 295 | durationMetric->set_name("METRIC_5"); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 296 | durationMetric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); |
Stefan Lafon | cfed20b | 2017-11-18 09:26:53 -0800 | [diff] [blame] | 297 | durationMetric->set_aggregation_type(DurationMetric_AggregationType_SUM); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 298 | keyMatcher = durationMetric->add_dimension(); |
| 299 | keyMatcher->set_key(WAKE_LOCK_UID_KEY_ID); |
Yao Chen | 967b205 | 2017-11-07 16:36:43 -0800 | [diff] [blame] | 300 | durationMetric->set_what("WL_HELD_PER_APP_PER_NAME"); |
Yao Chen | 5c925ad | 2017-11-15 14:15:46 -0800 | [diff] [blame] | 301 | durationMetric->set_condition("APP_IS_BACKGROUND_AND_SCREEN_ON"); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 302 | link = durationMetric->add_links(); |
| 303 | link->set_condition("APP_IS_BACKGROUND"); |
Stefan Lafon | a5b5191 | 2017-12-05 21:43:52 -0800 | [diff] [blame] | 304 | link->add_key_in_what()->set_key(WAKE_LOCK_UID_KEY_ID); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 305 | link->add_key_in_condition()->set_key(APP_USAGE_UID_KEY_ID); |
| 306 | |
Yao Chen | 5154a379 | 2017-10-30 22:57:06 -0700 | [diff] [blame] | 307 | // max Duration of an app holding any wl, while screen on and app in background, slice by uid |
| 308 | durationMetric = config.add_duration_metric(); |
Stefan Lafon | 7c8f0a5 | 2017-11-21 14:49:09 -0800 | [diff] [blame] | 309 | durationMetric->set_name("METRIC_6"); |
Yao Chen | 5154a379 | 2017-10-30 22:57:06 -0700 | [diff] [blame] | 310 | durationMetric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); |
Stefan Lafon | cfed20b | 2017-11-18 09:26:53 -0800 | [diff] [blame] | 311 | durationMetric->set_aggregation_type(DurationMetric_AggregationType_MAX_SPARSE); |
Yao Chen | 5154a379 | 2017-10-30 22:57:06 -0700 | [diff] [blame] | 312 | keyMatcher = durationMetric->add_dimension(); |
| 313 | keyMatcher->set_key(WAKE_LOCK_UID_KEY_ID); |
Yao Chen | 967b205 | 2017-11-07 16:36:43 -0800 | [diff] [blame] | 314 | durationMetric->set_what("WL_HELD_PER_APP_PER_NAME"); |
Yao Chen | 5c925ad | 2017-11-15 14:15:46 -0800 | [diff] [blame] | 315 | durationMetric->set_condition("APP_IS_BACKGROUND_AND_SCREEN_ON"); |
Yao Chen | 5154a379 | 2017-10-30 22:57:06 -0700 | [diff] [blame] | 316 | link = durationMetric->add_links(); |
| 317 | link->set_condition("APP_IS_BACKGROUND"); |
Stefan Lafon | a5b5191 | 2017-12-05 21:43:52 -0800 | [diff] [blame] | 318 | link->add_key_in_what()->set_key(WAKE_LOCK_UID_KEY_ID); |
Yao Chen | 5154a379 | 2017-10-30 22:57:06 -0700 | [diff] [blame] | 319 | link->add_key_in_condition()->set_key(APP_USAGE_UID_KEY_ID); |
| 320 | |
| 321 | // Duration of an app holding any wl, while screen on and app in background |
| 322 | durationMetric = config.add_duration_metric(); |
Stefan Lafon | 7c8f0a5 | 2017-11-21 14:49:09 -0800 | [diff] [blame] | 323 | durationMetric->set_name("METRIC_7"); |
Yao Chen | 5154a379 | 2017-10-30 22:57:06 -0700 | [diff] [blame] | 324 | durationMetric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); |
Stefan Lafon | cfed20b | 2017-11-18 09:26:53 -0800 | [diff] [blame] | 325 | durationMetric->set_aggregation_type(DurationMetric_AggregationType_MAX_SPARSE); |
Yao Chen | 967b205 | 2017-11-07 16:36:43 -0800 | [diff] [blame] | 326 | durationMetric->set_what("WL_HELD_PER_APP_PER_NAME"); |
Yao Chen | 5c925ad | 2017-11-15 14:15:46 -0800 | [diff] [blame] | 327 | durationMetric->set_condition("APP_IS_BACKGROUND_AND_SCREEN_ON"); |
Yao Chen | 5154a379 | 2017-10-30 22:57:06 -0700 | [diff] [blame] | 328 | link = durationMetric->add_links(); |
| 329 | link->set_condition("APP_IS_BACKGROUND"); |
Stefan Lafon | a5b5191 | 2017-12-05 21:43:52 -0800 | [diff] [blame] | 330 | link->add_key_in_what()->set_key(WAKE_LOCK_UID_KEY_ID); |
Yao Chen | 5154a379 | 2017-10-30 22:57:06 -0700 | [diff] [blame] | 331 | link->add_key_in_condition()->set_key(APP_USAGE_UID_KEY_ID); |
| 332 | |
| 333 | // Duration of screen on time. |
| 334 | durationMetric = config.add_duration_metric(); |
Stefan Lafon | 7c8f0a5 | 2017-11-21 14:49:09 -0800 | [diff] [blame] | 335 | durationMetric->set_name("METRIC_8"); |
Yangster | 1d4d686 | 2017-10-31 12:58:51 -0700 | [diff] [blame] | 336 | durationMetric->mutable_bucket()->set_bucket_size_millis(10 * 1000L); |
Stefan Lafon | cfed20b | 2017-11-18 09:26:53 -0800 | [diff] [blame] | 337 | durationMetric->set_aggregation_type(DurationMetric_AggregationType_SUM); |
Yao Chen | 5154a379 | 2017-10-30 22:57:06 -0700 | [diff] [blame] | 338 | durationMetric->set_what("SCREEN_IS_ON"); |
| 339 | |
Bookatz | 450099d | 2017-11-30 17:09:30 -0800 | [diff] [blame] | 340 | // Anomaly threshold for background count. |
Yao Chen | f09569f | 2017-12-13 17:00:51 -0800 | [diff] [blame] | 341 | // TODO(b/70627390): Uncomment once the bug is fixed. |
| 342 | /* |
Bookatz | 450099d | 2017-11-30 17:09:30 -0800 | [diff] [blame] | 343 | alert = config.add_alert(); |
| 344 | alert->set_name("ALERT_8"); |
| 345 | alert->set_metric_name("METRIC_8"); |
| 346 | alert->set_number_of_buckets(4); |
| 347 | alert->set_trigger_if_sum_gt(2000000000); // 2 seconds |
| 348 | alert->set_refractory_period_secs(120); |
| 349 | details = alert->mutable_incidentd_details(); |
Yao Chen | f09569f | 2017-12-13 17:00:51 -0800 | [diff] [blame] | 350 | details->add_section(-1);*/ |
Bookatz | 450099d | 2017-11-30 17:09:30 -0800 | [diff] [blame] | 351 | |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 352 | // Value metric to count KERNEL_WAKELOCK when screen turned on |
| 353 | ValueMetric* valueMetric = config.add_value_metric(); |
Stefan Lafon | 7c8f0a5 | 2017-11-21 14:49:09 -0800 | [diff] [blame] | 354 | valueMetric->set_name("METRIC_6"); |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 355 | valueMetric->set_what("KERNEL_WAKELOCK"); |
Chenjie Yu | 6842a8c | 2017-12-05 22:34:34 -0800 | [diff] [blame] | 356 | valueMetric->set_value_field(KERNEL_WAKELOCK_COUNT_KEY); |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 357 | valueMetric->set_condition("SCREEN_IS_ON"); |
| 358 | keyMatcher = valueMetric->add_dimension(); |
| 359 | keyMatcher->set_key(KERNEL_WAKELOCK_NAME_KEY); |
| 360 | // This is for testing easier. We should never set bucket size this small. |
| 361 | valueMetric->mutable_bucket()->set_bucket_size_millis(60 * 1000L); |
| 362 | |
Yao Chen | 5110bed | 2017-10-23 12:50:02 -0700 | [diff] [blame] | 363 | // Add an EventMetric to log process state change events. |
| 364 | EventMetric* eventMetric = config.add_event_metric(); |
Stefan Lafon | 7c8f0a5 | 2017-11-21 14:49:09 -0800 | [diff] [blame] | 365 | eventMetric->set_name("METRIC_9"); |
Yao Chen | 5110bed | 2017-10-23 12:50:02 -0700 | [diff] [blame] | 366 | eventMetric->set_what("SCREEN_TURNED_ON"); |
| 367 | |
Yangster | 1d4d686 | 2017-10-31 12:58:51 -0700 | [diff] [blame] | 368 | // Add an GaugeMetric. |
| 369 | GaugeMetric* gaugeMetric = config.add_gauge_metric(); |
Stefan Lafon | 7c8f0a5 | 2017-11-21 14:49:09 -0800 | [diff] [blame] | 370 | gaugeMetric->set_name("METRIC_10"); |
Yangster | 1d4d686 | 2017-10-31 12:58:51 -0700 | [diff] [blame] | 371 | gaugeMetric->set_what("DEVICE_TEMPERATURE"); |
Chenjie Yu | d9dfda7 | 2017-12-11 17:41:20 -0800 | [diff] [blame^] | 372 | gaugeMetric->mutable_gauge_fields()->add_field_num(DEVICE_TEMPERATURE_KEY); |
Yangster | 1d4d686 | 2017-10-31 12:58:51 -0700 | [diff] [blame] | 373 | gaugeMetric->mutable_bucket()->set_bucket_size_millis(60 * 1000L); |
| 374 | |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 375 | // Event matchers............ |
Stefan Lafon | b8c9aa8 | 2017-12-03 14:27:25 -0800 | [diff] [blame] | 376 | AtomMatcher* temperatureAtomMatcher = config.add_atom_matcher(); |
| 377 | temperatureAtomMatcher->set_name("DEVICE_TEMPERATURE"); |
| 378 | temperatureAtomMatcher->mutable_simple_atom_matcher()->set_tag( |
Yangster | 1d4d686 | 2017-10-31 12:58:51 -0700 | [diff] [blame] | 379 | DEVICE_TEMPERATURE_TAG_ID); |
| 380 | |
Stefan Lafon | b8c9aa8 | 2017-12-03 14:27:25 -0800 | [diff] [blame] | 381 | AtomMatcher* eventMatcher = config.add_atom_matcher(); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 382 | eventMatcher->set_name("SCREEN_TURNED_ON"); |
Stefan Lafon | b8c9aa8 | 2017-12-03 14:27:25 -0800 | [diff] [blame] | 383 | SimpleAtomMatcher* simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher(); |
| 384 | simpleAtomMatcher->set_tag(SCREEN_EVENT_TAG_ID); |
| 385 | KeyValueMatcher* keyValueMatcher = simpleAtomMatcher->add_key_value_matcher(); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 386 | keyValueMatcher->mutable_key_matcher()->set_key(SCREEN_EVENT_STATE_KEY); |
| 387 | keyValueMatcher->set_eq_int(SCREEN_EVENT_ON_VALUE); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 388 | |
Stefan Lafon | b8c9aa8 | 2017-12-03 14:27:25 -0800 | [diff] [blame] | 389 | eventMatcher = config.add_atom_matcher(); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 390 | eventMatcher->set_name("SCREEN_TURNED_OFF"); |
Stefan Lafon | b8c9aa8 | 2017-12-03 14:27:25 -0800 | [diff] [blame] | 391 | simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher(); |
| 392 | simpleAtomMatcher->set_tag(SCREEN_EVENT_TAG_ID); |
| 393 | keyValueMatcher = simpleAtomMatcher->add_key_value_matcher(); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 394 | keyValueMatcher->mutable_key_matcher()->set_key(SCREEN_EVENT_STATE_KEY); |
| 395 | keyValueMatcher->set_eq_int(SCREEN_EVENT_OFF_VALUE); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 396 | |
Stefan Lafon | b8c9aa8 | 2017-12-03 14:27:25 -0800 | [diff] [blame] | 397 | eventMatcher = config.add_atom_matcher(); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 398 | eventMatcher->set_name("PROCESS_STATE_CHANGE"); |
Stefan Lafon | b8c9aa8 | 2017-12-03 14:27:25 -0800 | [diff] [blame] | 399 | simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher(); |
| 400 | simpleAtomMatcher->set_tag(UID_PROCESS_STATE_TAG_ID); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 401 | |
Stefan Lafon | b8c9aa8 | 2017-12-03 14:27:25 -0800 | [diff] [blame] | 402 | eventMatcher = config.add_atom_matcher(); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 403 | eventMatcher->set_name("APP_GOES_BACKGROUND"); |
Stefan Lafon | b8c9aa8 | 2017-12-03 14:27:25 -0800 | [diff] [blame] | 404 | simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher(); |
| 405 | simpleAtomMatcher->set_tag(APP_USAGE_ID); |
| 406 | keyValueMatcher = simpleAtomMatcher->add_key_value_matcher(); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 407 | keyValueMatcher->mutable_key_matcher()->set_key(APP_USAGE_STATE_KEY); |
| 408 | keyValueMatcher->set_eq_int(APP_USAGE_BACKGROUND); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 409 | |
Stefan Lafon | b8c9aa8 | 2017-12-03 14:27:25 -0800 | [diff] [blame] | 410 | eventMatcher = config.add_atom_matcher(); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 411 | eventMatcher->set_name("APP_GOES_FOREGROUND"); |
Stefan Lafon | b8c9aa8 | 2017-12-03 14:27:25 -0800 | [diff] [blame] | 412 | simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher(); |
| 413 | simpleAtomMatcher->set_tag(APP_USAGE_ID); |
| 414 | keyValueMatcher = simpleAtomMatcher->add_key_value_matcher(); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 415 | keyValueMatcher->mutable_key_matcher()->set_key(APP_USAGE_STATE_KEY); |
| 416 | keyValueMatcher->set_eq_int(APP_USAGE_FOREGROUND); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 417 | |
Stefan Lafon | b8c9aa8 | 2017-12-03 14:27:25 -0800 | [diff] [blame] | 418 | eventMatcher = config.add_atom_matcher(); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 419 | eventMatcher->set_name("APP_GET_WL"); |
Stefan Lafon | b8c9aa8 | 2017-12-03 14:27:25 -0800 | [diff] [blame] | 420 | simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher(); |
| 421 | simpleAtomMatcher->set_tag(WAKE_LOCK_TAG_ID); |
| 422 | keyValueMatcher = simpleAtomMatcher->add_key_value_matcher(); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 423 | keyValueMatcher->mutable_key_matcher()->set_key(WAKE_LOCK_STATE_KEY); |
| 424 | keyValueMatcher->set_eq_int(WAKE_LOCK_ACQUIRE_VALUE); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 425 | |
Stefan Lafon | b8c9aa8 | 2017-12-03 14:27:25 -0800 | [diff] [blame] | 426 | eventMatcher = config.add_atom_matcher(); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 427 | eventMatcher->set_name("APP_RELEASE_WL"); |
Stefan Lafon | b8c9aa8 | 2017-12-03 14:27:25 -0800 | [diff] [blame] | 428 | simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher(); |
| 429 | simpleAtomMatcher->set_tag(WAKE_LOCK_TAG_ID); |
| 430 | keyValueMatcher = simpleAtomMatcher->add_key_value_matcher(); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 431 | keyValueMatcher->mutable_key_matcher()->set_key(WAKE_LOCK_STATE_KEY); |
| 432 | keyValueMatcher->set_eq_int(WAKE_LOCK_RELEASE_VALUE); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 433 | |
Chenjie Yu | 5305e1d | 2017-10-31 13:49:36 -0700 | [diff] [blame] | 434 | // pulled events |
Stefan Lafon | b8c9aa8 | 2017-12-03 14:27:25 -0800 | [diff] [blame] | 435 | eventMatcher = config.add_atom_matcher(); |
Chenjie Yu | 5305e1d | 2017-10-31 13:49:36 -0700 | [diff] [blame] | 436 | eventMatcher->set_name("KERNEL_WAKELOCK"); |
Stefan Lafon | b8c9aa8 | 2017-12-03 14:27:25 -0800 | [diff] [blame] | 437 | simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher(); |
| 438 | simpleAtomMatcher->set_tag(KERNEL_WAKELOCK_TAG_ID); |
Chenjie Yu | 5305e1d | 2017-10-31 13:49:36 -0700 | [diff] [blame] | 439 | |
Stefan Lafon | 12d01fa | 2017-12-04 20:56:09 -0800 | [diff] [blame] | 440 | // Predicates............. |
| 441 | Predicate* predicate = config.add_predicate(); |
| 442 | predicate->set_name("SCREEN_IS_ON"); |
| 443 | SimplePredicate* simplePredicate = predicate->mutable_simple_predicate(); |
| 444 | simplePredicate->set_start("SCREEN_TURNED_ON"); |
| 445 | simplePredicate->set_stop("SCREEN_TURNED_OFF"); |
| 446 | simplePredicate->set_count_nesting(false); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 447 | |
Stefan Lafon | 12d01fa | 2017-12-04 20:56:09 -0800 | [diff] [blame] | 448 | predicate = config.add_predicate(); |
| 449 | predicate->set_name("SCREEN_IS_OFF"); |
| 450 | simplePredicate = predicate->mutable_simple_predicate(); |
| 451 | simplePredicate->set_start("SCREEN_TURNED_OFF"); |
| 452 | simplePredicate->set_stop("SCREEN_TURNED_ON"); |
| 453 | simplePredicate->set_count_nesting(false); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 454 | |
Stefan Lafon | 12d01fa | 2017-12-04 20:56:09 -0800 | [diff] [blame] | 455 | predicate = config.add_predicate(); |
| 456 | predicate->set_name("APP_IS_BACKGROUND"); |
| 457 | simplePredicate = predicate->mutable_simple_predicate(); |
| 458 | simplePredicate->set_start("APP_GOES_BACKGROUND"); |
| 459 | simplePredicate->set_stop("APP_GOES_FOREGROUND"); |
| 460 | KeyMatcher* predicate_dimension1 = simplePredicate->add_dimension(); |
| 461 | predicate_dimension1->set_key(APP_USAGE_UID_KEY_ID); |
| 462 | simplePredicate->set_count_nesting(false); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 463 | |
Stefan Lafon | 12d01fa | 2017-12-04 20:56:09 -0800 | [diff] [blame] | 464 | predicate = config.add_predicate(); |
| 465 | predicate->set_name("APP_IS_BACKGROUND_AND_SCREEN_ON"); |
| 466 | Predicate_Combination* combination_predicate = predicate->mutable_combination(); |
| 467 | combination_predicate->set_operation(LogicalOperation::AND); |
| 468 | combination_predicate->add_predicate("APP_IS_BACKGROUND"); |
| 469 | combination_predicate->add_predicate("SCREEN_IS_ON"); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 470 | |
Stefan Lafon | 12d01fa | 2017-12-04 20:56:09 -0800 | [diff] [blame] | 471 | predicate = config.add_predicate(); |
| 472 | predicate->set_name("WL_HELD_PER_APP_PER_NAME"); |
| 473 | simplePredicate = predicate->mutable_simple_predicate(); |
| 474 | simplePredicate->set_start("APP_GET_WL"); |
| 475 | simplePredicate->set_stop("APP_RELEASE_WL"); |
| 476 | KeyMatcher* predicate_dimension = simplePredicate->add_dimension(); |
| 477 | predicate_dimension->set_key(WAKE_LOCK_UID_KEY_ID); |
| 478 | predicate_dimension = simplePredicate->add_dimension(); |
| 479 | predicate_dimension->set_key(WAKE_LOCK_NAME_KEY); |
| 480 | simplePredicate->set_count_nesting(true); |
Yao Chen | 967b205 | 2017-11-07 16:36:43 -0800 | [diff] [blame] | 481 | |
Stefan Lafon | 12d01fa | 2017-12-04 20:56:09 -0800 | [diff] [blame] | 482 | predicate = config.add_predicate(); |
| 483 | predicate->set_name("WL_HELD_PER_APP"); |
| 484 | simplePredicate = predicate->mutable_simple_predicate(); |
| 485 | simplePredicate->set_start("APP_GET_WL"); |
| 486 | simplePredicate->set_stop("APP_RELEASE_WL"); |
| 487 | simplePredicate->set_initial_value(SimplePredicate_InitialValue_FALSE); |
| 488 | predicate_dimension = simplePredicate->add_dimension(); |
| 489 | predicate_dimension->set_key(WAKE_LOCK_UID_KEY_ID); |
| 490 | simplePredicate->set_count_nesting(true); |
Yao Chen | 5154a379 | 2017-10-30 22:57:06 -0700 | [diff] [blame] | 491 | |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 492 | return config; |
| 493 | } |
| 494 | |
| 495 | } // namespace statsd |
| 496 | } // namespace os |
| 497 | } // namespace android |