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

Commit 6dd47b58 authored by Songchun Fan's avatar Songchun Fan
Browse files

[incremental] data loader manager interface

Checking in the interface for data loader manager and installation
files in android.content.pm.

Copied from branch master-instamatic. TODO to update the code with
latest API design.

Test: builds
Change-Id: Ie87dd8b45dc18f538ddabf87e2899e958133ff04
parent 7c738c6a
Loading
Loading
Loading
Loading
+23 −4
Original line number Diff line number Diff line
@@ -803,10 +803,9 @@ filegroup {
}

filegroup {
    name: "incremental_data_loader_aidl",
    name: "dataloader_aidl",
    srcs: [
        "core/java/android/service/incremental/IIncrementalDataLoaderStatusListener.aidl",
        "core/java/android/service/incremental/IIncrementalDataLoaderService.aidl",
        "core/java/android/content/pm/IDataLoaderStatusListener.aidl",
    ],
    path: "core/java",
}
@@ -815,7 +814,27 @@ aidl_interface {
    name: "libincremental_aidl",
    srcs: [
        ":incremental_aidl",
        ":incremental_data_loader_aidl",
    ],
    imports: [
        "libdataloader_aidl",
    ],
    backend: {
        java: {
            sdk_version: "28",
        },
        cpp: {
            enabled: true,
        },
        ndk: {
            enabled: true,
        },
    },
}

aidl_interface {
    name: "libdataloader_aidl",
    srcs: [
        ":dataloader_aidl",
    ],
    backend: {
        java: {
+7 −1
Original line number Diff line number Diff line
@@ -3427,7 +3427,6 @@ public abstract class Context {
            //@hide: TIME_DETECTOR_SERVICE,
            //@hide: TIME_ZONE_DETECTOR_SERVICE,
            PERMISSION_SERVICE,
            INCREMENTAL_SERVICE,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface ServiceName {}
@@ -4969,6 +4968,13 @@ public abstract class Context {
    @SystemApi
    public static final String APP_INTEGRITY_SERVICE = "app_integrity";

    /**
     * Use with {@link #getSystemService(String)} to retrieve an
     * {@link android.content.pm.DataLoaderManager}.
     * @hide
     */
    public static final String DATA_LOADER_MANAGER_SERVICE = "dataloadermanager";

    /**
     * Use with {@link #getSystemService(String)} to retrieve an
     * {@link android.os.incremental.IncrementalManager}.
+7 −0
Original line number Diff line number Diff line
@@ -4052,6 +4052,13 @@ public class Intent implements Parcelable, Cloneable {
    @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";

    /**
     * Used for looking up a Data Loader Service providers.
     * @hide
     */
    @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION)
    public static final String ACTION_LOAD_DATA = "android.intent.action.LOAD_DATA";

    /**
     * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
     * state.
+87 −0
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.content.pm;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Bundle;
import android.os.RemoteException;

/**
 * Data loader manager takes care of data loaders of different packages. It provides methods to
 * initialize a data loader binder service (binding and creating it), to return a binder of the data
 * loader binder service and to destroy a data loader binder service.
 * @see com.android.server.pm.DataLoaderManagerService
 * @hide
 */
public class DataLoaderManager {
    private static final String TAG = "DataLoaderManager";
    private final IDataLoaderManager mService;

    public DataLoaderManager(IDataLoaderManager service) {
        mService = service;
    }

    /**
     * Finds a data loader binder service and binds to it. This requires PackageManager.
     *
     * @param dataLoaderId ID for the new data loader binder service.
     * @param params       Bundle that contains parameters to configure the data loader service.
     *                     Must contain:
     *                     key: "packageName", value: String, package name of data loader service
     *                     package;
     *                     key: "extras", value: Bundle, client-specific data structures
     *
     * @param listener     Callback for the data loader service to report status back to the
     *                     caller.
     * @return false if 1) target ID collides with a data loader that is already bound to data
     * loader manager; 2) package name is not specified; 3) fails to find data loader package;
     * or 4) fails to bind to the specified data loader service, otherwise return true.
     */
    public boolean initializeDataLoader(int dataLoaderId, @NonNull Bundle params,
            @NonNull IDataLoaderStatusListener listener) {
        try {
            return mService.initializeDataLoader(dataLoaderId, params, listener);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Returns a binder interface of the data loader binder service, given its ID.
     */
    @Nullable
    public IDataLoader getDataLoader(int dataLoaderId) {
        try {
            return mService.getDataLoader(dataLoaderId);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Destroys the data loader binder service and removes it from data loader manager service.
     */
    @Nullable
    public void destroyDataLoader(int dataLoaderId) {
        try {
            mService.destroyDataLoader(dataLoaderId);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
}
+34 −0
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.content.pm;

import android.os.Bundle;
import android.content.pm.IDataLoaderStatusListener;
import android.content.pm.InstallationFile;
import java.util.List;

/**
 * TODO: update with new APIs
 * @hide
 */
oneway interface IDataLoader {
   void create(int id, in Bundle params, IDataLoaderStatusListener listener);
   void start(in List<InstallationFile> fileInfos);
   void stop();
   void destroy();
   void onFileCreated(long inode, in byte[] metadata);
}
Loading