From d27be3444f6bc5880489f4f8bc88b875bf7cedf8 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Wed, 10 Jan 2018 11:40:19 -0800 Subject: [PATCH] Expose an update_engine API that verifies the given payload metadata. android.os.UpdateEngine.verifyPayloadMetadata() allows a system updater to verify a payload can be safely applied, by using its payload metadata (usually a few hundred KiB only or even less). This would be useful in improving update UX, since the updater can be smarter to avoid installing an update that would fail to apply, or to fall back from an incremental to full payload. Bug: 65283633 Test: Build and flash walleye on device. Trigger a call to this API. Change-Id: I82546f6b2a8f27cfd956cc1677556e7221cce5fd --- api/system-current.txt | 1 + core/java/android/os/UpdateEngine.java | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/api/system-current.txt b/api/system-current.txt index 3dbb333ef7894..71df2726919cc 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -3806,6 +3806,7 @@ package android.os { method public void resume(); method public void suspend(); method public boolean unbind(); + method public boolean verifyPayloadMetadata(java.lang.String); } public static final class UpdateEngine.ErrorCodeConstants { diff --git a/core/java/android/os/UpdateEngine.java b/core/java/android/os/UpdateEngine.java index c6149bed9d6da..24c9c9177360d 100644 --- a/core/java/android/os/UpdateEngine.java +++ b/core/java/android/os/UpdateEngine.java @@ -271,4 +271,22 @@ public class UpdateEngine { } } } + + /** + * Verifies that a payload associated with the given payload metadata + * {@code payloadMetadataFilename} can be safely applied to ths device. + * Returns {@code true} if the update can successfully be applied and + * returns {@code false} otherwise. + * + * @param payloadMetadataFilename the location of the metadata without the + * {@code file://} prefix. + */ + @SystemApi + public boolean verifyPayloadMetadata(String payloadMetadataFilename) { + try { + return mUpdateEngine.verifyPayloadApplicable(payloadMetadataFilename); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } }