Merge "Offer to measure disk stats using quotas." am: f8720b95be am: 4b80a4a372 am: 1e1cdbead1
am: 7664e61885
Change-Id: I91c0810aad2ec530650855bcd2f1d25c309717a1
This commit is contained in:
@@ -509,10 +509,23 @@ class ContextImpl extends Context {
|
||||
* Common-path handling of app data dir creation
|
||||
*/
|
||||
private static File ensurePrivateDirExists(File file) {
|
||||
return ensurePrivateDirExists(file, 0771, -1);
|
||||
}
|
||||
|
||||
private static File ensurePrivateCacheDirExists(File file) {
|
||||
final int gid = UserHandle.getCacheAppGid(Process.myUid());
|
||||
return ensurePrivateDirExists(file, 02771, gid);
|
||||
}
|
||||
|
||||
private static File ensurePrivateDirExists(File file, int mode, int gid) {
|
||||
if (!file.exists()) {
|
||||
final String path = file.getAbsolutePath();
|
||||
try {
|
||||
Os.mkdir(file.getAbsolutePath(), 0771);
|
||||
Os.chmod(file.getAbsolutePath(), 0771);
|
||||
Os.mkdir(path, mode);
|
||||
Os.chmod(path, mode);
|
||||
if (gid != -1) {
|
||||
Os.chown(path, -1, gid);
|
||||
}
|
||||
} catch (ErrnoException e) {
|
||||
if (e.errno == OsConstants.EEXIST) {
|
||||
// We must have raced with someone; that's okay
|
||||
@@ -581,7 +594,7 @@ class ContextImpl extends Context {
|
||||
if (mCacheDir == null) {
|
||||
mCacheDir = new File(getDataDir(), "cache");
|
||||
}
|
||||
return ensurePrivateDirExists(mCacheDir);
|
||||
return ensurePrivateCacheDirExists(mCacheDir);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -591,7 +604,7 @@ class ContextImpl extends Context {
|
||||
if (mCodeCacheDir == null) {
|
||||
mCodeCacheDir = new File(getDataDir(), "code_cache");
|
||||
}
|
||||
return ensurePrivateDirExists(mCodeCacheDir);
|
||||
return ensurePrivateCacheDirExists(mCodeCacheDir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -818,7 +818,7 @@ public class Build {
|
||||
*/
|
||||
public static boolean isBuildConsistent() {
|
||||
// Don't care on eng builds. Incremental build may trigger false negative.
|
||||
if ("eng".equals(TYPE)) return true;
|
||||
if (IS_ENG) return true;
|
||||
|
||||
final String system = SystemProperties.get("ro.build.fingerprint");
|
||||
final String vendor = SystemProperties.get("ro.vendor.build.fingerprint");
|
||||
@@ -882,6 +882,10 @@ public class Build {
|
||||
public static final boolean IS_DEBUGGABLE =
|
||||
SystemProperties.getInt("ro.debuggable", 0) == 1;
|
||||
|
||||
/** {@hide} */
|
||||
public static final boolean IS_ENG =
|
||||
"eng".equals(getString("ro.build.type"));
|
||||
|
||||
/**
|
||||
* Specifies whether the permissions needed by a legacy app should be
|
||||
* reviewed before any of its components can run. A legacy app is one
|
||||
|
||||
@@ -184,6 +184,11 @@ public class Process {
|
||||
*/
|
||||
public static final int LAST_SHARED_APPLICATION_GID = 59999;
|
||||
|
||||
/** {@hide} */
|
||||
public static final int FIRST_APPLICATION_CACHE_GID = 20000;
|
||||
/** {@hide} */
|
||||
public static final int LAST_APPLICATION_CACHE_GID = 29999;
|
||||
|
||||
/**
|
||||
* Standard priority of application threads.
|
||||
* Use with {@link #setThreadPriority(int)} and
|
||||
|
||||
@@ -214,6 +214,15 @@ public final class UserHandle implements Parcelable {
|
||||
return appId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cache GID for a given UID or appId.
|
||||
* @hide
|
||||
*/
|
||||
public static int getCacheAppGid(int id) {
|
||||
return Process.FIRST_APPLICATION_CACHE_GID + (id % PER_USER_RANGE)
|
||||
- Process.FIRST_APPLICATION_UID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a text representation of the uid, breaking out its individual
|
||||
* components -- user, app, isolated, etc.
|
||||
|
||||
Reference in New Issue
Block a user