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

Commit 270ed6e9 authored by Eduard Dumitrescul's avatar Eduard Dumitrescul Committed by Android (Google) Code Review
Browse files

Merge "Update bugreport Uri to include userId" into main

parents ce077693 2934f74a
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -528,3 +528,13 @@ flag {
  description: "Enable any user (not just the Main User) to be a DeviceOwner"
  bug: "435271558"
}

flag {
  name: "fix_hsum_bugreport_share_crash"
  namespace: "enterprise"
  description: "[HSUM][Framework Bug][DO] TestDPC crashes when sharing a bugreport requested from TestDPC"
  bug: "341879351"
  metadata {
    purpose: PURPOSE_BUGFIX
  }
}
+15 −3
Original line number Diff line number Diff line
@@ -358,6 +358,7 @@ import android.compat.annotation.EnabledSince;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentProvider;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
@@ -9565,8 +9566,19 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
    void sendBugreportToDeviceOwner(Uri bugreportUri, String bugreportHash) {
        synchronized (getLockObject()) {
            final Intent intent = new Intent(DeviceAdminReceiver.ACTION_BUGREPORT_SHARE);
            final int deviceOwnerUserId = mOwners.getDeviceOwnerUserId();
            final Uri bugreportUriForUser;
            if (Flags.fixHsumBugreportShareCrash()) {
                // Bugreports are collected by the shell, which runs as UserHandle.USER_SYSTEM.
                bugreportUriForUser = ContentProvider.createContentUriForUser(
                        bugreportUri, UserHandle.of(UserHandle.USER_SYSTEM));
            } else {
                bugreportUriForUser = bugreportUri;
            }
            intent.setComponent(mOwners.getDeviceOwnerComponent());
            intent.setDataAndType(bugreportUri, RemoteBugreportManager.BUGREPORT_MIMETYPE);
            intent.setDataAndType(bugreportUriForUser, RemoteBugreportManager.BUGREPORT_MIMETYPE);
            intent.putExtra(DeviceAdminReceiver.EXTRA_BUGREPORT_HASH, bugreportHash);
            intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
@@ -9574,10 +9586,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                    .getService(UriGrantsManagerInternal.class);
            final NeededUriGrants needed = ugm.checkGrantUriPermissionFromIntent(intent,
                    Process.SHELL_UID, mOwners.getDeviceOwnerComponent().getPackageName(),
                    mOwners.getDeviceOwnerUserId());
                    deviceOwnerUserId);
            ugm.grantUriPermissionUncheckedFromIntent(needed, null);
            mContext.sendBroadcastAsUser(intent, UserHandle.of(mOwners.getDeviceOwnerUserId()));
            mContext.sendBroadcastAsUser(intent, UserHandle.of(deviceOwnerUserId));
        }
    }