am 050c87f8: am a950daf5: Merge changes Ieb566a2a,I953057cd

* commit '050c87f87e2a48c7bc90f5b15fb6e4e37e667286':
  Use Libcore's stat instead of FileUtils#getFileStatus
  Use Libcore.os.stat instead of FileUtils
This commit is contained in:
Kenny Root
2012-08-16 16:43:20 -07:00
committed by Android Git Automerger
5 changed files with 58 additions and 238 deletions

View File

@ -146,6 +146,7 @@ import java.util.Set;
import libcore.io.ErrnoException;
import libcore.io.IoUtils;
import libcore.io.Libcore;
import libcore.io.StructStat;
/**
* Keep track of all those .apks everywhere.
@ -305,8 +306,6 @@ public class PackageManagerService extends IPackageManager.Stub {
File mScanningPath;
int mLastScanError;
final int[] mOutPermissions = new int[3];
// ----------------------------------------------------------------
// Keys are String (package name), values are Package. This also serves
@ -3790,14 +3789,18 @@ public class PackageManagerService extends IPackageManager.Stub {
boolean uidError = false;
if (dataPath.exists()) {
// XXX should really do this check for each user.
mOutPermissions[1] = 0;
FileUtils.getPermissions(dataPath.getPath(), mOutPermissions);
int currentUid = 0;
try {
StructStat stat = Libcore.os.stat(dataPath.getPath());
currentUid = stat.st_uid;
} catch (ErrnoException e) {
Slog.e(TAG, "Couldn't stat path " + dataPath.getPath(), e);
}
// If we have mismatched owners for the data path, we have a problem.
if (mOutPermissions[1] != pkg.applicationInfo.uid) {
if (currentUid != pkg.applicationInfo.uid) {
boolean recovered = false;
if (mOutPermissions[1] == 0) {
if (currentUid == 0) {
// The directory somehow became owned by root. Wow.
// This is probably because the system was stopped while
// installd was in the middle of messing with its libs
@ -3826,7 +3829,7 @@ public class PackageManagerService extends IPackageManager.Stub {
? "System package " : "Third party package ";
String msg = prefix + pkg.packageName
+ " has changed from uid: "
+ mOutPermissions[1] + " to "
+ currentUid + " to "
+ pkg.applicationInfo.uid + "; old data erased";
reportSettingsProblem(Log.WARN, msg);
recovered = true;
@ -3858,11 +3861,11 @@ public class PackageManagerService extends IPackageManager.Stub {
if (!recovered) {
pkg.applicationInfo.dataDir = "/mismatched_uid/settings_"
+ pkg.applicationInfo.uid + "/fs_"
+ mOutPermissions[1];
+ currentUid;
pkg.applicationInfo.nativeLibraryDir = pkg.applicationInfo.dataDir;
String msg = "Package " + pkg.packageName
+ " has mismatched uid: "
+ mOutPermissions[1] + " on disk, "
+ currentUid + " on disk, "
+ pkg.applicationInfo.uid + " in settings";
// writer
synchronized (mPackages) {