Loading packages/Shell/res/layout/dialog_bugreport_info.xml +1 −1 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ android:paddingTop="15dp" android:paddingTop="15dp" android:paddingStart="24dp" android:paddingStart="24dp" android:paddingEnd="24dp" android:paddingEnd="24dp" android:focusableInTouchMode="true" android:layout_width="wrap_content" android:layout_width="wrap_content" android:layout_height="wrap_content"> android:layout_height="wrap_content"> <TextView <TextView Loading @@ -30,7 +31,6 @@ android:id="@+id/name" android:id="@+id/name" android:maxLength="30" android:maxLength="30" android:singleLine="true" android:singleLine="true" android:selectAllOnFocus="true" android:inputType="textNoSuggestions" android:inputType="textNoSuggestions" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="wrap_content"/> android:layout_height="wrap_content"/> Loading packages/Shell/src/com/android/shell/BugreportProgressService.java +14 −22 Original line number Original line Diff line number Diff line Loading @@ -454,21 +454,15 @@ public class BugreportProgressService extends Service { final String name = final String name = info.name != null ? info.name : mContext.getString(R.string.bugreport_unnamed); info.name != null ? info.name : mContext.getString(R.string.bugreport_unnamed); final Notification notification = new Notification.Builder(mContext) final Notification notification = newBaseNotification(mContext) .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb) .setContentTitle(title) .setContentTitle(title) .setTicker(title) .setTicker(title) .setContentText(name) .setContentText(name) .setContentInfo(percentText) .setContentInfo(percentText) .setProgress(info.max, info.progress, false) .setProgress(info.max, info.progress, false) .setOngoing(true) .setOngoing(true) .setLocalOnly(true) .setColor(mContext.getColor( com.android.internal.R.color.system_notification_accent_color)) .setContentIntent(infoPendingIntent) .setContentIntent(infoPendingIntent) .addAction(infoAction) .setActions(infoAction, screenshotAction, cancelAction) .addAction(screenshotAction) .addAction(cancelAction) .build(); .build(); if (info.finished) { if (info.finished) { Loading Loading @@ -928,17 +922,13 @@ public class BugreportProgressService extends Service { title = context.getString(R.string.bugreport_finished_title, info.id); title = context.getString(R.string.bugreport_finished_title, info.id); content = context.getString(R.string.bugreport_finished_text); content = context.getString(R.string.bugreport_finished_text); } } final Notification.Builder builder = new Notification.Builder(context) final Notification.Builder builder = newBaseNotification(context) .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb) .setContentTitle(title) .setContentTitle(title) .setTicker(title) .setTicker(title) .setContentText(content) .setContentText(content) .setContentIntent(PendingIntent.getService(context, info.id, shareIntent, .setContentIntent(PendingIntent.getService(context, info.id, shareIntent, PendingIntent.FLAG_UPDATE_CURRENT)) PendingIntent.FLAG_UPDATE_CURRENT)) .setDeleteIntent(newCancelIntent(context, info)) .setDeleteIntent(newCancelIntent(context, info)); .setLocalOnly(true) .setColor(context.getColor( com.android.internal.R.color.system_notification_accent_color)); if (!TextUtils.isEmpty(info.name)) { if (!TextUtils.isEmpty(info.name)) { builder.setContentInfo(info.name); builder.setContentInfo(info.name); Loading @@ -955,16 +945,21 @@ public class BugreportProgressService extends Service { */ */ private static void sendBugreportBeingUpdatedNotification(Context context, int id) { private static void sendBugreportBeingUpdatedNotification(Context context, int id) { final String title = context.getString(R.string.bugreport_updating_title); final String title = context.getString(R.string.bugreport_updating_title); final Notification.Builder builder = new Notification.Builder(context) final Notification.Builder builder = newBaseNotification(context) .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb) .setContentTitle(title) .setContentTitle(title) .setTicker(title) .setTicker(title) .setContentText(context.getString(R.string.bugreport_updating_wait)) .setContentText(context.getString(R.string.bugreport_updating_wait)); Log.v(TAG, "Sending 'Updating zip' notification for ID " + id + ": " + title); NotificationManager.from(context).notify(TAG, id, builder.build()); } private static Notification.Builder newBaseNotification(Context context) { return new Notification.Builder(context) .setCategory(Notification.CATEGORY_SYSTEM) .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb) .setLocalOnly(true) .setLocalOnly(true) .setColor(context.getColor( .setColor(context.getColor( com.android.internal.R.color.system_notification_accent_color)); com.android.internal.R.color.system_notification_accent_color)); Log.v(TAG, "Sending 'Updating zip' notification for ID " + id + ": " + title); NotificationManager.from(context).notify(TAG, id, builder.build()); } } /** /** Loading Loading @@ -1288,9 +1283,6 @@ public class BugreportProgressService extends Service { if (hasFocus) { if (hasFocus) { return; return; } } // Select-all is useful just initially, since the date-based filename is // full of hyphens. mInfoName.setSelectAllOnFocus(false); sanitizeName(); sanitizeName(); } } }); }); Loading packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java +18 −13 Original line number Original line Diff line number Diff line Loading @@ -291,6 +291,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { detailsUi.assertName(NAME); detailsUi.assertName(NAME); // Change name - it should have changed system property once focus is changed. // Change name - it should have changed system property once focus is changed. detailsUi.focusOnName(); detailsUi.nameField.setText(NEW_NAME); detailsUi.nameField.setText(NEW_NAME); detailsUi.focusAwayFromName(); detailsUi.focusAwayFromName(); assertPropertyValue(NAME_PROPERTY, NEW_NAME); assertPropertyValue(NAME_PROPERTY, NEW_NAME); Loading Loading @@ -966,40 +967,44 @@ public class BugreportReceiverTest extends InstrumentationTestCase { cancelButton = mUiBot.getObjectById("android:id/button2"); cancelButton = mUiBot.getObjectById("android:id/button2"); } } private void assertField(String name, UiObject field, String expected) { private void assertField(String name, UiObject field, String expected) try { throws UiObjectNotFoundException { String actual = field.getText().toString(); String actual = field.getText().toString(); assertEquals("Wrong value on field '" + name + "'", expected, actual); assertEquals("Wrong value on field '" + name + "'", expected, actual); } catch (UiObjectNotFoundException e) { // Should not happen... throw new IllegalStateException("field not found: " + name, e); } } } void assertName(String expected) { void assertName(String expected) throws UiObjectNotFoundException { assertField("name", nameField, expected); assertField("name", nameField, expected); } } void assertTitle(String expected) { void assertTitle(String expected) throws UiObjectNotFoundException { assertField("title", titleField, expected); assertField("title", titleField, expected); } } void assertDescription(String expected) { void assertDescription(String expected) throws UiObjectNotFoundException { assertField("description", descField, expected); assertField("description", descField, expected); } } /** * Set focus on the name field so it can be validated once focus is lost. */ void focusOnName() throws UiObjectNotFoundException { mUiBot.click(nameField, "name_field"); assertTrue("name_field not focused", nameField.isFocused()); } /** /** * Takes focus away from the name field so it can be validated. * Takes focus away from the name field so it can be validated. */ */ void focusAwayFromName() { void focusAwayFromName() throws UiObjectNotFoundException { mUiBot.click(titleField, "title_field"); // Change focus. mUiBot.click(titleField, "title_field"); // Change focus. mUiBot.pressBack(); // Dismiss keyboard. mUiBot.pressBack(); // Dismiss keyboard. assertFalse("name_field is focused", nameField.isFocused()); } } void reOpen() { void reOpen() { openProgressNotification(ID); openProgressNotification(ID); mUiBot.click(detailsButton, "details_button"); mUiBot.click(detailsButton, "details_button"); } } void clickOk() { void clickOk() { Loading Loading
packages/Shell/res/layout/dialog_bugreport_info.xml +1 −1 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ android:paddingTop="15dp" android:paddingTop="15dp" android:paddingStart="24dp" android:paddingStart="24dp" android:paddingEnd="24dp" android:paddingEnd="24dp" android:focusableInTouchMode="true" android:layout_width="wrap_content" android:layout_width="wrap_content" android:layout_height="wrap_content"> android:layout_height="wrap_content"> <TextView <TextView Loading @@ -30,7 +31,6 @@ android:id="@+id/name" android:id="@+id/name" android:maxLength="30" android:maxLength="30" android:singleLine="true" android:singleLine="true" android:selectAllOnFocus="true" android:inputType="textNoSuggestions" android:inputType="textNoSuggestions" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="wrap_content"/> android:layout_height="wrap_content"/> Loading
packages/Shell/src/com/android/shell/BugreportProgressService.java +14 −22 Original line number Original line Diff line number Diff line Loading @@ -454,21 +454,15 @@ public class BugreportProgressService extends Service { final String name = final String name = info.name != null ? info.name : mContext.getString(R.string.bugreport_unnamed); info.name != null ? info.name : mContext.getString(R.string.bugreport_unnamed); final Notification notification = new Notification.Builder(mContext) final Notification notification = newBaseNotification(mContext) .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb) .setContentTitle(title) .setContentTitle(title) .setTicker(title) .setTicker(title) .setContentText(name) .setContentText(name) .setContentInfo(percentText) .setContentInfo(percentText) .setProgress(info.max, info.progress, false) .setProgress(info.max, info.progress, false) .setOngoing(true) .setOngoing(true) .setLocalOnly(true) .setColor(mContext.getColor( com.android.internal.R.color.system_notification_accent_color)) .setContentIntent(infoPendingIntent) .setContentIntent(infoPendingIntent) .addAction(infoAction) .setActions(infoAction, screenshotAction, cancelAction) .addAction(screenshotAction) .addAction(cancelAction) .build(); .build(); if (info.finished) { if (info.finished) { Loading Loading @@ -928,17 +922,13 @@ public class BugreportProgressService extends Service { title = context.getString(R.string.bugreport_finished_title, info.id); title = context.getString(R.string.bugreport_finished_title, info.id); content = context.getString(R.string.bugreport_finished_text); content = context.getString(R.string.bugreport_finished_text); } } final Notification.Builder builder = new Notification.Builder(context) final Notification.Builder builder = newBaseNotification(context) .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb) .setContentTitle(title) .setContentTitle(title) .setTicker(title) .setTicker(title) .setContentText(content) .setContentText(content) .setContentIntent(PendingIntent.getService(context, info.id, shareIntent, .setContentIntent(PendingIntent.getService(context, info.id, shareIntent, PendingIntent.FLAG_UPDATE_CURRENT)) PendingIntent.FLAG_UPDATE_CURRENT)) .setDeleteIntent(newCancelIntent(context, info)) .setDeleteIntent(newCancelIntent(context, info)); .setLocalOnly(true) .setColor(context.getColor( com.android.internal.R.color.system_notification_accent_color)); if (!TextUtils.isEmpty(info.name)) { if (!TextUtils.isEmpty(info.name)) { builder.setContentInfo(info.name); builder.setContentInfo(info.name); Loading @@ -955,16 +945,21 @@ public class BugreportProgressService extends Service { */ */ private static void sendBugreportBeingUpdatedNotification(Context context, int id) { private static void sendBugreportBeingUpdatedNotification(Context context, int id) { final String title = context.getString(R.string.bugreport_updating_title); final String title = context.getString(R.string.bugreport_updating_title); final Notification.Builder builder = new Notification.Builder(context) final Notification.Builder builder = newBaseNotification(context) .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb) .setContentTitle(title) .setContentTitle(title) .setTicker(title) .setTicker(title) .setContentText(context.getString(R.string.bugreport_updating_wait)) .setContentText(context.getString(R.string.bugreport_updating_wait)); Log.v(TAG, "Sending 'Updating zip' notification for ID " + id + ": " + title); NotificationManager.from(context).notify(TAG, id, builder.build()); } private static Notification.Builder newBaseNotification(Context context) { return new Notification.Builder(context) .setCategory(Notification.CATEGORY_SYSTEM) .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb) .setLocalOnly(true) .setLocalOnly(true) .setColor(context.getColor( .setColor(context.getColor( com.android.internal.R.color.system_notification_accent_color)); com.android.internal.R.color.system_notification_accent_color)); Log.v(TAG, "Sending 'Updating zip' notification for ID " + id + ": " + title); NotificationManager.from(context).notify(TAG, id, builder.build()); } } /** /** Loading Loading @@ -1288,9 +1283,6 @@ public class BugreportProgressService extends Service { if (hasFocus) { if (hasFocus) { return; return; } } // Select-all is useful just initially, since the date-based filename is // full of hyphens. mInfoName.setSelectAllOnFocus(false); sanitizeName(); sanitizeName(); } } }); }); Loading
packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java +18 −13 Original line number Original line Diff line number Diff line Loading @@ -291,6 +291,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { detailsUi.assertName(NAME); detailsUi.assertName(NAME); // Change name - it should have changed system property once focus is changed. // Change name - it should have changed system property once focus is changed. detailsUi.focusOnName(); detailsUi.nameField.setText(NEW_NAME); detailsUi.nameField.setText(NEW_NAME); detailsUi.focusAwayFromName(); detailsUi.focusAwayFromName(); assertPropertyValue(NAME_PROPERTY, NEW_NAME); assertPropertyValue(NAME_PROPERTY, NEW_NAME); Loading Loading @@ -966,40 +967,44 @@ public class BugreportReceiverTest extends InstrumentationTestCase { cancelButton = mUiBot.getObjectById("android:id/button2"); cancelButton = mUiBot.getObjectById("android:id/button2"); } } private void assertField(String name, UiObject field, String expected) { private void assertField(String name, UiObject field, String expected) try { throws UiObjectNotFoundException { String actual = field.getText().toString(); String actual = field.getText().toString(); assertEquals("Wrong value on field '" + name + "'", expected, actual); assertEquals("Wrong value on field '" + name + "'", expected, actual); } catch (UiObjectNotFoundException e) { // Should not happen... throw new IllegalStateException("field not found: " + name, e); } } } void assertName(String expected) { void assertName(String expected) throws UiObjectNotFoundException { assertField("name", nameField, expected); assertField("name", nameField, expected); } } void assertTitle(String expected) { void assertTitle(String expected) throws UiObjectNotFoundException { assertField("title", titleField, expected); assertField("title", titleField, expected); } } void assertDescription(String expected) { void assertDescription(String expected) throws UiObjectNotFoundException { assertField("description", descField, expected); assertField("description", descField, expected); } } /** * Set focus on the name field so it can be validated once focus is lost. */ void focusOnName() throws UiObjectNotFoundException { mUiBot.click(nameField, "name_field"); assertTrue("name_field not focused", nameField.isFocused()); } /** /** * Takes focus away from the name field so it can be validated. * Takes focus away from the name field so it can be validated. */ */ void focusAwayFromName() { void focusAwayFromName() throws UiObjectNotFoundException { mUiBot.click(titleField, "title_field"); // Change focus. mUiBot.click(titleField, "title_field"); // Change focus. mUiBot.pressBack(); // Dismiss keyboard. mUiBot.pressBack(); // Dismiss keyboard. assertFalse("name_field is focused", nameField.isFocused()); } } void reOpen() { void reOpen() { openProgressNotification(ID); openProgressNotification(ID); mUiBot.click(detailsButton, "details_button"); mUiBot.click(detailsButton, "details_button"); } } void clickOk() { void clickOk() { Loading