summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2012-09-24 11:07:25 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-09-24 11:07:26 -0700
commit7451f15e7464fe8dd117b74c6dcff780785e0007 (patch)
tree1682eeedb67b07d3ed1d18d49c3dbfcff3ef3d35
parentb00df8e929f9ba865a95a7df3f949e6169332954 (diff)
parent556b09e184b891d9542092962ed248616810e054 (diff)
downloadframeworks_base-7451f15e7464fe8dd117b74c6dcff780785e0007.zip
frameworks_base-7451f15e7464fe8dd117b74c6dcff780785e0007.tar.gz
frameworks_base-7451f15e7464fe8dd117b74c6dcff780785e0007.tar.bz2
Merge "Fix issue #6926562: Ensure all multi-user cache files are managed correctly" into jb-mr1-dev
-rw-r--r--api/current.txt4
-rw-r--r--cmds/installd/commands.c29
-rw-r--r--core/java/android/content/Context.java24
3 files changed, 48 insertions, 9 deletions
diff --git a/api/current.txt b/api/current.txt
index 2b9bf65..77001a1 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -5440,8 +5440,8 @@ package android.content {
field public static final int MODE_ENABLE_WRITE_AHEAD_LOGGING = 8; // 0x8
field public static final int MODE_MULTI_PROCESS = 4; // 0x4
field public static final int MODE_PRIVATE = 0; // 0x0
- field public static final int MODE_WORLD_READABLE = 1; // 0x1
- field public static final int MODE_WORLD_WRITEABLE = 2; // 0x2
+ field public static final deprecated int MODE_WORLD_READABLE = 1; // 0x1
+ field public static final deprecated int MODE_WORLD_WRITEABLE = 2; // 0x2
field public static final java.lang.String NFC_SERVICE = "nfc";
field public static final java.lang.String NOTIFICATION_SERVICE = "notification";
field public static final java.lang.String NSD_SERVICE = "servicediscovery";
diff --git a/cmds/installd/commands.c b/cmds/installd/commands.c
index 2934261..a9945b7 100644
--- a/cmds/installd/commands.c
+++ b/cmds/installd/commands.c
@@ -338,13 +338,32 @@ int free_cache(int64_t free_size)
closedir(d);
}
- // Collect cache files on external storage (if it is mounted as part
+ // Collect cache files on external storage for all users (if it is mounted as part
// of the internal storage).
strcpy(tmpdir, android_media_dir.path);
- if (lookup_media_dir(tmpdir, "Android") == 0
- && lookup_media_dir(tmpdir, "data") == 0) {
- //ALOGI("adding cache files from %s\n", tmpdir);
- add_cache_files(cache, tmpdir, "cache");
+ dirpos = tmpdir + strlen(tmpdir);
+ d = opendir(tmpdir);
+ if (d != NULL) {
+ while ((de = readdir(d))) {
+ if (de->d_type == DT_DIR) {
+ const char *name = de->d_name;
+ /* skip any dir that doesn't start with a number, so not a user */
+ if (name[0] < '0' || name[0] > '9') {
+ continue;
+ }
+ if ((strlen(name)+(dirpos-tmpdir)) < (sizeof(tmpdir)-1)) {
+ strcpy(dirpos, name);
+ if (lookup_media_dir(tmpdir, "Android") == 0
+ && lookup_media_dir(tmpdir, "data") == 0) {
+ //ALOGI("adding cache files from %s\n", tmpdir);
+ add_cache_files(cache, tmpdir, "cache");
+ }
+ } else {
+ ALOGW("Path exceeds limit: %s%s", tmpdir, name);
+ }
+ }
+ }
+ closedir(d);
}
clear_cache_files(cache, free_size);
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 524962cb..9162d29 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -63,18 +63,34 @@ public abstract class Context {
*/
public static final int MODE_PRIVATE = 0x0000;
/**
+ * @deprecated Creating world-readable files is very dangerous, and likely
+ * to cause security holes in applications. It is strongly discouraged;
+ * instead, applications should use more formal mechanism for interactions
+ * such as {@link ContentProvider}, {@link BroadcastReceiver}, and
+ * {@link android.app.Service}. There are no guarantees that this
+ * access mode will remain on a file, such as when it goes through a
+ * backup and restore.
* File creation mode: allow all other applications to have read access
* to the created file.
* @see #MODE_PRIVATE
* @see #MODE_WORLD_WRITEABLE
*/
+ @Deprecated
public static final int MODE_WORLD_READABLE = 0x0001;
/**
+ * @deprecated Creating world-writable files is very dangerous, and likely
+ * to cause security holes in applications. It is strongly discouraged;
+ * instead, applications should use more formal mechanism for interactions
+ * such as {@link ContentProvider}, {@link BroadcastReceiver}, and
+ * {@link android.app.Service}. There are no guarantees that this
+ * access mode will remain on a file, such as when it goes through a
+ * backup and restore.
* File creation mode: allow all other applications to have write access
* to the created file.
* @see #MODE_PRIVATE
* @see #MODE_WORLD_READABLE
*/
+ @Deprecated
public static final int MODE_WORLD_WRITEABLE = 0x0002;
/**
* File creation mode: for use with {@link #openFileOutput}, if the file
@@ -645,8 +661,12 @@ public abstract class Context {
* are some important differences:
*
* <ul>
- * <li>The platform does not monitor the space available in external storage,
- * and thus will not automatically delete these files. Note that you should
+ * <li>The platform does not always monitor the space available in external
+ * storage, and thus may not automatically delete these files. Currently
+ * the only time files here will be deleted by the platform is when running
+ * on {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} or later and
+ * {@link android.os.Environment#isExternalStorageEmulated()
+ * Environment.isExternalStorageEmulated()} returns true. Note that you should
* be managing the maximum space you will use for these anyway, just like
* with {@link #getCacheDir()}.
* <li>External files are not always available: they will disappear if the