Prepare role code for modularization.

- PooledLambda: PoolLambda is replaced with plain lambdas, to avoid
adding ~20 classes to boot classpath (for each module that uses
lambda).

- SystemServiceRegistry: RoleFrameworkInitializer is added to add
ROLE_SERVICE, similar to other modules.

- RoleService: RoleManagerService is renamed to RoleService to better
reflect the manager/service relationship.

- @MainThread: import for Looper is removed because it's only used in
javadoc and triggers package not exist error during build. @linkplain
in the javadoc is also removed because it triggers an error in
Metalava parsing and isn't critical.

- Added small utilities: These utilities has their full version in
platform, but is too large and contains too many internal references
in methods unreferenced by role, whereas actually role only needs 1 or
2 methods from them. So just create a small copy of the used methods
for role modularization, and they will be moved into APEX with role.

Bug: 158736025
Test: manual
Change-Id: I74f20b37d23370e258e7fc7130e28c5312abf46c
This commit is contained in:
Hai Zhang
2021-01-21 17:37:39 -08:00
parent 84705c4ae3
commit 0de31fe1e2
18 changed files with 555 additions and 144 deletions

View File

@@ -168,7 +168,7 @@ import com.android.server.powerstats.PowerStatsService;
import com.android.server.profcollect.ProfcollectForwardingService;
import com.android.server.recoverysystem.RecoverySystemService;
import com.android.server.restrictions.RestrictionsManagerService;
import com.android.server.role.RoleManagerService;
import com.android.server.role.RoleServicePlatformHelper;
import com.android.server.security.FileIntegrityService;
import com.android.server.security.KeyAttestationApplicationIdProviderService;
import com.android.server.security.KeyChainSystemService;
@@ -353,6 +353,7 @@ public final class SystemServer implements Dumpable {
"com.android.server.ConnectivityServiceInitializer";
private static final String IP_CONNECTIVITY_METRICS_CLASS =
"com.android.server.connectivity.IpConnectivityMetrics";
private static final String ROLE_SERVICE_CLASS = "com.android.server.role.RoleService";
private static final String TETHERING_CONNECTOR_CLASS = "android.net.ITetheringConnector";
@@ -2032,8 +2033,9 @@ public final class SystemServer implements Dumpable {
// Grants default permissions and defines roles
t.traceBegin("StartRoleManagerService");
mSystemServiceManager.startService(new RoleManagerService(
mSystemContext, new RoleServicePlatformHelperImpl(mSystemContext)));
LocalManagerRegistry.addManager(RoleServicePlatformHelper.class,
new RoleServicePlatformHelperImpl(mSystemContext));
mSystemServiceManager.startService(ROLE_SERVICE_CLASS);
t.traceEnd();
// We need to always start this service, regardless of whether the