summaryrefslogtreecommitdiffstats
path: root/services/java/com/android
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2012-08-31 12:12:28 -0700
committerAmith Yamasani <yamasani@google.com>2012-08-31 15:33:21 -0700
commit61f57379ca2c5b6290c8da7548fa17128f7ab24f (patch)
tree1aadc5b172ecf5689455e03e5ab635b709d5021f /services/java/com/android
parent00453e7a0182b50cf01e65c97650b526284fe084 (diff)
downloadframeworks_base-61f57379ca2c5b6290c8da7548fa17128f7ab24f.zip
frameworks_base-61f57379ca2c5b6290c8da7548fa17128f7ab24f.tar.gz
frameworks_base-61f57379ca2c5b6290c8da7548fa17128f7ab24f.tar.bz2
Centralize the creation of the user system directory
Environment.getUserSystemDirectory(int userId) Use it all relevant places that was hardcoding it. Also, wipe out the user's system directory when user is removed, otherwise old state might be transferred to a new user. Change-Id: I788ce9c4cf9624229e65efa7047bc0c019ccef0a
Diffstat (limited to 'services/java/com/android')
-rw-r--r--services/java/com/android/server/AppWidgetServiceImpl.java5
-rw-r--r--services/java/com/android/server/SystemBackupAgent.java8
-rw-r--r--services/java/com/android/server/WallpaperManagerService.java12
-rw-r--r--services/java/com/android/server/pm/Settings.java7
-rw-r--r--services/java/com/android/server/pm/UserManagerService.java12
5 files changed, 29 insertions, 15 deletions
diff --git a/services/java/com/android/server/AppWidgetServiceImpl.java b/services/java/com/android/server/AppWidgetServiceImpl.java
index 79dabee..57ab921 100644
--- a/services/java/com/android/server/AppWidgetServiceImpl.java
+++ b/services/java/com/android/server/AppWidgetServiceImpl.java
@@ -40,6 +40,7 @@ import android.graphics.Point;
import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;
+import android.os.Environment;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.SystemClock;
@@ -1634,11 +1635,11 @@ class AppWidgetServiceImpl {
}
static File getSettingsFile(int userId) {
- return new File("/data/system/users/" + userId + "/" + SETTINGS_FILENAME);
+ return new File(Environment.getUserSystemDirectory(userId), SETTINGS_FILENAME);
}
AtomicFile savedStateFile() {
- File dir = new File("/data/system/users/" + mUserId);
+ File dir = Environment.getUserSystemDirectory(mUserId);
File settingsFile = getSettingsFile(mUserId);
if (!settingsFile.exists() && mUserId == 0) {
if (!dir.exists()) {
diff --git a/services/java/com/android/server/SystemBackupAgent.java b/services/java/com/android/server/SystemBackupAgent.java
index a7a583c..8cf273d 100644
--- a/services/java/com/android/server/SystemBackupAgent.java
+++ b/services/java/com/android/server/SystemBackupAgent.java
@@ -24,8 +24,10 @@ import android.app.backup.FullBackup;
import android.app.backup.FullBackupDataOutput;
import android.app.backup.WallpaperBackupHelper;
import android.content.Context;
+import android.os.Environment;
import android.os.ParcelFileDescriptor;
import android.os.ServiceManager;
+import android.os.UserHandle;
import android.util.Slog;
@@ -45,11 +47,13 @@ public class SystemBackupAgent extends BackupAgentHelper {
private static final String WALLPAPER_INFO_FILENAME = "wallpaper_info.xml";
// TODO: Will need to change if backing up non-primary user's wallpaper
- private static final String WALLPAPER_IMAGE_DIR = "/data/system/users/0";
+ private static final String WALLPAPER_IMAGE_DIR =
+ Environment.getUserSystemDirectory(UserHandle.USER_OWNER).getAbsolutePath();
private static final String WALLPAPER_IMAGE = WallpaperBackupHelper.WALLPAPER_IMAGE;
// TODO: Will need to change if backing up non-primary user's wallpaper
- private static final String WALLPAPER_INFO_DIR = "/data/system/users/0";
+ private static final String WALLPAPER_INFO_DIR =
+ Environment.getUserSystemDirectory(UserHandle.USER_OWNER).getAbsolutePath();
private static final String WALLPAPER_INFO = WallpaperBackupHelper.WALLPAPER_INFO;
// Use old keys to keep legacy data compatibility and avoid writing two wallpapers
private static final String WALLPAPER_IMAGE_KEY = WallpaperBackupHelper.WALLPAPER_IMAGE_KEY;
diff --git a/services/java/com/android/server/WallpaperManagerService.java b/services/java/com/android/server/WallpaperManagerService.java
index 643e937..b8a37cf 100644
--- a/services/java/com/android/server/WallpaperManagerService.java
+++ b/services/java/com/android/server/WallpaperManagerService.java
@@ -92,8 +92,6 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
* restarting it vs. just reverting to the static wallpaper.
*/
static final long MIN_WALLPAPER_CRASH_TIME = 10000;
-
- static final File WALLPAPER_BASE_DIR = new File("/data/system/users");
static final String WALLPAPER = "wallpaper";
static final String WALLPAPER_INFO = "wallpaper_info.xml";
@@ -395,12 +393,12 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
mIPackageManager = AppGlobals.getPackageManager();
mMonitor = new MyPackageMonitor();
mMonitor.register(context, null, true);
- WALLPAPER_BASE_DIR.mkdirs();
- loadSettingsLocked(0);
+ getWallpaperDir(UserHandle.USER_OWNER).mkdirs();
+ loadSettingsLocked(UserHandle.USER_OWNER);
}
private static File getWallpaperDir(int userId) {
- return new File(WALLPAPER_BASE_DIR + "/" + userId);
+ return Environment.getUserSystemDirectory(userId);
}
@Override
@@ -414,7 +412,7 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
public void systemReady() {
if (DEBUG) Slog.v(TAG, "systemReady");
- WallpaperData wallpaper = mWallpaperMap.get(0);
+ WallpaperData wallpaper = mWallpaperMap.get(UserHandle.USER_OWNER);
switchWallpaper(wallpaper);
wallpaper.wallpaperObserver = new WallpaperObserver(wallpaper);
wallpaper.wallpaperObserver.startWatching();
@@ -880,7 +878,7 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
}
private static JournaledFile makeJournaledFile(int userId) {
- final String base = getWallpaperDir(userId) + "/" + WALLPAPER_INFO;
+ final String base = new File(getWallpaperDir(userId), WALLPAPER_INFO).getAbsolutePath();
return new JournaledFile(new File(base), new File(base + ".tmp"));
}
diff --git a/services/java/com/android/server/pm/Settings.java b/services/java/com/android/server/pm/Settings.java
index 68b594a..5f10d44 100644
--- a/services/java/com/android/server/pm/Settings.java
+++ b/services/java/com/android/server/pm/Settings.java
@@ -745,13 +745,12 @@ final class Settings {
}
private File getUserPackagesStateFile(int userId) {
- return new File(mSystemDir,
- "users/" + userId + "/package-restrictions.xml");
+ return new File(Environment.getUserSystemDirectory(userId), "package-restrictions.xml");
}
private File getUserPackagesStateBackupFile(int userId) {
- return new File(mSystemDir,
- "users/" + userId + "/package-restrictions-backup.xml");
+ return new File(Environment.getUserSystemDirectory(userId),
+ "package-restrictions-backup.xml");
}
void writeAllUsersPackageRestrictionsLPr() {
diff --git a/services/java/com/android/server/pm/UserManagerService.java b/services/java/com/android/server/pm/UserManagerService.java
index 492158d..a13c16e 100644
--- a/services/java/com/android/server/pm/UserManagerService.java
+++ b/services/java/com/android/server/pm/UserManagerService.java
@@ -594,6 +594,7 @@ public class UserManagerService extends IUserManager.Stub {
// Update the user list
writeUserListLocked();
updateUserIdsLocked();
+ removeDirectoryRecursive(Environment.getUserSystemDirectory(userHandle));
}
}
@@ -603,6 +604,17 @@ public class UserManagerService extends IUserManager.Stub {
mContext.sendBroadcast(addedIntent, android.Manifest.permission.MANAGE_USERS);
}
+ private void removeDirectoryRecursive(File parent) {
+ if (parent.isDirectory()) {
+ String[] files = parent.list();
+ for (String filename : files) {
+ File child = new File(parent, filename);
+ removeDirectoryRecursive(child);
+ }
+ }
+ parent.delete();
+ }
+
@Override
public int getUserSerialNumber(int userHandle) {
synchronized (mPackagesLock) {