2024-09-14 12:07:02 -04:00
|
|
|
From 277d3d387c624668019378f1613a699ed0acc50b Mon Sep 17 00:00:00 2001
|
2024-08-17 10:04:14 -04:00
|
|
|
From: Kiran S <krns@google.com>
|
|
|
|
Date: Mon, 13 May 2024 05:49:06 +0000
|
|
|
|
Subject: [PATCH] Restrict USB poups while setup is in progress
|
|
|
|
|
|
|
|
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:ec96cc3e3a81d21f2249db381c10638bb307cf39)
|
|
|
|
Merged-In: I7d54534696fd73f3b94c5b4250142eed9341c5d8
|
|
|
|
Change-Id: I7d54534696fd73f3b94c5b4250142eed9341c5d8
|
|
|
|
---
|
|
|
|
.../usb/UsbProfileGroupSettingsManager.java | 21 +++++++++++++++++++
|
|
|
|
1 file changed, 21 insertions(+)
|
|
|
|
|
|
|
|
diff --git a/services/usb/java/com/android/server/usb/UsbProfileGroupSettingsManager.java b/services/usb/java/com/android/server/usb/UsbProfileGroupSettingsManager.java
|
2024-09-14 12:07:02 -04:00
|
|
|
index 74c3939a1b1cd..2e25798b25d81 100644
|
2024-08-17 10:04:14 -04:00
|
|
|
--- a/services/usb/java/com/android/server/usb/UsbProfileGroupSettingsManager.java
|
|
|
|
+++ b/services/usb/java/com/android/server/usb/UsbProfileGroupSettingsManager.java
|
|
|
|
@@ -16,6 +16,8 @@
|
|
|
|
|
|
|
|
package com.android.server.usb;
|
|
|
|
|
|
|
|
+import static android.provider.Settings.Secure.USER_SETUP_COMPLETE;
|
|
|
|
+
|
|
|
|
import static com.android.internal.app.IntentForwarderActivity.FORWARD_INTENT_TO_MANAGED_PROFILE;
|
|
|
|
|
|
|
|
import android.annotation.NonNull;
|
2024-09-14 12:07:02 -04:00
|
|
|
@@ -42,6 +44,7 @@
|
2024-08-17 10:04:14 -04:00
|
|
|
import android.os.Environment;
|
|
|
|
import android.os.UserHandle;
|
|
|
|
import android.os.UserManager;
|
|
|
|
+import android.provider.Settings;
|
|
|
|
import android.service.usb.UsbProfileGroupSettingsManagerProto;
|
|
|
|
import android.service.usb.UsbSettingsAccessoryPreferenceProto;
|
|
|
|
import android.service.usb.UsbSettingsDevicePreferenceProto;
|
2024-09-14 12:07:02 -04:00
|
|
|
@@ -762,10 +765,28 @@ private void resolveActivity(Intent intent, UsbDevice device, boolean showMtpNot
|
2024-08-17 10:04:14 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ if (shouldRestrictOverlayActivities()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
// Start activity with registered intent
|
|
|
|
resolveActivity(intent, matches, defaultActivity, device, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
public void deviceAttachedForFixedHandler(UsbDevice device, ComponentName component) {
|
|
|
|
final Intent intent = createDeviceAttachedIntent(device);
|
|
|
|
|