2024-06-16 15:55:36 -04:00
|
|
|
From a0059406f6fa6fa600bd6d5fc488de1d3aa956af Mon Sep 17 00:00:00 2001
|
2024-06-13 15:08:09 -04:00
|
|
|
From: Haoran Zhang <haoranzhang@google.com>
|
|
|
|
Date: Wed, 13 Mar 2024 17:08:00 +0000
|
2024-06-16 15:55:36 -04:00
|
|
|
Subject: [PATCH] Add in check for intent filter when setting/updating service
|
2024-06-13 15:08:09 -04:00
|
|
|
|
|
|
|
For test, I registered two tests around on ABTD. CtsAutoFillServiceTestCases module is passing except three known failures:
|
|
|
|
|
|
|
|
Test run link:
|
|
|
|
- https://android-build.corp.google.com/builds/abtd/run/L33300030002610600
|
|
|
|
- https://android-build.corp.google.com/builds/abtd/run/L58100030002616607
|
|
|
|
|
|
|
|
Bug: b/324874908
|
|
|
|
Test: atest CtsAutoFillServiceTestCases
|
|
|
|
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:141d9d050346bfc4673c429382deb1b3d210f6ad)
|
2024-06-16 15:55:36 -04:00
|
|
|
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:51d64705ab70788a536c26d4df5e63f0952ec98f)
|
2024-06-13 15:08:09 -04:00
|
|
|
Merged-In: I51c2e3788ac29ff4d6b86aa2a735ff2ea1463a77
|
|
|
|
Change-Id: I51c2e3788ac29ff4d6b86aa2a735ff2ea1463a77
|
|
|
|
---
|
|
|
|
.../autofill/AutofillManagerServiceImpl.java | 27 +++++++++++++++++++
|
|
|
|
1 file changed, 27 insertions(+)
|
|
|
|
|
|
|
|
diff --git a/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java b/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java
|
2024-06-16 15:55:36 -04:00
|
|
|
index 57ffe0498a88e..309f78006d4b6 100644
|
2024-06-13 15:08:09 -04:00
|
|
|
--- a/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java
|
|
|
|
+++ b/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java
|
|
|
|
@@ -32,8 +32,10 @@
|
2024-06-16 15:55:36 -04:00
|
|
|
import android.app.ActivityTaskManager;
|
|
|
|
import android.app.IActivityTaskManager;
|
2024-06-13 15:08:09 -04:00
|
|
|
import android.content.ComponentName;
|
|
|
|
+import android.content.Intent;
|
|
|
|
import android.content.pm.PackageManager;
|
|
|
|
import android.content.pm.PackageManager.NameNotFoundException;
|
|
|
|
+import android.content.pm.ResolveInfo;
|
|
|
|
import android.content.pm.ServiceInfo;
|
|
|
|
import android.graphics.Rect;
|
|
|
|
import android.metrics.LogMaker;
|
2024-06-16 15:55:36 -04:00
|
|
|
@@ -235,6 +237,31 @@ protected boolean updateLocked(boolean disabled) {
|
2024-06-13 15:08:09 -04:00
|
|
|
@Override // from PerUserSystemService
|
|
|
|
protected ServiceInfo newServiceInfoLocked(@NonNull ComponentName serviceComponent)
|
|
|
|
throws NameNotFoundException {
|
|
|
|
+ final List<ResolveInfo> resolveInfos =
|
|
|
|
+ getContext().getPackageManager().queryIntentServicesAsUser(
|
|
|
|
+ new Intent(AutofillService.SERVICE_INTERFACE),
|
|
|
|
+ // The MATCH_INSTANT flag is added because curret autofill CTS module is
|
|
|
|
+ // defined in one apk, which makes the test autofill service installed in a
|
|
|
|
+ // instant app when the CTS tests are running in instant app mode.
|
|
|
|
+ // TODO: Remove MATCH_INSTANT flag after completing refactoring the CTS module
|
|
|
|
+ // to make the test autofill service a separate apk.
|
|
|
|
+ PackageManager.GET_META_DATA | PackageManager.MATCH_INSTANT,
|
|
|
|
+ mUserId);
|
|
|
|
+ boolean serviceHasAutofillIntentFilter = false;
|
|
|
|
+ for (ResolveInfo resolveInfo : resolveInfos) {
|
|
|
|
+ final ServiceInfo serviceInfo = resolveInfo.serviceInfo;
|
|
|
|
+ if (serviceInfo.getComponentName().equals(serviceComponent)) {
|
|
|
|
+ serviceHasAutofillIntentFilter = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!serviceHasAutofillIntentFilter) {
|
|
|
|
+ Slog.w(TAG,
|
|
|
|
+ "Autofill service from '" + serviceComponent.getPackageName() + "' does"
|
|
|
|
+ + "not have intent filter " + AutofillService.SERVICE_INTERFACE);
|
|
|
|
+ throw new SecurityException("Service does not declare intent filter "
|
|
|
|
+ + AutofillService.SERVICE_INTERFACE);
|
|
|
|
+ }
|
|
|
|
mInfo = new AutofillServiceInfo(getContext(), serviceComponent, mUserId);
|
|
|
|
return mInfo.getServiceInfo();
|
|
|
|
}
|