release-request-9ea7e78e-6b61-49c5-9e1f-cea25771451a-for-aosp-emu-2.5-release-4321995 snap-temp-L97200000100436973

Change-Id: I2aa2b60be5ff2375bed052d758236be976af5623
diff --git a/emu_test/config/boot_cfg.csv b/emu_test/config/boot_cfg.csv
index 0c9b10c..2d6b8fc 100644
--- a/emu_test/config/boot_cfg.csv
+++ b/emu_test/config/boot_cfg.csv
@@ -1,5 +1,7 @@
 Device Config,,,,,,,Linux,,,,Windows,,,,,MacOSX,,,
 API*,TAG*,ABI*,DEVICE,RAM,GPU,ORI,Ubuntu 12.04 HD Graphics 4000,Ubuntu 14.04 HD 4400,Ubuntu 14.04 Quadro 600,Ubuntu 15.04 Quadro K600,Win 7 32-bit HD 4400,Win 7 64-bit HD 4400,Win 8 64-bit Quadro 600,Win 8.1 64-bit Quadro 600,Win 10 64-bit Quadro 600,Mac 10.10.5 Intel HD 5000,Mac 10.10.5 Iris Pro,Mac 10.8.5 Intel HD 5000,Mac 10.11.1 Iris Pro
+API P,google_apis,x86,Nexus 6P,2048,yes,master,P,P,P,P,P,P,P,P,P,P,P,P,P
+API P,google_apis,x86_64,Nexus 6P,2048,yes,master,P,P,P,P,P,P,P,P,P,P,P,P,P
 API 26,android-tv,x86,Android TV (1080p),2048,yes,public,P,P,P,P,P,P,P,P,P,P,P,P,P
 ,google_apis,x86,Nexus 6P,2048,yes,public,P,P,P,P,P,P,P,P,P,P,P,P,P
 ,google_apis_playstore,x86,Nexus 6P,2048,yes,public,P,P,P,P,P,P,P,P,P,P,P,P,P
diff --git a/emu_test/utils/download_unzip_image.py b/emu_test/utils/download_unzip_image.py
index 21fdc83..ab6b120 100644
--- a/emu_test/utils/download_unzip_image.py
+++ b/emu_test/utils/download_unzip_image.py
@@ -56,7 +56,7 @@
     elif 'jb-mr2-emu' in branch_name:
       api = '18'
     elif 'master' in branch_name:
-      api = 'O'
+      api = 'P'
 
     else:
       raise ValueError("unsupported image %s", branch_name)
diff --git a/system_image_uitests/app/build.gradle b/system_image_uitests/app/build.gradle
index 0da275a..b636a19 100644
--- a/system_image_uitests/app/build.gradle
+++ b/system_image_uitests/app/build.gradle
@@ -2,7 +2,7 @@
 
 android {
     compileSdkVersion 25
-    buildToolsVersion "24.0.3"
+    buildToolsVersion '25.0.0'
 
     compileOptions {
         sourceCompatibility JavaVersion.VERSION_1_7
diff --git a/system_image_uitests/app/src/androidTest/java/com/android/devtools/systemimage/uitest/smoke/NetworkIOTest.java b/system_image_uitests/app/src/androidTest/java/com/android/devtools/systemimage/uitest/smoke/NetworkIOTest.java
index 7a1b62d..b281fe9 100644
--- a/system_image_uitests/app/src/androidTest/java/com/android/devtools/systemimage/uitest/smoke/NetworkIOTest.java
+++ b/system_image_uitests/app/src/androidTest/java/com/android/devtools/systemimage/uitest/smoke/NetworkIOTest.java
@@ -176,24 +176,19 @@
         }
     }
 
-    private UiObject2 navigateToDataSwitch(Instrumentation instrumentation) throws UiObjectNotFoundException {
+    private UiObject2 navigateToDataSwitch(Instrumentation instrumentation, String label) throws UiObjectNotFoundException {
         final UiDevice device = UiDevice.getInstance(instrumentation);
         String containerRes = (testFramework.getApi() >= 24) ?
                 Res.NETWORK_SWITCHES_RECYCLER_VIEW_RES : Res.NETWORK_SWITCHES_CONTAINER_RES;
-        String dataSwitch = (testFramework.getApi() >= 26) ? "Mobile data" : "Cellular data";
-        String label = "Data usage";
+        String[] path = testFramework.getApi() >= 26 ? new String[] {"Settings", "Network & Internet", "Data Usage"} :
+                new String[] {"Settings", "Data Usage"};
 
-        if (testFramework.getApi() >= 26) {
-            SettingsUtil.openItem(instrumentation, "Network & Internet");
-            device.findObject(new UiSelector().text(label)).clickAndWaitForNewWindow();
-        } else {
-            SettingsUtil.openItem(instrumentation, label);
-        }
+        AppLauncher.launchPath(instrumentation, path);
 
         return UiAutomatorPlus.findObjectByRelative(
                 instrumentation,
                 By.clazz("android.widget.Switch"),
-                By.text(dataSwitch),
+                By.text(label),
                 By.res(containerRes));
     }
 
@@ -221,10 +216,10 @@
     public void toggleCellularDataOff() throws Exception {
         final Instrumentation instrumentation = testFramework.getInstrumentation();
         UiDevice device = UiDevice.getInstance(instrumentation);
-        // TODO: Add a fixture method in AppLauncher class to launch a specified path.
         int api = testFramework.getApi();
+        String label = "Cellular data";
         if (api >= 23) {
-            UiObject2 dataSwitch = navigateToDataSwitch(instrumentation);
+            UiObject2 dataSwitch = navigateToDataSwitch(instrumentation, label);
 
             // Test requires "Cellular data" switch widget to start in the on state.
             if (!dataSwitch.isChecked()) {
@@ -284,10 +279,11 @@
     public void toggleCellularDataOn() throws Exception {
         final Instrumentation instrumentation = testFramework.getInstrumentation();
         UiDevice device = UiDevice.getInstance(instrumentation);
-        // TODO: Add a fixture method in AppLauncher class to launch a specified path.
         int api = testFramework.getApi();
+        String label = api >= 26 ? "Mobile data" : "Cellular data";
+
         if (api >= 23) {
-            UiObject2 dataSwitch = navigateToDataSwitch(instrumentation);
+            UiObject2 dataSwitch = navigateToDataSwitch(instrumentation, label);
 
             // Test requires "Cellular data" switch widget to start in the off state.
             if (dataSwitch.isChecked()) {
diff --git a/system_image_uitests/app/src/main/java/com/android/devtools/systemimage/uitest/utils/AppLauncher.java b/system_image_uitests/app/src/main/java/com/android/devtools/systemimage/uitest/utils/AppLauncher.java
index 06fcbdd..33b4a77 100644
--- a/system_image_uitests/app/src/main/java/com/android/devtools/systemimage/uitest/utils/AppLauncher.java
+++ b/system_image_uitests/app/src/main/java/com/android/devtools/systemimage/uitest/utils/AppLauncher.java
@@ -69,4 +69,29 @@
         }
         app.clickAndWaitForNewWindow();
     }
-}
+
+    /**
+     * Launches application in a specific path.
+     *
+     * @param instrumentation see {@link android.test.InstrumentationTestCase#getInstrumentation()
+     *                        getInstrumentation}
+     * @param appPath         the app path to launch
+     * @throws UiObjectNotFoundException if it fails to find a UI object.
+     */
+    public static void launchPath(Instrumentation instrumentation, String... appPath)
+            throws UiObjectNotFoundException {
+        final UiDevice device = UiDevice.getInstance(instrumentation);
+        launch(instrumentation, appPath[0]);
+
+        for (int i = 1; i < appPath.length; ++i) {
+            UiSelector selector = new UiSelector().textMatches("(?i)"+appPath[i]);
+            try {
+                UiScrollable scrollable = new UiScrollable(new UiSelector().scrollable(true));
+                scrollable.scrollIntoView(selector);
+            } catch (UiObjectNotFoundException e) {
+
+          }
+            device.findObject(selector).clickAndWaitForNewWindow();
+        }
+    }
+}
\ No newline at end of file
diff --git a/system_image_uitests/build.gradle b/system_image_uitests/build.gradle
index 74b2ab0..570c44b 100644
--- a/system_image_uitests/build.gradle
+++ b/system_image_uitests/build.gradle
@@ -5,7 +5,7 @@
         jcenter()
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:2.2.3'
+        classpath 'com.android.tools.build:gradle:3.0.0-alpha8'
 
         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files
diff --git a/system_image_uitests/gradle/wrapper/gradle-wrapper.properties b/system_image_uitests/gradle/wrapper/gradle-wrapper.properties
index 0f7fc23..a3c6081 100644
--- a/system_image_uitests/gradle/wrapper/gradle-wrapper.properties
+++ b/system_image_uitests/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Mon Dec 12 13:55:16 PST 2016
+#Tue Aug 29 11:49:51 PDT 2017
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-milestone-1-all.zip