Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
Restrict USB poups while setup is in progress
Browse files Browse the repository at this point in the history
Test: Cherry pick of http://ag/27094197
Bug: 294105066
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:2ce2e54a040342373e401f9c2e70035ede4e63ad)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:71042ac086b3470f4086c5c76fc2b6c4e3dff263)
Merged-In: I7d54534696fd73f3b94c5b4250142eed9341c5d8
Change-Id: I7d54534696fd73f3b94c5b4250142eed9341c5d8
  • Loading branch information
Kiran S authored and thestinger committed Aug 6, 2024
1 parent 55b8dcf commit 09e6958
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,10 @@ private void resolveActivity(Intent intent, UsbDevice device, boolean showMtpNot
return;
}

if (shouldRestrictOverlayActivities()) {
return;
}

// Start activity with registered intent
resolveActivity(intent, matches, defaultActivity, device, null);
}
Expand All @@ -948,6 +952,15 @@ private void resolveActivity(Intent intent, UsbDevice device, boolean showMtpNot
* enabled in the manifest file.
*/
private boolean shouldRestrictOverlayActivities() {
if (Settings.Secure.getIntForUser(
mContext.getContentResolver(),
USER_SETUP_COMPLETE,
/* defaultValue= */ 1,
UserHandle.CURRENT.getIdentifier())
== 0) {
Slog.d(TAG, "restricting usb overlay activities as setup is not complete");
return true;
}

if (!Flags.allowRestrictionOfOverlayActivities()) return false;

Expand Down

0 comments on commit 09e6958

Please sign in to comment.