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