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 | |
Jeff Brown | b880d88 | 2014-02-10 19:47:07 -0800 | [diff] [blame] | 19 | import android.content.Context; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 20 | import android.content.pm.PackageStats; |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 21 | import android.os.Build; |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 22 | import android.util.Slog; |
Narayan Kamath | 6c4b9de | 2014-08-08 12:44:12 +0100 | [diff] [blame] | 23 | import dalvik.system.VMRuntime; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 24 | |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 25 | import com.android.internal.os.InstallerConnection; |
| 26 | import com.android.server.SystemService; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 28 | public final class Installer extends SystemService { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 29 | private static final String TAG = "Installer"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 31 | private final InstallerConnection mInstaller; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | |
Jeff Brown | b880d88 | 2014-02-10 19:47:07 -0800 | [diff] [blame] | 33 | public Installer(Context context) { |
| 34 | super(context); |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 35 | mInstaller = new InstallerConnection(); |
Jeff Brown | b880d88 | 2014-02-10 19:47:07 -0800 | [diff] [blame] | 36 | } |
| 37 | |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 38 | @Override |
| 39 | public void onStart() { |
| 40 | Slog.i(TAG, "Waiting for installd to be ready."); |
| 41 | ping(); |
| 42 | } |
| 43 | |
Robert Craig | 0f40dc9 | 2013-03-25 06:33:03 -0400 | [diff] [blame] | 44 | public int install(String name, int uid, int gid, String seinfo) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 45 | StringBuilder builder = new StringBuilder("install"); |
| 46 | builder.append(' '); |
| 47 | builder.append(name); |
| 48 | builder.append(' '); |
| 49 | builder.append(uid); |
| 50 | builder.append(' '); |
| 51 | builder.append(gid); |
Robert Craig | 0f40dc9 | 2013-03-25 06:33:03 -0400 | [diff] [blame] | 52 | builder.append(' '); |
| 53 | builder.append(seinfo != null ? seinfo : "!"); |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 54 | return mInstaller.execute(builder.toString()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | } |
| 56 | |
Alex Light | a25dc2b | 2014-08-05 14:25:43 -0700 | [diff] [blame] | 57 | public int patchoat(String apkPath, int uid, boolean isPublic, String pkgName, |
| 58 | String instructionSet) { |
Narayan Kamath | 6c4b9de | 2014-08-08 12:44:12 +0100 | [diff] [blame] | 59 | if (!isValidInstructionSet(instructionSet)) { |
| 60 | Slog.e(TAG, "Invalid instruction set: " + instructionSet); |
| 61 | return -1; |
| 62 | } |
| 63 | |
Calin Juravle | feb1930 | 2014-08-21 19:00:15 +0100 | [diff] [blame] | 64 | return mInstaller.patchoat(apkPath, uid, isPublic, pkgName, instructionSet); |
Alex Light | a25dc2b | 2014-08-05 14:25:43 -0700 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | public int patchoat(String apkPath, int uid, boolean isPublic, String instructionSet) { |
Narayan Kamath | 6c4b9de | 2014-08-08 12:44:12 +0100 | [diff] [blame] | 68 | if (!isValidInstructionSet(instructionSet)) { |
| 69 | Slog.e(TAG, "Invalid instruction set: " + instructionSet); |
| 70 | return -1; |
| 71 | } |
| 72 | |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 73 | return mInstaller.patchoat(apkPath, uid, isPublic, instructionSet); |
Alex Light | a25dc2b | 2014-08-05 14:25:43 -0700 | [diff] [blame] | 74 | } |
| 75 | |
Narayan Kamath | 0349e8c | 2014-05-01 11:41:20 +0100 | [diff] [blame] | 76 | public int dexopt(String apkPath, int uid, boolean isPublic, String instructionSet) { |
Narayan Kamath | 6c4b9de | 2014-08-08 12:44:12 +0100 | [diff] [blame] | 77 | if (!isValidInstructionSet(instructionSet)) { |
| 78 | Slog.e(TAG, "Invalid instruction set: " + instructionSet); |
| 79 | return -1; |
| 80 | } |
| 81 | |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 82 | return mInstaller.dexopt(apkPath, uid, isPublic, instructionSet); |
Dave Allison | 0efbd9a | 2014-01-30 14:19:51 -0800 | [diff] [blame] | 83 | } |
| 84 | |
Narayan Kamath | 0349e8c | 2014-05-01 11:41:20 +0100 | [diff] [blame] | 85 | public int dexopt(String apkPath, int uid, boolean isPublic, String pkgName, |
Calin Juravle | feb1930 | 2014-08-21 19:00:15 +0100 | [diff] [blame] | 86 | String instructionSet, boolean vmSafeMode) { |
Narayan Kamath | 6c4b9de | 2014-08-08 12:44:12 +0100 | [diff] [blame] | 87 | if (!isValidInstructionSet(instructionSet)) { |
| 88 | Slog.e(TAG, "Invalid instruction set: " + instructionSet); |
| 89 | return -1; |
| 90 | } |
| 91 | |
Calin Juravle | feb1930 | 2014-08-21 19:00:15 +0100 | [diff] [blame] | 92 | return mInstaller.dexopt(apkPath, uid, isPublic, pkgName, instructionSet, vmSafeMode); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 93 | } |
| 94 | |
MÃ¥rten Kongstad | 48d2232 | 2014-01-31 14:43:27 +0100 | [diff] [blame] | 95 | public int idmap(String targetApkPath, String overlayApkPath, int uid) { |
| 96 | StringBuilder builder = new StringBuilder("idmap"); |
| 97 | builder.append(' '); |
| 98 | builder.append(targetApkPath); |
| 99 | builder.append(' '); |
| 100 | builder.append(overlayApkPath); |
| 101 | builder.append(' '); |
| 102 | builder.append(uid); |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 103 | return mInstaller.execute(builder.toString()); |
MÃ¥rten Kongstad | 48d2232 | 2014-01-31 14:43:27 +0100 | [diff] [blame] | 104 | } |
| 105 | |
Narayan Kamath | 0349e8c | 2014-05-01 11:41:20 +0100 | [diff] [blame] | 106 | public int movedex(String srcPath, String dstPath, String instructionSet) { |
Narayan Kamath | 6c4b9de | 2014-08-08 12:44:12 +0100 | [diff] [blame] | 107 | if (!isValidInstructionSet(instructionSet)) { |
| 108 | Slog.e(TAG, "Invalid instruction set: " + instructionSet); |
| 109 | return -1; |
| 110 | } |
| 111 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 112 | StringBuilder builder = new StringBuilder("movedex"); |
| 113 | builder.append(' '); |
| 114 | builder.append(srcPath); |
| 115 | builder.append(' '); |
| 116 | builder.append(dstPath); |
Narayan Kamath | 0349e8c | 2014-05-01 11:41:20 +0100 | [diff] [blame] | 117 | builder.append(' '); |
| 118 | builder.append(instructionSet); |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 119 | return mInstaller.execute(builder.toString()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 120 | } |
| 121 | |
Narayan Kamath | 0349e8c | 2014-05-01 11:41:20 +0100 | [diff] [blame] | 122 | public int rmdex(String codePath, String instructionSet) { |
Narayan Kamath | 6c4b9de | 2014-08-08 12:44:12 +0100 | [diff] [blame] | 123 | if (!isValidInstructionSet(instructionSet)) { |
| 124 | Slog.e(TAG, "Invalid instruction set: " + instructionSet); |
| 125 | return -1; |
| 126 | } |
| 127 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 128 | StringBuilder builder = new StringBuilder("rmdex"); |
| 129 | builder.append(' '); |
| 130 | builder.append(codePath); |
Narayan Kamath | 0349e8c | 2014-05-01 11:41:20 +0100 | [diff] [blame] | 131 | builder.append(' '); |
| 132 | builder.append(instructionSet); |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 133 | return mInstaller.execute(builder.toString()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 134 | } |
| 135 | |
Amith Yamasani | 0b28549 | 2011-04-14 17:35:23 -0700 | [diff] [blame] | 136 | public int remove(String name, int userId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 137 | StringBuilder builder = new StringBuilder("remove"); |
| 138 | builder.append(' '); |
| 139 | builder.append(name); |
Amith Yamasani | 0b28549 | 2011-04-14 17:35:23 -0700 | [diff] [blame] | 140 | builder.append(' '); |
| 141 | builder.append(userId); |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 142 | return mInstaller.execute(builder.toString()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 143 | } |
| 144 | |
Kenny Root | 35ab3ad | 2011-02-02 16:42:14 -0800 | [diff] [blame] | 145 | public int rename(String oldname, String newname) { |
Dianne Hackborn | b858dfd | 2010-02-02 10:49:14 -0800 | [diff] [blame] | 146 | StringBuilder builder = new StringBuilder("rename"); |
| 147 | builder.append(' '); |
| 148 | builder.append(oldname); |
| 149 | builder.append(' '); |
| 150 | builder.append(newname); |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 151 | return mInstaller.execute(builder.toString()); |
Dianne Hackborn | b858dfd | 2010-02-02 10:49:14 -0800 | [diff] [blame] | 152 | } |
| 153 | |
Dave Burke | 383fa18 | 2012-10-23 23:12:19 -0700 | [diff] [blame] | 154 | public int fixUid(String name, int uid, int gid) { |
Dianne Hackborn | d0c5f51 | 2012-06-07 16:53:59 -0700 | [diff] [blame] | 155 | StringBuilder builder = new StringBuilder("fixuid"); |
| 156 | builder.append(' '); |
| 157 | builder.append(name); |
| 158 | builder.append(' '); |
| 159 | builder.append(uid); |
| 160 | builder.append(' '); |
Dave Burke | 383fa18 | 2012-10-23 23:12:19 -0700 | [diff] [blame] | 161 | builder.append(gid); |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 162 | return mInstaller.execute(builder.toString()); |
Dianne Hackborn | d0c5f51 | 2012-06-07 16:53:59 -0700 | [diff] [blame] | 163 | } |
| 164 | |
Amith Yamasani | 54289b8 | 2012-10-01 10:39:14 -0700 | [diff] [blame] | 165 | public int deleteCacheFiles(String name, int userId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 166 | StringBuilder builder = new StringBuilder("rmcache"); |
| 167 | builder.append(' '); |
| 168 | builder.append(name); |
Amith Yamasani | 54289b8 | 2012-10-01 10:39:14 -0700 | [diff] [blame] | 169 | builder.append(' '); |
| 170 | builder.append(userId); |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 171 | return mInstaller.execute(builder.toString()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 172 | } |
Kenny Root | cf0b38c | 2011-03-22 14:17:59 -0700 | [diff] [blame] | 173 | |
Jeff Sharkey | 4ed745d | 2014-07-15 20:39:15 -0700 | [diff] [blame] | 174 | public int deleteCodeCacheFiles(String name, int userId) { |
| 175 | StringBuilder builder = new StringBuilder("rmcodecache"); |
| 176 | builder.append(' '); |
| 177 | builder.append(name); |
| 178 | builder.append(' '); |
| 179 | builder.append(userId); |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 180 | return mInstaller.execute(builder.toString()); |
Jeff Sharkey | 4ed745d | 2014-07-15 20:39:15 -0700 | [diff] [blame] | 181 | } |
| 182 | |
Robert Craig | 8643dc6 | 2013-07-29 09:06:51 -0400 | [diff] [blame] | 183 | public int createUserData(String name, int uid, int userId, String seinfo) { |
Amith Yamasani | 0b28549 | 2011-04-14 17:35:23 -0700 | [diff] [blame] | 184 | StringBuilder builder = new StringBuilder("mkuserdata"); |
| 185 | builder.append(' '); |
| 186 | builder.append(name); |
| 187 | builder.append(' '); |
| 188 | builder.append(uid); |
| 189 | builder.append(' '); |
| 190 | builder.append(userId); |
Robert Craig | 8643dc6 | 2013-07-29 09:06:51 -0400 | [diff] [blame] | 191 | builder.append(' '); |
| 192 | builder.append(seinfo != null ? seinfo : "!"); |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 193 | return mInstaller.execute(builder.toString()); |
Amith Yamasani | 0b28549 | 2011-04-14 17:35:23 -0700 | [diff] [blame] | 194 | } |
| 195 | |
Robin Lee | 06505d2 | 2014-07-09 17:43:56 +0000 | [diff] [blame] | 196 | public int createUserConfig(int userId) { |
| 197 | StringBuilder builder = new StringBuilder("mkuserconfig"); |
| 198 | builder.append(' '); |
| 199 | builder.append(userId); |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 200 | return mInstaller.execute(builder.toString()); |
Robin Lee | 06505d2 | 2014-07-09 17:43:56 +0000 | [diff] [blame] | 201 | } |
| 202 | |
Amith Yamasani | 0b28549 | 2011-04-14 17:35:23 -0700 | [diff] [blame] | 203 | public int removeUserDataDirs(int userId) { |
| 204 | StringBuilder builder = new StringBuilder("rmuser"); |
| 205 | builder.append(' '); |
| 206 | builder.append(userId); |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 207 | return mInstaller.execute(builder.toString()); |
Amith Yamasani | 0b28549 | 2011-04-14 17:35:23 -0700 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | public int clearUserData(String name, int userId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 211 | StringBuilder builder = new StringBuilder("rmuserdata"); |
| 212 | builder.append(' '); |
| 213 | builder.append(name); |
Amith Yamasani | 0b28549 | 2011-04-14 17:35:23 -0700 | [diff] [blame] | 214 | builder.append(' '); |
| 215 | builder.append(userId); |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 216 | return mInstaller.execute(builder.toString()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 217 | } |
Kenny Root | cf0b38c | 2011-03-22 14:17:59 -0700 | [diff] [blame] | 218 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 219 | public boolean ping() { |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 220 | if (mInstaller.execute("ping") < 0) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 221 | return false; |
| 222 | } else { |
| 223 | return true; |
| 224 | } |
| 225 | } |
Kenny Root | cf0b38c | 2011-03-22 14:17:59 -0700 | [diff] [blame] | 226 | |
Narayan Kamath | 152d5cd | 2014-06-24 12:19:10 +0000 | [diff] [blame] | 227 | public int pruneDexCache(String cacheSubDir) { |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 228 | return mInstaller.execute("prunedexcache " + cacheSubDir); |
Narayan Kamath | 5406f59 | 2014-06-16 13:54:10 +0000 | [diff] [blame] | 229 | } |
| 230 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 231 | public int freeCache(long freeStorageSize) { |
| 232 | StringBuilder builder = new StringBuilder("freecache"); |
| 233 | builder.append(' '); |
| 234 | builder.append(String.valueOf(freeStorageSize)); |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 235 | return mInstaller.execute(builder.toString()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 236 | } |
| 237 | |
Dianne Hackborn | ecc8d6f | 2013-05-01 18:54:11 -0700 | [diff] [blame] | 238 | public int getSizeInfo(String pkgName, int persona, String apkPath, String libDirPath, |
Narayan Kamath | ff110bd | 2014-07-04 18:30:45 +0100 | [diff] [blame] | 239 | String fwdLockApkPath, String asecPath, String[] instructionSets, PackageStats pStats) { |
Narayan Kamath | 6c4b9de | 2014-08-08 12:44:12 +0100 | [diff] [blame] | 240 | for (String instructionSet : instructionSets) { |
| 241 | if (!isValidInstructionSet(instructionSet)) { |
| 242 | Slog.e(TAG, "Invalid instruction set: " + instructionSet); |
| 243 | return -1; |
| 244 | } |
| 245 | } |
| 246 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 247 | StringBuilder builder = new StringBuilder("getsize"); |
| 248 | builder.append(' '); |
| 249 | builder.append(pkgName); |
| 250 | builder.append(' '); |
Dianne Hackborn | 0c38049 | 2012-08-20 17:23:30 -0700 | [diff] [blame] | 251 | builder.append(persona); |
| 252 | builder.append(' '); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 253 | builder.append(apkPath); |
| 254 | builder.append(' '); |
Narayan Kamath | ff110bd | 2014-07-04 18:30:45 +0100 | [diff] [blame] | 255 | // TODO: Extend getSizeInfo to look at the full subdirectory tree, |
| 256 | // not just the first level. |
Dianne Hackborn | ecc8d6f | 2013-05-01 18:54:11 -0700 | [diff] [blame] | 257 | builder.append(libDirPath != null ? libDirPath : "!"); |
| 258 | builder.append(' '); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 259 | builder.append(fwdLockApkPath != null ? fwdLockApkPath : "!"); |
Dianne Hackborn | 292f8bc | 2011-06-27 16:27:41 -0700 | [diff] [blame] | 260 | builder.append(' '); |
| 261 | builder.append(asecPath != null ? asecPath : "!"); |
Narayan Kamath | 0349e8c | 2014-05-01 11:41:20 +0100 | [diff] [blame] | 262 | builder.append(' '); |
Narayan Kamath | ff110bd | 2014-07-04 18:30:45 +0100 | [diff] [blame] | 263 | // TODO: Extend getSizeInfo to look at *all* instrution sets, not |
| 264 | // just the primary. |
| 265 | builder.append(instructionSets[0]); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 266 | |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 267 | String s = mInstaller.transact(builder.toString()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 268 | String res[] = s.split(" "); |
| 269 | |
Dianne Hackborn | 292f8bc | 2011-06-27 16:27:41 -0700 | [diff] [blame] | 270 | if ((res == null) || (res.length != 5)) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 271 | return -1; |
| 272 | } |
| 273 | try { |
| 274 | pStats.codeSize = Long.parseLong(res[1]); |
| 275 | pStats.dataSize = Long.parseLong(res[2]); |
| 276 | pStats.cacheSize = Long.parseLong(res[3]); |
Dianne Hackborn | 292f8bc | 2011-06-27 16:27:41 -0700 | [diff] [blame] | 277 | pStats.externalCodeSize = Long.parseLong(res[4]); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 278 | return Integer.parseInt(res[0]); |
| 279 | } catch (NumberFormatException e) { |
| 280 | return -1; |
| 281 | } |
Kenny Root | cf0b38c | 2011-03-22 14:17:59 -0700 | [diff] [blame] | 282 | } |
Dianne Hackborn | b858dfd | 2010-02-02 10:49:14 -0800 | [diff] [blame] | 283 | |
| 284 | public int moveFiles() { |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 285 | return mInstaller.execute("movefiles"); |
Dianne Hackborn | b858dfd | 2010-02-02 10:49:14 -0800 | [diff] [blame] | 286 | } |
Kenny Root | 6a6b007 | 2010-10-07 16:46:10 -0700 | [diff] [blame] | 287 | |
Kenny Root | ddbe50d | 2012-09-06 13:18:37 -0700 | [diff] [blame] | 288 | /** |
Narayan Kamath | ff110bd | 2014-07-04 18:30:45 +0100 | [diff] [blame] | 289 | * Links the 32 bit native library directory in an application's data directory to the |
| 290 | * real location for backward compatibility. Note that no such symlink is created for |
| 291 | * 64 bit shared libraries. |
Kenny Root | ddbe50d | 2012-09-06 13:18:37 -0700 | [diff] [blame] | 292 | * |
Kenny Root | ddbe50d | 2012-09-06 13:18:37 -0700 | [diff] [blame] | 293 | * @return -1 on error |
| 294 | */ |
Narayan Kamath | ff110bd | 2014-07-04 18:30:45 +0100 | [diff] [blame] | 295 | public int linkNativeLibraryDirectory(String dataPath, String nativeLibPath32, int userId) { |
Kenny Root | 6a6b007 | 2010-10-07 16:46:10 -0700 | [diff] [blame] | 296 | if (dataPath == null) { |
Kenny Root | 9bbd70a | 2012-09-10 11:13:36 -0700 | [diff] [blame] | 297 | Slog.e(TAG, "linkNativeLibraryDirectory dataPath is null"); |
Kenny Root | 6a6b007 | 2010-10-07 16:46:10 -0700 | [diff] [blame] | 298 | return -1; |
Narayan Kamath | ff110bd | 2014-07-04 18:30:45 +0100 | [diff] [blame] | 299 | } else if (nativeLibPath32 == null) { |
Kenny Root | 9bbd70a | 2012-09-10 11:13:36 -0700 | [diff] [blame] | 300 | Slog.e(TAG, "linkNativeLibraryDirectory nativeLibPath is null"); |
Kenny Root | 6a6b007 | 2010-10-07 16:46:10 -0700 | [diff] [blame] | 301 | return -1; |
| 302 | } |
| 303 | |
| 304 | StringBuilder builder = new StringBuilder("linklib "); |
| 305 | builder.append(dataPath); |
| 306 | builder.append(' '); |
Narayan Kamath | ff110bd | 2014-07-04 18:30:45 +0100 | [diff] [blame] | 307 | builder.append(nativeLibPath32); |
Kenny Root | a3e9079 | 2012-10-18 10:58:36 -0700 | [diff] [blame] | 308 | builder.append(' '); |
| 309 | builder.append(userId); |
Kenny Root | 6a6b007 | 2010-10-07 16:46:10 -0700 | [diff] [blame] | 310 | |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 311 | return mInstaller.execute(builder.toString()); |
Kenny Root | 6a6b007 | 2010-10-07 16:46:10 -0700 | [diff] [blame] | 312 | } |
Robert Craig | 4385343 | 2014-03-04 11:57:23 -0500 | [diff] [blame] | 313 | |
Nick Kralevich | ce30fca85 | 2014-03-31 20:20:41 +0000 | [diff] [blame] | 314 | public boolean restoreconData(String pkgName, String seinfo, int uid) { |
| 315 | StringBuilder builder = new StringBuilder("restorecondata"); |
| 316 | builder.append(' '); |
| 317 | builder.append(pkgName); |
| 318 | builder.append(' '); |
| 319 | builder.append(seinfo != null ? seinfo : "!"); |
| 320 | builder.append(' '); |
| 321 | builder.append(uid); |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 322 | return (mInstaller.execute(builder.toString()) == 0); |
Robert Craig | 4385343 | 2014-03-04 11:57:23 -0500 | [diff] [blame] | 323 | } |
Narayan Kamath | 6c4b9de | 2014-08-08 12:44:12 +0100 | [diff] [blame] | 324 | |
| 325 | /** |
| 326 | * Returns true iff. {@code instructionSet} is a valid instruction set. |
| 327 | */ |
| 328 | private static boolean isValidInstructionSet(String instructionSet) { |
| 329 | if (instructionSet == null) { |
| 330 | return false; |
| 331 | } |
| 332 | |
| 333 | for (String abi : Build.SUPPORTED_ABIS) { |
| 334 | if (instructionSet.equals(VMRuntime.getInstructionSet(abi))) { |
| 335 | return true; |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | return false; |
| 340 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 341 | } |