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

Commit 6f28d5e6 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Migrating Incremental* APIs to PackageManager APIs."

parents 06194d4d 1ecfcece
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -833,6 +833,7 @@ filegroup {
    name: "dataloader_aidl",
    srcs: [
        "core/java/android/content/pm/DataLoaderParamsParcel.aidl",
        "core/java/android/content/pm/DataLoaderType.aidl",
        "core/java/android/content/pm/FileSystemControlParcel.aidl",
        "core/java/android/content/pm/IDataLoaderStatusListener.aidl",
        "core/java/android/content/pm/IPackageInstallerSessionFileSystemConnector.aidl",
+6 −4
Original line number Diff line number Diff line
@@ -1934,10 +1934,12 @@ package android.content.pm {
  }
  public class DataLoaderParams {
    ctor public DataLoaderParams(@NonNull String, @NonNull String, @Nullable java.util.Map<java.lang.String,android.os.ParcelFileDescriptor>);
    method @NonNull public static final android.content.pm.DataLoaderParams forIncremental(@NonNull android.content.ComponentName, @NonNull String, @Nullable java.util.Map<java.lang.String,android.os.ParcelFileDescriptor>);
    method @NonNull public static final android.content.pm.DataLoaderParams forStreaming(@NonNull android.content.ComponentName, @NonNull String);
    method @NonNull public final String getArguments();
    method @NonNull public final android.content.ComponentName getComponentName();
    method @NonNull public final java.util.Map<java.lang.String,android.os.ParcelFileDescriptor> getDynamicArgs();
    method @NonNull public final String getPackageName();
    method @NonNull public final String getStaticArgs();
    method @NonNull public final int getType();
  }
  public final class InstantAppInfo implements android.os.Parcelable {
@@ -2050,11 +2052,11 @@ package android.content.pm {
  public static class PackageInstaller.SessionParams implements android.os.Parcelable {
    method @RequiresPermission(android.Manifest.permission.ALLOCATE_AGGRESSIVE) public void setAllocateAggressive(boolean);
    method @Deprecated public void setAllowDowngrade(boolean);
    method @RequiresPermission(android.Manifest.permission.INSTALL_PACKAGES) public void setDataLoaderParams(@NonNull android.content.pm.DataLoaderParams);
    method public void setDontKillApp(boolean);
    method public void setEnableRollback(boolean);
    method public void setEnableRollback(boolean, int);
    method @RequiresPermission(android.Manifest.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS) public void setGrantedRuntimePermissions(String[]);
    method @RequiresPermission(android.Manifest.permission.INSTALL_PACKAGES) public void setIncrementalParams(@NonNull android.content.pm.DataLoaderParams);
    method @RequiresPermission(android.Manifest.permission.INSTALL_PACKAGES) public void setInstallAsApex();
    method public void setInstallAsInstantApp(boolean);
    method public void setInstallAsVirtualPreload();
+52 −20
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.content.pm;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.content.ComponentName;
import android.os.ParcelFileDescriptor;

import java.util.Arrays;
@@ -26,7 +27,7 @@ import java.util.Map;
import java.util.stream.Collectors;

/**
 * This class represents the parameters used to configure an Incremental Data Loader.
 * This class represents the parameters used to configure a Data Loader.
 *
 * WARNING: This is a system API to aid internal development.
 * Use at your own risk. It will change or be removed without warning.
@@ -34,13 +35,41 @@ import java.util.stream.Collectors;
 */
@SystemApi
public class DataLoaderParams {
    @NonNull private final DataLoaderParamsParcel mData;
    @NonNull
    private final DataLoaderParamsParcel mData;

    public DataLoaderParams(@NonNull String url, @NonNull String packageName,
    /**
     * Creates and populates set of Data Loader parameters for Streaming installation.
     *
     * @param componentName Data Loader component supporting Streaming installation.
     * @param arguments free form installation arguments
     */
    public static final @NonNull DataLoaderParams forStreaming(@NonNull ComponentName componentName,
            @NonNull String arguments) {
        return new DataLoaderParams(DataLoaderType.STREAMING, componentName, arguments, null);
    }

    /**
     * Creates and populates set of Data Loader parameters for Incremental installation.
     *
     * @param componentName Data Loader component supporting Incremental installation.
     * @param arguments free form installation arguments
     * @param namedFds TODO(b/146080380) remove
     */
    public static final @NonNull DataLoaderParams forIncremental(
            @NonNull ComponentName componentName, @NonNull String arguments,
            @Nullable Map<String, ParcelFileDescriptor> namedFds) {
        return new DataLoaderParams(DataLoaderType.INCREMENTAL, componentName, arguments, namedFds);
    }

    /** @hide */
    public DataLoaderParams(@NonNull @DataLoaderType int type, @NonNull ComponentName componentName,
            @NonNull String arguments, @Nullable Map<String, ParcelFileDescriptor> namedFds) {
        DataLoaderParamsParcel data = new DataLoaderParamsParcel();
        data.staticArgs = url;
        data.packageName = packageName;
        data.type = type;
        data.packageName = componentName.getPackageName();
        data.className = componentName.getClassName();
        data.arguments = arguments;
        if (namedFds == null || namedFds.isEmpty()) {
            data.dynamicArgs = new NamedParcelFileDescriptor[0];
        } else {
@@ -56,36 +85,39 @@ public class DataLoaderParams {
        mData = data;
    }

    /**
     * @hide
     */
    public DataLoaderParams(@NonNull DataLoaderParamsParcel data) {
    /** @hide */
    DataLoaderParams(@NonNull DataLoaderParamsParcel data) {
        mData = data;
    }

    /** @hide */
    public final @NonNull DataLoaderParamsParcel getData() {
        return mData;
    }

    /**
     * @return static server's URL
     * @return data loader type
     */
    public final @NonNull String getStaticArgs() {
        return mData.staticArgs;
    public final @NonNull @DataLoaderType int getType() {
        return mData.type;
    }

    /**
     * @return data loader's package name
     * @return data loader's component name
     */
    public final @NonNull String getPackageName() {
        return mData.packageName;
    public final @NonNull ComponentName getComponentName() {
        return new ComponentName(mData.packageName, mData.className);
    }

    /**
     * @hide
     * @return data loader's arguments
     */
    public final @NonNull DataLoaderParamsParcel getData() {
        return mData;
    public final @NonNull String getArguments() {
        return mData.arguments;
    }

    /**
     * @return data loader's dynamic arguments such as file descriptors
     * @return data loader's dynamic arguments such as file descriptors TODO: remove
     */
    public final @NonNull Map<String, ParcelFileDescriptor> getDynamicArgs() {
        return Arrays.stream(mData.dynamicArgs).collect(
+4 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.content.pm;

import android.content.pm.DataLoaderType;
import android.content.pm.NamedParcelFileDescriptor;

/**
@@ -23,7 +24,9 @@ import android.content.pm.NamedParcelFileDescriptor;
 * @hide
 */
parcelable DataLoaderParamsParcel {
    DataLoaderType type;
    @utf8InCpp String packageName;
    @utf8InCpp String staticArgs;
    @utf8InCpp String className;
    @utf8InCpp String arguments;
    NamedParcelFileDescriptor[] dynamicArgs;
}
+37 −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;

/**
 * Types of Data Loader for an installation session.
 * @hide
 */
@Backing(type="int")
enum DataLoaderType {
    /**
    * Default value, legacy installation.
    */
    NONE = 0,
    /**
     * Streaming installation using data loader.
     */
    STREAMING = 1,
    /**
     * Streaming installation using Incremental FileSystem.
     */
    INCREMENTAL = 2,
}
Loading