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

Commit d1b41d49 authored by Songchun Fan's avatar Songchun Fan
Browse files

[incremental] Manager, Storage and changes to Package Manager Service

Checking in basic high-level classes and their interactions with
package manager service.

Incremental Manager manages IncrementalStorage instances. Both are
backed by Incremental Service.

Package Manager Service uses Incremental Manager to handle file
operaions on Incremental File System, such as renaming and cleanup.

Also adding place holders for native library handling.

Test: builds
Change-Id: I78b64f795de480e109aeaffe61272a413a6b4be5
parent 8baf5b75
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -772,7 +772,7 @@ cc_library {
filegroup {
    name: "incremental_aidl",
    srcs: [
        "core/java/android/os/incremental/IIncrementalService.aidl",
        "core/java/android/os/incremental/IIncrementalManager.aidl",
        "core/java/android/os/incremental/IIncrementalServiceProxy.aidl",
        "core/java/android/os/incremental/IncrementalDataLoaderParamsParcel.aidl",
        "core/java/android/os/incremental/IncrementalFileSystemControlParcel.aidl",
+8 −0
Original line number Diff line number Diff line
@@ -3384,6 +3384,7 @@ public abstract class Context {
            //@hide: SYSTEM_UPDATE_SERVICE,
            //@hide: TIME_DETECTOR_SERVICE,
            PERMISSION_SERVICE,
            INCREMENTAL_SERVICE,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface ServiceName {}
@@ -4916,6 +4917,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.os.incremental.IncrementalManager}.
     * @hide
     */
    public static final String INCREMENTAL_SERVICE = "incremental";

    /**
     * Determine whether the given permission is allowed for a particular
     * process and user ID running in the system.
+16 −8
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ package android.os.incremental;
import android.os.incremental.IncrementalDataLoaderParamsParcel;

/** @hide */
interface IIncrementalService {
interface IIncrementalManager {
    /**
     * A set of flags for the |createMode| parameters when creating a new Incremental storage.
     */
@@ -52,6 +52,12 @@ interface IIncrementalService {
     */
    int makeDirectory(int storageId, in @utf8InCpp String pathUnderStorage);

    /**
     * Recursively creates a directory under a storage. The target directory is specified by its relative path under the storage.
     * All the parent directories of the target directory will be created if they do not exist already.
     */
    int makeDirectories(int storageId, in @utf8InCpp String pathUnderStorage);

    /**
     * Creates a file under a storage, specifying its name, size and metadata.
     */
@@ -64,10 +70,12 @@ interface IIncrementalService {
    int makeFileFromRange(int storageId, in @utf8InCpp String targetPathUnderStorage, in @utf8InCpp String sourcePathUnderStorage, long start, long end);

    /**
     * Creates a hard link between two files in a storage.
     * Both source and destination are specified by relative paths under storage.
     * Creates a hard link between two files in two storage instances.
     * Source and dest specified by parent storage IDs and their relative paths under the storage.
     * The source and dest storage instances should be in the same fs mount.
     * Note: destStorageId can be the same as sourceStorageId.
     */
    int makeLink(int storageId, in @utf8InCpp String sourcePathUnderStorage, in @utf8InCpp String destPathUnderStorage);
    int makeLink(int sourceStorageId, in @utf8InCpp String sourcePathUnderStorage, int destStorageId, in @utf8InCpp String destPathUnderStorage);

    /**
     * Deletes a hard link in a storage, specified by the relative path of the link target under storage.
@@ -85,12 +93,12 @@ interface IIncrementalService {
    byte[] getFileMetadata(int storageId, in @utf8InCpp String pathUnderStorage);

    /**
     * Returns the list of file paths under a storage.
     * Starts loading data for a storage.
     */
    @utf8InCpp String[] getFileList(int storageId);
    boolean startLoading(int storageId);

    /**
     * Starts loading data for a storage.
     * Deletes a storage given its ID. Deletes its bind mounts and unmount it. Stop its data loader.
     */
    boolean startLoading(int storageId);
    void deleteStorage(int storageId);
}
+84 −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.os.incremental;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.ParcelFileDescriptor;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * This class represents the parameters used to configure an Incremental Data Loader.
 * Hide for now.
 * @hide
 */
public class IncrementalDataLoaderParams {
    @NonNull private final IncrementalDataLoaderParamsParcel mData;

    public IncrementalDataLoaderParams(@NonNull String url, @NonNull String packageName,
            @Nullable Map<String, ParcelFileDescriptor> namedFds) {
        IncrementalDataLoaderParamsParcel data = new IncrementalDataLoaderParamsParcel();
        data.staticArgs = url;
        data.packageName = packageName;
        if (namedFds == null || namedFds.isEmpty()) {
            data.dynamicArgs = new NamedParcelFileDescriptor[0];
        } else {
            data.dynamicArgs = new NamedParcelFileDescriptor[namedFds.size()];
            int i = 0;
            for (Map.Entry<String, ParcelFileDescriptor> namedFd : namedFds.entrySet()) {
                data.dynamicArgs[i] = new NamedParcelFileDescriptor();
                data.dynamicArgs[i].name = namedFd.getKey();
                data.dynamicArgs[i].fd = namedFd.getValue();
                i += 1;
            }
        }
        mData = data;
    }

    public IncrementalDataLoaderParams(@NonNull IncrementalDataLoaderParamsParcel data) {
        mData = data;
    }

    /**
     * @return static server's URL
     */
    public final @NonNull String getStaticArgs() {
        return mData.staticArgs;
    }

    /**
     * @return data loader's package name
     */
    public final @NonNull String getPackageName() {
        return mData.packageName;
    }

    public final @NonNull IncrementalDataLoaderParamsParcel getData() {
        return mData;
    }

    /**
     * @return data loader's dynamic arguments such as file descriptors
     */
    public final @NonNull Map<String, ParcelFileDescriptor> getDynamicArgs() {
        return Arrays.stream(mData.dynamicArgs).collect(
            Collectors.toMap(p->p.name, p->p.fd));
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ import android.os.incremental.NamedParcelFileDescriptor;
 * @hide
 */
parcelable IncrementalDataLoaderParamsParcel {
    @utf8InCpp String staticUri;
    @utf8InCpp String packageName;
    @utf8InCpp String staticArgs;
    NamedParcelFileDescriptor[] dynamicArgs;
}
Loading