Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ba244090 authored by Michal Karpinski's avatar Michal Karpinski
Browse files

Rework of remote bugreports UX

New notifications, that open dialogs.

Bug: 26226230
Change-Id: I50f9ab23b6c6d03892889d9081cabb0a3d858f91
parent 34bfcf1f
Loading
Loading
Loading
Loading
+62 −0
Original line number Diff line number Diff line
@@ -343,6 +343,68 @@ public class DevicePolicyManager {
    public static final String ACTION_PROVISION_FINALIZATION
            = "android.app.action.PROVISION_FINALIZATION";

    /**
     * Action: Bugreport sharing with device owner has been accepted by the user.
     *
     * @hide
     */
    public static final String ACTION_BUGREPORT_SHARING_ACCEPTED =
            "com.android.server.action.BUGREPORT_SHARING_ACCEPTED";

    /**
     * Action: Bugreport sharing with device owner has been declined by the user.
     *
     * @hide
     */
    public static final String ACTION_BUGREPORT_SHARING_DECLINED =
            "com.android.server.action.BUGREPORT_SHARING_DECLINED";

    /**
     * Action: Bugreport has been collected and is dispatched to {@link DevicePolicyManagerService}.
     *
     * @hide
     */
    public static final String ACTION_REMOTE_BUGREPORT_DISPATCH =
            "android.intent.action.REMOTE_BUGREPORT_DISPATCH";

    /**
     * Extra for shared bugreport's SHA-256 hash.
     *
     * @hide
     */
    public static final String EXTRA_REMOTE_BUGREPORT_HASH =
            "android.intent.extra.REMOTE_BUGREPORT_HASH";

    /**
     * Extra for remote bugreport notification shown type.
     *
     * @hide
     */
    public static final String EXTRA_BUGREPORT_NOTIFICATION_TYPE =
            "android.app.extra.bugreport_notification_type";

    /**
     * Notification type for a started remote bugreport flow.
     *
     * @hide
     */
    public static final int NOTIFICATION_BUGREPORT_STARTED = 1;

    /**
     * Notification type for a bugreport that has already been accepted to be shared, but is still
     * being taken.
     *
     * @hide
     */
    public static final int NOTIFICATION_BUGREPORT_ACCEPTED_NOT_FINISHED = 2;

    /**
     * Notification type for a bugreport that has been taken and can be shared or declined.
     *
     * @hide
     */
    public static final int NOTIFICATION_BUGREPORT_FINISHED_NOT_ACCEPTED = 3;

    /**
     * A {@link android.os.Parcelable} extra of type {@link android.os.PersistableBundle} that
     * allows a mobile device management application or NFC programmer application which starts
+13 −0
Original line number Diff line number Diff line
@@ -1241,6 +1241,19 @@ public final class Settings {
    public static final String ACTION_SHOW_ADMIN_SUPPORT_DETAILS
            = "android.settings.SHOW_ADMIN_SUPPORT_DETAILS";

    /**
     * Activity Action: Show a dialog for remote bugreport flow.
     * <p>
     * Input: Nothing.
     * <p>
     * Output: Nothing.
     *
     * @hide
     */
    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    public static final String ACTION_SHOW_REMOTE_BUGREPORT_DIALOG
            = "android.settings.SHOW_REMOTE_BUGREPORT_DIALOG";

    // End of Intent actions for Settings

    /**
+6 −8
Original line number Diff line number Diff line
@@ -2917,20 +2917,18 @@
    <!-- Message of notification shown when ADB is actively connected to the phone. -->
    <string name="adb_active_notification_message">Touch to disable USB debugging.</string>

    <!-- Title of notification shown to indicate that bug report is being collected. -->
    <string name="taking_remote_bugreport_notification_title">Taking bug report\u2026</string>
    <!-- Title of notification shown to ask for user consent for sharing a bugreport that was requested remotely by the IT administrator. -->
    <string name="share_remote_bugreport_notification_title">Share bug report?</string>
    <!-- Title of notification shown to indicate that bug report is still being collected after sharing was accepted. -->
    <string name="sharing_remote_bugreport_notification_title">Sharing bug report\u2026</string>
    <!-- Message of notification shown to ask for user consent for sharing a bugreport that was requested remotely by the IT administrator. -->
    <string name="share_remote_bugreport_notification_message">Your IT admin requested a bug report to help troubleshoot this device. Apps and data may be shared and your device may temporarily slow down.</string>
    <!-- Message of notification shown to ask for user consent for sharing a bugreport that was requested remotely by the IT administrator. -->
    <string name="share_finished_remote_bugreport_notification_message">Your IT admin requested a bug report to help troubleshoot this device. Apps and data may be shared.</string>
    <!-- Message of notification shown to shown to indicate that bug report is still being collected after sharing was accepted. -->
    <string name="sharing_remote_bugreport_notification_message">This may temporarily slow down your device</string>
    <!-- Message of a notification shown to ask for user consent for sharing a bugreport that was requested remotely by the IT administrator. -->
    <string name="share_remote_bugreport_notification_message_finished">Your IT admin requested a bug report to help troubleshoot this device. Apps and data may be shared.</string>
    <!-- Acceptance label of notification shown to ask for user consent for sharing the remote bugreport. -->
    <string name="share_remote_bugreport_notification_accept">ACCEPT</string>
    <string name="share_remote_bugreport_action">SHARE</string>
    <!-- Decline label of notification shown to ask for user consent for sharing the remote bugreport. -->
    <string name="share_remote_bugreport_notification_decline">DECLINE</string>
    <string name="decline_remote_bugreport_action">DECLINE</string>

    <!-- Used to replace %s in urls retreived from the signin server with locales.  For Some        -->
    <!-- devices we don't support all the locales we ship to and need to replace the '%s' with a    -->
+4 −5
Original line number Diff line number Diff line
@@ -1771,13 +1771,12 @@
  <java-symbol type="string" name="accessibility_binding_label" />
  <java-symbol type="string" name="adb_active_notification_message" />
  <java-symbol type="string" name="adb_active_notification_title" />
  <java-symbol type="string" name="taking_remote_bugreport_notification_title" />
  <java-symbol type="string" name="share_remote_bugreport_notification_title" />
  <java-symbol type="string" name="share_remote_bugreport_notification_message" />
  <java-symbol type="string" name="share_finished_remote_bugreport_notification_message" />
  <java-symbol type="string" name="sharing_remote_bugreport_notification_title" />
  <java-symbol type="string" name="sharing_remote_bugreport_notification_message" />
  <java-symbol type="string" name="share_remote_bugreport_notification_accept" />
  <java-symbol type="string" name="share_remote_bugreport_notification_decline" />
  <java-symbol type="string" name="share_remote_bugreport_notification_message_finished" />
  <java-symbol type="string" name="share_remote_bugreport_action" />
  <java-symbol type="string" name="decline_remote_bugreport_action" />
  <java-symbol type="string" name="aerr_application" />
  <java-symbol type="string" name="aerr_process" />
  <java-symbol type="string" name="aerr_application_repeated" />
+20 −20
Original line number Diff line number Diff line
@@ -328,7 +328,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {

        @Override
        public void onReceive(Context context, Intent intent) {
            if (RemoteBugreportUtils.ACTION_REMOTE_BUGREPORT_DISPATCH.equals(intent.getAction())
            if (DevicePolicyManager.ACTION_REMOTE_BUGREPORT_DISPATCH.equals(intent.getAction())
                    && mRemoteBugreportServiceIsActive.get()) {
                onBugreportFinished(intent);
            }
@@ -342,10 +342,9 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
            String action = intent.getAction();
            mInjector.getNotificationManager().cancel(LOG_TAG,
                    RemoteBugreportUtils.NOTIFICATION_ID);
            if (RemoteBugreportUtils.ACTION_REMOTE_BUGREPORT_SHARING_ACCEPTED.equals(action)) {
            if (DevicePolicyManager.ACTION_BUGREPORT_SHARING_ACCEPTED.equals(action)) {
                onBugreportSharingAccepted();
            } else if (RemoteBugreportUtils.ACTION_REMOTE_BUGREPORT_SHARING_DECLINED
                    .equals(action)) {
            } else if (DevicePolicyManager.ACTION_BUGREPORT_SHARING_DECLINED.equals(action)) {
                onBugreportSharingDeclined();
            }
            mContext.unregisterReceiver(mRemoteBugreportConsentReceiver);
@@ -437,15 +436,14 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                    && userHandle == mOwners.getDeviceOwnerUserId()
                    && getDeviceOwnerRemoteBugreportUri() != null) {
                IntentFilter filterConsent = new IntentFilter();
                filterConsent.addAction(
                        RemoteBugreportUtils.ACTION_REMOTE_BUGREPORT_SHARING_DECLINED);
                filterConsent.addAction(
                        RemoteBugreportUtils.ACTION_REMOTE_BUGREPORT_SHARING_ACCEPTED);
                filterConsent.addAction(DevicePolicyManager.ACTION_BUGREPORT_SHARING_DECLINED);
                filterConsent.addAction(DevicePolicyManager.ACTION_BUGREPORT_SHARING_ACCEPTED);
                mContext.registerReceiver(mRemoteBugreportConsentReceiver, filterConsent);
                mInjector.getNotificationManager().notify(LOG_TAG,
                mInjector.getNotificationManager().notifyAsUser(LOG_TAG,
                        RemoteBugreportUtils.NOTIFICATION_ID,
                        RemoteBugreportUtils.buildNotification(mContext,
                                RemoteBugreportUtils.NOTIFICATION_BUGREPORT_FINISHED_NOT_ACCEPTED));
                                DevicePolicyManager.NOTIFICATION_BUGREPORT_FINISHED_NOT_ACCEPTED),
                                UserHandle.ALL);
            }
            if (Intent.ACTION_BOOT_COMPLETED.equals(action)
                    || ACTION_EXPIRED_PASSWORD_NOTIFICATION.equals(action)) {
@@ -5068,9 +5066,9 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
            mRemoteBugreportServiceIsActive.set(true);
            mRemoteBugreportSharingAccepted.set(false);
            registerRemoteBugreportReceivers();
            mInjector.getNotificationManager().notify(LOG_TAG, RemoteBugreportUtils.NOTIFICATION_ID,
            mInjector.getNotificationManager().notifyAsUser(LOG_TAG, RemoteBugreportUtils.NOTIFICATION_ID,
                    RemoteBugreportUtils.buildNotification(mContext,
                            RemoteBugreportUtils.NOTIFICATION_BUGREPORT_STARTED));
                            DevicePolicyManager.NOTIFICATION_BUGREPORT_STARTED), UserHandle.ALL);
            mHandler.postDelayed(mRemoteBugreportTimeoutRunnable,
                    RemoteBugreportUtils.REMOTE_BUGREPORT_TIMEOUT_MILLIS);
            return true;
@@ -5104,7 +5102,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
    private void registerRemoteBugreportReceivers() {
        try {
            IntentFilter filterFinished = new IntentFilter(
                    RemoteBugreportUtils.ACTION_REMOTE_BUGREPORT_DISPATCH,
                    DevicePolicyManager.ACTION_REMOTE_BUGREPORT_DISPATCH,
                    RemoteBugreportUtils.BUGREPORT_MIMETYPE);
            mContext.registerReceiver(mRemoteBugreportFinishedReceiver, filterFinished);
        } catch (IntentFilter.MalformedMimeTypeException e) {
@@ -5112,8 +5110,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
            Slog.w(LOG_TAG, "Failed to set type " + RemoteBugreportUtils.BUGREPORT_MIMETYPE, e);
        }
        IntentFilter filterConsent = new IntentFilter();
        filterConsent.addAction(RemoteBugreportUtils.ACTION_REMOTE_BUGREPORT_SHARING_DECLINED);
        filterConsent.addAction(RemoteBugreportUtils.ACTION_REMOTE_BUGREPORT_SHARING_ACCEPTED);
        filterConsent.addAction(DevicePolicyManager.ACTION_BUGREPORT_SHARING_DECLINED);
        filterConsent.addAction(DevicePolicyManager.ACTION_BUGREPORT_SHARING_ACCEPTED);
        mContext.registerReceiver(mRemoteBugreportConsentReceiver, filterConsent);
    }

@@ -5126,16 +5124,17 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
            bugreportUriString = bugreportUri.toString();
        }
        String bugreportHash = intent.getStringExtra(
                RemoteBugreportUtils.EXTRA_REMOTE_BUGREPORT_HASH);
                DevicePolicyManager.EXTRA_REMOTE_BUGREPORT_HASH);
        if (mRemoteBugreportSharingAccepted.get()) {
            shareBugreportWithDeviceOwnerIfExists(bugreportUriString, bugreportHash);
            mInjector.getNotificationManager().cancel(LOG_TAG,
                    RemoteBugreportUtils.NOTIFICATION_ID);
        } else {
            setDeviceOwnerRemoteBugreportUriAndHash(bugreportUriString, bugreportHash);
            mInjector.getNotificationManager().notify(LOG_TAG, RemoteBugreportUtils.NOTIFICATION_ID,
            mInjector.getNotificationManager().notifyAsUser(LOG_TAG, RemoteBugreportUtils.NOTIFICATION_ID,
                    RemoteBugreportUtils.buildNotification(mContext,
                            RemoteBugreportUtils.NOTIFICATION_BUGREPORT_FINISHED_NOT_ACCEPTED));
                            DevicePolicyManager.NOTIFICATION_BUGREPORT_FINISHED_NOT_ACCEPTED),
                            UserHandle.ALL);
        }
        mContext.unregisterReceiver(mRemoteBugreportFinishedReceiver);
    }
@@ -5166,9 +5165,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        if (bugreportUriString != null) {
            shareBugreportWithDeviceOwnerIfExists(bugreportUriString, bugreportHash);
        } else if (mRemoteBugreportServiceIsActive.get()) {
            mInjector.getNotificationManager().notify(LOG_TAG, RemoteBugreportUtils.NOTIFICATION_ID,
            mInjector.getNotificationManager().notifyAsUser(LOG_TAG, RemoteBugreportUtils.NOTIFICATION_ID,
                    RemoteBugreportUtils.buildNotification(mContext,
                            RemoteBugreportUtils.NOTIFICATION_BUGREPORT_ACCEPTED_NOT_FINISHED));
                            DevicePolicyManager.NOTIFICATION_BUGREPORT_ACCEPTED_NOT_FINISHED),
                            UserHandle.ALL);
        }
    }

Loading