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

Commit ad95ea97 authored by JW Wang's avatar JW Wang Committed by Android (Google) Code Review
Browse files

Merge changes Ied68ad03,I83e1cfed

* changes:
  Don't reference RollbackManagerService directly (2/n)
  Move service registration code into a System API (1/n)
parents 9f9360b4 41a5d353
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -9,6 +9,14 @@ package android.annotation {

}

package android.content.rollback {

  public class RollbackManagerFrameworkInitializer {
    method public static void initialize();
  }

}

package android.net {

  public final class TetheredClient implements android.os.Parcelable {
+2 −12
Original line number Diff line number Diff line
@@ -68,8 +68,7 @@ import android.content.pm.LauncherApps;
import android.content.pm.PackageManager;
import android.content.pm.ShortcutManager;
import android.content.res.Resources;
import android.content.rollback.IRollbackManager;
import android.content.rollback.RollbackManager;
import android.content.rollback.RollbackManagerFrameworkInitializer;
import android.debug.AdbManager;
import android.debug.IAdbManager;
import android.hardware.ConsumerIrManager;
@@ -1245,16 +1244,6 @@ public final class SystemServiceRegistry {
                        return new RoleControllerManager(ctx.getOuterContext());
                    }});

        registerService(Context.ROLLBACK_SERVICE, RollbackManager.class,
                new CachedServiceFetcher<RollbackManager>() {
                    @Override
                    public RollbackManager createService(ContextImpl ctx)
                            throws ServiceNotFoundException {
                        IBinder b = ServiceManager.getServiceOrThrow(Context.ROLLBACK_SERVICE);
                        return new RollbackManager(ctx.getOuterContext(),
                                IRollbackManager.Stub.asInterface(b));
                    }});

        registerService(Context.DYNAMIC_SYSTEM_SERVICE, DynamicSystemManager.class,
                new CachedServiceFetcher<DynamicSystemManager>() {
                    @Override
@@ -1341,6 +1330,7 @@ public final class SystemServiceRegistry {
            AppSearchManagerFrameworkInitializer.initialize();
            WifiFrameworkInitializer.registerServiceWrappers();
            StatsFrameworkInitializer.registerServiceWrappers();
            RollbackManagerFrameworkInitializer.initialize();
        } 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...
+43 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 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.content.rollback;

import android.annotation.SystemApi;
import android.app.SystemServiceRegistry;
import android.content.Context;

/**
 * Class holding initialization code for the RollbackManager module.
 *
 * @hide
 */
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
public class RollbackManagerFrameworkInitializer {
    private RollbackManagerFrameworkInitializer() {}

    /**
     * Called by {@link SystemServiceRegistry}'s static initializer and registers RollbackManager
     * to {@link Context}, so that {@link Context#getSystemService} can return it.
     *
     * @throws IllegalStateException if this is called from anywhere besides
     *     {@link SystemServiceRegistry}
     */
    public static void initialize() {
        SystemServiceRegistry.registerContextAwareService(
                Context.ROLLBACK_SERVICE, RollbackManager.class,
                (context, b) -> new RollbackManager(context, IRollbackManager.Stub.asInterface(b)));
    }
}
+3 −2
Original line number Diff line number Diff line
@@ -145,7 +145,6 @@ import com.android.server.power.ThermalManagerService;
import com.android.server.recoverysystem.RecoverySystemService;
import com.android.server.restrictions.RestrictionsManagerService;
import com.android.server.role.RoleManagerService;
import com.android.server.rollback.RollbackManagerService;
import com.android.server.security.FileIntegrityService;
import com.android.server.security.KeyAttestationApplicationIdProviderService;
import com.android.server.security.KeyChainSystemService;
@@ -291,6 +290,8 @@ public final class SystemServer {
            "com.android.server.blob.BlobStoreManagerService";
    private static final String APP_SEARCH_MANAGER_SERVICE_CLASS =
            "com.android.server.appsearch.AppSearchManagerService";
    private static final String ROLLBACK_MANAGER_SERVICE_CLASS =
            "com.android.server.rollback.RollbackManagerService";

    private static final String TETHERING_CONNECTOR_CLASS = "android.net.ITetheringConnector";

@@ -961,7 +962,7 @@ public final class SystemServer {

        // Manages apk rollbacks.
        t.traceBegin("StartRollbackManagerService");
        mSystemServiceManager.startService(RollbackManagerService.class);
        mSystemServiceManager.startService(ROLLBACK_MANAGER_SERVICE_CLASS);
        t.traceEnd();

        // Service to capture bugreports.