summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorSongchun Fan <schfan@google.com>2019-11-29 15:20:18 -0800
committerSongchun Fan <schfan@google.com>2019-12-04 11:00:23 -0800
commit6dd47b58c53acee91810cd2714b97aacbfbfec6a (patch)
tree2d056e58407e47c742896c715cb011631f587a09 /core/java/android
parent7c738c6ac83ab35ea5a910addf06835cfc7fe3ae (diff)
[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
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/content/Context.java8
-rw-r--r--core/java/android/content/Intent.java7
-rw-r--r--core/java/android/content/pm/DataLoaderManager.java87
-rw-r--r--core/java/android/content/pm/IDataLoader.aidl34
-rw-r--r--core/java/android/content/pm/IDataLoaderManager.aidl29
-rw-r--r--core/java/android/content/pm/IDataLoaderStatusListener.aidl (renamed from core/java/android/service/incremental/IIncrementalDataLoaderStatusListener.aidl)8
-rw-r--r--core/java/android/content/pm/InstallationFile.aidl23
-rw-r--r--core/java/android/content/pm/InstallationFile.java118
-rw-r--r--core/java/android/os/incremental/IIncrementalServiceProxy.aidl4
-rw-r--r--core/java/android/service/incremental/IIncrementalDataLoaderService.aidl34
10 files changed, 311 insertions, 41 deletions
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 341b5206ba90..d370a380bc3b 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -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 {}
@@ -4971,6 +4970,13 @@ public abstract class Context {
/**
* 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}.
* @hide
*/
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 40aca0ef2033..af7b98683219 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -4053,6 +4053,13 @@ public class Intent implements Parcelable, Cloneable {
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.
* @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
diff --git a/core/java/android/content/pm/DataLoaderManager.java b/core/java/android/content/pm/DataLoaderManager.java
new file mode 100644
index 000000000000..26880384e502
--- /dev/null
+++ b/core/java/android/content/pm/DataLoaderManager.java
@@ -0,0 +1,87 @@
+/*
+ * 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();
+ }
+ }
+}
diff --git a/core/java/android/content/pm/IDataLoader.aidl b/core/java/android/content/pm/IDataLoader.aidl
new file mode 100644
index 000000000000..60cc9ba9e141
--- /dev/null
+++ b/core/java/android/content/pm/IDataLoader.aidl
@@ -0,0 +1,34 @@
+/*
+ * 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);
+}
diff --git a/core/java/android/content/pm/IDataLoaderManager.aidl b/core/java/android/content/pm/IDataLoaderManager.aidl
new file mode 100644
index 000000000000..f453c9b6c45f
--- /dev/null
+++ b/core/java/android/content/pm/IDataLoaderManager.aidl
@@ -0,0 +1,29 @@
+/*
+ * 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.IDataLoader;
+import android.content.pm.IDataLoaderStatusListener;
+import java.util.List;
+
+/** @hide */
+interface IDataLoaderManager {
+ boolean initializeDataLoader(int id, in Bundle params, IDataLoaderStatusListener listener);
+ IDataLoader getDataLoader(int dataLoaderId);
+ void destroyDataLoader(int dataLoaderId);
+} \ No newline at end of file
diff --git a/core/java/android/service/incremental/IIncrementalDataLoaderStatusListener.aidl b/core/java/android/content/pm/IDataLoaderStatusListener.aidl
index f04242dc6c02..a60d6ee2d28a 100644
--- a/core/java/android/service/incremental/IIncrementalDataLoaderStatusListener.aidl
+++ b/core/java/android/content/pm/IDataLoaderStatusListener.aidl
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-package android.service.incremental;
+package android.content.pm;
/**
- * Callbacks from DataLoaderService to IncrementalService to report data loader status.
+ * Callbacks from a data loader binder service to report data loader status.
* @hide
*/
-oneway interface IIncrementalDataLoaderStatusListener {
+oneway interface IDataLoaderStatusListener {
/** Data loader status */
const int DATA_LOADER_READY = 0;
const int DATA_LOADER_NOT_READY = 1;
@@ -31,6 +31,6 @@ oneway interface IIncrementalDataLoaderStatusListener {
const int DATA_LOADER_CONNECTION_OK = 6;
/** Data loader status callback */
- void onStatusChanged(in int storageId, in int status);
+ void onStatusChanged(in int dataLoaderId, in int status);
}
diff --git a/core/java/android/content/pm/InstallationFile.aidl b/core/java/android/content/pm/InstallationFile.aidl
new file mode 100644
index 000000000000..1edff9d6c7aa
--- /dev/null
+++ b/core/java/android/content/pm/InstallationFile.aidl
@@ -0,0 +1,23 @@
+/*
+ * 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;
+
+/**
+ * Describes a file which is part of a package installation.
+ */
+parcelable InstallationFile;
+
diff --git a/core/java/android/content/pm/InstallationFile.java b/core/java/android/content/pm/InstallationFile.java
new file mode 100644
index 000000000000..ac5fd1e41075
--- /dev/null
+++ b/core/java/android/content/pm/InstallationFile.java
@@ -0,0 +1,118 @@
+/*
+ * 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.IntDef;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Defines the properties of a file in an installation session.
+ * TODO(b/136132412): update with new APIs.
+ *
+ * @hide
+ */
+public final class InstallationFile implements Parcelable {
+ public static final int FILE_TYPE_UNKNOWN = -1;
+ public static final int FILE_TYPE_APK = 0;
+ public static final int FILE_TYPE_LIB = 1;
+ public static final int FILE_TYPE_OBB = 2;
+
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = {"FILE_TYPE_"}, value = {
+ FILE_TYPE_APK,
+ FILE_TYPE_LIB,
+ FILE_TYPE_OBB,
+ })
+ public @interface FileType {
+ }
+
+ private String mFileName;
+ private @FileType int mFileType;
+ private long mFileSize;
+ private byte[] mMetadata;
+
+ public InstallationFile(@NonNull String fileName, long fileSize,
+ @Nullable byte[] metadata) {
+ mFileName = fileName;
+ mFileSize = fileSize;
+ mMetadata = metadata;
+ if (fileName.toLowerCase().endsWith(".apk")) {
+ mFileType = FILE_TYPE_APK;
+ } else if (fileName.toLowerCase().endsWith(".obb")) {
+ mFileType = FILE_TYPE_OBB;
+ } else if (fileName.toLowerCase().endsWith(".so") && fileName.toLowerCase().startsWith(
+ "lib/")) {
+ mFileType = FILE_TYPE_LIB;
+ } else {
+ mFileType = FILE_TYPE_UNKNOWN;
+ }
+ }
+
+ public @FileType int getFileType() {
+ return mFileType;
+ }
+
+ public @NonNull String getName() {
+ return mFileName;
+ }
+
+ public long getSize() {
+ return mFileSize;
+ }
+
+ public @Nullable byte[] getMetadata() {
+ return mMetadata;
+ }
+
+ private InstallationFile(Parcel source) {
+ mFileName = source.readString();
+ mFileType = source.readInt();
+ mFileSize = source.readLong();
+ mMetadata = source.createByteArray();
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ dest.writeString(mFileName);
+ dest.writeInt(mFileType);
+ dest.writeLong(mFileSize);
+ dest.writeByteArray(mMetadata);
+ }
+
+ 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/os/incremental/IIncrementalServiceProxy.aidl b/core/java/android/os/incremental/IIncrementalServiceProxy.aidl
index 12740eaf3425..ffff52e5aac9 100644
--- a/core/java/android/os/incremental/IIncrementalServiceProxy.aidl
+++ b/core/java/android/os/incremental/IIncrementalServiceProxy.aidl
@@ -18,7 +18,7 @@ package android.os.incremental;
import android.os.incremental.IncrementalFileSystemControlParcel;
import android.os.incremental.IncrementalDataLoaderParamsParcel;
-import android.service.incremental.IIncrementalDataLoaderStatusListener;
+import android.content.pm.IDataLoaderStatusListener;
/**
* Binder service to receive calls from native Incremental Service and handle Java tasks such as
@@ -29,7 +29,7 @@ interface IIncrementalServiceProxy {
boolean prepareDataLoader(int mountId,
in IncrementalFileSystemControlParcel control,
in IncrementalDataLoaderParamsParcel params,
- in IIncrementalDataLoaderStatusListener listener);
+ in IDataLoaderStatusListener listener);
boolean startDataLoader(int mountId);
void showHealthBlockedUI(int mountId);
void destroyDataLoader(int mountId);
diff --git a/core/java/android/service/incremental/IIncrementalDataLoaderService.aidl b/core/java/android/service/incremental/IIncrementalDataLoaderService.aidl
deleted file mode 100644
index 723fc594bd72..000000000000
--- a/core/java/android/service/incremental/IIncrementalDataLoaderService.aidl
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.service.incremental;
-
-import android.os.incremental.IncrementalDataLoaderParamsParcel;
-import android.os.incremental.IncrementalFileSystemControlParcel;
-import android.service.incremental.IIncrementalDataLoaderStatusListener;
-
-/** @hide */
-oneway interface IIncrementalDataLoaderService {
- void createDataLoader(in int storageId,
- in IncrementalFileSystemControlParcel control,
- in IncrementalDataLoaderParamsParcel params,
- in IIncrementalDataLoaderStatusListener listener,
- in boolean start);
- void startDataLoader(in int storageId);
- void stopDataLoader(in int storageId);
- void destroyDataLoader(in int storageId);
- void onFileCreated(in int storageId, in long inode, in byte[] metadata);
-}