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

Commit 7f051b52 authored by Songchun Fan's avatar Songchun Fan
Browse files

remove proxy binder service IIncrementalManager

This is no longer needed because native Incremental Service directly
uses IDataLoaderManager.

BUG: 150406132
Test: atest service.incremental_test
Test: atest PackageManagerShellCommandIncrementalTest
Change-Id: Idbde2988883becbf3eb707d42c0558774a6073e8
parent cbed111b
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -981,7 +981,6 @@ filegroup {
filegroup {
    name: "incremental_manager_aidl",
    srcs: [
        "core/java/android/os/incremental/IIncrementalManager.aidl",
        "core/java/android/os/incremental/IIncrementalService.aidl",
        "core/java/android/os/incremental/IncrementalNewFileParams.aidl",
        "core/java/android/os/incremental/IncrementalSignature.aidl",
+0 −3
Original line number Diff line number Diff line
@@ -1297,9 +1297,6 @@ public final class SystemServiceRegistry {
                    throws ServiceNotFoundException {
                    return new LightsManager(ctx);
                }});
        //TODO(b/136132412): refactor this: 1) merge IIncrementalManager.aidl and
        //IIncrementalManagerNative.aidl, 2) implement the binder interface in
        //IncrementalManagerService.java, 3) use JNI to call native functions
        registerService(Context.INCREMENTAL_SERVICE, IncrementalManager.class,
                new CachedServiceFetcher<IncrementalManager>() {
                    @Override
+0 −36
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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.os.incremental;

import android.content.pm.FileSystemControlParcel;
import android.content.pm.DataLoaderParamsParcel;
import android.content.pm.IDataLoaderStatusListener;

/**
 * Binder service to receive calls from native Incremental Service and handle Java tasks such as
 * looking up data loader service package names, binding and talking to the data loader service.
 * @hide
 */
interface IIncrementalManager {
    boolean prepareDataLoader(int mountId,
        in FileSystemControlParcel control,
        in DataLoaderParamsParcel params,
        in IDataLoaderStatusListener listener);
    boolean startDataLoader(int mountId);
    void showHealthBlockedUI(int mountId);
    void destroyDataLoader(int mountId);
}
+0 −6
Original line number Diff line number Diff line
@@ -16817,10 +16817,6 @@ HSPLcom/android/server/incident/RequestQueue;-><init>(Landroid/os/Handler;)V
PLcom/android/server/incident/RequestQueue;->access$000(Lcom/android/server/incident/RequestQueue;)Ljava/util/ArrayList;
PLcom/android/server/incident/RequestQueue;->enqueue(Landroid/os/IBinder;ZLjava/lang/Runnable;)V
PLcom/android/server/incident/RequestQueue;->start()V
HSPLcom/android/server/incremental/IncrementalManagerService;-><init>(Landroid/content/Context;)V
PLcom/android/server/incremental/IncrementalManagerService;->dump(Ljava/io/FileDescriptor;Ljava/io/PrintWriter;[Ljava/lang/String;)V
HSPLcom/android/server/incremental/IncrementalManagerService;->start(Landroid/content/Context;)Lcom/android/server/incremental/IncrementalManagerService;
PLcom/android/server/incremental/IncrementalManagerService;->systemReady()V
HPLcom/android/server/infra/-$$Lambda$AbstractMasterSystemService$1$TLhe3_2yHs5UB69Y7lf2s7OxJCo;-><init>(Ljava/lang/String;)V
PLcom/android/server/infra/-$$Lambda$AbstractMasterSystemService$1$TLhe3_2yHs5UB69Y7lf2s7OxJCo;->visit(Ljava/lang/Object;)V
HSPLcom/android/server/infra/-$$Lambda$AbstractMasterSystemService$_fKw-VUP0pSfcMMlgRqoT4OPhxw;-><init>(Lcom/android/server/infra/AbstractMasterSystemService;Ljava/lang/String;)V
@@ -43466,8 +43462,6 @@ Lcom/android/server/incident/PendingReports;
Lcom/android/server/incident/RequestQueue$1;
Lcom/android/server/incident/RequestQueue$Rec;
Lcom/android/server/incident/RequestQueue;
Lcom/android/server/incremental/IncrementalManagerService;
Lcom/android/server/incremental/IncrementalManagerShellCommand;
Lcom/android/server/infra/-$$Lambda$AbstractMasterSystemService$1$TLhe3_2yHs5UB69Y7lf2s7OxJCo;
Lcom/android/server/infra/-$$Lambda$AbstractMasterSystemService$_fKw-VUP0pSfcMMlgRqoT4OPhxw;
Lcom/android/server/infra/-$$Lambda$AbstractMasterSystemService$su3lJpEVIbL-C7doP4eboTpqjxU;
+0 −146
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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 com.android.server.incremental;

import android.annotation.NonNull;
import android.content.Context;
import android.content.pm.DataLoaderManager;
import android.content.pm.DataLoaderParamsParcel;
import android.content.pm.FileSystemControlParcel;
import android.content.pm.IDataLoader;
import android.content.pm.IDataLoaderStatusListener;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.incremental.IIncrementalManager;
import android.util.Slog;

import com.android.internal.util.DumpUtils;

import java.io.FileDescriptor;
import java.io.PrintWriter;

/**
 * This service has the following purposes:
 * 1) Starts the IIncrementalManager binder service.
 * 1) Starts the native IIncrementalManagerService binder service.
 * 2) Handles shell commands for "incremental" service.
 * 3) Handles binder calls from the native IIncrementalManagerService binder service and pass
 *    them to a data loader binder service.
 */

public class IncrementalManagerService extends IIncrementalManager.Stub  {
    private static final String TAG = "IncrementalManagerService";
    private static final String BINDER_SERVICE_NAME = "incremental";
    // DataLoaderManagerService should have been started before us
    private @NonNull DataLoaderManager mDataLoaderManager;
    private long mNativeInstance;
    private final @NonNull Context mContext;

    /**
     * Starts IIncrementalManager binder service and register to Service Manager.
     * Starts the native IIncrementalManagerNative binder service.
     */
    public static IncrementalManagerService start(Context context) {
        IncrementalManagerService self = new IncrementalManagerService(context);
        if (self.mNativeInstance == 0) {
            return null;
        }
        return self;
    }

    private IncrementalManagerService(Context context) {
        mContext = context;
        mDataLoaderManager = mContext.getSystemService(DataLoaderManager.class);
        ServiceManager.addService(BINDER_SERVICE_NAME, this);
        // Starts and register IIncrementalManagerNative service
        mNativeInstance = nativeStartService();
    }

    @SuppressWarnings("resource")
    @Override
    protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        if (!DumpUtils.checkDumpAndUsageStatsPermission(mContext, TAG, pw)) return;
        nativeDump(mNativeInstance, fd.getInt$());
    }

    /**
     * Notifies native IIncrementalManager service that system is ready.
     */
    public void systemReady() {
        nativeSystemReady(mNativeInstance);
    }

    /**
     * Finds data loader service provider and binds to it. This requires PackageManager.
     */
    @Override
    public boolean prepareDataLoader(int mountId, FileSystemControlParcel control,
            DataLoaderParamsParcel params,
            IDataLoaderStatusListener listener) {
        DataLoaderManager dataLoaderManager = mContext.getSystemService(DataLoaderManager.class);
        if (dataLoaderManager == null) {
            Slog.e(TAG, "Failed to find data loader manager service");
            return false;
        }
        if (!dataLoaderManager.initializeDataLoader(mountId, params, control, listener)) {
            Slog.e(TAG, "Failed to initialize data loader");
            return false;
        }
        return true;
    }


    @Override
    public boolean startDataLoader(int mountId) {
        IDataLoader dataLoader = mDataLoaderManager.getDataLoader(mountId);
        if (dataLoader == null) {
            Slog.e(TAG, "Start failed to retrieve data loader for ID=" + mountId);
            return false;
        }
        try {
            dataLoader.start();
            return true;
        } catch (RemoteException ex) {
            return false;
        }
    }

    @Override
    public void destroyDataLoader(int mountId) {
        IDataLoader dataLoader = mDataLoaderManager.getDataLoader(mountId);
        if (dataLoader == null) {
            Slog.e(TAG, "Destroy failed to retrieve data loader for ID=" + mountId);
            return;
        }
        try {
            dataLoader.destroy();
        } catch (RemoteException ex) {
            return;
        }
    }

    @Override
    public void showHealthBlockedUI(int mountId) {
        // TODO(b/136132412): implement this
    }

    private static native long nativeStartService();

    private static native void nativeSystemReady(long nativeInstance);

    private static native void nativeDump(long nativeInstance, int fd);
}
Loading