Merge "Added edi collector for app standby feature" into pi-dev am: a3e75de8cb
am: a6fbaa423d
Change-Id: If28146366006c93b6758aa5fafea374405ca6d65
diff --git a/build/device_info_package.mk b/build/device_info_package.mk
index a7bf688..5cc7cb5 100644
--- a/build/device_info_package.mk
+++ b/build/device_info_package.mk
@@ -23,6 +23,7 @@
android.permission.READ_PHONE_STATE \
android.permission.WRITE_EXTERNAL_STORAGE
DEVICE_INFO_ACTIVITIES += \
+ $(DEVICE_INFO_PACKAGE).AppStandbyDeviceInfo \
$(DEVICE_INFO_PACKAGE).ConfigurationDeviceInfo \
$(DEVICE_INFO_PACKAGE).CpuDeviceInfo \
$(DEVICE_INFO_PACKAGE).FeatureDeviceInfo \
diff --git a/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/AppStandbyDeviceInfo.java b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/AppStandbyDeviceInfo.java
new file mode 100644
index 0000000..9481407
--- /dev/null
+++ b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/AppStandbyDeviceInfo.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.compatibility.common.deviceinfo;
+
+import com.android.compatibility.common.util.DeviceInfoStore;
+import com.android.compatibility.common.util.SystemUtil;
+
+/**
+ * A device info collector that collects whether app standby was turned on or off in a device
+ */
+public final class AppStandbyDeviceInfo extends DeviceInfo {
+ private static final String KEY_APP_STANDBY_ENABLED = "app_standby_enabled";
+ private static final String CMD_IS_APP_STANDBY_ENABLED =
+ "dumpsys usagestats is-app-standby-enabled";
+
+ @Override
+ protected void collectDeviceInfo(DeviceInfoStore store) throws Exception {
+ store.addResult(KEY_APP_STANDBY_ENABLED, getAppStandbyEnabled());
+ }
+
+ private boolean getAppStandbyEnabled() {
+ final String result = SystemUtil.runShellCommand(CMD_IS_APP_STANDBY_ENABLED).trim();
+ return Boolean.parseBoolean(result);
+ }
+}