blob: 738ab089bdd511dfa5e18eb6b2b582722b0449f5 [file] [log] [blame]
Amith Yamasani4b2e9342011-03-31 12:38:53 -07001/*
2 * Copyright (C) 2011 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
17package com.android.server.pm;
18
Amith Yamasanib8151ec2012-04-18 18:02:48 -070019import static android.os.ParcelFileDescriptor.MODE_CREATE;
20import static android.os.ParcelFileDescriptor.MODE_READ_WRITE;
21
Amith Yamasani13593602012-03-22 16:16:17 -070022import com.android.internal.util.ArrayUtils;
Amith Yamasani4b2e9342011-03-31 12:38:53 -070023import com.android.internal.util.FastXmlSerializer;
24
Amith Yamasani0b285492011-04-14 17:35:23 -070025import android.content.pm.ApplicationInfo;
26import android.content.pm.PackageManager;
Amith Yamasani4b2e9342011-03-31 12:38:53 -070027import android.content.pm.UserInfo;
28import android.os.Environment;
29import android.os.FileUtils;
Amith Yamasanib8151ec2012-04-18 18:02:48 -070030import android.os.ParcelFileDescriptor;
Amith Yamasani0b285492011-04-14 17:35:23 -070031import android.os.SystemClock;
Amith Yamasani742a6712011-05-04 14:49:28 -070032import android.os.UserId;
Amith Yamasani0b285492011-04-14 17:35:23 -070033import android.util.Log;
Amith Yamasani4b2e9342011-03-31 12:38:53 -070034import android.util.Slog;
35import android.util.SparseArray;
36import android.util.Xml;
37
38import java.io.BufferedOutputStream;
39import java.io.File;
40import java.io.FileInputStream;
Amith Yamasanib8151ec2012-04-18 18:02:48 -070041import java.io.FileNotFoundException;
Amith Yamasani4b2e9342011-03-31 12:38:53 -070042import java.io.FileOutputStream;
43import java.io.IOException;
44import java.util.ArrayList;
45import java.util.List;
46
47import org.xmlpull.v1.XmlPullParser;
48import org.xmlpull.v1.XmlPullParserException;
49import org.xmlpull.v1.XmlSerializer;
50
Amith Yamasani0b285492011-04-14 17:35:23 -070051public class UserManager {
Amith Yamasanib8151ec2012-04-18 18:02:48 -070052
53 private static final String TAG = "UserManager";
54
Amith Yamasani4b2e9342011-03-31 12:38:53 -070055 private static final String TAG_NAME = "name";
56
57 private static final String ATTR_FLAGS = "flags";
58
Amith Yamasanib8151ec2012-04-18 18:02:48 -070059 private static final String ATTR_ICON_PATH = "icon";
60
Amith Yamasani4b2e9342011-03-31 12:38:53 -070061 private static final String ATTR_ID = "id";
62
63 private static final String TAG_USERS = "users";
64
65 private static final String TAG_USER = "user";
66
Amith Yamasani0b285492011-04-14 17:35:23 -070067 private static final String LOG_TAG = "UserManager";
Amith Yamasani4b2e9342011-03-31 12:38:53 -070068
Amith Yamasani0b285492011-04-14 17:35:23 -070069 private static final String USER_INFO_DIR = "system" + File.separator + "users";
Amith Yamasani4b2e9342011-03-31 12:38:53 -070070 private static final String USER_LIST_FILENAME = "userlist.xml";
Amith Yamasanib8151ec2012-04-18 18:02:48 -070071 private static final String USER_PHOTO_FILENAME = "photo.png";
Amith Yamasani4b2e9342011-03-31 12:38:53 -070072
Amith Yamasani13593602012-03-22 16:16:17 -070073 private SparseArray<UserInfo> mUsers = new SparseArray<UserInfo>();
Amith Yamasani4b2e9342011-03-31 12:38:53 -070074
75 private final File mUsersDir;
76 private final File mUserListFile;
Amith Yamasani0b285492011-04-14 17:35:23 -070077 private int[] mUserIds;
78
79 private Installer mInstaller;
80 private File mBaseUserPath;
Amith Yamasani4b2e9342011-03-31 12:38:53 -070081
82 /**
83 * Available for testing purposes.
84 */
Amith Yamasani0b285492011-04-14 17:35:23 -070085 UserManager(File dataDir, File baseUserPath) {
Amith Yamasani4b2e9342011-03-31 12:38:53 -070086 mUsersDir = new File(dataDir, USER_INFO_DIR);
87 mUsersDir.mkdirs();
Amith Yamasani483f3b02012-03-13 16:08:00 -070088 // Make zeroth user directory, for services to migrate their files to that location
89 File userZeroDir = new File(mUsersDir, "0");
90 userZeroDir.mkdirs();
Amith Yamasani0b285492011-04-14 17:35:23 -070091 mBaseUserPath = baseUserPath;
Amith Yamasani4b2e9342011-03-31 12:38:53 -070092 FileUtils.setPermissions(mUsersDir.toString(),
93 FileUtils.S_IRWXU|FileUtils.S_IRWXG
94 |FileUtils.S_IROTH|FileUtils.S_IXOTH,
95 -1, -1);
96 mUserListFile = new File(mUsersDir, USER_LIST_FILENAME);
97 readUserList();
98 }
99
Amith Yamasani0b285492011-04-14 17:35:23 -0700100 public UserManager(Installer installer, File baseUserPath) {
101 this(Environment.getDataDirectory(), baseUserPath);
102 mInstaller = installer;
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700103 }
104
105 public List<UserInfo> getUsers() {
Amith Yamasani13593602012-03-22 16:16:17 -0700106 synchronized (mUsers) {
107 ArrayList<UserInfo> users = new ArrayList<UserInfo>(mUsers.size());
108 for (int i = 0; i < mUsers.size(); i++) {
109 users.add(mUsers.valueAt(i));
110 }
111 return users;
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700112 }
Amith Yamasani13593602012-03-22 16:16:17 -0700113 }
114
115 public UserInfo getUser(int userId) {
116 synchronized (mUsers) {
117 UserInfo info = mUsers.get(userId);
118 return info;
119 }
120 }
121
122 public boolean exists(int userId) {
123 synchronized (mUsers) {
124 return ArrayUtils.contains(mUserIds, userId);
125 }
126 }
127
Amith Yamasanib8151ec2012-04-18 18:02:48 -0700128 public void setUserName(int userId, String name) {
Amith Yamasani13593602012-03-22 16:16:17 -0700129 synchronized (mUsers) {
130 UserInfo info = mUsers.get(userId);
131 if (name != null && !name.equals(info.name)) {
132 info.name = name;
133 writeUserLocked(info);
134 }
135 }
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700136 }
137
Amith Yamasanib8151ec2012-04-18 18:02:48 -0700138 public ParcelFileDescriptor setUserIcon(int userId) {
139 synchronized (mUsers) {
140 UserInfo info = mUsers.get(userId);
141 if (info == null) return null;
142 ParcelFileDescriptor fd = updateIconBitmapLocked(info);
143 if (fd != null) {
144 writeUserLocked(info);
145 }
146 return fd;
147 }
148 }
149
150 private ParcelFileDescriptor updateIconBitmapLocked(UserInfo info) {
151 try {
152 File dir = new File(mUsersDir, Integer.toString(info.id));
153 File file = new File(dir, USER_PHOTO_FILENAME);
154 if (!dir.exists()) {
155 dir.mkdir();
156 FileUtils.setPermissions(
157 dir.getPath(),
158 FileUtils.S_IRWXU|FileUtils.S_IRWXG|FileUtils.S_IXOTH,
159 -1, -1);
160 }
161 ParcelFileDescriptor fd = ParcelFileDescriptor.open(file,
162 MODE_CREATE|MODE_READ_WRITE);
163 info.iconPath = file.getAbsolutePath();
164 return fd;
165 } catch (FileNotFoundException e) {
166 Slog.w(TAG, "Error setting photo for user ", e);
167 }
168 return null;
169 }
170
Amith Yamasani0b285492011-04-14 17:35:23 -0700171 /**
172 * Returns an array of user ids. This array is cached here for quick access, so do not modify or
173 * cache it elsewhere.
174 * @return the array of user ids.
175 */
176 int[] getUserIds() {
177 return mUserIds;
178 }
179
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700180 private void readUserList() {
Amith Yamasani13593602012-03-22 16:16:17 -0700181 synchronized (mUsers) {
182 readUserListLocked();
183 }
184 }
185
186 private void readUserListLocked() {
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700187 if (!mUserListFile.exists()) {
Amith Yamasani13593602012-03-22 16:16:17 -0700188 fallbackToSingleUserLocked();
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700189 return;
190 }
191 FileInputStream fis = null;
192 try {
193 fis = new FileInputStream(mUserListFile);
194 XmlPullParser parser = Xml.newPullParser();
195 parser.setInput(fis, null);
196 int type;
197 while ((type = parser.next()) != XmlPullParser.START_TAG
198 && type != XmlPullParser.END_DOCUMENT) {
199 ;
200 }
201
202 if (type != XmlPullParser.START_TAG) {
Amith Yamasani0b285492011-04-14 17:35:23 -0700203 Slog.e(LOG_TAG, "Unable to read user list");
Amith Yamasani13593602012-03-22 16:16:17 -0700204 fallbackToSingleUserLocked();
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700205 return;
206 }
207
208 while ((type = parser.next()) != XmlPullParser.END_DOCUMENT) {
209 if (type == XmlPullParser.START_TAG && parser.getName().equals(TAG_USER)) {
210 String id = parser.getAttributeValue(null, ATTR_ID);
211 UserInfo user = readUser(Integer.parseInt(id));
212 if (user != null) {
213 mUsers.put(user.id, user);
214 }
215 }
216 }
Amith Yamasani13593602012-03-22 16:16:17 -0700217 updateUserIdsLocked();
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700218 } catch (IOException ioe) {
Amith Yamasani13593602012-03-22 16:16:17 -0700219 fallbackToSingleUserLocked();
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700220 } catch (XmlPullParserException pe) {
Amith Yamasani13593602012-03-22 16:16:17 -0700221 fallbackToSingleUserLocked();
Dianne Hackbornbfd89b32011-12-15 18:22:54 -0800222 } finally {
223 if (fis != null) {
224 try {
225 fis.close();
226 } catch (IOException e) {
227 }
228 }
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700229 }
230 }
231
Amith Yamasani13593602012-03-22 16:16:17 -0700232 private void fallbackToSingleUserLocked() {
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700233 // Create the primary user
Amith Yamasanib8151ec2012-04-18 18:02:48 -0700234 UserInfo primary = new UserInfo(0, "Primary", null,
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700235 UserInfo.FLAG_ADMIN | UserInfo.FLAG_PRIMARY);
236 mUsers.put(0, primary);
Amith Yamasani13593602012-03-22 16:16:17 -0700237 updateUserIdsLocked();
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700238
Amith Yamasani13593602012-03-22 16:16:17 -0700239 writeUserListLocked();
240 writeUserLocked(primary);
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700241 }
242
243 /*
244 * Writes the user file in this format:
245 *
246 * <user flags="20039023" id="0">
247 * <name>Primary</name>
248 * </user>
249 */
Amith Yamasani13593602012-03-22 16:16:17 -0700250 private void writeUserLocked(UserInfo userInfo) {
Amith Yamasani742a6712011-05-04 14:49:28 -0700251 FileOutputStream fos = null;
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700252 try {
253 final File mUserFile = new File(mUsersDir, userInfo.id + ".xml");
Amith Yamasani742a6712011-05-04 14:49:28 -0700254 fos = new FileOutputStream(mUserFile);
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700255 final BufferedOutputStream bos = new BufferedOutputStream(fos);
256
257 // XmlSerializer serializer = XmlUtils.serializerInstance();
258 final XmlSerializer serializer = new FastXmlSerializer();
259 serializer.setOutput(bos, "utf-8");
260 serializer.startDocument(null, true);
261 serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
262
263 serializer.startTag(null, TAG_USER);
264 serializer.attribute(null, ATTR_ID, Integer.toString(userInfo.id));
265 serializer.attribute(null, ATTR_FLAGS, Integer.toString(userInfo.flags));
Amith Yamasanib8151ec2012-04-18 18:02:48 -0700266 if (userInfo.iconPath != null) {
267 serializer.attribute(null, ATTR_ICON_PATH, userInfo.iconPath);
268 }
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700269
270 serializer.startTag(null, TAG_NAME);
271 serializer.text(userInfo.name);
272 serializer.endTag(null, TAG_NAME);
273
274 serializer.endTag(null, TAG_USER);
275
276 serializer.endDocument();
277 } catch (IOException ioe) {
Amith Yamasani0b285492011-04-14 17:35:23 -0700278 Slog.e(LOG_TAG, "Error writing user info " + userInfo.id + "\n" + ioe);
Amith Yamasani742a6712011-05-04 14:49:28 -0700279 } finally {
280 if (fos != null) {
281 try {
282 fos.close();
283 } catch (IOException ioe) {
284 }
285 }
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700286 }
287 }
288
289 /*
290 * Writes the user list file in this format:
291 *
292 * <users>
293 * <user id="0"></user>
294 * <user id="2"></user>
295 * </users>
296 */
Amith Yamasani13593602012-03-22 16:16:17 -0700297 private void writeUserListLocked() {
Amith Yamasani742a6712011-05-04 14:49:28 -0700298 FileOutputStream fos = null;
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700299 try {
Amith Yamasani742a6712011-05-04 14:49:28 -0700300 fos = new FileOutputStream(mUserListFile);
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700301 final BufferedOutputStream bos = new BufferedOutputStream(fos);
302
303 // XmlSerializer serializer = XmlUtils.serializerInstance();
304 final XmlSerializer serializer = new FastXmlSerializer();
305 serializer.setOutput(bos, "utf-8");
306 serializer.startDocument(null, true);
307 serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
308
309 serializer.startTag(null, TAG_USERS);
310
311 for (int i = 0; i < mUsers.size(); i++) {
312 UserInfo user = mUsers.valueAt(i);
313 serializer.startTag(null, TAG_USER);
314 serializer.attribute(null, ATTR_ID, Integer.toString(user.id));
315 serializer.endTag(null, TAG_USER);
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700316 }
317
318 serializer.endTag(null, TAG_USERS);
319
320 serializer.endDocument();
321 } catch (IOException ioe) {
Amith Yamasani0b285492011-04-14 17:35:23 -0700322 Slog.e(LOG_TAG, "Error writing user list");
Amith Yamasani742a6712011-05-04 14:49:28 -0700323 } finally {
324 if (fos != null) {
325 try {
326 fos.close();
327 } catch (IOException ioe) {
328 }
329 }
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700330 }
331 }
332
333 private UserInfo readUser(int id) {
334 int flags = 0;
335 String name = null;
Amith Yamasanib8151ec2012-04-18 18:02:48 -0700336 String iconPath = null;
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700337
338 FileInputStream fis = null;
339 try {
340 File userFile = new File(mUsersDir, Integer.toString(id) + ".xml");
341 fis = new FileInputStream(userFile);
342 XmlPullParser parser = Xml.newPullParser();
343 parser.setInput(fis, null);
344 int type;
345 while ((type = parser.next()) != XmlPullParser.START_TAG
346 && type != XmlPullParser.END_DOCUMENT) {
347 ;
348 }
349
350 if (type != XmlPullParser.START_TAG) {
Amith Yamasani0b285492011-04-14 17:35:23 -0700351 Slog.e(LOG_TAG, "Unable to read user " + id);
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700352 return null;
353 }
354
355 if (type == XmlPullParser.START_TAG && parser.getName().equals(TAG_USER)) {
356 String storedId = parser.getAttributeValue(null, ATTR_ID);
357 if (Integer.parseInt(storedId) != id) {
Amith Yamasani0b285492011-04-14 17:35:23 -0700358 Slog.e(LOG_TAG, "User id does not match the file name");
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700359 return null;
360 }
361 String flagString = parser.getAttributeValue(null, ATTR_FLAGS);
362 flags = Integer.parseInt(flagString);
Amith Yamasanib8151ec2012-04-18 18:02:48 -0700363 iconPath = parser.getAttributeValue(null, ATTR_ICON_PATH);
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700364
365 while ((type = parser.next()) != XmlPullParser.START_TAG
366 && type != XmlPullParser.END_DOCUMENT) {
367 }
368 if (type == XmlPullParser.START_TAG && parser.getName().equals(TAG_NAME)) {
369 type = parser.next();
370 if (type == XmlPullParser.TEXT) {
371 name = parser.getText();
372 }
373 }
374 }
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700375
Amith Yamasanib8151ec2012-04-18 18:02:48 -0700376 UserInfo userInfo = new UserInfo(id, name, iconPath, flags);
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700377 return userInfo;
378
379 } catch (IOException ioe) {
380 } catch (XmlPullParserException pe) {
Dianne Hackbornbfd89b32011-12-15 18:22:54 -0800381 } finally {
382 if (fis != null) {
383 try {
384 fis.close();
385 } catch (IOException e) {
386 }
387 }
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700388 }
389 return null;
390 }
391
Amith Yamasani13593602012-03-22 16:16:17 -0700392 public UserInfo createUser(String name, int flags) {
Amith Yamasani0b285492011-04-14 17:35:23 -0700393 int userId = getNextAvailableId();
Amith Yamasanib8151ec2012-04-18 18:02:48 -0700394 UserInfo userInfo = new UserInfo(userId, name, null, flags);
Amith Yamasani0b285492011-04-14 17:35:23 -0700395 File userPath = new File(mBaseUserPath, Integer.toString(userId));
Amith Yamasani13593602012-03-22 16:16:17 -0700396 if (!createPackageFolders(userId, userPath)) {
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700397 return null;
398 }
Amith Yamasani13593602012-03-22 16:16:17 -0700399 synchronized (mUsers) {
400 mUsers.put(userId, userInfo);
401 writeUserListLocked();
402 writeUserLocked(userInfo);
403 updateUserIdsLocked();
404 }
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700405 return userInfo;
406 }
407
Amith Yamasani0b285492011-04-14 17:35:23 -0700408 /**
409 * Removes a user and all data directories created for that user. This method should be called
410 * after the user's processes have been terminated.
411 * @param id the user's id
412 */
Amith Yamasani13593602012-03-22 16:16:17 -0700413 public boolean removeUser(int id) {
414 synchronized (mUsers) {
415 return removeUserLocked(id);
416 }
417 }
418
419 private boolean removeUserLocked(int id) {
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700420 // Remove from the list
421 UserInfo userInfo = mUsers.get(id);
422 if (userInfo != null) {
423 // Remove this user from the list
424 mUsers.remove(id);
425 // Remove user file
426 File userFile = new File(mUsersDir, id + ".xml");
427 userFile.delete();
Amith Yamasani0b285492011-04-14 17:35:23 -0700428 // Update the user list
Amith Yamasani13593602012-03-22 16:16:17 -0700429 writeUserListLocked();
430 updateUserIdsLocked();
431 return true;
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700432 }
Amith Yamasani13593602012-03-22 16:16:17 -0700433 return false;
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700434 }
435
Amith Yamasani0b285492011-04-14 17:35:23 -0700436 public void installPackageForAllUsers(String packageName, int uid) {
437 for (int userId : mUserIds) {
438 // Don't do it for the primary user, it will become recursive.
439 if (userId == 0)
440 continue;
Amith Yamasani742a6712011-05-04 14:49:28 -0700441 mInstaller.createUserData(packageName, UserId.getUid(userId, uid),
Amith Yamasani0b285492011-04-14 17:35:23 -0700442 userId);
443 }
444 }
445
446 public void clearUserDataForAllUsers(String packageName) {
447 for (int userId : mUserIds) {
448 // Don't do it for the primary user, it will become recursive.
449 if (userId == 0)
450 continue;
451 mInstaller.clearUserData(packageName, userId);
452 }
453 }
454
455 public void removePackageForAllUsers(String packageName) {
456 for (int userId : mUserIds) {
457 // Don't do it for the primary user, it will become recursive.
458 if (userId == 0)
459 continue;
460 mInstaller.remove(packageName, userId);
461 }
462 }
463
464 /**
465 * Caches the list of user ids in an array, adjusting the array size when necessary.
466 */
Amith Yamasani13593602012-03-22 16:16:17 -0700467 private void updateUserIdsLocked() {
Amith Yamasani0b285492011-04-14 17:35:23 -0700468 if (mUserIds == null || mUserIds.length != mUsers.size()) {
469 mUserIds = new int[mUsers.size()];
470 }
471 for (int i = 0; i < mUsers.size(); i++) {
472 mUserIds[i] = mUsers.keyAt(i);
473 }
474 }
475
476 /**
477 * Returns the next available user id, filling in any holes in the ids.
Amith Yamasani742a6712011-05-04 14:49:28 -0700478 * TODO: May not be a good idea to recycle ids, in case it results in confusion
479 * for data and battery stats collection, or unexpected cross-talk.
Amith Yamasani0b285492011-04-14 17:35:23 -0700480 * @return
481 */
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700482 private int getNextAvailableId() {
483 int i = 0;
484 while (i < Integer.MAX_VALUE) {
485 if (mUsers.indexOfKey(i) < 0) {
486 break;
487 }
488 i++;
489 }
490 return i;
491 }
492
Amith Yamasani13593602012-03-22 16:16:17 -0700493 private boolean createPackageFolders(int id, File userPath) {
Amith Yamasani0b285492011-04-14 17:35:23 -0700494 // mInstaller may not be available for unit-tests.
Amith Yamasani13593602012-03-22 16:16:17 -0700495 if (mInstaller == null) return true;
Amith Yamasani0b285492011-04-14 17:35:23 -0700496
Amith Yamasani0b285492011-04-14 17:35:23 -0700497 // Create the user path
498 userPath.mkdir();
499 FileUtils.setPermissions(userPath.toString(), FileUtils.S_IRWXU | FileUtils.S_IRWXG
500 | FileUtils.S_IXOTH, -1, -1);
501
Amith Yamasani742a6712011-05-04 14:49:28 -0700502 mInstaller.cloneUserData(0, id, false);
503
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700504 return true;
505 }
506
Amith Yamasani13593602012-03-22 16:16:17 -0700507 boolean removePackageFolders(int id) {
Amith Yamasani0b285492011-04-14 17:35:23 -0700508 // mInstaller may not be available for unit-tests.
509 if (mInstaller == null) return true;
510
511 mInstaller.removeUserDataDirs(id);
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700512 return true;
513 }
514}