summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorSongchun Fan <schfan@google.com>2020-03-04 22:53:12 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-03-04 22:53:12 +0000
commitecd96c2be41cf6b811a89fedb1cc32882c6fa1f2 (patch)
treee135dd79c4e71f905bb1189dd224c56f2c3e1420 /core/java/android
parente8de8f21bd33e607e842f117df46fb575191aa79 (diff)
parent6381d6193ed699ef1df930f6b7bf1ac80ec467d0 (diff)
Merge "make IDataLoaderManager and IDataLoader stable interfaces" into rvc-dev
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/content/pm/DataLoaderManager.java16
-rw-r--r--core/java/android/content/pm/IDataLoader.aidl12
-rw-r--r--core/java/android/content/pm/IDataLoaderManager.aidl7
-rw-r--r--core/java/android/content/pm/InstallationFile.java66
-rw-r--r--core/java/android/content/pm/InstallationFileLocation.aidl26
-rw-r--r--core/java/android/content/pm/InstallationFileParcel.aidl31
-rw-r--r--core/java/android/content/pm/PackageInstaller.java6
-rw-r--r--core/java/android/os/incremental/IncrementalFileStorages.java19
-rw-r--r--core/java/android/service/dataloader/DataLoaderService.java20
9 files changed, 108 insertions, 95 deletions
diff --git a/core/java/android/content/pm/DataLoaderManager.java b/core/java/android/content/pm/DataLoaderManager.java
index 26880384e502..4a6193888685 100644
--- a/core/java/android/content/pm/DataLoaderManager.java
+++ b/core/java/android/content/pm/DataLoaderManager.java
@@ -18,7 +18,6 @@ package android.content.pm;
import android.annotation.NonNull;
import android.annotation.Nullable;
-import android.os.Bundle;
import android.os.RemoteException;
/**
@@ -40,22 +39,19 @@ public class DataLoaderManager {
* 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 params DataLoaderParamsParcel object that contains data loader params, including
+ * its package name, class name, and additional parameters.
+ * @param control FileSystemControlParcel that contains filesystem control handlers.
* @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) {
+ public boolean initializeDataLoader(int dataLoaderId, @NonNull DataLoaderParamsParcel params,
+ @NonNull FileSystemControlParcel control, @NonNull IDataLoaderStatusListener listener) {
try {
- return mService.initializeDataLoader(dataLoaderId, params, listener);
+ return mService.initializeDataLoader(dataLoaderId, params, control, listener);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
diff --git a/core/java/android/content/pm/IDataLoader.aidl b/core/java/android/content/pm/IDataLoader.aidl
index b5baa9379d16..6a2658d72e41 100644
--- a/core/java/android/content/pm/IDataLoader.aidl
+++ b/core/java/android/content/pm/IDataLoader.aidl
@@ -16,20 +16,22 @@
package android.content.pm;
-import android.os.Bundle;
+import android.content.pm.DataLoaderParamsParcel;
+import android.content.pm.FileSystemControlParcel;
import android.content.pm.IDataLoaderStatusListener;
-import android.content.pm.InstallationFile;
+import android.content.pm.InstallationFileParcel;
import java.util.List;
/**
- * TODO: update with new APIs
* @hide
*/
oneway interface IDataLoader {
- void create(int id, in Bundle params, IDataLoaderStatusListener listener);
+ void create(int id, in DataLoaderParamsParcel params,
+ in FileSystemControlParcel control,
+ IDataLoaderStatusListener listener);
void start();
void stop();
void destroy();
- void prepareImage(in List<InstallationFile> addedFiles, in List<String> removedFiles);
+ void prepareImage(in InstallationFileParcel[] addedFiles, in @utf8InCpp String[] removedFiles);
}
diff --git a/core/java/android/content/pm/IDataLoaderManager.aidl b/core/java/android/content/pm/IDataLoaderManager.aidl
index f453c9b6c45f..1336f7229ee7 100644
--- a/core/java/android/content/pm/IDataLoaderManager.aidl
+++ b/core/java/android/content/pm/IDataLoaderManager.aidl
@@ -16,14 +16,15 @@
package android.content.pm;
-import android.os.Bundle;
+import android.content.pm.DataLoaderParamsParcel;
+import android.content.pm.FileSystemControlParcel;
import android.content.pm.IDataLoader;
import android.content.pm.IDataLoaderStatusListener;
-import java.util.List;
/** @hide */
interface IDataLoaderManager {
- boolean initializeDataLoader(int id, in Bundle params, IDataLoaderStatusListener listener);
+ boolean initializeDataLoader(int id, in DataLoaderParamsParcel params,
+ in FileSystemControlParcel control, IDataLoaderStatusListener listener);
IDataLoader getDataLoader(int dataLoaderId);
void destroyDataLoader(int dataLoaderId);
} \ No newline at end of file
diff --git a/core/java/android/content/pm/InstallationFile.java b/core/java/android/content/pm/InstallationFile.java
index b449945628d2..edc04c9e7248 100644
--- a/core/java/android/content/pm/InstallationFile.java
+++ b/core/java/android/content/pm/InstallationFile.java
@@ -19,81 +19,47 @@ package android.content.pm;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
-import android.os.Parcel;
-import android.os.Parcelable;
/**
* Defines the properties of a file in an installation session.
* @hide
*/
@SystemApi
-public final class InstallationFile implements Parcelable {
- private final @PackageInstaller.FileLocation int mLocation;
- private final @NonNull String mName;
- private final long mLengthBytes;
- private final @Nullable byte[] mMetadata;
- private final @Nullable byte[] mSignature;
+public final class InstallationFile {
+ private final @NonNull InstallationFileParcel mParcel;
public InstallationFile(@PackageInstaller.FileLocation int location, @NonNull String name,
long lengthBytes, @Nullable byte[] metadata, @Nullable byte[] signature) {
- mLocation = location;
- mName = name;
- mLengthBytes = lengthBytes;
- mMetadata = metadata;
- mSignature = signature;
+ mParcel = new InstallationFileParcel();
+ mParcel.location = location;
+ mParcel.name = name;
+ mParcel.size = lengthBytes;
+ mParcel.metadata = metadata;
+ mParcel.signature = signature;
}
public @PackageInstaller.FileLocation int getLocation() {
- return mLocation;
+ return mParcel.location;
}
public @NonNull String getName() {
- return mName;
+ return mParcel.name;
}
public long getLengthBytes() {
- return mLengthBytes;
+ return mParcel.size;
}
public @Nullable byte[] getMetadata() {
- return mMetadata;
+ return mParcel.metadata;
}
public @Nullable byte[] getSignature() {
- return mSignature;
+ return mParcel.signature;
}
- private InstallationFile(Parcel source) {
- mLocation = source.readInt();
- mName = source.readString();
- mLengthBytes = source.readLong();
- mMetadata = source.createByteArray();
- mSignature = source.createByteArray();
+ /** @hide */
+ public @NonNull InstallationFileParcel getData() {
+ return mParcel;
}
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(@NonNull Parcel dest, int flags) {
- dest.writeInt(mLocation);
- dest.writeString(mName);
- dest.writeLong(mLengthBytes);
- dest.writeByteArray(mMetadata);
- dest.writeByteArray(mSignature);
- }
-
- public static final @NonNull Creator<InstallationFile> CREATOR =
- new Creator<InstallationFile>() {
- public InstallationFile createFromParcel(Parcel source) {
- return new InstallationFile(source);
- }
-
- public InstallationFile[] newArray(int size) {
- return new InstallationFile[size];
- }
- };
-
}
diff --git a/core/java/android/content/pm/InstallationFileLocation.aidl b/core/java/android/content/pm/InstallationFileLocation.aidl
new file mode 100644
index 000000000000..501640aa5c7e
--- /dev/null
+++ b/core/java/android/content/pm/InstallationFileLocation.aidl
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2020 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;
+
+/** @hide */
+@Backing(type="int")
+enum InstallationFileLocation {
+ UNKNOWN = -1,
+ DATA_APP = 0,
+ MEDIA_OBB = 1,
+ MEDIA_DATA = 2
+} \ No newline at end of file
diff --git a/core/java/android/content/pm/InstallationFileParcel.aidl b/core/java/android/content/pm/InstallationFileParcel.aidl
new file mode 100644
index 000000000000..b7efc1947cc3
--- /dev/null
+++ b/core/java/android/content/pm/InstallationFileParcel.aidl
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2020 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.content.pm.InstallationFileLocation;
+
+/**
+ * Describes a file which is part of a package installation.
+ * @hide
+ */
+parcelable InstallationFileParcel {
+ String name;
+ InstallationFileLocation location;
+ long size;
+ byte[] metadata;
+ byte[] signature;
+}
diff --git a/core/java/android/content/pm/PackageInstaller.java b/core/java/android/content/pm/PackageInstaller.java
index 2acbb97cb20a..1f5317679bd2 100644
--- a/core/java/android/content/pm/PackageInstaller.java
+++ b/core/java/android/content/pm/PackageInstaller.java
@@ -372,7 +372,7 @@ public class PackageInstaller {
* {@hide}
*/
@SystemApi
- public static final int LOCATION_DATA_APP = 0;
+ public static final int LOCATION_DATA_APP = InstallationFileLocation.DATA_APP;
/**
* Target location for the file in installation session is
@@ -380,7 +380,7 @@ public class PackageInstaller {
* {@hide}
*/
@SystemApi
- public static final int LOCATION_MEDIA_OBB = 1;
+ public static final int LOCATION_MEDIA_OBB = InstallationFileLocation.MEDIA_OBB;
/**
* Target location for the file in installation session is
@@ -390,7 +390,7 @@ public class PackageInstaller {
* {@hide}
*/
@SystemApi
- public static final int LOCATION_MEDIA_DATA = 2;
+ public static final int LOCATION_MEDIA_DATA = InstallationFileLocation.MEDIA_DATA;
/** @hide */
@IntDef(prefix = { "LOCATION_" }, value = {
diff --git a/core/java/android/os/incremental/IncrementalFileStorages.java b/core/java/android/os/incremental/IncrementalFileStorages.java
index ab224a2c0b51..251995a14090 100644
--- a/core/java/android/os/incremental/IncrementalFileStorages.java
+++ b/core/java/android/os/incremental/IncrementalFileStorages.java
@@ -36,7 +36,7 @@ import android.annotation.Nullable;
import android.content.Context;
import android.content.pm.DataLoaderParams;
import android.content.pm.IDataLoaderStatusListener;
-import android.content.pm.InstallationFile;
+import android.content.pm.InstallationFileParcel;
import android.text.TextUtils;
import android.util.Slog;
@@ -76,7 +76,7 @@ public final class IncrementalFileStorages {
@NonNull File stageDir,
@NonNull DataLoaderParams dataLoaderParams,
@Nullable IDataLoaderStatusListener dataLoaderStatusListener,
- List<InstallationFile> addedFiles) throws IOException {
+ List<InstallationFileParcel> addedFiles) throws IOException {
// TODO(b/136132412): sanity check if session should not be incremental
IncrementalManager incrementalManager = (IncrementalManager) context.getSystemService(
Context.INCREMENTAL_SERVICE);
@@ -94,17 +94,17 @@ public final class IncrementalFileStorages {
result.mDefaultStorage.bind(stageDir.getAbsolutePath());
}
- for (InstallationFile file : addedFiles) {
- if (file.getLocation() == LOCATION_DATA_APP) {
+ for (InstallationFileParcel file : addedFiles) {
+ if (file.location == LOCATION_DATA_APP) {
try {
result.addApkFile(file);
} catch (IOException e) {
// TODO(b/146080380): add incremental-specific error code
throw new IOException(
- "Failed to add file to IncFS: " + file.getName() + ", reason: ", e);
+ "Failed to add file to IncFS: " + file.name + ", reason: ", e);
}
} else {
- throw new IOException("Unknown file location: " + file.getLocation());
+ throw new IOException("Unknown file location: " + file.location);
}
}
@@ -154,12 +154,11 @@ public final class IncrementalFileStorages {
}
}
- private void addApkFile(@NonNull InstallationFile apk) throws IOException {
- final String apkName = apk.getName();
+ private void addApkFile(@NonNull InstallationFileParcel apk) throws IOException {
+ final String apkName = apk.name;
final File targetFile = new File(mStageDir, apkName);
if (!targetFile.exists()) {
- mDefaultStorage.makeFile(apkName, apk.getLengthBytes(), null, apk.getMetadata(),
- apk.getSignature());
+ mDefaultStorage.makeFile(apkName, apk.size, null, apk.metadata, apk.signature);
}
}
diff --git a/core/java/android/service/dataloader/DataLoaderService.java b/core/java/android/service/dataloader/DataLoaderService.java
index 41900015d6a5..5bf1975a44ff 100644
--- a/core/java/android/service/dataloader/DataLoaderService.java
+++ b/core/java/android/service/dataloader/DataLoaderService.java
@@ -27,8 +27,8 @@ import android.content.pm.FileSystemControlParcel;
import android.content.pm.IDataLoader;
import android.content.pm.IDataLoaderStatusListener;
import android.content.pm.InstallationFile;
+import android.content.pm.InstallationFileParcel;
import android.content.pm.NamedParcelFileDescriptor;
-import android.os.Bundle;
import android.os.IBinder;
import android.os.ParcelFileDescriptor;
import android.util.ExceptionUtils;
@@ -36,7 +36,6 @@ import android.util.Slog;
import java.io.IOException;
import java.util.Collection;
-import java.util.List;
/**
* The base class for implementing data loader service to control data loaders. Expecting
@@ -105,18 +104,11 @@ public abstract class DataLoaderService extends Service {
private int mId;
@Override
- public void create(int id, @NonNull Bundle options,
+ public void create(int id, @NonNull DataLoaderParamsParcel params,
+ @NonNull FileSystemControlParcel control,
@NonNull IDataLoaderStatusListener listener)
- throws IllegalArgumentException, RuntimeException {
+ throws RuntimeException {
mId = id;
- final DataLoaderParamsParcel params = options.getParcelable("params");
- if (params == null) {
- throw new IllegalArgumentException("Must specify data loader params");
- }
- final FileSystemControlParcel control = options.getParcelable("control");
- if (control == null) {
- throw new IllegalArgumentException("Must specify control parcel");
- }
try {
if (!nativeCreateDataLoader(id, control, params, listener)) {
Slog.e(TAG, "Failed to create native loader for " + mId);
@@ -178,7 +170,7 @@ public abstract class DataLoaderService extends Service {
}
@Override
- public void prepareImage(List<InstallationFile> addedFiles, List<String> removedFiles) {
+ public void prepareImage(InstallationFileParcel[] addedFiles, String[] removedFiles) {
if (!nativePrepareImage(mId, addedFiles, removedFiles)) {
Slog.w(TAG, "Failed to destroy loader: " + mId);
}
@@ -240,7 +232,7 @@ public abstract class DataLoaderService extends Service {
private native boolean nativeDestroyDataLoader(int storageId);
private native boolean nativePrepareImage(int storageId,
- List<InstallationFile> addedFiles, List<String> removedFiles);
+ InstallationFileParcel[] addedFiles, String[] removedFiles);
private static native void nativeWriteData(long nativeInstance, String name, long offsetBytes,
long lengthBytes, ParcelFileDescriptor incomingFd);