1*5a923131SAndroid Build Coastguard Worker /* 2*5a923131SAndroid Build Coastguard Worker * Copyright (C) 2020 The Android Open Source Project 3*5a923131SAndroid Build Coastguard Worker * 4*5a923131SAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*5a923131SAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*5a923131SAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*5a923131SAndroid Build Coastguard Worker * 8*5a923131SAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*5a923131SAndroid Build Coastguard Worker * 10*5a923131SAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*5a923131SAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*5a923131SAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*5a923131SAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*5a923131SAndroid Build Coastguard Worker * limitations under the License. 15*5a923131SAndroid Build Coastguard Worker */ 16*5a923131SAndroid Build Coastguard Worker 17*5a923131SAndroid Build Coastguard Worker package android.os; 18*5a923131SAndroid Build Coastguard Worker 19*5a923131SAndroid Build Coastguard Worker import android.os.IUpdateEngineStableCallback; 20*5a923131SAndroid Build Coastguard Worker import android.os.ParcelFileDescriptor; 21*5a923131SAndroid Build Coastguard Worker 22*5a923131SAndroid Build Coastguard Worker /** 23*5a923131SAndroid Build Coastguard Worker * The stable interface exposed by the update engine daemon. 24*5a923131SAndroid Build Coastguard Worker * 25*5a923131SAndroid Build Coastguard Worker * WARNING: this interface exposes less capabilities than IUpdateEngine, 26*5a923131SAndroid Build Coastguard Worker * for instance, not having a cancel method. This is relied on for 27*5a923131SAndroid Build Coastguard Worker * security. 28*5a923131SAndroid Build Coastguard Worker * @hide 29*5a923131SAndroid Build Coastguard Worker */ 30*5a923131SAndroid Build Coastguard Worker interface IUpdateEngineStable { 31*5a923131SAndroid Build Coastguard Worker /** 32*5a923131SAndroid Build Coastguard Worker * Apply the given payload as provided in the given file descriptor. 33*5a923131SAndroid Build Coastguard Worker * 34*5a923131SAndroid Build Coastguard Worker * See {@link #bind(IUpdateEngineCallback)} for status updates. 35*5a923131SAndroid Build Coastguard Worker * 36*5a923131SAndroid Build Coastguard Worker * @param pfd The file descriptor opened at the payload file. Note that the daemon must have 37*5a923131SAndroid Build Coastguard Worker * enough permission to operate on the file descriptor. 38*5a923131SAndroid Build Coastguard Worker * @param payload_offset offset into pfd where the payload binary starts. 39*5a923131SAndroid Build Coastguard Worker * @param payload_size length after payload_offset to read from pfd. If 0, it will be auto 40*5a923131SAndroid Build Coastguard Worker * detected. 41*5a923131SAndroid Build Coastguard Worker * @param headerKeyValuePairs additional header key value pairs, in the format of "key=value". 42*5a923131SAndroid Build Coastguard Worker * @see android.os.UpdateEngine#applyPayload(android.content.res.AssetFileDescriptor, String[]) 43*5a923131SAndroid Build Coastguard Worker * @hide 44*5a923131SAndroid Build Coastguard Worker */ applyPayloadFd(in ParcelFileDescriptor pfd, in long payload_offset, in long payload_size, in String[] headerKeyValuePairs)45*5a923131SAndroid Build Coastguard Worker void applyPayloadFd(in ParcelFileDescriptor pfd, 46*5a923131SAndroid Build Coastguard Worker in long payload_offset, 47*5a923131SAndroid Build Coastguard Worker in long payload_size, 48*5a923131SAndroid Build Coastguard Worker in String[] headerKeyValuePairs); 49*5a923131SAndroid Build Coastguard Worker 50*5a923131SAndroid Build Coastguard Worker /** 51*5a923131SAndroid Build Coastguard Worker * Bind a callback for status updates on payload application. 52*5a923131SAndroid Build Coastguard Worker * 53*5a923131SAndroid Build Coastguard Worker * At any given time, only one callback can be bound. If a callback is already bound, 54*5a923131SAndroid Build Coastguard Worker * subsequent binding will fail and return false until the bound callback is unbound. That is, 55*5a923131SAndroid Build Coastguard Worker * binding is first-come, first-serve. 56*5a923131SAndroid Build Coastguard Worker * 57*5a923131SAndroid Build Coastguard Worker * A bound callback may be unbound explicitly by calling 58*5a923131SAndroid Build Coastguard Worker * {@link #unbind(IUpdateEngineStableCallback)}, or 59*5a923131SAndroid Build Coastguard Worker * implicitly when the process implementing the callback dies. 60*5a923131SAndroid Build Coastguard Worker * 61*5a923131SAndroid Build Coastguard Worker * @param callback See {@link IUpdateEngineStableCallback} 62*5a923131SAndroid Build Coastguard Worker * @return true if binding is successful, false otherwise. 63*5a923131SAndroid Build Coastguard Worker * @see android.os.UpdateEngine#bind(android.os.UpdateEngineCallback) 64*5a923131SAndroid Build Coastguard Worker * @hide 65*5a923131SAndroid Build Coastguard Worker */ bind(IUpdateEngineStableCallback callback)66*5a923131SAndroid Build Coastguard Worker boolean bind(IUpdateEngineStableCallback callback); 67*5a923131SAndroid Build Coastguard Worker 68*5a923131SAndroid Build Coastguard Worker /** 69*5a923131SAndroid Build Coastguard Worker * Unbind a possibly bound callback. 70*5a923131SAndroid Build Coastguard Worker * 71*5a923131SAndroid Build Coastguard Worker * If the provided callback does not match the previously bound callback, unbinding fails. 72*5a923131SAndroid Build Coastguard Worker * 73*5a923131SAndroid Build Coastguard Worker * Note that a callback may also be unbound when the process implementing the callback dies. 74*5a923131SAndroid Build Coastguard Worker * Hence, a client usually does not need to explicitly unbind a callback unless it wants to change 75*5a923131SAndroid Build Coastguard Worker * the bound callback. 76*5a923131SAndroid Build Coastguard Worker * 77*5a923131SAndroid Build Coastguard Worker * @param callback The callback to be unbound. See {@link IUpdateEngineStableCallback}. 78*5a923131SAndroid Build Coastguard Worker * @return true if unbinding is successful, false otherwise. 79*5a923131SAndroid Build Coastguard Worker * @see android.os.UpdateEngine#unbind(android.os.UpdateEngineCallback) 80*5a923131SAndroid Build Coastguard Worker * @hide 81*5a923131SAndroid Build Coastguard Worker */ unbind(IUpdateEngineStableCallback callback)82*5a923131SAndroid Build Coastguard Worker boolean unbind(IUpdateEngineStableCallback callback); 83*5a923131SAndroid Build Coastguard Worker 84*5a923131SAndroid Build Coastguard Worker 85*5a923131SAndroid Build Coastguard Worker /** 86*5a923131SAndroid Build Coastguard Worker * Run postinstall scripts for the given |partition| 87*5a923131SAndroid Build Coastguard Worker * This allows developers to run postinstall for a partition at 88*5a923131SAndroid Build Coastguard Worker * a time they see fit. For example, they may wish to run postinstall 89*5a923131SAndroid Build Coastguard Worker * script when device is IDLE and charging. This method would return 90*5a923131SAndroid Build Coastguard Worker * immediately if |partition| is empty or does not correspond to any 91*5a923131SAndroid Build Coastguard Worker * partitions on device. |partition| is expected to be unsuffixed, for 92*5a923131SAndroid Build Coastguard Worker * example system,product,system_ext, etc. 93*5a923131SAndroid Build Coastguard Worker * It is allowed to call this function multiple times with the same 94*5a923131SAndroid Build Coastguard Worker * partition. Postinstall script for that partition would get run more 95*5a923131SAndroid Build Coastguard Worker * than once. Owners of postinstall scripts should be designed to work 96*5a923131SAndroid Build Coastguard Worker * correctly in such cases(idempotent). Note this expectation holds even 97*5a923131SAndroid Build Coastguard Worker * without this API, and it has been so for years. 98*5a923131SAndroid Build Coastguard Worker * @param Name of thje partition to run postinstall scripts. Should not 99*5a923131SAndroid Build Coastguard Worker * contain slot suffix.(e.g. system,product,system_ext) 100*5a923131SAndroid Build Coastguard Worker * 101*5a923131SAndroid Build Coastguard Worker * @hide 102*5a923131SAndroid Build Coastguard Worker */ triggerPostinstall(in String partition)103*5a923131SAndroid Build Coastguard Worker void triggerPostinstall(in String partition); 104*5a923131SAndroid Build Coastguard Worker } 105