The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 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 | |
Kenny Root | cf0b38c | 2011-03-22 14:17:59 -0700 | [diff] [blame] | 17 | package com.android.server.pm; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 18 | |
Fyodor Kupolov | b94c165 | 2015-03-03 12:25:30 -0800 | [diff] [blame] | 19 | import android.annotation.Nullable; |
Jeff Brown | b880d88 | 2014-02-10 19:47:07 -0800 | [diff] [blame] | 20 | import android.content.Context; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 21 | import android.content.pm.PackageStats; |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 22 | import android.os.Build; |
Jeff Sharkey | 9f2f218 | 2016-12-21 09:18:33 -0700 | [diff] [blame] | 23 | import android.os.IBinder; |
| 24 | import android.os.IBinder.DeathRecipient; |
Jeff Sharkey | 70b4d10 | 2016-12-05 11:19:28 -0700 | [diff] [blame] | 25 | import android.os.IInstalld; |
Jeff Sharkey | 9f2f218 | 2016-12-21 09:18:33 -0700 | [diff] [blame] | 26 | import android.os.RemoteException; |
Jeff Sharkey | 70b4d10 | 2016-12-05 11:19:28 -0700 | [diff] [blame] | 27 | import android.os.ServiceManager; |
Jeff Sharkey | 9f2f218 | 2016-12-21 09:18:33 -0700 | [diff] [blame] | 28 | import android.text.format.DateUtils; |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 29 | import android.util.Slog; |
Jeff Sharkey | 790a4ec | 2015-04-09 13:18:44 -0700 | [diff] [blame] | 30 | |
Jeff Sharkey | 9f2f218 | 2016-12-21 09:18:33 -0700 | [diff] [blame] | 31 | import com.android.internal.os.BackgroundThread; |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 32 | import com.android.server.SystemService; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | |
Jeff Sharkey | fdeeeea | 2016-01-11 17:34:24 -0700 | [diff] [blame] | 34 | import dalvik.system.VMRuntime; |
| 35 | |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 36 | public class Installer extends SystemService { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 37 | private static final String TAG = "Installer"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | |
Todd Kennedy | fa54ab7 | 2015-09-25 07:46:12 -0700 | [diff] [blame] | 39 | /* *************************************************************************** |
| 40 | * IMPORTANT: These values are passed to native code. Keep them in sync with |
| 41 | * frameworks/native/cmds/installd/installd.h |
| 42 | * **************************************************************************/ |
| 43 | /** Application should be visible to everyone */ |
Andreas Gampe | bdd30d8 | 2016-03-20 11:32:11 -0700 | [diff] [blame] | 44 | public static final int DEXOPT_PUBLIC = 1 << 1; |
Todd Kennedy | fa54ab7 | 2015-09-25 07:46:12 -0700 | [diff] [blame] | 45 | /** Application wants to allow debugging of its code */ |
Nicolas Geoffray | 56123ba | 2017-05-05 14:30:02 +0100 | [diff] [blame] | 46 | public static final int DEXOPT_DEBUGGABLE = 1 << 2; |
Todd Kennedy | fa54ab7 | 2015-09-25 07:46:12 -0700 | [diff] [blame] | 47 | /** The system boot has finished */ |
Nicolas Geoffray | 56123ba | 2017-05-05 14:30:02 +0100 | [diff] [blame] | 48 | public static final int DEXOPT_BOOTCOMPLETE = 1 << 3; |
Andreas Gampe | bdd30d8 | 2016-03-20 11:32:11 -0700 | [diff] [blame] | 49 | /** Hint that the dexopt type is profile-guided. */ |
Nicolas Geoffray | 56123ba | 2017-05-05 14:30:02 +0100 | [diff] [blame] | 50 | public static final int DEXOPT_PROFILE_GUIDED = 1 << 4; |
Calin Juravle | c22c30e | 2017-01-16 19:18:48 -0800 | [diff] [blame] | 51 | /** The compilation is for a secondary dex file. */ |
Nicolas Geoffray | 56123ba | 2017-05-05 14:30:02 +0100 | [diff] [blame] | 52 | public static final int DEXOPT_SECONDARY_DEX = 1 << 5; |
Calin Juravle | c22c30e | 2017-01-16 19:18:48 -0800 | [diff] [blame] | 53 | /** Ignore the result of dexoptNeeded and force compilation. */ |
Nicolas Geoffray | 56123ba | 2017-05-05 14:30:02 +0100 | [diff] [blame] | 54 | public static final int DEXOPT_FORCE = 1 << 6; |
Calin Juravle | c22c30e | 2017-01-16 19:18:48 -0800 | [diff] [blame] | 55 | /** Indicates that the dex file passed to dexopt in on CE storage. */ |
Nicolas Geoffray | 56123ba | 2017-05-05 14:30:02 +0100 | [diff] [blame] | 56 | public static final int DEXOPT_STORAGE_CE = 1 << 7; |
Calin Juravle | c22c30e | 2017-01-16 19:18:48 -0800 | [diff] [blame] | 57 | /** Indicates that the dex file passed to dexopt in on DE storage. */ |
Nicolas Geoffray | 56123ba | 2017-05-05 14:30:02 +0100 | [diff] [blame] | 58 | public static final int DEXOPT_STORAGE_DE = 1 << 8; |
David Sehr | 2118ec4 | 2017-10-25 14:28:29 -0700 | [diff] [blame] | 59 | /** Indicates that dexopt is invoked from the background service. */ |
| 60 | public static final int DEXOPT_IDLE_BACKGROUND_JOB = 1 << 9; |
Todd Kennedy | fa54ab7 | 2015-09-25 07:46:12 -0700 | [diff] [blame] | 61 | |
Jeff Sharkey | 47f7108 | 2016-02-01 17:03:54 -0700 | [diff] [blame] | 62 | // NOTE: keep in sync with installd |
| 63 | public static final int FLAG_CLEAR_CACHE_ONLY = 1 << 8; |
| 64 | public static final int FLAG_CLEAR_CODE_CACHE_ONLY = 1 << 9; |
Jeff Sharkey | 5eb3eb5 | 2016-12-13 08:44:51 -0700 | [diff] [blame] | 65 | public static final int FLAG_USE_QUOTA = 1 << 12; |
Jeff Sharkey | 458428e | 2017-02-22 11:47:15 -0700 | [diff] [blame] | 66 | public static final int FLAG_FREE_CACHE_V2 = 1 << 13; |
| 67 | public static final int FLAG_FREE_CACHE_V2_DEFY_QUOTA = 1 << 14; |
| 68 | public static final int FLAG_FREE_CACHE_NOOP = 1 << 15; |
Jeff Sharkey | 1566233 | 2017-04-03 16:41:29 -0600 | [diff] [blame] | 69 | public static final int FLAG_FORCE = 1 << 16; |
Jeff Sharkey | fdeeeea | 2016-01-11 17:34:24 -0700 | [diff] [blame] | 70 | |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 71 | private final boolean mIsolated; |
| 72 | |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 73 | private volatile IInstalld mInstalld; |
Jeff Sharkey | c8ddc2d | 2016-12-05 23:14:41 -0700 | [diff] [blame] | 74 | private volatile Object mWarnIfHeld; |
| 75 | |
Jeff Brown | b880d88 | 2014-02-10 19:47:07 -0800 | [diff] [blame] | 76 | public Installer(Context context) { |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 77 | this(context, false); |
Jeff Brown | b880d88 | 2014-02-10 19:47:07 -0800 | [diff] [blame] | 78 | } |
| 79 | |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 80 | /** |
| 81 | * @param isolated indicates if this object should <em>not</em> connect to |
| 82 | * the real {@code installd}. All remote calls will be ignored |
| 83 | * unless you extend this class and intercept them. |
| 84 | */ |
| 85 | public Installer(Context context, boolean isolated) { |
Andreas Gampe | d15300c | 2016-06-23 20:27:12 -0700 | [diff] [blame] | 86 | super(context); |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 87 | mIsolated = isolated; |
Andreas Gampe | d15300c | 2016-06-23 20:27:12 -0700 | [diff] [blame] | 88 | } |
| 89 | |
Jeff Sharkey | 8948c01 | 2015-11-03 12:33:54 -0800 | [diff] [blame] | 90 | /** |
| 91 | * Yell loudly if someone tries making future calls while holding a lock on |
| 92 | * the given object. |
| 93 | */ |
| 94 | public void setWarnIfHeld(Object warnIfHeld) { |
Jeff Sharkey | c8ddc2d | 2016-12-05 23:14:41 -0700 | [diff] [blame] | 95 | mWarnIfHeld = warnIfHeld; |
Jeff Sharkey | 8948c01 | 2015-11-03 12:33:54 -0800 | [diff] [blame] | 96 | } |
| 97 | |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 98 | @Override |
| 99 | public void onStart() { |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 100 | if (mIsolated) { |
| 101 | mInstalld = null; |
| 102 | } else { |
Jeff Sharkey | 9f2f218 | 2016-12-21 09:18:33 -0700 | [diff] [blame] | 103 | connect(); |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | private void connect() { |
| 108 | IBinder binder = ServiceManager.getService("installd"); |
| 109 | if (binder != null) { |
| 110 | try { |
| 111 | binder.linkToDeath(new DeathRecipient() { |
| 112 | @Override |
| 113 | public void binderDied() { |
| 114 | Slog.w(TAG, "installd died; reconnecting"); |
| 115 | connect(); |
| 116 | } |
| 117 | }, 0); |
| 118 | } catch (RemoteException e) { |
| 119 | binder = null; |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | if (binder != null) { |
| 124 | mInstalld = IInstalld.Stub.asInterface(binder); |
Jeff Sharkey | 82add8a | 2017-03-11 19:44:16 -0700 | [diff] [blame] | 125 | try { |
| 126 | invalidateMounts(); |
| 127 | } catch (InstallerException ignored) { |
| 128 | } |
Jeff Sharkey | 9f2f218 | 2016-12-21 09:18:33 -0700 | [diff] [blame] | 129 | } else { |
| 130 | Slog.w(TAG, "installd not found; trying again"); |
| 131 | BackgroundThread.getHandler().postDelayed(() -> { |
| 132 | connect(); |
| 133 | }, DateUtils.SECOND_IN_MILLIS); |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 134 | } |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 135 | } |
| 136 | |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 137 | /** |
| 138 | * Do several pre-flight checks before making a remote call. |
| 139 | * |
| 140 | * @return if the remote call should continue. |
| 141 | */ |
| 142 | private boolean checkBeforeRemote() { |
Jeff Sharkey | c8ddc2d | 2016-12-05 23:14:41 -0700 | [diff] [blame] | 143 | if (mWarnIfHeld != null && Thread.holdsLock(mWarnIfHeld)) { |
| 144 | Slog.wtf(TAG, "Calling thread " + Thread.currentThread().getName() + " is holding 0x" |
| 145 | + Integer.toHexString(System.identityHashCode(mWarnIfHeld)), new Throwable()); |
| 146 | } |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 147 | if (mIsolated) { |
| 148 | Slog.i(TAG, "Ignoring request because this installer is isolated"); |
| 149 | return false; |
| 150 | } else { |
| 151 | return true; |
| 152 | } |
Jeff Sharkey | c8ddc2d | 2016-12-05 23:14:41 -0700 | [diff] [blame] | 153 | } |
| 154 | |
Jeff Sharkey | 1c6f723 | 2016-12-19 16:39:02 -0700 | [diff] [blame] | 155 | public long createAppData(String uuid, String packageName, int userId, int flags, int appId, |
Jeff Sharkey | c8ddc2d | 2016-12-05 23:14:41 -0700 | [diff] [blame] | 156 | String seInfo, int targetSdkVersion) throws InstallerException { |
Jeff Sharkey | 1c6f723 | 2016-12-19 16:39:02 -0700 | [diff] [blame] | 157 | if (!checkBeforeRemote()) return -1; |
Jeff Sharkey | c8ddc2d | 2016-12-05 23:14:41 -0700 | [diff] [blame] | 158 | try { |
Jeff Sharkey | 1c6f723 | 2016-12-19 16:39:02 -0700 | [diff] [blame] | 159 | return mInstalld.createAppData(uuid, packageName, userId, flags, appId, seInfo, |
Jeff Sharkey | 70b4d10 | 2016-12-05 11:19:28 -0700 | [diff] [blame] | 160 | targetSdkVersion); |
Jeff Sharkey | 447a3ac | 2016-12-12 10:15:37 -0700 | [diff] [blame] | 161 | } catch (Exception e) { |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 162 | throw InstallerException.from(e); |
Jeff Sharkey | 70b4d10 | 2016-12-05 11:19:28 -0700 | [diff] [blame] | 163 | } |
Jeff Sharkey | 790a4ec | 2015-04-09 13:18:44 -0700 | [diff] [blame] | 164 | } |
| 165 | |
Jeff Sharkey | 019ac85 | 2016-12-05 23:39:46 -0700 | [diff] [blame] | 166 | public void restoreconAppData(String uuid, String packageName, int userId, int flags, int appId, |
| 167 | String seInfo) throws InstallerException { |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 168 | if (!checkBeforeRemote()) return; |
Jeff Sharkey | 019ac85 | 2016-12-05 23:39:46 -0700 | [diff] [blame] | 169 | try { |
| 170 | mInstalld.restoreconAppData(uuid, packageName, userId, flags, appId, seInfo); |
Jeff Sharkey | 447a3ac | 2016-12-12 10:15:37 -0700 | [diff] [blame] | 171 | } catch (Exception e) { |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 172 | throw InstallerException.from(e); |
Jeff Sharkey | 019ac85 | 2016-12-05 23:39:46 -0700 | [diff] [blame] | 173 | } |
Jeff Sharkey | 790a4ec | 2015-04-09 13:18:44 -0700 | [diff] [blame] | 174 | } |
| 175 | |
Jeff Sharkey | 019ac85 | 2016-12-05 23:39:46 -0700 | [diff] [blame] | 176 | public void migrateAppData(String uuid, String packageName, int userId, int flags) |
Jeff Sharkey | e469713 | 2016-02-06 19:46:15 -0700 | [diff] [blame] | 177 | throws InstallerException { |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 178 | if (!checkBeforeRemote()) return; |
Jeff Sharkey | 019ac85 | 2016-12-05 23:39:46 -0700 | [diff] [blame] | 179 | try { |
| 180 | mInstalld.migrateAppData(uuid, packageName, userId, flags); |
Jeff Sharkey | 447a3ac | 2016-12-12 10:15:37 -0700 | [diff] [blame] | 181 | } catch (Exception e) { |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 182 | throw InstallerException.from(e); |
Jeff Sharkey | 019ac85 | 2016-12-05 23:39:46 -0700 | [diff] [blame] | 183 | } |
Jeff Sharkey | e469713 | 2016-02-06 19:46:15 -0700 | [diff] [blame] | 184 | } |
| 185 | |
Jeff Sharkey | 019ac85 | 2016-12-05 23:39:46 -0700 | [diff] [blame] | 186 | public void clearAppData(String uuid, String packageName, int userId, int flags, |
| 187 | long ceDataInode) throws InstallerException { |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 188 | if (!checkBeforeRemote()) return; |
Jeff Sharkey | 019ac85 | 2016-12-05 23:39:46 -0700 | [diff] [blame] | 189 | try { |
| 190 | mInstalld.clearAppData(uuid, packageName, userId, flags, ceDataInode); |
Jeff Sharkey | 447a3ac | 2016-12-12 10:15:37 -0700 | [diff] [blame] | 191 | } catch (Exception e) { |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 192 | throw InstallerException.from(e); |
Jeff Sharkey | 019ac85 | 2016-12-05 23:39:46 -0700 | [diff] [blame] | 193 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 194 | } |
| 195 | |
Jeff Sharkey | 019ac85 | 2016-12-05 23:39:46 -0700 | [diff] [blame] | 196 | public void destroyAppData(String uuid, String packageName, int userId, int flags, |
| 197 | long ceDataInode) throws InstallerException { |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 198 | if (!checkBeforeRemote()) return; |
Jeff Sharkey | 019ac85 | 2016-12-05 23:39:46 -0700 | [diff] [blame] | 199 | try { |
| 200 | mInstalld.destroyAppData(uuid, packageName, userId, flags, ceDataInode); |
Jeff Sharkey | 447a3ac | 2016-12-12 10:15:37 -0700 | [diff] [blame] | 201 | } catch (Exception e) { |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 202 | throw InstallerException.from(e); |
Jeff Sharkey | 019ac85 | 2016-12-05 23:39:46 -0700 | [diff] [blame] | 203 | } |
Dave Allison | 0efbd9a | 2014-01-30 14:19:51 -0800 | [diff] [blame] | 204 | } |
| 205 | |
Jeff Sharkey | 1566233 | 2017-04-03 16:41:29 -0600 | [diff] [blame] | 206 | public void fixupAppData(String uuid, int flags) throws InstallerException { |
| 207 | if (!checkBeforeRemote()) return; |
| 208 | try { |
| 209 | mInstalld.fixupAppData(uuid, flags); |
| 210 | } catch (Exception e) { |
| 211 | throw InstallerException.from(e); |
| 212 | } |
| 213 | } |
| 214 | |
Jeff Sharkey | c8ddc2d | 2016-12-05 23:14:41 -0700 | [diff] [blame] | 215 | public void moveCompleteApp(String fromUuid, String toUuid, String packageName, |
| 216 | String dataAppName, int appId, String seInfo, int targetSdkVersion) |
Janis Danisevskis | f340974 | 2016-01-12 14:46:33 +0000 | [diff] [blame] | 217 | throws InstallerException { |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 218 | if (!checkBeforeRemote()) return; |
Jeff Sharkey | c8ddc2d | 2016-12-05 23:14:41 -0700 | [diff] [blame] | 219 | try { |
| 220 | mInstalld.moveCompleteApp(fromUuid, toUuid, packageName, dataAppName, appId, seInfo, |
| 221 | targetSdkVersion); |
Jeff Sharkey | 447a3ac | 2016-12-12 10:15:37 -0700 | [diff] [blame] | 222 | } catch (Exception e) { |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 223 | throw InstallerException.from(e); |
Jeff Sharkey | c8ddc2d | 2016-12-05 23:14:41 -0700 | [diff] [blame] | 224 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 225 | } |
| 226 | |
Jeff Sharkey | 82ca901 | 2017-01-08 17:06:58 -0700 | [diff] [blame] | 227 | public void getAppSize(String uuid, String[] packageNames, int userId, int flags, int appId, |
| 228 | long[] ceDataInodes, String[] codePaths, PackageStats stats) |
Jeff Sharkey | 5eb3eb5 | 2016-12-13 08:44:51 -0700 | [diff] [blame] | 229 | throws InstallerException { |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 230 | if (!checkBeforeRemote()) return; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 231 | try { |
Jeff Sharkey | 82ca901 | 2017-01-08 17:06:58 -0700 | [diff] [blame] | 232 | final long[] res = mInstalld.getAppSize(uuid, packageNames, userId, flags, |
| 233 | appId, ceDataInodes, codePaths); |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 234 | stats.codeSize += res[0]; |
| 235 | stats.dataSize += res[1]; |
| 236 | stats.cacheSize += res[2]; |
Jeff Sharkey | 82ca901 | 2017-01-08 17:06:58 -0700 | [diff] [blame] | 237 | stats.externalCodeSize += res[3]; |
| 238 | stats.externalDataSize += res[4]; |
| 239 | stats.externalCacheSize += res[5]; |
| 240 | } catch (Exception e) { |
| 241 | throw InstallerException.from(e); |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | public void getUserSize(String uuid, int userId, int flags, int[] appIds, PackageStats stats) |
| 246 | throws InstallerException { |
| 247 | if (!checkBeforeRemote()) return; |
| 248 | try { |
| 249 | final long[] res = mInstalld.getUserSize(uuid, userId, flags, appIds); |
| 250 | stats.codeSize += res[0]; |
| 251 | stats.dataSize += res[1]; |
| 252 | stats.cacheSize += res[2]; |
| 253 | stats.externalCodeSize += res[3]; |
| 254 | stats.externalDataSize += res[4]; |
| 255 | stats.externalCacheSize += res[5]; |
| 256 | } catch (Exception e) { |
| 257 | throw InstallerException.from(e); |
| 258 | } |
| 259 | } |
| 260 | |
Jeff Sharkey | 0034788 | 2017-04-17 16:44:12 -0600 | [diff] [blame] | 261 | public long[] getExternalSize(String uuid, int userId, int flags, int[] appIds) |
| 262 | throws InstallerException { |
Jeff Sharkey | c8b29ac | 2017-07-06 11:29:06 -0600 | [diff] [blame] | 263 | if (!checkBeforeRemote()) return new long[6]; |
Jeff Sharkey | 82ca901 | 2017-01-08 17:06:58 -0700 | [diff] [blame] | 264 | try { |
Jeff Sharkey | 0034788 | 2017-04-17 16:44:12 -0600 | [diff] [blame] | 265 | return mInstalld.getExternalSize(uuid, userId, flags, appIds); |
Jeff Sharkey | 447a3ac | 2016-12-12 10:15:37 -0700 | [diff] [blame] | 266 | } catch (Exception e) { |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 267 | throw InstallerException.from(e); |
Jeff Sharkey | 4288419 | 2016-04-09 16:12:01 -0600 | [diff] [blame] | 268 | } |
| 269 | } |
| 270 | |
Jeff Sharkey | 36ba022 | 2017-01-18 12:11:31 -0700 | [diff] [blame] | 271 | public void setAppQuota(String uuid, int userId, int appId, long cacheQuota) |
| 272 | throws InstallerException { |
| 273 | if (!checkBeforeRemote()) return; |
| 274 | try { |
| 275 | mInstalld.setAppQuota(uuid, userId, appId, cacheQuota); |
| 276 | } catch (Exception e) { |
| 277 | throw InstallerException.from(e); |
| 278 | } |
| 279 | } |
| 280 | |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 281 | public void dexopt(String apkPath, int uid, @Nullable String pkgName, String instructionSet, |
Calin Juravle | db4a79a | 2015-12-23 18:55:08 +0200 | [diff] [blame] | 282 | int dexoptNeeded, @Nullable String outputPath, int dexFlags, |
Calin Juravle | 811a75a | 2017-04-05 22:49:38 -0700 | [diff] [blame] | 283 | String compilerFilter, @Nullable String volumeUuid, @Nullable String sharedLibraries, |
David Brazdil | 3d44ed0 | 2018-01-16 20:01:47 +0000 | [diff] [blame] | 284 | @Nullable String seInfo, boolean downgrade, int targetSdkVersion) |
Jeff Hao | c7b9482 | 2016-03-16 15:56:07 -0700 | [diff] [blame] | 285 | throws InstallerException { |
Jeff Sharkey | fdeeeea | 2016-01-11 17:34:24 -0700 | [diff] [blame] | 286 | assertValidInstructionSet(instructionSet); |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 287 | if (!checkBeforeRemote()) return; |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 288 | try { |
| 289 | mInstalld.dexopt(apkPath, uid, pkgName, instructionSet, dexoptNeeded, outputPath, |
David Brazdil | 3d44ed0 | 2018-01-16 20:01:47 +0000 | [diff] [blame] | 290 | dexFlags, compilerFilter, volumeUuid, sharedLibraries, seInfo, downgrade, |
| 291 | targetSdkVersion); |
Jeff Sharkey | 447a3ac | 2016-12-12 10:15:37 -0700 | [diff] [blame] | 292 | } catch (Exception e) { |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 293 | throw InstallerException.from(e); |
| 294 | } |
Andreas Gampe | bdd30d8 | 2016-03-20 11:32:11 -0700 | [diff] [blame] | 295 | } |
| 296 | |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 297 | public boolean mergeProfiles(int uid, String packageName) throws InstallerException { |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 298 | if (!checkBeforeRemote()) return false; |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 299 | try { |
| 300 | return mInstalld.mergeProfiles(uid, packageName); |
Jeff Sharkey | 447a3ac | 2016-12-12 10:15:37 -0700 | [diff] [blame] | 301 | } catch (Exception e) { |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 302 | throw InstallerException.from(e); |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 303 | } |
Jeff Sharkey | fdeeeea | 2016-01-11 17:34:24 -0700 | [diff] [blame] | 304 | } |
| 305 | |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 306 | public boolean dumpProfiles(int uid, String packageName, String codePaths) |
David Sehr | a877708 | 2016-05-24 15:25:23 -0700 | [diff] [blame] | 307 | throws InstallerException { |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 308 | if (!checkBeforeRemote()) return false; |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 309 | try { |
| 310 | return mInstalld.dumpProfiles(uid, packageName, codePaths); |
Jeff Sharkey | 447a3ac | 2016-12-12 10:15:37 -0700 | [diff] [blame] | 311 | } catch (Exception e) { |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 312 | throw InstallerException.from(e); |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 313 | } |
David Sehr | a877708 | 2016-05-24 15:25:23 -0700 | [diff] [blame] | 314 | } |
| 315 | |
Mathieu Chartier | 235845d | 2017-05-10 15:09:19 -0700 | [diff] [blame] | 316 | public boolean copySystemProfile(String systemProfile, int uid, String packageName) |
| 317 | throws InstallerException { |
| 318 | if (!checkBeforeRemote()) return false; |
| 319 | try { |
| 320 | return mInstalld.copySystemProfile(systemProfile, uid, packageName); |
| 321 | } catch (Exception e) { |
| 322 | throw InstallerException.from(e); |
| 323 | } |
| 324 | } |
| 325 | |
Jeff Sharkey | fdeeeea | 2016-01-11 17:34:24 -0700 | [diff] [blame] | 326 | public void idmap(String targetApkPath, String overlayApkPath, int uid) |
| 327 | throws InstallerException { |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 328 | if (!checkBeforeRemote()) return; |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 329 | try { |
| 330 | mInstalld.idmap(targetApkPath, overlayApkPath, uid); |
Jeff Sharkey | 447a3ac | 2016-12-12 10:15:37 -0700 | [diff] [blame] | 331 | } catch (Exception e) { |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 332 | throw InstallerException.from(e); |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 333 | } |
Jeff Sharkey | fdeeeea | 2016-01-11 17:34:24 -0700 | [diff] [blame] | 334 | } |
| 335 | |
MÃ¥rten Kongstad | 16382634 | 2016-06-02 09:35:09 +0200 | [diff] [blame] | 336 | public void removeIdmap(String overlayApkPath) throws InstallerException { |
| 337 | if (!checkBeforeRemote()) return; |
| 338 | try { |
| 339 | mInstalld.removeIdmap(overlayApkPath); |
| 340 | } catch (Exception e) { |
| 341 | throw InstallerException.from(e); |
| 342 | } |
| 343 | } |
| 344 | |
Jeff Sharkey | fdeeeea | 2016-01-11 17:34:24 -0700 | [diff] [blame] | 345 | public void rmdex(String codePath, String instructionSet) throws InstallerException { |
| 346 | assertValidInstructionSet(instructionSet); |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 347 | if (!checkBeforeRemote()) return; |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 348 | try { |
| 349 | mInstalld.rmdex(codePath, instructionSet); |
Jeff Sharkey | 447a3ac | 2016-12-12 10:15:37 -0700 | [diff] [blame] | 350 | } catch (Exception e) { |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 351 | throw InstallerException.from(e); |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 352 | } |
Jeff Sharkey | fdeeeea | 2016-01-11 17:34:24 -0700 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | public void rmPackageDir(String packageDir) throws InstallerException { |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 356 | if (!checkBeforeRemote()) return; |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 357 | try { |
| 358 | mInstalld.rmPackageDir(packageDir); |
Jeff Sharkey | 447a3ac | 2016-12-12 10:15:37 -0700 | [diff] [blame] | 359 | } catch (Exception e) { |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 360 | throw InstallerException.from(e); |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 361 | } |
Jeff Sharkey | fdeeeea | 2016-01-11 17:34:24 -0700 | [diff] [blame] | 362 | } |
| 363 | |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 364 | public void clearAppProfiles(String packageName) throws InstallerException { |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 365 | if (!checkBeforeRemote()) return; |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 366 | try { |
| 367 | mInstalld.clearAppProfiles(packageName); |
Jeff Sharkey | 447a3ac | 2016-12-12 10:15:37 -0700 | [diff] [blame] | 368 | } catch (Exception e) { |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 369 | throw InstallerException.from(e); |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 370 | } |
Calin Juravle | d6d27e3 | 2016-03-23 13:59:18 +0000 | [diff] [blame] | 371 | } |
| 372 | |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 373 | public void destroyAppProfiles(String packageName) throws InstallerException { |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 374 | if (!checkBeforeRemote()) return; |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 375 | try { |
| 376 | mInstalld.destroyAppProfiles(packageName); |
Jeff Sharkey | 447a3ac | 2016-12-12 10:15:37 -0700 | [diff] [blame] | 377 | } catch (Exception e) { |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 378 | throw InstallerException.from(e); |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 379 | } |
David Brazdil | 9aa6db0 | 2016-03-08 12:57:12 +0000 | [diff] [blame] | 380 | } |
| 381 | |
Jeff Sharkey | fcf1e55 | 2016-04-14 20:44:58 -0600 | [diff] [blame] | 382 | public void createUserData(String uuid, int userId, int userSerial, int flags) |
| 383 | throws InstallerException { |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 384 | if (!checkBeforeRemote()) return; |
Jeff Sharkey | 019ac85 | 2016-12-05 23:39:46 -0700 | [diff] [blame] | 385 | try { |
| 386 | mInstalld.createUserData(uuid, userId, userSerial, flags); |
Jeff Sharkey | 447a3ac | 2016-12-12 10:15:37 -0700 | [diff] [blame] | 387 | } catch (Exception e) { |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 388 | throw InstallerException.from(e); |
Jeff Sharkey | 019ac85 | 2016-12-05 23:39:46 -0700 | [diff] [blame] | 389 | } |
Jeff Sharkey | fdeeeea | 2016-01-11 17:34:24 -0700 | [diff] [blame] | 390 | } |
| 391 | |
Jeff Sharkey | fcf1e55 | 2016-04-14 20:44:58 -0600 | [diff] [blame] | 392 | public void destroyUserData(String uuid, int userId, int flags) throws InstallerException { |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 393 | if (!checkBeforeRemote()) return; |
Jeff Sharkey | 019ac85 | 2016-12-05 23:39:46 -0700 | [diff] [blame] | 394 | try { |
| 395 | mInstalld.destroyUserData(uuid, userId, flags); |
Jeff Sharkey | 447a3ac | 2016-12-12 10:15:37 -0700 | [diff] [blame] | 396 | } catch (Exception e) { |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 397 | throw InstallerException.from(e); |
Jeff Sharkey | 019ac85 | 2016-12-05 23:39:46 -0700 | [diff] [blame] | 398 | } |
Jeff Sharkey | fdeeeea | 2016-01-11 17:34:24 -0700 | [diff] [blame] | 399 | } |
| 400 | |
| 401 | public void markBootComplete(String instructionSet) throws InstallerException { |
| 402 | assertValidInstructionSet(instructionSet); |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 403 | if (!checkBeforeRemote()) return; |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 404 | try { |
| 405 | mInstalld.markBootComplete(instructionSet); |
Jeff Sharkey | 447a3ac | 2016-12-12 10:15:37 -0700 | [diff] [blame] | 406 | } catch (Exception e) { |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 407 | throw InstallerException.from(e); |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 408 | } |
Jeff Sharkey | fdeeeea | 2016-01-11 17:34:24 -0700 | [diff] [blame] | 409 | } |
| 410 | |
Jeff Sharkey | ddff807 | 2017-05-26 13:10:46 -0600 | [diff] [blame] | 411 | public void freeCache(String uuid, long targetFreeBytes, long cacheReservedBytes, int flags) |
| 412 | throws InstallerException { |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 413 | if (!checkBeforeRemote()) return; |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 414 | try { |
Jeff Sharkey | ddff807 | 2017-05-26 13:10:46 -0600 | [diff] [blame] | 415 | mInstalld.freeCache(uuid, targetFreeBytes, cacheReservedBytes, flags); |
Jeff Sharkey | 447a3ac | 2016-12-12 10:15:37 -0700 | [diff] [blame] | 416 | } catch (Exception e) { |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 417 | throw InstallerException.from(e); |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 418 | } |
Jeff Sharkey | fdeeeea | 2016-01-11 17:34:24 -0700 | [diff] [blame] | 419 | } |
| 420 | |
Kenny Root | ddbe50d | 2012-09-06 13:18:37 -0700 | [diff] [blame] | 421 | /** |
Jeff Sharkey | fdeeeea | 2016-01-11 17:34:24 -0700 | [diff] [blame] | 422 | * Links the 32 bit native library directory in an application's data |
| 423 | * directory to the real location for backward compatibility. Note that no |
| 424 | * such symlink is created for 64 bit shared libraries. |
Kenny Root | ddbe50d | 2012-09-06 13:18:37 -0700 | [diff] [blame] | 425 | */ |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 426 | public void linkNativeLibraryDirectory(String uuid, String packageName, String nativeLibPath32, |
Jeff Sharkey | fdeeeea | 2016-01-11 17:34:24 -0700 | [diff] [blame] | 427 | int userId) throws InstallerException { |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 428 | if (!checkBeforeRemote()) return; |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 429 | try { |
| 430 | mInstalld.linkNativeLibraryDirectory(uuid, packageName, nativeLibPath32, userId); |
Jeff Sharkey | 447a3ac | 2016-12-12 10:15:37 -0700 | [diff] [blame] | 431 | } catch (Exception e) { |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 432 | throw InstallerException.from(e); |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 433 | } |
Kenny Root | 6a6b007 | 2010-10-07 16:46:10 -0700 | [diff] [blame] | 434 | } |
Robert Craig | 4385343 | 2014-03-04 11:57:23 -0500 | [diff] [blame] | 435 | |
Jeff Sharkey | fdeeeea | 2016-01-11 17:34:24 -0700 | [diff] [blame] | 436 | public void createOatDir(String oatDir, String dexInstructionSet) |
| 437 | throws InstallerException { |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 438 | if (!checkBeforeRemote()) return; |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 439 | try { |
| 440 | mInstalld.createOatDir(oatDir, dexInstructionSet); |
Jeff Sharkey | 447a3ac | 2016-12-12 10:15:37 -0700 | [diff] [blame] | 441 | } catch (Exception e) { |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 442 | throw InstallerException.from(e); |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 443 | } |
Jeff Sharkey | 790a4ec | 2015-04-09 13:18:44 -0700 | [diff] [blame] | 444 | } |
| 445 | |
Jeff Sharkey | fdeeeea | 2016-01-11 17:34:24 -0700 | [diff] [blame] | 446 | public void linkFile(String relativePath, String fromBase, String toBase) |
| 447 | throws InstallerException { |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 448 | if (!checkBeforeRemote()) return; |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 449 | try { |
| 450 | mInstalld.linkFile(relativePath, fromBase, toBase); |
Jeff Sharkey | 447a3ac | 2016-12-12 10:15:37 -0700 | [diff] [blame] | 451 | } catch (Exception e) { |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 452 | throw InstallerException.from(e); |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 453 | } |
Robert Craig | 4385343 | 2014-03-04 11:57:23 -0500 | [diff] [blame] | 454 | } |
Narayan Kamath | 6c4b9de | 2014-08-08 12:44:12 +0100 | [diff] [blame] | 455 | |
Andreas Gampe | abcbe2f | 2016-02-26 11:25:36 -0800 | [diff] [blame] | 456 | public void moveAb(String apkPath, String instructionSet, String outputPath) |
| 457 | throws InstallerException { |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 458 | if (!checkBeforeRemote()) return; |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 459 | try { |
| 460 | mInstalld.moveAb(apkPath, instructionSet, outputPath); |
Jeff Sharkey | 447a3ac | 2016-12-12 10:15:37 -0700 | [diff] [blame] | 461 | } catch (Exception e) { |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 462 | throw InstallerException.from(e); |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 463 | } |
Andreas Gampe | abcbe2f | 2016-02-26 11:25:36 -0800 | [diff] [blame] | 464 | } |
| 465 | |
Andreas Gampe | 33c592d | 2016-09-09 17:08:53 -0700 | [diff] [blame] | 466 | public void deleteOdex(String apkPath, String instructionSet, String outputPath) |
| 467 | throws InstallerException { |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 468 | if (!checkBeforeRemote()) return; |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 469 | try { |
| 470 | mInstalld.deleteOdex(apkPath, instructionSet, outputPath); |
Jeff Sharkey | 447a3ac | 2016-12-12 10:15:37 -0700 | [diff] [blame] | 471 | } catch (Exception e) { |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 472 | throw InstallerException.from(e); |
Jeff Sharkey | c24fa02 | 2016-12-07 10:37:47 -0700 | [diff] [blame] | 473 | } |
Andreas Gampe | 33c592d | 2016-09-09 17:08:53 -0700 | [diff] [blame] | 474 | } |
| 475 | |
Calin Juravle | 1aa5f88 | 2017-01-25 01:05:50 -0800 | [diff] [blame] | 476 | public boolean reconcileSecondaryDexFile(String apkPath, String packageName, int uid, |
| 477 | String[] isas, @Nullable String volumeUuid, int flags) throws InstallerException { |
| 478 | for (int i = 0; i < isas.length; i++) { |
| 479 | assertValidInstructionSet(isas[i]); |
| 480 | } |
| 481 | if (!checkBeforeRemote()) return false; |
| 482 | try { |
| 483 | return mInstalld.reconcileSecondaryDexFile(apkPath, packageName, uid, isas, |
| 484 | volumeUuid, flags); |
| 485 | } catch (Exception e) { |
| 486 | throw InstallerException.from(e); |
| 487 | } |
| 488 | } |
| 489 | |
Alan Stokes | a002360 | 2017-10-16 12:31:44 +0100 | [diff] [blame] | 490 | public byte[] hashSecondaryDexFile(String dexPath, String packageName, int uid, |
| 491 | @Nullable String volumeUuid, int flags) throws InstallerException { |
| 492 | if (!checkBeforeRemote()) return new byte[0]; |
| 493 | try { |
| 494 | return mInstalld.hashSecondaryDexFile(dexPath, packageName, uid, volumeUuid, flags); |
| 495 | } catch (Exception e) { |
| 496 | throw InstallerException.from(e); |
| 497 | } |
| 498 | } |
| 499 | |
Calin Juravle | fd9f8ae | 2017-11-29 18:26:55 -0800 | [diff] [blame] | 500 | public boolean createProfileSnapshot(int appId, String packageName, String codePath) |
| 501 | throws InstallerException { |
| 502 | if (!checkBeforeRemote()) return false; |
| 503 | try { |
Calin Juravle | 388cd5f | 2017-12-05 12:33:32 -0800 | [diff] [blame] | 504 | return mInstalld.createProfileSnapshot(appId, packageName, codePath); |
Calin Juravle | fd9f8ae | 2017-11-29 18:26:55 -0800 | [diff] [blame] | 505 | } catch (Exception e) { |
| 506 | throw InstallerException.from(e); |
| 507 | } |
| 508 | } |
| 509 | |
| 510 | public void destroyProfileSnapshot(String packageName, String codePath) |
| 511 | throws InstallerException { |
| 512 | if (!checkBeforeRemote()) return; |
| 513 | try { |
| 514 | mInstalld.destroyProfileSnapshot(packageName, codePath); |
| 515 | } catch (Exception e) { |
| 516 | throw InstallerException.from(e); |
| 517 | } |
| 518 | } |
| 519 | |
Jeff Sharkey | 7d25faf | 2017-01-16 20:58:40 -0700 | [diff] [blame] | 520 | public void invalidateMounts() throws InstallerException { |
| 521 | if (!checkBeforeRemote()) return; |
| 522 | try { |
| 523 | mInstalld.invalidateMounts(); |
| 524 | } catch (Exception e) { |
| 525 | throw InstallerException.from(e); |
| 526 | } |
| 527 | } |
| 528 | |
Jeff Sharkey | d5d5e92 | 2017-02-21 10:51:23 -0700 | [diff] [blame] | 529 | public boolean isQuotaSupported(String volumeUuid) throws InstallerException { |
| 530 | if (!checkBeforeRemote()) return false; |
| 531 | try { |
| 532 | return mInstalld.isQuotaSupported(volumeUuid); |
| 533 | } catch (Exception e) { |
| 534 | throw InstallerException.from(e); |
| 535 | } |
| 536 | } |
| 537 | |
Jeff Sharkey | fdeeeea | 2016-01-11 17:34:24 -0700 | [diff] [blame] | 538 | private static void assertValidInstructionSet(String instructionSet) |
| 539 | throws InstallerException { |
Narayan Kamath | 6c4b9de | 2014-08-08 12:44:12 +0100 | [diff] [blame] | 540 | for (String abi : Build.SUPPORTED_ABIS) { |
Jeff Sharkey | fdeeeea | 2016-01-11 17:34:24 -0700 | [diff] [blame] | 541 | if (VMRuntime.getInstructionSet(abi).equals(instructionSet)) { |
| 542 | return; |
Narayan Kamath | 6c4b9de | 2014-08-08 12:44:12 +0100 | [diff] [blame] | 543 | } |
| 544 | } |
Jeff Sharkey | fdeeeea | 2016-01-11 17:34:24 -0700 | [diff] [blame] | 545 | throw new InstallerException("Invalid instruction set: " + instructionSet); |
Narayan Kamath | 6c4b9de | 2014-08-08 12:44:12 +0100 | [diff] [blame] | 546 | } |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 547 | |
| 548 | public static class InstallerException extends Exception { |
| 549 | public InstallerException(String detailMessage) { |
| 550 | super(detailMessage); |
| 551 | } |
| 552 | |
| 553 | public static InstallerException from(Exception e) throws InstallerException { |
Jeff Sharkey | 447a3ac | 2016-12-12 10:15:37 -0700 | [diff] [blame] | 554 | throw new InstallerException(e.toString()); |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 555 | } |
| 556 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 557 | } |