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

Commit f2fc3e30 authored by Hai Zhang's avatar Hai Zhang
Browse files

Revert^2 "Expose role API for Settings on RoleManager."

ec6ebc3a

Also made the APIs test API instead of system API, to be turned into
system API later during the actual move into module.

Bug: 158736025
Test: atest RcsProvisioningMonitorTest
Change-Id: I74ce1b8352b6e3afc595d8d0f08db28b8c2f29c3
parent ce2a8043
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -449,13 +449,10 @@ package android.app.prediction {

package android.app.role {

  public class RoleControllerManager {
    method @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS) public void isApplicationVisibleForRole(@NonNull String, @NonNull String, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Boolean>);
    method @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS) public void isRoleVisible(@NonNull String, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Boolean>);
  }

  public final class RoleManager {
    method @Nullable public String getSmsRoleHolder(int);
    method @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS) public void isApplicationVisibleForRole(@NonNull String, @NonNull String, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Boolean>);
    method @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS) public void isRoleVisible(@NonNull String, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Boolean>);
  }

}
+0 −9
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ import android.app.contentsuggestions.IContentSuggestionsManager;
import android.app.job.JobSchedulerFrameworkInitializer;
import android.app.people.PeopleManager;
import android.app.prediction.AppPredictionManager;
import android.app.role.RoleControllerManager;
import android.app.role.RoleManager;
import android.app.search.SearchUiManager;
import android.app.slice.SliceManager;
@@ -1315,14 +1314,6 @@ public final class SystemServiceRegistry {
                        return new RoleManager(ctx.getOuterContext());
                    }});

        registerService(Context.ROLE_CONTROLLER_SERVICE, RoleControllerManager.class,
                new CachedServiceFetcher<RoleControllerManager>() {
                    @Override
                    public RoleControllerManager createService(ContextImpl ctx)
                            throws ServiceNotFoundException {
                        return new RoleControllerManager(ctx.getOuterContext());
                    }});

        registerService(Context.DYNAMIC_SYSTEM_SERVICE, DynamicSystemManager.class,
                new CachedServiceFetcher<DynamicSystemManager>() {
                    @Override
+0 −26
Original line number Diff line number Diff line
@@ -20,8 +20,6 @@ import android.Manifest;
import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
import android.annotation.RequiresPermission;
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.app.ActivityThread;
import android.content.ComponentName;
import android.content.Context;
@@ -48,8 +46,6 @@ import java.util.function.Consumer;
 *
 * @hide
 */
@SystemService(Context.ROLE_CONTROLLER_SERVICE)
@TestApi
public class RoleControllerManager {

    private static final String LOG_TAG = RoleControllerManager.class.getSimpleName();
@@ -198,33 +194,12 @@ public class RoleControllerManager {
        propagateCallback(operation, "onClearRoleHolders", callback);
    }

    /**
     * @see RoleControllerService#onIsApplicationQualifiedForRole(String, String)
     *
     * @deprecated Use {@link #isApplicationVisibleForRole(String, String, Executor, Consumer)}
     *             instead.
     *
     * @hide
     */
    @RequiresPermission(Manifest.permission.MANAGE_ROLE_HOLDERS)
    public void isApplicationQualifiedForRole(@NonNull String roleName, @NonNull String packageName,
            @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<Boolean> callback) {
        AndroidFuture<Bundle> operation = mRemoteService.postAsync(service -> {
            AndroidFuture<Bundle> future = new AndroidFuture<>();
            service.isApplicationQualifiedForRole(roleName, packageName,
                    new RemoteCallback(future::complete));
            return future;
        });
        propagateCallback(operation, "isApplicationQualifiedForRole", executor, callback);
    }

    /**
     * @see RoleControllerService#onIsApplicationVisibleForRole(String, String)
     *
     * @hide
     */
    @RequiresPermission(Manifest.permission.MANAGE_ROLE_HOLDERS)
    @TestApi
    public void isApplicationVisibleForRole(@NonNull String roleName, @NonNull String packageName,
            @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<Boolean> callback) {
        AndroidFuture<Bundle> operation = mRemoteService.postAsync(service -> {
@@ -242,7 +217,6 @@ public class RoleControllerManager {
     * @hide
     */
    @RequiresPermission(Manifest.permission.MANAGE_ROLE_HOLDERS)
    @TestApi
    public void isRoleVisible(@NonNull String roleName,
            @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<Boolean> callback) {
        AndroidFuture<Bundle> operation = mRemoteService.postAsync(service -> {
+42 −0
Original line number Diff line number Diff line
@@ -174,6 +174,9 @@ public final class RoleManager {
    @NonNull
    private final Object mListenersLock = new Object();

    @NonNull
    private final RoleControllerManager mRoleControllerManager;

    /**
     * @hide
     */
@@ -181,6 +184,7 @@ public final class RoleManager {
        mContext = context;
        mService = IRoleManager.Stub.asInterface(ServiceManager.getServiceOrThrow(
                Context.ROLE_SERVICE));
        mRoleControllerManager = new RoleControllerManager(context);
    }

    /**
@@ -676,6 +680,44 @@ public final class RoleManager {
        }
    }

    /**
     * Check whether a role should be visible to user.
     *
     * @param roleName name of the role to check for
     * @param executor the executor to execute callback on
     * @param callback the callback to receive whether the role should be visible to user
     *
     * @hide
     */
    @RequiresPermission(Manifest.permission.MANAGE_ROLE_HOLDERS)
    @TestApi
    public void isRoleVisible(@NonNull String roleName,
            @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<Boolean> callback) {
        mRoleControllerManager.isRoleVisible(roleName, executor, callback);
    }

    /**
     * Check whether an application is visible for a role.
     *
     * While an application can be qualified for a role, it can still stay hidden from user (thus
     * not visible). If an application is visible for a role, we may show things related to the role
     * for it, e.g. showing an entry pointing to the role settings in its application info page.
     *
     * @param roleName the name of the role to check for
     * @param packageName the package name of the application to check for
     * @param executor the executor to execute callback on
     * @param callback the callback to receive whether the application is visible for the role
     *
     * @hide
     */
    @RequiresPermission(Manifest.permission.MANAGE_ROLE_HOLDERS)
    @TestApi
    public void isApplicationVisibleForRole(@NonNull String roleName, @NonNull String packageName,
            @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<Boolean> callback) {
        mRoleControllerManager.isApplicationVisibleForRole(roleName, packageName, executor,
                callback);
    }

    private static class OnRoleHoldersChangedListenerDelegate
            extends IOnRoleHoldersChangedListener.Stub {

+0 −10
Original line number Diff line number Diff line
@@ -4832,16 +4832,6 @@ public abstract class Context {
     */
    public static final String ROLE_SERVICE = "role";

    /**
     * Official published name of the (internal) role controller service.
     *
     * @see #getSystemService(String)
     * @see android.app.role.RoleControllerService
     *
     * @hide
     */
    public static final String ROLE_CONTROLLER_SERVICE = "role_controller";

    /**
     * Use with {@link #getSystemService(String)} to retrieve a
     * {@link android.hardware.camera2.CameraManager} for interacting with