From 8e3eeb507afdf563b02c1f77fa9dd18018ff9763 Mon Sep 17 00:00:00 2001 From: Alex Buynytskyy Date: Thu, 25 Mar 2021 14:52:33 -0700 Subject: [PATCH] Making the rest of Streaming installation API public. Something was left behind when we opened the installation API. Bug: 152310230 Test: atest PackageManagerShellCommandTest PackageManagerShellCommandIncrementalTest IncrementalServiceTest PackageManagerServiceTest ChecksumsTest Change-Id: Ia2d4c3f3e97c8432fcca094d6e0f4e97dcc048d4 --- core/api/current.txt | 28 +++++++++++++++++++ core/api/system-current.txt | 27 ------------------ .../android/content/pm/InstallationFile.java | 9 ++---- .../android/content/pm/PackageInstaller.java | 13 +++++---- .../service/dataloader/DataLoaderService.java | 18 +----------- 5 files changed, 39 insertions(+), 56 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index acd1e99de8495..b76f5cc23f192 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -12079,6 +12079,14 @@ package android.content.pm { field @NonNull public static final android.os.Parcelable.Creator CREATOR; } + public final class InstallationFile { + method public long getLengthBytes(); + method public int getLocation(); + method @Nullable public byte[] getMetadata(); + method @NonNull public String getName(); + method @Nullable public byte[] getSignature(); + } + public class InstrumentationInfo extends android.content.pm.PackageItemInfo implements android.os.Parcelable { ctor public InstrumentationInfo(); ctor public InstrumentationInfo(android.content.pm.InstrumentationInfo); @@ -12316,6 +12324,7 @@ package android.content.pm { method @NonNull public java.io.InputStream openRead(@NonNull String) throws java.io.IOException; method @NonNull public java.io.OutputStream openWrite(@NonNull String, long, long) throws java.io.IOException; method public void removeChildSessionId(int); + method public void removeFile(int, @NonNull String); method public void removeSplit(@NonNull String) throws java.io.IOException; method @Deprecated public void setChecksums(@NonNull String, @NonNull java.util.List, @Nullable byte[]) throws java.io.IOException; method public void setStagingProgress(float); @@ -38237,6 +38246,25 @@ package android.service.controls.templates { } +package android.service.dataloader { + + public abstract class DataLoaderService extends android.app.Service { + ctor public DataLoaderService(); + method @NonNull public final android.os.IBinder onBind(@NonNull android.content.Intent); + method @Nullable public android.service.dataloader.DataLoaderService.DataLoader onCreateDataLoader(@NonNull android.content.pm.DataLoaderParams); + } + + public static interface DataLoaderService.DataLoader { + method public boolean onCreate(@NonNull android.content.pm.DataLoaderParams, @NonNull android.service.dataloader.DataLoaderService.FileSystemConnector); + method public boolean onPrepareImage(@NonNull java.util.Collection, @NonNull java.util.Collection); + } + + public static final class DataLoaderService.FileSystemConnector { + method @RequiresPermission(android.Manifest.permission.INSTALL_PACKAGES) public void writeData(@NonNull String, long, long, @NonNull android.os.ParcelFileDescriptor) throws java.io.IOException; + } + +} + package android.service.dreams { public class DreamService extends android.app.Service implements android.view.Window.Callback { diff --git a/core/api/system-current.txt b/core/api/system-current.txt index e2227eadfc94d..31a571c5e0e9a 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -2462,14 +2462,6 @@ package android.content.pm { method @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_PROFILES) public void startActivity(@NonNull android.content.ComponentName, @NonNull android.os.UserHandle); } - public final class InstallationFile { - method public long getLengthBytes(); - method public int getLocation(); - method @Nullable public byte[] getMetadata(); - method @NonNull public String getName(); - method @Nullable public byte[] getSignature(); - } - public final class InstantAppInfo implements android.os.Parcelable { ctor public InstantAppInfo(android.content.pm.ApplicationInfo, String[], String[]); ctor public InstantAppInfo(String, CharSequence, String[], String[]); @@ -2564,7 +2556,6 @@ package android.content.pm { public static class PackageInstaller.Session implements java.io.Closeable { method @RequiresPermission(android.Manifest.permission.INSTALL_PACKAGES) public void commitTransferred(@NonNull android.content.IntentSender); - method public void removeFile(int, @NonNull String); } public static class PackageInstaller.SessionInfo implements android.os.Parcelable { @@ -9734,24 +9725,6 @@ package android.service.contentsuggestions { } -package android.service.dataloader { - - public abstract class DataLoaderService extends android.app.Service { - ctor public DataLoaderService(); - method @Nullable public android.service.dataloader.DataLoaderService.DataLoader onCreateDataLoader(@NonNull android.content.pm.DataLoaderParams); - } - - public static interface DataLoaderService.DataLoader { - method public boolean onCreate(@NonNull android.content.pm.DataLoaderParams, @NonNull android.service.dataloader.DataLoaderService.FileSystemConnector); - method public boolean onPrepareImage(@NonNull java.util.Collection, @NonNull java.util.Collection); - } - - public static final class DataLoaderService.FileSystemConnector { - method @RequiresPermission(android.Manifest.permission.INSTALL_PACKAGES) public void writeData(@NonNull String, long, long, @NonNull android.os.ParcelFileDescriptor) throws java.io.IOException; - } - -} - package android.service.displayhash { public final class DisplayHashParams implements android.os.Parcelable { diff --git a/core/java/android/content/pm/InstallationFile.java b/core/java/android/content/pm/InstallationFile.java index de761ad1a305b..e764020777143 100644 --- a/core/java/android/content/pm/InstallationFile.java +++ b/core/java/android/content/pm/InstallationFile.java @@ -18,21 +18,16 @@ package android.content.pm; import android.annotation.NonNull; import android.annotation.Nullable; -import android.annotation.SystemApi; /** * Definition of a file in a streaming installation session. * You can use this class to retrieve the information of such a file, such as its name, size and * metadata. These file attributes will be consistent with those used in: - * {@code PackageInstaller.Session#addFile}, when the file was first added into the session. - * - * WARNING: This is a system API to aid internal development. - * Use at your own risk. It will change or be removed without warning. + * {@code android.content.pm.PackageInstaller.Session#addFile}, when the file was first added + * into the session. * * @see android.content.pm.PackageInstaller.Session#addFile - * @hide */ -@SystemApi public final class InstallationFile { private final @NonNull InstallationFileParcel mParcel; diff --git a/core/java/android/content/pm/PackageInstaller.java b/core/java/android/content/pm/PackageInstaller.java index 5afec06449206..3013e23315e56 100644 --- a/core/java/android/content/pm/PackageInstaller.java +++ b/core/java/android/content/pm/PackageInstaller.java @@ -1165,7 +1165,8 @@ public class PackageInstaller { } /** - * Adds a file to session. On commit this file will be pulled from dataLoader. + * Adds a file to session. On commit this file will be pulled from dataLoader {@code + * android.service.dataloader.DataLoaderService.DataLoader}. * * @param location target location for the file. Possible values: * {@link #LOCATION_DATA_APP}, @@ -1184,7 +1185,9 @@ public class PackageInstaller { * APK Signature Scheme v4 * @throws SecurityException if called after the session has been * sealed or abandoned - * @throws IllegalStateException if called for non-callback session + * @throws IllegalStateException if called for non-streaming session + * + * @see android.content.pm.InstallationFile */ public void addFile(@FileLocation int location, @NonNull String name, long lengthBytes, @NonNull byte[] metadata, @Nullable byte[] signature) { @@ -1205,10 +1208,8 @@ public class PackageInstaller { * @param name name of a file, e.g. split. * @throws SecurityException if called after the session has been * sealed or abandoned - * @throws IllegalStateException if called for non-callback session - * {@hide} + * @throws IllegalStateException if called for non-streaming session */ - @SystemApi public void removeFile(@FileLocation int location, @NonNull String name) { try { mSession.removeFile(location, name); @@ -2015,6 +2016,8 @@ public class PackageInstaller { * Set the data loader params for the session. * This also switches installation into data provider mode and disallow direct writes into * staging folder. + * + * @see android.service.dataloader.DataLoaderService.DataLoader */ public void setDataLoaderParams(@NonNull DataLoaderParams dataLoaderParams) { this.dataLoaderParams = dataLoaderParams; diff --git a/core/java/android/service/dataloader/DataLoaderService.java b/core/java/android/service/dataloader/DataLoaderService.java index ad6316cf3d95f..3ad80d3e97fac 100644 --- a/core/java/android/service/dataloader/DataLoaderService.java +++ b/core/java/android/service/dataloader/DataLoaderService.java @@ -19,7 +19,6 @@ package android.service.dataloader; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.RequiresPermission; -import android.annotation.SystemApi; import android.app.Service; import android.content.Intent; import android.content.pm.DataLoaderParams; @@ -41,25 +40,15 @@ import java.util.Collection; /** * The base class for implementing data loader service to control data loaders. Expecting - * Incremental Service to bind to a children class of this. - * - * WARNING: This is a system API to aid internal development. - * Use at your own risk. It will change or be removed without warning. - * - * TODO(b/136132412): update with latest API design - * - * @hide + * Installation Session to bind to a children class of this. */ -@SystemApi public abstract class DataLoaderService extends Service { private static final String TAG = "DataLoaderService"; private final DataLoaderBinderService mBinder = new DataLoaderBinderService(); /** * Managed DataLoader interface. Each instance corresponds to a single installation session. - * @hide */ - @SystemApi public interface DataLoader { /** * A virtual constructor. @@ -88,9 +77,7 @@ public abstract class DataLoaderService extends Service { * DataLoader factory method. * * @return An instance of a DataLoader. - * @hide */ - @SystemApi public @Nullable DataLoader onCreateDataLoader(@NonNull DataLoaderParams dataLoaderParams) { return null; } @@ -156,10 +143,7 @@ public abstract class DataLoaderService extends Service { /** * Used by the DataLoaderService implementations. - * - * @hide */ - @SystemApi public static final class FileSystemConnector { /** * Create a wrapper for a native instance.