Merge "Remove unused symbols for a11y."
diff --git a/api/current.txt b/api/current.txt
index 54f2290..a0b2d4a 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -9791,6 +9791,7 @@
field public int theme;
field public int uiOptions;
field public int uid;
+ field public java.lang.String volumeUuid;
}
public static class ApplicationInfo.DisplayNameComparator implements java.util.Comparator {
diff --git a/api/system-current.txt b/api/system-current.txt
index 0e7f818..c6a8a0e 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -10210,6 +10210,7 @@
field public int theme;
field public int uiOptions;
field public int uid;
+ field public java.lang.String volumeUuid;
}
public static class ApplicationInfo.DisplayNameComparator implements java.util.Comparator {
diff --git a/api/test-current.txt b/api/test-current.txt
index e5cd68a..f55ed10 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -9819,6 +9819,7 @@
field public int theme;
field public int uiOptions;
field public int uid;
+ field public java.lang.String volumeUuid;
}
public static class ApplicationInfo.DisplayNameComparator implements java.util.Comparator {
diff --git a/core/java/android/app/usage/StorageStatsManager.java b/core/java/android/app/usage/StorageStatsManager.java
index 695994b..9d30771 100644
--- a/core/java/android/app/usage/StorageStatsManager.java
+++ b/core/java/android/app/usage/StorageStatsManager.java
@@ -18,6 +18,7 @@
import android.annotation.WorkerThread;
import android.content.Context;
+import android.content.pm.ApplicationInfo;
import android.os.RemoteException;
import android.os.UserHandle;
@@ -99,6 +100,8 @@
* @param volumeUuid the UUID of the storage volume you're interested in, or
* {@code null} to specify the default internal storage.
* @param uid the UID you're interested in.
+ * @see ApplicationInfo#volumeUuid
+ * @see ApplicationInfo#uid
*/
@WorkerThread
public StorageStats queryStatsForUid(String volumeUuid, int uid) {
diff --git a/core/java/android/content/pm/ApplicationInfo.java b/core/java/android/content/pm/ApplicationInfo.java
index 3d9ba96..ec74617 100644
--- a/core/java/android/content/pm/ApplicationInfo.java
+++ b/core/java/android/content/pm/ApplicationInfo.java
@@ -596,8 +596,13 @@
*/
public int largestWidthLimitDp = 0;
- /** {@hide} */
+ /**
+ * UUID of the storage volume on which this application is being hosted. For
+ * apps hosted on the default internal storage at
+ * {@link Environment#getDataDirectory()}, the UUID value is {@code null}.
+ */
public String volumeUuid;
+
/** {@hide} */
public String scanSourceDir;
/** {@hide} */
diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java
index d6688e3..a41f45b 100644
--- a/core/java/android/os/Process.java
+++ b/core/java/android/os/Process.java
@@ -189,6 +189,13 @@
/** {@hide} */
public static final int LAST_APPLICATION_CACHE_GID = 29999;
+ /** {@hide} */
+ public static final int MEDIA_AUDIO_GID = 1055;
+ /** {@hide} */
+ public static final int MEDIA_VIDEO_GID = 1056;
+ /** {@hide} */
+ public static final int MEDIA_IMAGE_GID = 1057;
+
/**
* Standard priority of application threads.
* Use with {@link #setThreadPriority(int)} and
diff --git a/core/java/android/os/StrictMode.java b/core/java/android/os/StrictMode.java
index ae981b7..b9e4bad 100644
--- a/core/java/android/os/StrictMode.java
+++ b/core/java/android/os/StrictMode.java
@@ -40,6 +40,7 @@
import dalvik.system.BlockGuard;
import dalvik.system.CloseGuard;
import dalvik.system.VMDebug;
+import dalvik.system.VMRuntime;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -423,7 +424,21 @@
* disk operations but will likely expand in future releases.
*/
public Builder detectAll() {
- return enable(ALL_THREAD_DETECT_BITS);
+ detectDiskReads();
+ detectDiskWrites();
+ detectNetwork();
+
+ final int targetSdk = VMRuntime.getRuntime().getTargetSdkVersion();
+ if (targetSdk >= Build.VERSION_CODES.HONEYCOMB) {
+ detectCustomSlowCalls();
+ }
+ if (targetSdk >= Build.VERSION_CODES.M) {
+ detectResourceMismatches();
+ }
+ if (targetSdk >= Build.VERSION_CODES.O) {
+ detectUnbufferedIo();
+ }
+ return this;
}
/**
@@ -722,18 +737,31 @@
* but will likely expand in future releases.
*/
public Builder detectAll() {
- int flags = DETECT_VM_ACTIVITY_LEAKS | DETECT_VM_CURSOR_LEAKS
- | DETECT_VM_CLOSABLE_LEAKS | DETECT_VM_REGISTRATION_LEAKS
- | DETECT_VM_FILE_URI_EXPOSURE | DETECT_VM_CONTENT_URI_WITHOUT_PERMISSION
- | DETECT_VM_UNTAGGED_SOCKET;
+ detectLeakedSqlLiteObjects();
- // TODO: always add DETECT_VM_CLEARTEXT_NETWORK once we have facility
- // for apps to mark sockets that should be ignored
- if (SystemProperties.getBoolean(CLEARTEXT_PROPERTY, false)) {
- flags |= DETECT_VM_CLEARTEXT_NETWORK;
+ final int targetSdk = VMRuntime.getRuntime().getTargetSdkVersion();
+ if (targetSdk >= Build.VERSION_CODES.HONEYCOMB) {
+ detectActivityLeaks();
+ detectLeakedClosableObjects();
}
-
- return enable(flags);
+ if (targetSdk >= Build.VERSION_CODES.JELLY_BEAN) {
+ detectLeakedRegistrationObjects();
+ }
+ if (targetSdk >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
+ detectFileUriExposure();
+ }
+ if (targetSdk >= Build.VERSION_CODES.M) {
+ // TODO: always add DETECT_VM_CLEARTEXT_NETWORK once we have
+ // facility for apps to mark sockets that should be ignored
+ if (SystemProperties.getBoolean(CLEARTEXT_PROPERTY, false)) {
+ detectCleartextNetwork();
+ }
+ }
+ if (targetSdk >= Build.VERSION_CODES.O) {
+ detectContentUriWithoutPermission();
+ detectUntaggedSockets();
+ }
+ return this;
}
/**
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index c5c380c..388054d 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -66,6 +66,8 @@
private final IUserManager mService;
private final Context mContext;
+ private Boolean mIsManagedProfileCached;
+
/**
* @hide
* No user restriction.
@@ -970,8 +972,14 @@
*/
@SystemApi
public boolean isManagedProfile() {
+ // No need for synchronization. Once it becomes non-null, it'll be non-null forever.
+ // Worst case we might end up calling the AIDL method multiple times but that's fine.
+ if (mIsManagedProfileCached != null) {
+ return mIsManagedProfileCached;
+ }
try {
- return mService.isManagedProfile(UserHandle.myUserId());
+ mIsManagedProfileCached = mService.isManagedProfile(UserHandle.myUserId());
+ return mIsManagedProfileCached;
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
@@ -987,6 +995,9 @@
*/
@SystemApi
public boolean isManagedProfile(@UserIdInt int userId) {
+ if (userId == UserHandle.myUserId()) {
+ return isManagedProfile();
+ }
try {
return mService.isManagedProfile(userId);
} catch (RemoteException re) {
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index ae53980..f1bffd3 100755
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -10139,6 +10139,12 @@
* @hide
*/
public static final String WARNING_TEMPERATURE = "warning_temperature";
+
+ /**
+ * Whether the diskstats logging task is enabled/disabled.
+ * @hide
+ */
+ public static final String ENABLE_DISKSTATS_LOGGING = "enable_diskstats_logging";
}
/**
diff --git a/packages/SettingsLib/src/com/android/settingslib/HelpUtils.java b/packages/SettingsLib/src/com/android/settingslib/HelpUtils.java
index b037a3da..fc697ce 100644
--- a/packages/SettingsLib/src/com/android/settingslib/HelpUtils.java
+++ b/packages/SettingsLib/src/com/android/settingslib/HelpUtils.java
@@ -198,7 +198,7 @@
intent.putExtra(feedbackIntentExtraKey, packageNameKey);
intent.putExtra(feedbackIntentNameKey, packageNameValue);
}
- intent.putExtra(EXTRA_THEME, 1 /* Light, dark action bar */);
+ intent.putExtra(EXTRA_THEME, 0 /* Light theme */);
TypedArray array = context.obtainStyledAttributes(new int[]{android.R.attr.colorPrimary});
intent.putExtra(EXTRA_PRIMARY_COLOR, array.getColor(0, 0));
array.recycle();
diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java
index c07add0..629da86 100644
--- a/services/core/java/com/android/server/StorageManagerService.java
+++ b/services/core/java/com/android/server/StorageManagerService.java
@@ -108,6 +108,8 @@
import com.android.server.NativeDaemonConnector.SensitiveArg;
import com.android.server.pm.PackageManagerService;
import com.android.server.storage.AppFuseBridge;
+import com.android.server.storage.FileCollector;
+
import libcore.io.IoUtils;
import libcore.util.EmptyArray;
@@ -817,6 +819,9 @@
}
private void handleSystemReady() {
+ // Register kernel mapping from extensions to statistics GIDs
+ FileCollector.updateKernelExtensions();
+
initIfReadyAndConnected();
resetIfReadyAndConnected();
diff --git a/services/core/java/com/android/server/storage/DiskStatsLoggingService.java b/services/core/java/com/android/server/storage/DiskStatsLoggingService.java
index 0a3abf3..7c43162 100644
--- a/services/core/java/com/android/server/storage/DiskStatsLoggingService.java
+++ b/services/core/java/com/android/server/storage/DiskStatsLoggingService.java
@@ -21,6 +21,7 @@
import android.app.job.JobScheduler;
import android.app.job.JobService;
import android.content.ComponentName;
+import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.PackageStats;
import android.os.AsyncTask;
@@ -28,6 +29,7 @@
import android.os.Environment;
import android.os.Environment.UserEnvironment;
import android.os.UserHandle;
+import android.provider.Settings;
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
@@ -54,7 +56,7 @@
public boolean onStartJob(JobParameters params) {
// We need to check the preconditions again because they may not be enforced for
// subsequent runs.
- if (!isCharging(this)) {
+ if (!isCharging(this) || !isDumpsysTaskEnabled(getContentResolver())) {
jobFinished(params, true);
return false;
}
@@ -105,6 +107,12 @@
}
@VisibleForTesting
+ static boolean isDumpsysTaskEnabled(ContentResolver resolver) {
+ // The default is to treat the task as enabled.
+ return Settings.Global.getInt(resolver, Settings.Global.ENABLE_DISKSTATS_LOGGING, 1) != 0;
+ }
+
+ @VisibleForTesting
static class LogRunnable implements Runnable {
private static final long TIMEOUT_MILLIS = TimeUnit.MINUTES.toMillis(10);
diff --git a/services/core/java/com/android/server/storage/FileCollector.java b/services/core/java/com/android/server/storage/FileCollector.java
index 90f9f139..59cfaf7 100644
--- a/services/core/java/com/android/server/storage/FileCollector.java
+++ b/services/core/java/com/android/server/storage/FileCollector.java
@@ -26,7 +26,6 @@
import java.io.File;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
-import java.util.Map;
/**
* FileCollector walks over a directory and categorizes storage usage by their type.
@@ -44,8 +43,9 @@
AUDIO })
private @interface FileTypes {}
-
- private static final Map<String, Integer> EXTENSION_MAP = new ArrayMap<String, Integer>();
+ // NOTE: If you update these extensions, you'll also want to update
+ // matchgen.py over in installd which is used for non-quota stats.
+ private static final ArrayMap<String, Integer> EXTENSION_MAP = new ArrayMap<>();
static {
// Audio
EXTENSION_MAP.put("aac", AUDIO);
@@ -144,6 +144,36 @@
EXTENSION_MAP.put("xwd", IMAGES);
}
+ private static File mkdir(File parent, String name) {
+ final File file = new File(parent, name);
+ file.mkdir();
+ return file;
+ }
+
+ /**
+ * Update the mapping used by sdcardfs to map from file extensions to GIDs
+ * used for statistics purposes.
+ */
+ public static void updateKernelExtensions() {
+ final File root = new File("/config/sdcardfs/extensions/");
+ if (!root.exists()) return;
+
+ final File audio = mkdir(root, Integer.toString(android.os.Process.MEDIA_AUDIO_GID));
+ final File video = mkdir(root, Integer.toString(android.os.Process.MEDIA_VIDEO_GID));
+ final File image = mkdir(root, Integer.toString(android.os.Process.MEDIA_IMAGE_GID));
+
+ for (int i = 0; i < EXTENSION_MAP.size(); i++) {
+ final String ext = EXTENSION_MAP.keyAt(i);
+ final int type = EXTENSION_MAP.valueAt(i);
+
+ switch (type) {
+ case AUDIO: mkdir(audio, ext); break;
+ case VIDEO: mkdir(video, ext); break;
+ case IMAGES: mkdir(image, ext); break;
+ }
+ }
+ }
+
/**
* Returns the file categorization measurement result.
* @param path Directory to collect and categorize storage in.