summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2013-09-26 21:02:10 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-09-26 21:02:10 +0000
commitd2534f8c05ccdf692f1e265ae719b67290d15050 (patch)
tree81bb8feae2b9ffd6014a1d23b9362051387b1427 /services
parent8c6c04197e58be6f3e46ba6a38f5d16e4fb091fa (diff)
parentfc95e70abd1ab94668e312aa3862ca6b89832da4 (diff)
downloadframeworks_base-d2534f8c05ccdf692f1e265ae719b67290d15050.zip
frameworks_base-d2534f8c05ccdf692f1e265ae719b67290d15050.tar.gz
frameworks_base-d2534f8c05ccdf692f1e265ae719b67290d15050.tar.bz2
Merge "Don't remove restrictions files that are valid" into klp-dev
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/pm/UserManagerService.java24
1 files changed, 17 insertions, 7 deletions
diff --git a/services/java/com/android/server/pm/UserManagerService.java b/services/java/com/android/server/pm/UserManagerService.java
index d0e9fe1..c33134a 100644
--- a/services/java/com/android/server/pm/UserManagerService.java
+++ b/services/java/com/android/server/pm/UserManagerService.java
@@ -110,6 +110,7 @@ public class UserManagerService extends IUserManager.Stub {
private static final String USER_PHOTO_FILENAME = "photo.png";
private static final String RESTRICTIONS_FILE_PREFIX = "res_";
+ private static final String XML_SUFFIX = ".xml";
private static final int MIN_USER_ID = 10;
@@ -622,7 +623,7 @@ public class UserManagerService extends IUserManager.Stub {
*/
private void writeUserLocked(UserInfo userInfo) {
FileOutputStream fos = null;
- AtomicFile userFile = new AtomicFile(new File(mUsersDir, userInfo.id + ".xml"));
+ AtomicFile userFile = new AtomicFile(new File(mUsersDir, userInfo.id + XML_SUFFIX));
try {
fos = userFile.startWrite();
final BufferedOutputStream bos = new BufferedOutputStream(fos);
@@ -751,7 +752,7 @@ public class UserManagerService extends IUserManager.Stub {
FileInputStream fis = null;
try {
AtomicFile userFile =
- new AtomicFile(new File(mUsersDir, Integer.toString(id) + ".xml"));
+ new AtomicFile(new File(mUsersDir, Integer.toString(id) + XML_SUFFIX));
fis = userFile.openRead();
XmlPullParser parser = Xml.newPullParser();
parser.setInput(fis, null);
@@ -909,7 +910,7 @@ public class UserManagerService extends IUserManager.Stub {
if (all) {
resFile.delete();
} else {
- String pkg = fileName.substring(RESTRICTIONS_FILE_PREFIX.length());
+ String pkg = restrictionsFileNameToPackage(fileName);
if (!isPackageInstalled(pkg, userId)) {
resFile.delete();
}
@@ -926,7 +927,7 @@ public class UserManagerService extends IUserManager.Stub {
private void cleanAppRestrictionsForPackage(String pkg, int userId) {
synchronized (mPackagesLock) {
File dir = Environment.getUserSystemDirectory(userId);
- File resFile = new File(dir, RESTRICTIONS_FILE_PREFIX + pkg);
+ File resFile = new File(dir, packageToRestrictionsFileName(pkg));
if (resFile.exists()) {
resFile.delete();
}
@@ -1072,7 +1073,7 @@ public class UserManagerService extends IUserManager.Stub {
mRestrictionsPinStates.remove(userHandle);
// Remove user file
- AtomicFile userFile = new AtomicFile(new File(mUsersDir, userHandle + ".xml"));
+ AtomicFile userFile = new AtomicFile(new File(mUsersDir, userHandle + XML_SUFFIX));
userFile.delete();
// Update the user list
writeUserListLocked();
@@ -1307,7 +1308,7 @@ public class UserManagerService extends IUserManager.Stub {
try {
AtomicFile restrictionsFile =
new AtomicFile(new File(Environment.getUserSystemDirectory(userId),
- RESTRICTIONS_FILE_PREFIX + packageName + ".xml"));
+ packageToRestrictionsFileName(packageName)));
fis = restrictionsFile.openRead();
XmlPullParser parser = Xml.newPullParser();
parser.setInput(fis, null);
@@ -1368,7 +1369,7 @@ public class UserManagerService extends IUserManager.Stub {
FileOutputStream fos = null;
AtomicFile restrictionsFile = new AtomicFile(
new File(Environment.getUserSystemDirectory(userId),
- RESTRICTIONS_FILE_PREFIX + packageName + ".xml"));
+ packageToRestrictionsFileName(packageName)));
try {
fos = restrictionsFile.startWrite();
final BufferedOutputStream bos = new BufferedOutputStream(fos);
@@ -1498,6 +1499,15 @@ public class UserManagerService extends IUserManager.Stub {
}
}
+ private String packageToRestrictionsFileName(String packageName) {
+ return RESTRICTIONS_FILE_PREFIX + packageName + XML_SUFFIX;
+ }
+
+ private String restrictionsFileNameToPackage(String fileName) {
+ return fileName.substring(RESTRICTIONS_FILE_PREFIX.length(),
+ (int) (fileName.length() - XML_SUFFIX.length()));
+ }
+
@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)