From bcc56339bb74737b235376c338efd21db843d796 Mon Sep 17 00:00:00 2001 From: "Kyeongkab.Nam" Date: Tue, 9 Apr 2019 12:07:37 +0900 Subject: [PATCH] Add a new API applyPayloadFd() of UpdateEngine Due to the restriction of Treble, update_engine cannot access to OTA packages located on non-core domain area. (e.g. /data/vendor/upgrade/xxx.zip) To solve such problem, update_engine needs to accept a file descriptor (FD) of OTA package file instead of its URI. Accordingly, UpdateEngine also needs to add a new interface of applyPayload which accepts FD. Test: Manual update Bug: 130209137 Change-Id: Ic924445c4abf27fd7dc111c74b972ac7ff9ffa6b --- 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 cf55fbef1ff5a..466ecd1e7891e 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -4268,6 +4268,7 @@ package android.os { public class UpdateEngine { ctor public UpdateEngine(); method public void applyPayload(String, long, long, String[]); + method public void applyPayload(java.io.FileDescriptor, long, long, String[]); method public boolean bind(android.os.UpdateEngineCallback, android.os.Handler); method public boolean bind(android.os.UpdateEngineCallback); method public void cancel(); diff --git a/core/java/android/os/UpdateEngine.java b/core/java/android/os/UpdateEngine.java index 8f2826c16b631..69bdde35a967e 100644 --- a/core/java/android/os/UpdateEngine.java +++ b/core/java/android/os/UpdateEngine.java @@ -21,6 +21,8 @@ import android.os.IUpdateEngine; import android.os.IUpdateEngineCallback; import android.os.RemoteException; +import java.io.FileDescriptor; + /** * UpdateEngine handles calls to the update engine which takes care of A/B OTA * updates. It wraps up the update engine Binder APIs and exposes them as @@ -186,6 +188,22 @@ public class UpdateEngine { } } + /** + * Applies the payload passed as file descriptor {@code fd} instead of + * using the {@code file://} scheme. + * + *

See {@link #applyPayload(String)} for {@code offset}, {@code size} and + * {@code headerKeyValuePairs} parameters. + */ + public void applyPayload(FileDescriptor fd, long offset, long size, + String[] headerKeyValuePairs) { + try { + mUpdateEngine.applyPayloadFd(fd, offset, size, headerKeyValuePairs); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + /** * Permanently cancels an in-progress update. *