Merge "Add executor for the callback."

This commit is contained in:
TreeHugger Robot
2021-12-06 16:45:11 +00:00
committed by Android (Google) Code Review
2 changed files with 8 additions and 3 deletions

View File

@@ -12666,7 +12666,7 @@ package android.content.pm {
method @NonNull public java.io.OutputStream openWrite(@NonNull String, long, long) throws java.io.IOException;
method public void removeChildSessionId(int);
method public void removeSplit(@NonNull String) throws java.io.IOException;
method public void requestChecksums(@NonNull String, int, @NonNull java.util.List<java.security.cert.Certificate>, @NonNull android.content.pm.PackageManager.OnChecksumsReadyListener) throws java.security.cert.CertificateEncodingException, java.io.FileNotFoundException;
method public void requestChecksums(@NonNull String, int, @NonNull java.util.List<java.security.cert.Certificate>, @NonNull java.util.concurrent.Executor, @NonNull android.content.pm.PackageManager.OnChecksumsReadyListener) throws java.security.cert.CertificateEncodingException, java.io.FileNotFoundException;
method @Deprecated public void setChecksums(@NonNull String, @NonNull java.util.List<android.content.pm.Checksum>, @Nullable byte[]) throws java.io.IOException;
method public void setStagingProgress(float);
method public void transfer(@NonNull String) throws android.content.pm.PackageManager.NameNotFoundException;

View File

@@ -28,6 +28,7 @@ import static android.content.pm.Checksum.TYPE_WHOLE_SHA256;
import static android.content.pm.Checksum.TYPE_WHOLE_SHA512;
import android.Manifest;
import android.annotation.CallbackExecutor;
import android.annotation.CurrentTimeMillisLong;
import android.annotation.IntDef;
import android.annotation.NonNull;
@@ -1354,6 +1355,7 @@ public class PackageInstaller {
* {@link PackageManager#TRUST_NONE} disables optimized
* installer-enforced checksums, otherwise the list has to be
* a non-empty list of certificates.
* @param executor the {@link Executor} on which to invoke the callback
* @param onChecksumsReadyListener called once when the results are available.
* @throws CertificateEncodingException if an encoding error occurs for trustedInstallers.
* @throws FileNotFoundException if the file does not exist.
@@ -1361,11 +1363,13 @@ public class PackageInstaller {
*/
public void requestChecksums(@NonNull String name, @Checksum.TypeMask int required,
@NonNull List<Certificate> trustedInstallers,
@NonNull @CallbackExecutor Executor executor,
@NonNull PackageManager.OnChecksumsReadyListener onChecksumsReadyListener)
throws CertificateEncodingException, FileNotFoundException {
Objects.requireNonNull(name);
Objects.requireNonNull(onChecksumsReadyListener);
Objects.requireNonNull(trustedInstallers);
Objects.requireNonNull(executor);
Objects.requireNonNull(onChecksumsReadyListener);
if (trustedInstallers == PackageManager.TRUST_ALL) {
trustedInstallers = null;
} else if (trustedInstallers == PackageManager.TRUST_NONE) {
@@ -1381,7 +1385,8 @@ public class PackageInstaller {
@Override
public void onChecksumsReady(List<ApkChecksum> checksums)
throws RemoteException {
onChecksumsReadyListener.onChecksumsReady(checksums);
executor.execute(
() -> onChecksumsReadyListener.onChecksumsReady(checksums));
}
};
mSession.requestChecksums(name, DEFAULT_CHECKSUMS, required,