Loading core/java/android/annotation/MainThread.java +1 −4 Original line number Diff line number Diff line Loading @@ -21,8 +21,6 @@ import static java.lang.annotation.ElementType.PARAMETER; import static java.lang.annotation.ElementType.TYPE; import static java.lang.annotation.RetentionPolicy.SOURCE; import android.os.Looper; import java.lang.annotation.Retention; import java.lang.annotation.Target; Loading @@ -40,8 +38,7 @@ import java.lang.annotation.Target; * </code> * </pre> * * @memberDoc This method must be called from the * {@linkplain Looper#getMainLooper() main thread} of your app. * @memberDoc This method must be called from the main thread of your app. * @hide */ @Retention(SOURCE) Loading core/java/android/app/SystemServiceRegistry.java +2 −9 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ import android.app.contentsuggestions.IContentSuggestionsManager; import android.app.job.JobSchedulerFrameworkInitializer; import android.app.people.PeopleManager; import android.app.prediction.AppPredictionManager; import android.app.role.RoleManager; import android.app.role.RoleFrameworkInitializer; import android.app.search.SearchUiManager; import android.app.slice.SliceManager; import android.app.time.TimeManager; Loading Loading @@ -1320,14 +1320,6 @@ public final class SystemServiceRegistry { ctx.getMainThreadHandler()); }}); registerService(Context.ROLE_SERVICE, RoleManager.class, new CachedServiceFetcher<RoleManager>() { @Override public RoleManager createService(ContextImpl ctx) throws ServiceNotFoundException { return new RoleManager(ctx.getOuterContext()); }}); registerService(Context.DYNAMIC_SYSTEM_SERVICE, DynamicSystemManager.class, new CachedServiceFetcher<DynamicSystemManager>() { @Override Loading Loading @@ -1423,6 +1415,7 @@ public final class SystemServiceRegistry { RollbackManagerFrameworkInitializer.initialize(); MediaFrameworkPlatformInitializer.registerServiceWrappers(); MediaFrameworkInitializer.registerServiceWrappers(); RoleFrameworkInitializer.registerServiceWrappers(); } finally { // If any of the above code throws, we're in a pretty bad shape and the process // will likely crash, but we'll reset it just in case there's an exception handler... Loading core/java/android/app/role/RoleControllerManager.java +7 −8 Original line number Diff line number Diff line Loading @@ -20,15 +20,15 @@ import android.Manifest; import android.annotation.CallbackExecutor; import android.annotation.NonNull; import android.annotation.RequiresPermission; import android.app.ActivityThread; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.os.Binder; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.os.RemoteCallback; import android.util.Log; import android.util.SparseArray; Loading Loading @@ -95,11 +95,10 @@ public class RoleControllerManager { private RoleControllerManager(@NonNull ComponentName remoteServiceComponentName, @NonNull Handler handler, @NonNull Context context) { synchronized (sRemoteServicesLock) { int userId = context.getUserId(); int userId = context.getUser().getIdentifier(); ServiceConnector<IRoleController> remoteService = sRemoteServices.get(userId); if (remoteService == null) { remoteService = new ServiceConnector.Impl<IRoleController>( ActivityThread.currentApplication(), remoteService = new ServiceConnector.Impl<IRoleController>(context, new Intent(RoleControllerService.SERVICE_INTERFACE) .setComponent(remoteServiceComponentName), 0 /* bindingFlags */, userId, IRoleController.Stub::asInterface) { Loading @@ -119,7 +118,7 @@ public class RoleControllerManager { * @hide */ public RoleControllerManager(@NonNull Context context) { this(getRemoteServiceComponentName(context), context.getMainThreadHandler(), context); this(getRemoteServiceComponentName(context), new Handler(Looper.getMainLooper()), context); } @NonNull Loading @@ -127,8 +126,8 @@ public class RoleControllerManager { Intent intent = new Intent(RoleControllerService.SERVICE_INTERFACE); PackageManager packageManager = context.getPackageManager(); intent.setPackage(packageManager.getPermissionControllerPackageName()); ResolveInfo resolveInfo = packageManager.resolveService(intent, 0); return resolveInfo.getComponentInfo().getComponentName(); ServiceInfo serviceInfo = packageManager.resolveService(intent, 0).serviceInfo; return new ComponentName(serviceInfo.packageName, serviceInfo.name); } /** Loading core/java/android/app/role/RoleControllerService.java +8 −13 Original line number Diff line number Diff line Loading @@ -33,7 +33,6 @@ import android.os.RemoteCallback; import android.os.UserHandle; import com.android.internal.util.Preconditions; import com.android.internal.util.function.pooled.PooledLambda; import java.util.Objects; import java.util.concurrent.Executor; Loading Loading @@ -85,9 +84,7 @@ public abstract class RoleControllerService extends Service { Objects.requireNonNull(callback, "callback cannot be null"); mWorkerHandler.sendMessage(PooledLambda.obtainMessage( RoleControllerService::grantDefaultRoles, RoleControllerService.this, callback)); mWorkerHandler.post(() -> RoleControllerService.this.grantDefaultRoles(callback)); } @Override Loading @@ -100,9 +97,8 @@ public abstract class RoleControllerService extends Service { "packageName cannot be null or empty"); Objects.requireNonNull(callback, "callback cannot be null"); mWorkerHandler.sendMessage(PooledLambda.obtainMessage( RoleControllerService::onAddRoleHolder, RoleControllerService.this, roleName, packageName, flags, callback)); mWorkerHandler.post(() -> RoleControllerService.this.onAddRoleHolder(roleName, packageName, flags, callback)); } @Override Loading @@ -115,9 +111,8 @@ public abstract class RoleControllerService extends Service { "packageName cannot be null or empty"); Objects.requireNonNull(callback, "callback cannot be null"); mWorkerHandler.sendMessage(PooledLambda.obtainMessage( RoleControllerService::onRemoveRoleHolder, RoleControllerService.this, roleName, packageName, flags, callback)); mWorkerHandler.post(() -> RoleControllerService.this.onRemoveRoleHolder(roleName, packageName, flags, callback)); } @Override Loading @@ -127,9 +122,8 @@ public abstract class RoleControllerService extends Service { Preconditions.checkStringNotEmpty(roleName, "roleName cannot be null or empty"); Objects.requireNonNull(callback, "callback cannot be null"); mWorkerHandler.sendMessage(PooledLambda.obtainMessage( RoleControllerService::onClearRoleHolders, RoleControllerService.this, roleName, flags, callback)); mWorkerHandler.post(() -> RoleControllerService.this.onClearRoleHolders(roleName, flags, callback)); } private void enforceCallerSystemUid(@NonNull String methodName) { Loading Loading @@ -274,6 +268,7 @@ public abstract class RoleControllerService extends Service { * * @deprecated Implement {@link #onIsApplicationVisibleForRole(String, String)} instead. */ @Deprecated public abstract boolean onIsApplicationQualifiedForRole(@NonNull String roleName, @NonNull String packageName); Loading core/java/android/app/role/RoleFrameworkInitializer.java 0 → 100644 +43 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.app.role; import android.app.SystemServiceRegistry; import android.content.Context; /** * Class holding initialization code for role in the permission module. * * @hide */ //@SystemApi public class RoleFrameworkInitializer { private RoleFrameworkInitializer() {} /** * Called by {@link SystemServiceRegistry}'s static initializer and registers * {@link RoleManager} to {@link Context}, so that {@link Context#getSystemService} can return * it. * * <p>If this is called from other places, it throws a {@link IllegalStateException). */ public static void registerServiceWrappers() { SystemServiceRegistry.registerContextAwareService(Context.ROLE_SERVICE, RoleManager.class, (context, serviceBinder) -> new RoleManager(context, IRoleManager.Stub.asInterface(serviceBinder))); } } Loading
core/java/android/annotation/MainThread.java +1 −4 Original line number Diff line number Diff line Loading @@ -21,8 +21,6 @@ import static java.lang.annotation.ElementType.PARAMETER; import static java.lang.annotation.ElementType.TYPE; import static java.lang.annotation.RetentionPolicy.SOURCE; import android.os.Looper; import java.lang.annotation.Retention; import java.lang.annotation.Target; Loading @@ -40,8 +38,7 @@ import java.lang.annotation.Target; * </code> * </pre> * * @memberDoc This method must be called from the * {@linkplain Looper#getMainLooper() main thread} of your app. * @memberDoc This method must be called from the main thread of your app. * @hide */ @Retention(SOURCE) Loading
core/java/android/app/SystemServiceRegistry.java +2 −9 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ import android.app.contentsuggestions.IContentSuggestionsManager; import android.app.job.JobSchedulerFrameworkInitializer; import android.app.people.PeopleManager; import android.app.prediction.AppPredictionManager; import android.app.role.RoleManager; import android.app.role.RoleFrameworkInitializer; import android.app.search.SearchUiManager; import android.app.slice.SliceManager; import android.app.time.TimeManager; Loading Loading @@ -1320,14 +1320,6 @@ public final class SystemServiceRegistry { ctx.getMainThreadHandler()); }}); registerService(Context.ROLE_SERVICE, RoleManager.class, new CachedServiceFetcher<RoleManager>() { @Override public RoleManager createService(ContextImpl ctx) throws ServiceNotFoundException { return new RoleManager(ctx.getOuterContext()); }}); registerService(Context.DYNAMIC_SYSTEM_SERVICE, DynamicSystemManager.class, new CachedServiceFetcher<DynamicSystemManager>() { @Override Loading Loading @@ -1423,6 +1415,7 @@ public final class SystemServiceRegistry { RollbackManagerFrameworkInitializer.initialize(); MediaFrameworkPlatformInitializer.registerServiceWrappers(); MediaFrameworkInitializer.registerServiceWrappers(); RoleFrameworkInitializer.registerServiceWrappers(); } finally { // If any of the above code throws, we're in a pretty bad shape and the process // will likely crash, but we'll reset it just in case there's an exception handler... Loading
core/java/android/app/role/RoleControllerManager.java +7 −8 Original line number Diff line number Diff line Loading @@ -20,15 +20,15 @@ import android.Manifest; import android.annotation.CallbackExecutor; import android.annotation.NonNull; import android.annotation.RequiresPermission; import android.app.ActivityThread; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.os.Binder; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.os.RemoteCallback; import android.util.Log; import android.util.SparseArray; Loading Loading @@ -95,11 +95,10 @@ public class RoleControllerManager { private RoleControllerManager(@NonNull ComponentName remoteServiceComponentName, @NonNull Handler handler, @NonNull Context context) { synchronized (sRemoteServicesLock) { int userId = context.getUserId(); int userId = context.getUser().getIdentifier(); ServiceConnector<IRoleController> remoteService = sRemoteServices.get(userId); if (remoteService == null) { remoteService = new ServiceConnector.Impl<IRoleController>( ActivityThread.currentApplication(), remoteService = new ServiceConnector.Impl<IRoleController>(context, new Intent(RoleControllerService.SERVICE_INTERFACE) .setComponent(remoteServiceComponentName), 0 /* bindingFlags */, userId, IRoleController.Stub::asInterface) { Loading @@ -119,7 +118,7 @@ public class RoleControllerManager { * @hide */ public RoleControllerManager(@NonNull Context context) { this(getRemoteServiceComponentName(context), context.getMainThreadHandler(), context); this(getRemoteServiceComponentName(context), new Handler(Looper.getMainLooper()), context); } @NonNull Loading @@ -127,8 +126,8 @@ public class RoleControllerManager { Intent intent = new Intent(RoleControllerService.SERVICE_INTERFACE); PackageManager packageManager = context.getPackageManager(); intent.setPackage(packageManager.getPermissionControllerPackageName()); ResolveInfo resolveInfo = packageManager.resolveService(intent, 0); return resolveInfo.getComponentInfo().getComponentName(); ServiceInfo serviceInfo = packageManager.resolveService(intent, 0).serviceInfo; return new ComponentName(serviceInfo.packageName, serviceInfo.name); } /** Loading
core/java/android/app/role/RoleControllerService.java +8 −13 Original line number Diff line number Diff line Loading @@ -33,7 +33,6 @@ import android.os.RemoteCallback; import android.os.UserHandle; import com.android.internal.util.Preconditions; import com.android.internal.util.function.pooled.PooledLambda; import java.util.Objects; import java.util.concurrent.Executor; Loading Loading @@ -85,9 +84,7 @@ public abstract class RoleControllerService extends Service { Objects.requireNonNull(callback, "callback cannot be null"); mWorkerHandler.sendMessage(PooledLambda.obtainMessage( RoleControllerService::grantDefaultRoles, RoleControllerService.this, callback)); mWorkerHandler.post(() -> RoleControllerService.this.grantDefaultRoles(callback)); } @Override Loading @@ -100,9 +97,8 @@ public abstract class RoleControllerService extends Service { "packageName cannot be null or empty"); Objects.requireNonNull(callback, "callback cannot be null"); mWorkerHandler.sendMessage(PooledLambda.obtainMessage( RoleControllerService::onAddRoleHolder, RoleControllerService.this, roleName, packageName, flags, callback)); mWorkerHandler.post(() -> RoleControllerService.this.onAddRoleHolder(roleName, packageName, flags, callback)); } @Override Loading @@ -115,9 +111,8 @@ public abstract class RoleControllerService extends Service { "packageName cannot be null or empty"); Objects.requireNonNull(callback, "callback cannot be null"); mWorkerHandler.sendMessage(PooledLambda.obtainMessage( RoleControllerService::onRemoveRoleHolder, RoleControllerService.this, roleName, packageName, flags, callback)); mWorkerHandler.post(() -> RoleControllerService.this.onRemoveRoleHolder(roleName, packageName, flags, callback)); } @Override Loading @@ -127,9 +122,8 @@ public abstract class RoleControllerService extends Service { Preconditions.checkStringNotEmpty(roleName, "roleName cannot be null or empty"); Objects.requireNonNull(callback, "callback cannot be null"); mWorkerHandler.sendMessage(PooledLambda.obtainMessage( RoleControllerService::onClearRoleHolders, RoleControllerService.this, roleName, flags, callback)); mWorkerHandler.post(() -> RoleControllerService.this.onClearRoleHolders(roleName, flags, callback)); } private void enforceCallerSystemUid(@NonNull String methodName) { Loading Loading @@ -274,6 +268,7 @@ public abstract class RoleControllerService extends Service { * * @deprecated Implement {@link #onIsApplicationVisibleForRole(String, String)} instead. */ @Deprecated public abstract boolean onIsApplicationQualifiedForRole(@NonNull String roleName, @NonNull String packageName); Loading
core/java/android/app/role/RoleFrameworkInitializer.java 0 → 100644 +43 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.app.role; import android.app.SystemServiceRegistry; import android.content.Context; /** * Class holding initialization code for role in the permission module. * * @hide */ //@SystemApi public class RoleFrameworkInitializer { private RoleFrameworkInitializer() {} /** * Called by {@link SystemServiceRegistry}'s static initializer and registers * {@link RoleManager} to {@link Context}, so that {@link Context#getSystemService} can return * it. * * <p>If this is called from other places, it throws a {@link IllegalStateException). */ public static void registerServiceWrappers() { SystemServiceRegistry.registerContextAwareService(Context.ROLE_SERVICE, RoleManager.class, (context, serviceBinder) -> new RoleManager(context, IRoleManager.Stub.asInterface(serviceBinder))); } }