diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-08-16 15:25:08 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-08-16 15:25:08 +0000 |
commit | ffdbf89ad51e81f491c9612a348bf68d1adae02d (patch) | |
tree | a298f25aabaea8a85728abd8d339249ceb722b55 | |
parent | d51230da37c3e9eda165534ef2eeda031ca3aa2b (diff) | |
parent | 0ab3b35a4afb77e642265eb242d8d2c62ee4efd1 (diff) | |
download | platform_testing-ffdbf89ad51e81f491c9612a348bf68d1adae02d.tar.gz |
Snap for 8953554 from 0ab3b35a4afb77e642265eb242d8d2c62ee4efd1 to mainline-wifi-releaseaml_wif_331112000aml_wif_331016070
Change-Id: I851f65d5c0e57b985c835ac96d0ccabfe0c606ba
-rw-r--r-- | libraries/device-collectors/src/main/java/android/device/collectors/PerfettoListener.java | 9 | ||||
-rw-r--r-- | libraries/health/rules/src/android/platform/test/rule/AddAppToHomescreenRule.java | 27 |
2 files changed, 25 insertions, 11 deletions
diff --git a/libraries/device-collectors/src/main/java/android/device/collectors/PerfettoListener.java b/libraries/device-collectors/src/main/java/android/device/collectors/PerfettoListener.java index d24e0fc1c..875f60294 100644 --- a/libraries/device-collectors/src/main/java/android/device/collectors/PerfettoListener.java +++ b/libraries/device-collectors/src/main/java/android/device/collectors/PerfettoListener.java @@ -49,7 +49,7 @@ public class PerfettoListener extends BaseMetricListener { // Default perfetto config file name when text proto config is used. private static final String DEFAULT_TEXT_CONFIG_FILE = "trace_config.textproto"; // Default wait time before stopping the perfetto trace. - private static final String DEFAULT_WAIT_TIME_MSECS = "3000"; + private static final String DEFAULT_WAIT_TIME_MSECS = "0"; // Option to pass the folder name which contains the perfetto trace config file. private static final String PERFETTO_CONFIG_ROOT_DIR_ARG = "perfetto_config_root_dir"; // Default folder name to look for the perfetto config file. @@ -77,7 +77,7 @@ public class PerfettoListener extends BaseMetricListener { // perfetto trace. public static final String PERFETTO_START_WAIT_TIME_ARG = "perfetto_start_wait_time_ms"; // Default wait time before starting the perfetto trace. - public static final String DEFAULT_START_WAIT_TIME_MSECS = "3000"; + public static final String DEFAULT_START_WAIT_TIME_MSECS = "0"; // Regular expression pattern to identify multiple spaces. public static final String SPACES_PATTERN = "\\s+"; // Space replacement value @@ -317,12 +317,11 @@ public class PerfettoListener extends BaseMetricListener { Boolean.parseBoolean(args.getString(HOLD_WAKELOCK_WHILE_COLLECTING)); // Wait time before stopping the perfetto trace collection after the test - // is completed. Defaulted to 3000 msecs if perfetto_wait_time_ms is not passed. - // TODO: b/118122395 for parsing failures. + // is completed. Defaulted to 0 msecs. mWaitTimeInMs = Long.parseLong(args.getString(PERFETTO_WAIT_TIME_ARG, DEFAULT_WAIT_TIME_MSECS)); - // TODO: b/165344369 to avoid wait time before starting the perfetto trace. + // Wait time before the perfetto trace is started. mWaitStartTimeInMs = Long.parseLong( args.getString( diff --git a/libraries/health/rules/src/android/platform/test/rule/AddAppToHomescreenRule.java b/libraries/health/rules/src/android/platform/test/rule/AddAppToHomescreenRule.java index 764cbdcc9..ac645c0c1 100644 --- a/libraries/health/rules/src/android/platform/test/rule/AddAppToHomescreenRule.java +++ b/libraries/health/rules/src/android/platform/test/rule/AddAppToHomescreenRule.java @@ -25,11 +25,16 @@ import org.junit.runner.Description; /** Drags an app to the homescreen for quick access. */ public class AddAppToHomescreenRule extends TestWatcher { - private final String LOG_TAG = AddAppToHomescreenRule.class.getSimpleName(); + private static final String LOG_TAG = AddAppToHomescreenRule.class.getSimpleName(); + private static final String ADD_APP_TO_HOMESCREEN = "add-app-to-homescreen"; + private static final String HOME_SCREEN_APP_NAME = "homescreen-app-name"; private final LauncherInstrumentation mLauncher = new LauncherInstrumentation(); - private final String mAppName; + private String mAppName; + + public AddAppToHomescreenRule() { + } public AddAppToHomescreenRule(String appName) { mAppName = appName; @@ -37,14 +42,24 @@ public class AddAppToHomescreenRule extends TestWatcher { @Override protected void starting(Description description) { + if (!Boolean.parseBoolean(getArguments().getString(ADD_APP_TO_HOMESCREEN, "false"))) { + Log.d(LOG_TAG, "Adding the app icon to the homescreen is disabled."); + return; + } + + String appName = getArguments().getString(HOME_SCREEN_APP_NAME, ""); + if(appName != null && !appName.isEmpty()) { + mAppName = appName; + } + + // TODO(b/241957916): Use the #goHome method when it's synced to AOSP. mLauncher.pressHome(); Workspace workspace = mLauncher.getWorkspace(); if (workspace.tryGetWorkspaceAppIcon(mAppName) != null) { - Log.d(LOG_TAG, "App icon is already on the homescreen."); + Log.d(LOG_TAG, String.format("App icon (%s) is already on the homescreen.", mAppName)); } else { - Log.d(LOG_TAG, "Adding app icon to home screen."); - mLauncher - .getWorkspace() + Log.d(LOG_TAG, String.format("Adding app icon (%s) to the homescreen.", mAppName)); + workspace .switchToAllApps() .getAppIcon(mAppName) .dragToWorkspace(/* startsActivity */ false, /* isWidgetShortcut */ false); |