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)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:afbc3a4929172e287ff3cbff2b5c9598a7c1e490)
Merged-In: I35715e948b9166c42372b7d40a30a7102018a148
Change-Id: I35715e948b9166c42372b7d40a30a7102018a148
This commit is contained in:
Achim Thesmann
2023-07-29 04:34:06 +00:00
committed by Cherrypicker Worker
parent 16f8639404
commit 0ca2e98773

View File

@@ -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);
}