Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 84705c4a authored by Hai Zhang's avatar Hai Zhang
Browse files

Add necessary system APIs for moving role into module.

- Added Context.getUser() to system API, to allow module framework
classes to also implement multi-user support in manager classes.

- Added PackageManager.getPermissionControllerPackageName() to system
API for RoleControllerManager to know which package to bind to.

Bug: 158736025
Test: build
Change-Id: If69a97573eb1e676145e0accdfa73fef320aabe7
parent bd47187f
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -40,6 +40,22 @@ package android.app.role {

}

package android.content {

  public abstract class Context {
    method @NonNull public android.os.UserHandle getUser();
  }

}

package android.content.pm {

  public abstract class PackageManager {
    method @NonNull public String getPermissionControllerPackageName();
  }

}

package android.content.rollback {

  public class RollbackManagerFrameworkInitializer {
+2 −2
Original line number Diff line number Diff line
@@ -588,7 +588,7 @@ package android.content {
  public abstract class Context {
    method @NonNull public java.io.File getCrateDir(@NonNull String);
    method public abstract int getDisplayId();
    method public android.os.UserHandle getUser();
    method @NonNull public android.os.UserHandle getUser();
    method public int getUserId();
    method public void setAutofillOptions(@Nullable android.content.AutofillOptions);
    method public void setContentCaptureOptions(@Nullable android.content.ContentCaptureOptions);
@@ -643,7 +643,7 @@ package android.content.pm {
    method public abstract int getInstallReason(@NonNull String, @NonNull android.os.UserHandle);
    method @NonNull public abstract java.util.List<android.content.pm.ApplicationInfo> getInstalledApplicationsAsUser(int, int);
    method @Nullable public abstract String[] getNamesForUids(int[]);
    method @NonNull public abstract String getPermissionControllerPackageName();
    method @NonNull public String getPermissionControllerPackageName();
    method @NonNull public abstract String getServicesSystemSharedLibraryPackageName();
    method @NonNull public abstract String getSharedSystemSharedLibraryPackageName();
    method @Nullable public String getSystemTextClassifierPackageName();
+6 −1
Original line number Diff line number Diff line
@@ -5889,9 +5889,14 @@ public abstract class Context {
            throws PackageManager.NameNotFoundException;

    /**
     * Get the user associated with this context
     * Get the user associated with this context.
     *
     * @return the user associated with this context
     *
     * @hide
     */
    @NonNull
    @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
    @TestApi
    public UserHandle getUser() {
        return android.os.Process.myUserHandle();
+6 −4
Original line number Diff line number Diff line
@@ -4821,15 +4821,17 @@ public abstract class PackageManager {
    /**
     * Gets the package name of the component controlling runtime permissions.
     *
     * @return The package name.
     * @return the package name of the component controlling runtime permissions
     *
     * @hide
     */
    @SuppressWarnings("HiddenAbstractMethod")
    @UnsupportedAppUsage
    @NonNull
    @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
    @TestApi
    public abstract String getPermissionControllerPackageName();
    @UnsupportedAppUsage
    public String getPermissionControllerPackageName() {
        throw new RuntimeException("Not implemented. Must override in a subclass.");
    }

    /**
     * Add a new dynamic permission to the system.  For this to work, your
+11 −1
Original line number Diff line number Diff line
@@ -8802,9 +8802,19 @@ public class PackageManagerService extends IPackageManager.Stub
    @Override
    public String getPermissionControllerPackageName() {
        synchronized (mLock) {
            if (mRequiredPermissionControllerPackage != null) {
                final PackageSetting ps = getPackageSetting(mRequiredPermissionControllerPackage);
                if (ps != null) {
                    final int callingUid = Binder.getCallingUid();
                    final int callingUserId = UserHandle.getUserId(callingUid);
                    if (!shouldFilterApplicationLocked(ps, callingUid, callingUserId)) {
                        return mRequiredPermissionControllerPackage;
                    }
                }
            }
            throw new IllegalStateException("PermissionController is not found");
        }
    }
    String getPackageInstallerPackageName() {
        synchronized (mLock) {
Loading