Loading packages/Shell/res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -76,4 +76,7 @@ <!-- Label of button that save bugreport details. --> <string name="save">Save</string> <!-- Title displayed in the activity chooser used to share the bug report [CHAR LIMIT=30]--> <string name="bugreport_intent_chooser_title">Share Bug report</string> </resources> packages/Shell/src/com/android/shell/BugreportProgressService.java +6 −1 Original line number Diff line number Diff line Loading @@ -1000,12 +1000,17 @@ public class BugreportProgressService extends Service { notifIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // Send the share intent... mContext.startActivity(notifIntent); sendShareIntent(mContext, notifIntent); // ... and stop watching this process. stopProgress(id); } static void sendShareIntent(Context context, Intent intent) { context.startActivity(Intent.createChooser(intent, context.getResources().getText(R.string.bugreport_intent_chooser_title))); } /** * Sends a notification indicating the bugreport has finished so use can share it. */ Loading packages/Shell/src/com/android/shell/BugreportWarningActivity.java +2 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static com.android.shell.BugreportPrefs.STATE_SHOW; import static com.android.shell.BugreportPrefs.STATE_UNKNOWN; import static com.android.shell.BugreportPrefs.getWarningState; import static com.android.shell.BugreportPrefs.setWarningState; import static com.android.shell.BugreportProgressService.sendShareIntent; import android.app.AlertDialog; import android.content.DialogInterface; Loading Loading @@ -78,7 +79,7 @@ public class BugreportWarningActivity extends AlertActivity if (which == AlertDialog.BUTTON_POSITIVE) { // Remember confirm state, and launch target setWarningState(this, mConfirmRepeat.isChecked() ? STATE_HIDE : STATE_SHOW); startActivity(mSendIntent); sendShareIntent(this, mSendIntent); } finish(); Loading packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -175,6 +175,8 @@ public class BugreportReceiverTest extends InstrumentationTestCase { mDescription = sb.toString(); setWarningState(mContext, STATE_HIDE); mUiBot.turnScreenOn(); } public void testProgress() throws Exception { Loading packages/Shell/tests/src/com/android/shell/UiBot.java +10 −43 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import android.support.test.uiautomator.By; import android.support.test.uiautomator.UiDevice; import android.support.test.uiautomator.UiObject; import android.support.test.uiautomator.UiObjectNotFoundException; import android.support.test.uiautomator.UiScrollable; import android.support.test.uiautomator.UiSelector; import android.support.test.uiautomator.Until; import android.util.Log; Loading Loading @@ -156,56 +155,24 @@ final class UiBot { } /** * Chooses a given activity to handle an Intent, using the "Just Once" button. * Chooses a given activity to handle an Intent. * * @param name name of the activity as displayed in the UI (typically the value set by * {@code android:label} in the manifest). */ // TODO: UI Automator should provide such logic. public void chooseActivity(String name) { // First check if the activity is the default option. String shareText = "Share with " + name; Log.v(TAG, "Waiting for ActivityChooser text: '" + shareText + "'"); boolean gotIt = mDevice.wait(Until.hasObject(By.text(shareText)), mTimeout); boolean justOnceHack = false; if (gotIt) { Log.v(TAG, "Found activity " + name + ", it's the default action"); clickJustOnce(); } else { // Since it's not, need to find it in the scrollable list... Log.v(TAG, "Activity " + name + " is not default action"); UiScrollable activitiesList = new UiScrollable(new UiSelector().scrollable(true)); try { activitiesList.scrollForward(); } catch (UiObjectNotFoundException e) { // TODO: for some paranormal issue, the first time a test is run the scrollable // activity list is displayed but calling scrollForwad() (or even isScrollable()) // throws a "UiObjectNotFoundException: UiSelector[SCROLLABLE=true]" exception justOnceHack = true; Log.d(TAG, "could not scroll forward", e); } // It uses an intent chooser now, so just getting the activity by text is enough... UiObject activity = getVisibleObject(name); // ... then select it. click(activity, name); if (justOnceHack) { clickJustOnce(); } } } private void clickJustOnce() { boolean gotIt = mDevice.wait(Until.hasObject(By.res("android", "button_once")), mTimeout); assertTrue("'Just Once' button not visible yet", gotIt); UiObject justOnce = mDevice .findObject(new UiSelector().resourceId("android:id/button_once")); assertTrue("'Just Once' button not found", justOnce.exists()); click(justOnce, "Just Once"); } public void pressBack() { mDevice.pressBack(); } public void turnScreenOn() throws Exception { mDevice.executeShellCommand("input keyevent KEYCODE_WAKEUP"); mDevice.executeShellCommand("wm dismiss-keyguard"); } } Loading
packages/Shell/res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -76,4 +76,7 @@ <!-- Label of button that save bugreport details. --> <string name="save">Save</string> <!-- Title displayed in the activity chooser used to share the bug report [CHAR LIMIT=30]--> <string name="bugreport_intent_chooser_title">Share Bug report</string> </resources>
packages/Shell/src/com/android/shell/BugreportProgressService.java +6 −1 Original line number Diff line number Diff line Loading @@ -1000,12 +1000,17 @@ public class BugreportProgressService extends Service { notifIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // Send the share intent... mContext.startActivity(notifIntent); sendShareIntent(mContext, notifIntent); // ... and stop watching this process. stopProgress(id); } static void sendShareIntent(Context context, Intent intent) { context.startActivity(Intent.createChooser(intent, context.getResources().getText(R.string.bugreport_intent_chooser_title))); } /** * Sends a notification indicating the bugreport has finished so use can share it. */ Loading
packages/Shell/src/com/android/shell/BugreportWarningActivity.java +2 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static com.android.shell.BugreportPrefs.STATE_SHOW; import static com.android.shell.BugreportPrefs.STATE_UNKNOWN; import static com.android.shell.BugreportPrefs.getWarningState; import static com.android.shell.BugreportPrefs.setWarningState; import static com.android.shell.BugreportProgressService.sendShareIntent; import android.app.AlertDialog; import android.content.DialogInterface; Loading Loading @@ -78,7 +79,7 @@ public class BugreportWarningActivity extends AlertActivity if (which == AlertDialog.BUTTON_POSITIVE) { // Remember confirm state, and launch target setWarningState(this, mConfirmRepeat.isChecked() ? STATE_HIDE : STATE_SHOW); startActivity(mSendIntent); sendShareIntent(this, mSendIntent); } finish(); Loading
packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -175,6 +175,8 @@ public class BugreportReceiverTest extends InstrumentationTestCase { mDescription = sb.toString(); setWarningState(mContext, STATE_HIDE); mUiBot.turnScreenOn(); } public void testProgress() throws Exception { Loading
packages/Shell/tests/src/com/android/shell/UiBot.java +10 −43 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import android.support.test.uiautomator.By; import android.support.test.uiautomator.UiDevice; import android.support.test.uiautomator.UiObject; import android.support.test.uiautomator.UiObjectNotFoundException; import android.support.test.uiautomator.UiScrollable; import android.support.test.uiautomator.UiSelector; import android.support.test.uiautomator.Until; import android.util.Log; Loading Loading @@ -156,56 +155,24 @@ final class UiBot { } /** * Chooses a given activity to handle an Intent, using the "Just Once" button. * Chooses a given activity to handle an Intent. * * @param name name of the activity as displayed in the UI (typically the value set by * {@code android:label} in the manifest). */ // TODO: UI Automator should provide such logic. public void chooseActivity(String name) { // First check if the activity is the default option. String shareText = "Share with " + name; Log.v(TAG, "Waiting for ActivityChooser text: '" + shareText + "'"); boolean gotIt = mDevice.wait(Until.hasObject(By.text(shareText)), mTimeout); boolean justOnceHack = false; if (gotIt) { Log.v(TAG, "Found activity " + name + ", it's the default action"); clickJustOnce(); } else { // Since it's not, need to find it in the scrollable list... Log.v(TAG, "Activity " + name + " is not default action"); UiScrollable activitiesList = new UiScrollable(new UiSelector().scrollable(true)); try { activitiesList.scrollForward(); } catch (UiObjectNotFoundException e) { // TODO: for some paranormal issue, the first time a test is run the scrollable // activity list is displayed but calling scrollForwad() (or even isScrollable()) // throws a "UiObjectNotFoundException: UiSelector[SCROLLABLE=true]" exception justOnceHack = true; Log.d(TAG, "could not scroll forward", e); } // It uses an intent chooser now, so just getting the activity by text is enough... UiObject activity = getVisibleObject(name); // ... then select it. click(activity, name); if (justOnceHack) { clickJustOnce(); } } } private void clickJustOnce() { boolean gotIt = mDevice.wait(Until.hasObject(By.res("android", "button_once")), mTimeout); assertTrue("'Just Once' button not visible yet", gotIt); UiObject justOnce = mDevice .findObject(new UiSelector().resourceId("android:id/button_once")); assertTrue("'Just Once' button not found", justOnce.exists()); click(justOnce, "Just Once"); } public void pressBack() { mDevice.pressBack(); } public void turnScreenOn() throws Exception { mDevice.executeShellCommand("input keyevent KEYCODE_WAKEUP"); mDevice.executeShellCommand("wm dismiss-keyguard"); } }