Loading core/java/android/accounts/AccountManagerService.java +2 −2 Original line number Diff line number Diff line Loading @@ -1879,7 +1879,7 @@ public class AccountManagerService private static String getDatabaseName(int userId) { File systemDir = Environment.getSystemSecureDirectory(); File databaseFile = new File(systemDir, "users/" + userId + "/" + DATABASE_NAME); File databaseFile = new File(Environment.getUserSystemDirectory(userId), DATABASE_NAME); if (userId == 0) { // Migrate old file, if it exists, to the new location. // Make sure the new file doesn't already exist. A dummy file could have been Loading @@ -1888,7 +1888,7 @@ public class AccountManagerService File oldFile = new File(systemDir, DATABASE_NAME); if (oldFile.exists() && !databaseFile.exists()) { // Check for use directory; create if it doesn't exist, else renameTo will fail File userDir = new File(systemDir, "users/" + userId); File userDir = Environment.getUserSystemDirectory(userId); if (!userDir.exists()) { if (!userDir.mkdirs()) { throw new IllegalStateException("User dir cannot be created: " + userDir); Loading core/java/android/app/backup/WallpaperBackupHelper.java +11 −3 Original line number Diff line number Diff line Loading @@ -20,7 +20,9 @@ import android.app.WallpaperManager; import android.content.Context; import android.graphics.BitmapFactory; import android.graphics.Point; import android.os.Environment; import android.os.ParcelFileDescriptor; import android.os.UserHandle; import android.util.Slog; import android.view.Display; import android.view.WindowManager; Loading @@ -39,8 +41,12 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu // This path must match what the WallpaperManagerService uses // TODO: Will need to change if backing up non-primary user's wallpaper public static final String WALLPAPER_IMAGE = "/data/system/users/0/wallpaper"; public static final String WALLPAPER_INFO = "/data/system/users/0/wallpaper_info.xml"; public static final String WALLPAPER_IMAGE = new File(Environment.getUserSystemDirectory(UserHandle.USER_OWNER), "wallpaper").getAbsolutePath(); public static final String WALLPAPER_INFO = new File(Environment.getUserSystemDirectory(UserHandle.USER_OWNER), "wallpaper_info.xml").getAbsolutePath(); // Use old keys to keep legacy data compatibility and avoid writing two wallpapers public static final String WALLPAPER_IMAGE_KEY = "/data/data/com.android.settings/files/wallpaper"; Loading @@ -50,7 +56,9 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu // will be saved to this file from the restore stream, then renamed to the proper // location if it's deemed suitable. // TODO: Will need to change if backing up non-primary user's wallpaper private static final String STAGE_FILE = "/data/system/users/0/wallpaper-tmp"; private static final String STAGE_FILE = new File(Environment.getUserSystemDirectory(UserHandle.USER_OWNER), "wallpaper-tmp").getAbsolutePath(); Context mContext; String[] mFiles; Loading core/java/android/os/Environment.java +11 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,17 @@ public class Environment { return MEDIA_STORAGE_DIRECTORY; } /** * Return the system directory for a user. This is for use by system services to store * files relating to the user. This directory will be automatically deleted when the user * is removed. * * @hide */ public static File getUserSystemDirectory(int userId) { return new File(new File(getSystemSecureDirectory(), "users"), Integer.toString(userId)); } /** * Returns whether the Encrypted File System feature is enabled on the device or not. * @return <code>true</code> if Encrypted File System feature is enabled, <code>false</code> Loading core/java/com/android/internal/widget/LockSettingsService.java +5 −2 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.os.Binder; import android.os.Environment; import android.os.RemoteException; import android.os.SystemProperties; import android.os.UserHandle; Loading Loading @@ -173,7 +174,8 @@ public class LockSettingsService extends ILockSettings.Stub { // Leave it in the same place for user 0 return dataSystemDirectory + LOCK_PATTERN_FILE; } else { return dataSystemDirectory + "users/" + userId + "/" + LOCK_PATTERN_FILE; return new File(Environment.getUserSystemDirectory(userId), LOCK_PATTERN_FILE) .getAbsolutePath(); } } Loading @@ -185,7 +187,8 @@ public class LockSettingsService extends ILockSettings.Stub { // Leave it in the same place for user 0 return dataSystemDirectory + LOCK_PASSWORD_FILE; } else { return dataSystemDirectory + "users/" + userId + "/" + LOCK_PASSWORD_FILE; return new File(Environment.getUserSystemDirectory(userId), LOCK_PASSWORD_FILE) .getAbsolutePath(); } } Loading services/java/com/android/server/AppWidgetServiceImpl.java +3 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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()) { Loading Loading
core/java/android/accounts/AccountManagerService.java +2 −2 Original line number Diff line number Diff line Loading @@ -1879,7 +1879,7 @@ public class AccountManagerService private static String getDatabaseName(int userId) { File systemDir = Environment.getSystemSecureDirectory(); File databaseFile = new File(systemDir, "users/" + userId + "/" + DATABASE_NAME); File databaseFile = new File(Environment.getUserSystemDirectory(userId), DATABASE_NAME); if (userId == 0) { // Migrate old file, if it exists, to the new location. // Make sure the new file doesn't already exist. A dummy file could have been Loading @@ -1888,7 +1888,7 @@ public class AccountManagerService File oldFile = new File(systemDir, DATABASE_NAME); if (oldFile.exists() && !databaseFile.exists()) { // Check for use directory; create if it doesn't exist, else renameTo will fail File userDir = new File(systemDir, "users/" + userId); File userDir = Environment.getUserSystemDirectory(userId); if (!userDir.exists()) { if (!userDir.mkdirs()) { throw new IllegalStateException("User dir cannot be created: " + userDir); Loading
core/java/android/app/backup/WallpaperBackupHelper.java +11 −3 Original line number Diff line number Diff line Loading @@ -20,7 +20,9 @@ import android.app.WallpaperManager; import android.content.Context; import android.graphics.BitmapFactory; import android.graphics.Point; import android.os.Environment; import android.os.ParcelFileDescriptor; import android.os.UserHandle; import android.util.Slog; import android.view.Display; import android.view.WindowManager; Loading @@ -39,8 +41,12 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu // This path must match what the WallpaperManagerService uses // TODO: Will need to change if backing up non-primary user's wallpaper public static final String WALLPAPER_IMAGE = "/data/system/users/0/wallpaper"; public static final String WALLPAPER_INFO = "/data/system/users/0/wallpaper_info.xml"; public static final String WALLPAPER_IMAGE = new File(Environment.getUserSystemDirectory(UserHandle.USER_OWNER), "wallpaper").getAbsolutePath(); public static final String WALLPAPER_INFO = new File(Environment.getUserSystemDirectory(UserHandle.USER_OWNER), "wallpaper_info.xml").getAbsolutePath(); // Use old keys to keep legacy data compatibility and avoid writing two wallpapers public static final String WALLPAPER_IMAGE_KEY = "/data/data/com.android.settings/files/wallpaper"; Loading @@ -50,7 +56,9 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu // will be saved to this file from the restore stream, then renamed to the proper // location if it's deemed suitable. // TODO: Will need to change if backing up non-primary user's wallpaper private static final String STAGE_FILE = "/data/system/users/0/wallpaper-tmp"; private static final String STAGE_FILE = new File(Environment.getUserSystemDirectory(UserHandle.USER_OWNER), "wallpaper-tmp").getAbsolutePath(); Context mContext; String[] mFiles; Loading
core/java/android/os/Environment.java +11 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,17 @@ public class Environment { return MEDIA_STORAGE_DIRECTORY; } /** * Return the system directory for a user. This is for use by system services to store * files relating to the user. This directory will be automatically deleted when the user * is removed. * * @hide */ public static File getUserSystemDirectory(int userId) { return new File(new File(getSystemSecureDirectory(), "users"), Integer.toString(userId)); } /** * Returns whether the Encrypted File System feature is enabled on the device or not. * @return <code>true</code> if Encrypted File System feature is enabled, <code>false</code> Loading
core/java/com/android/internal/widget/LockSettingsService.java +5 −2 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.os.Binder; import android.os.Environment; import android.os.RemoteException; import android.os.SystemProperties; import android.os.UserHandle; Loading Loading @@ -173,7 +174,8 @@ public class LockSettingsService extends ILockSettings.Stub { // Leave it in the same place for user 0 return dataSystemDirectory + LOCK_PATTERN_FILE; } else { return dataSystemDirectory + "users/" + userId + "/" + LOCK_PATTERN_FILE; return new File(Environment.getUserSystemDirectory(userId), LOCK_PATTERN_FILE) .getAbsolutePath(); } } Loading @@ -185,7 +187,8 @@ public class LockSettingsService extends ILockSettings.Stub { // Leave it in the same place for user 0 return dataSystemDirectory + LOCK_PASSWORD_FILE; } else { return dataSystemDirectory + "users/" + userId + "/" + LOCK_PASSWORD_FILE; return new File(Environment.getUserSystemDirectory(userId), LOCK_PASSWORD_FILE) .getAbsolutePath(); } } Loading
services/java/com/android/server/AppWidgetServiceImpl.java +3 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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()) { Loading