1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.server.devicepolicy; 18 19 import android.app.admin.DevicePolicyManager.InstallSystemUpdateCallback; 20 import android.app.admin.StartInstallingUpdateCallback; 21 import android.content.Context; 22 import android.os.ParcelFileDescriptor; 23 import android.os.RecoverySystem; 24 import android.util.Log; 25 26 import java.io.IOException; 27 28 /** 29 * Used for installing an update for <a href="https://source.android.com/devices/tech/ota/nonab">non 30 * AB</a> devices. 31 */ 32 class NonAbUpdateInstaller extends UpdateInstaller { NonAbUpdateInstaller(Context context, ParcelFileDescriptor updateFileDescriptor, StartInstallingUpdateCallback callback, DevicePolicyManagerService.Injector injector, DevicePolicyConstants constants)33 NonAbUpdateInstaller(Context context, 34 ParcelFileDescriptor updateFileDescriptor, 35 StartInstallingUpdateCallback callback, DevicePolicyManagerService.Injector injector, 36 DevicePolicyConstants constants) { 37 super(context, updateFileDescriptor, callback, injector, constants); 38 } 39 40 @Override installUpdateInThread()41 public void installUpdateInThread() { 42 try { 43 RecoverySystem.installPackage(mContext, mCopiedUpdateFile); 44 notifyCallbackOnSuccess(); 45 } catch (IOException e) { 46 Log.w(TAG, "IO error while trying to install non AB update.", e); 47 notifyCallbackOnError( 48 InstallSystemUpdateCallback.UPDATE_ERROR_UNKNOWN, 49 Log.getStackTraceString(e)); 50 } 51 } 52 } 53