summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Gazal Agarwal <agazal@google.com> 2024-10-14 21:33:34 +0000
committer Gazal Agarwal <agazal@google.com> 2024-10-22 16:21:44 +0000
commitc7bd7ffb7489e21c8266dd10c4e1f4b981cea0f3 (patch)
tree672602b510e1ea7ac2f10534935b30cbe67a33e7
parent24a5e6b6338769048d5fd9748b2b6ffa82092588 (diff)
Delegate bugreport consent for system apps.
For system apps with the required permission and an in-built consent page, the report will be approved and the bugreport consent popup will be skipped. Bug: 324046728 PWG consultation: b/285006273 Test: Build and flash image. Trigger the Send Feedback flow from settings. Ensure the OS bugreport consent popup is skipped. Check logs to verify consent was delegated. atest CtsRootBugreportTestCases Flag: android.os.allow_consentless_bugreport_delegated_consent Change-Id: I720531386a21f32e5dafcd4d9994d4a54c7921bc
-rw-r--r--services/core/java/com/android/server/incident/PendingReports.java32
-rw-r--r--services/core/java/com/android/server/incident/TEST_MAPPING10
2 files changed, 36 insertions, 6 deletions
diff --git a/services/core/java/com/android/server/incident/PendingReports.java b/services/core/java/com/android/server/incident/PendingReports.java
index adcda0a63152..35b3673fdf77 100644
--- a/services/core/java/com/android/server/incident/PendingReports.java
+++ b/services/core/java/com/android/server/incident/PendingReports.java
@@ -304,16 +304,16 @@ class PendingReports {
denyReportBeforeAddingRec(listener, callingPackage);
return;
}
+ AttributionSource attributionSource =
+ new AttributionSource.Builder(callingUid)
+ .setPackageName(callingPackage)
+ .build();
// Only with userdebug/eng build: it could check capture consentless bugreport permission
// and approve the report when it's granted.
boolean captureConsentlessBugreportOnUserdebugBuildGranted = false;
if ((Build.IS_USERDEBUG || Build.IS_ENG)
&& (flags & IncidentManager.FLAG_ALLOW_CONSENTLESS_BUGREPORT) != 0) {
- AttributionSource attributionSource =
- new AttributionSource.Builder(callingUid)
- .setPackageName(callingPackage)
- .build();
captureConsentlessBugreportOnUserdebugBuildGranted =
mPermissionManager.checkPermissionForDataDelivery(
Manifest.permission.CAPTURE_CONSENTLESS_BUGREPORT_ON_USERDEBUG_BUILD,
@@ -321,12 +321,32 @@ class PendingReports {
/* message= */ null)
== PERMISSION_GRANTED;
}
- if (captureConsentlessBugreportOnUserdebugBuildGranted) {
+
+ // Allow system apps to skip the consent dialog and use their in-built consent mechanism
+ // instead.
+ boolean captureConsentlessBugreportDelegatedConsentGranted = false;
+ if ((flags & IncidentManager.FLAG_ALLOW_CONSENTLESS_BUGREPORT) != 0) {
+ captureConsentlessBugreportDelegatedConsentGranted =
+ mPermissionManager.checkPermissionForDataDelivery(
+ Manifest.permission
+ .CAPTURE_CONSENTLESS_BUGREPORT_DELEGATED_CONSENT,
+ attributionSource,
+ /* message= */ null)
+ == PERMISSION_GRANTED;
+ }
+
+ if (captureConsentlessBugreportOnUserdebugBuildGranted
+ || captureConsentlessBugreportDelegatedConsentGranted) {
try {
PendingReportRec rec =
new PendingReportRec(
callingPackage, receiverClass, reportId, flags, listener);
- Log.d(TAG, "approving consentless report: " + rec.getUri());
+ if (captureConsentlessBugreportOnUserdebugBuildGranted) {
+ Log.d(TAG, "approving consentless report: " + rec.getUri());
+ }
+ if (captureConsentlessBugreportDelegatedConsentGranted) {
+ Log.d(TAG, "delegating consent for report: " + rec.getUri());
+ }
listener.onReportApproved();
return;
} catch (RemoteException e) {
diff --git a/services/core/java/com/android/server/incident/TEST_MAPPING b/services/core/java/com/android/server/incident/TEST_MAPPING
new file mode 100644
index 000000000000..4f789dbba2b8
--- /dev/null
+++ b/services/core/java/com/android/server/incident/TEST_MAPPING
@@ -0,0 +1,10 @@
+{
+ "postsubmit": [
+ {
+ "name": "CtsRootBugreportTestCases"
+ },
+ {
+ "name": "BugreportManagerTestCases"
+ }
+ ]
+} \ No newline at end of file