summaryrefslogtreecommitdiff
path: root/services/appfunctions/java
diff options
context:
space:
mode:
author Oluwarotimi Adesina <oadesina@google.com> 2024-12-30 12:50:21 +0000
committer Oluwarotimi Adesina <oadesina@google.com> 2024-12-30 22:37:20 +0000
commit1f40027e306493d006cd724e8fcb0dc51d5a4940 (patch)
treea7517d54f04060da9275f83d8b3c4148851234fd /services/appfunctions/java
parente9f92c9e587ed958de63f56152caf97492a51307 (diff)
Grant target implicit visibility onExecuteAppFunctions
Flag: android.app.appfunctions.flags.enable_app_function_manager Test: atest CtsAppFunctionTestCases -c Bug: 386324561 Change-Id: I4fd8bdad13f69f2e4837b29b5cee5c2c9552152c
Diffstat (limited to 'services/appfunctions/java')
-rw-r--r--services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerService.java6
-rw-r--r--services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java30
-rw-r--r--services/appfunctions/java/com/android/server/appfunctions/ServiceHelperImpl.java2
3 files changed, 32 insertions, 6 deletions
diff --git a/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerService.java b/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerService.java
index c293087defb6..dc6afe17403d 100644
--- a/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerService.java
+++ b/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerService.java
@@ -19,7 +19,9 @@ package com.android.server.appfunctions;
import android.annotation.NonNull;
import android.app.appfunctions.AppFunctionManagerConfiguration;
import android.content.Context;
+import android.content.pm.PackageManagerInternal;
+import com.android.server.LocalServices;
import com.android.server.SystemService;
/** Service that manages app functions. */
@@ -28,7 +30,9 @@ public class AppFunctionManagerService extends SystemService {
public AppFunctionManagerService(Context context) {
super(context);
- mServiceImpl = new AppFunctionManagerServiceImpl(context);
+ mServiceImpl =
+ new AppFunctionManagerServiceImpl(
+ context, LocalServices.getService(PackageManagerInternal.class));
}
@Override
diff --git a/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java b/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java
index 37276ddac75a..57d33f1a051e 100644
--- a/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java
+++ b/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java
@@ -50,6 +50,7 @@ import android.app.appsearch.observer.ObserverSpec;
import android.app.appsearch.observer.SchemaChangeInfo;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.PackageManagerInternal;
import android.os.Binder;
import android.os.CancellationSignal;
import android.os.IBinder;
@@ -87,8 +88,10 @@ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub {
private final Context mContext;
private final Map<String, Object> mLocks = new WeakHashMap<>();
private final AppFunctionsLoggerWrapper mLoggerWrapper;
+ private final PackageManagerInternal mPackageManagerInternal;
- public AppFunctionManagerServiceImpl(@NonNull Context context) {
+ public AppFunctionManagerServiceImpl(
+ @NonNull Context context, @NonNull PackageManagerInternal packageManagerInternal) {
this(
context,
new RemoteServiceCallerImpl<>(
@@ -96,7 +99,8 @@ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub {
new CallerValidatorImpl(context),
new ServiceHelperImpl(context),
new ServiceConfigImpl(),
- new AppFunctionsLoggerWrapper(context));
+ new AppFunctionsLoggerWrapper(context),
+ packageManagerInternal);
}
@VisibleForTesting
@@ -106,13 +110,15 @@ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub {
CallerValidator callerValidator,
ServiceHelper appFunctionInternalServiceHelper,
ServiceConfig serviceConfig,
- AppFunctionsLoggerWrapper loggerWrapper) {
+ AppFunctionsLoggerWrapper loggerWrapper,
+ PackageManagerInternal packageManagerInternal) {
mContext = Objects.requireNonNull(context);
mRemoteServiceCaller = Objects.requireNonNull(remoteServiceCaller);
mCallerValidator = Objects.requireNonNull(callerValidator);
mInternalServiceHelper = Objects.requireNonNull(appFunctionInternalServiceHelper);
mServiceConfig = serviceConfig;
mLoggerWrapper = loggerWrapper;
+ mPackageManagerInternal = Objects.requireNonNull(packageManagerInternal);
}
/** Called when the user is unlocked. */
@@ -260,6 +266,24 @@ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub {
"Cannot find the target service."));
return;
}
+ // Grant target app implicit visibility to the caller
+ final int grantRecipientUserId = targetUser.getIdentifier();
+ final int grantRecipientAppId =
+ UserHandle.getAppId(
+ mPackageManagerInternal.getPackageUid(
+ requestInternal
+ .getClientRequest()
+ .getTargetPackageName(),
+ /* flags= */ 0,
+ /* userId= */ grantRecipientUserId));
+ if (grantRecipientAppId > 0) {
+ mPackageManagerInternal.grantImplicitAccess(
+ grantRecipientUserId,
+ serviceIntent,
+ grantRecipientAppId,
+ callingUid,
+ /* direct= */ true);
+ }
bindAppFunctionServiceUnchecked(
requestInternal,
serviceIntent,
diff --git a/services/appfunctions/java/com/android/server/appfunctions/ServiceHelperImpl.java b/services/appfunctions/java/com/android/server/appfunctions/ServiceHelperImpl.java
index 37a377950a87..071fda4f5d0c 100644
--- a/services/appfunctions/java/com/android/server/appfunctions/ServiceHelperImpl.java
+++ b/services/appfunctions/java/com/android/server/appfunctions/ServiceHelperImpl.java
@@ -31,8 +31,6 @@ import java.util.Objects;
class ServiceHelperImpl implements ServiceHelper {
private final Context mContext;
- // TODO(b/357551503): Keep track of unlocked users.
-
ServiceHelperImpl(@NonNull Context context) {
mContext = Objects.requireNonNull(context);
}