From afbc3a4929172e287ff3cbff2b5c9598a7c1e490 Mon Sep 17 00:00:00 2001 From: Achim Thesmann Date: Sat, 29 Jul 2023 04:34:06 +0000 Subject: [PATCH] Allow BAL from PrintServiceSettingsFragment This fixes the info button on the printer in the printer list (the call is from the system (uid=1000) and needs to allow BAL to start the activity). This only opts in sending a single pending intent to the previous (pre U) behavior which allows BAL. Therefore the risk of the change is minimal. This was reported by an external partner. Bug: 277761614 Test: manual test & presubmit (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:fdb87fe235887460081ed396cf6ab902f1971b5d) Merged-In: I35715e948b9166c42372b7d40a30a7102018a148 Change-Id: I35715e948b9166c42372b7d40a30a7102018a148 --- .../settings/print/PrintServiceSettingsFragment.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/print/PrintServiceSettingsFragment.java b/src/com/android/settings/print/PrintServiceSettingsFragment.java index 39b5ab9e978..c5316e6e524 100644 --- a/src/com/android/settings/print/PrintServiceSettingsFragment.java +++ b/src/com/android/settings/print/PrintServiceSettingsFragment.java @@ -17,6 +17,7 @@ package com.android.settings.print; import android.app.Activity; +import android.app.ActivityOptions; import android.app.settings.SettingsEnums; import android.content.ComponentName; import android.content.Context; @@ -547,8 +548,13 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment @Override public void onClick(View v) { try { + Bundle options = ActivityOptions.makeBasic() + .setPendingIntentBackgroundActivityStartMode( + ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED) + .toBundle(); getActivity().startIntentSender( - printer.getInfoIntent().getIntentSender(), null, 0, 0, 0); + printer.getInfoIntent().getIntentSender(), null, 0, 0, 0, + options); } catch (SendIntentException e) { Log.e(LOG_TAG, "Could not execute pending info intent: %s", e); }