diff options
| author | 2013-04-19 13:35:37 -0700 | |
|---|---|---|
| committer | 2013-04-19 13:35:37 -0700 | |
| commit | 1b50e4ead5463f4dcc03f9c5ed64963af0d4d9eb (patch) | |
| tree | d893b8a48358ff1a556bc91ef5727dc65f1fe551 | |
| parent | 7b2ad857a8a88c0688224d7236ba171f11cda586 (diff) | |
| parent | ca2a6374aadb95ca3f151d4bc2fdd3127f04e5e7 (diff) | |
am ca2a6374: Merge "Environment should only warn when asked." into jb-mr2-dev
* commit 'ca2a6374aadb95ca3f151d4bc2fdd3127f04e5e7':
Environment should only warn when asked.
| -rw-r--r-- | core/java/android/os/Environment.java | 31 | ||||
| -rw-r--r-- | services/java/com/android/server/SystemServer.java | 3 |
2 files changed, 22 insertions, 12 deletions
diff --git a/core/java/android/os/Environment.java b/core/java/android/os/Environment.java index d9846ecb2b21..61eef1f16997 100644 --- a/core/java/android/os/Environment.java +++ b/core/java/android/os/Environment.java @@ -51,6 +51,7 @@ public class Environment { private static final String SYSTEM_PROPERTY_EFS_ENABLED = "persist.security.efs.enabled"; private static UserEnvironment sCurrentUser; + private static boolean sUserRequired; private static final Object sLock = new Object(); @@ -223,7 +224,7 @@ public class Environment { * @hide */ public static File getMediaStorageDirectory() { - throwIfSystem(); + throwIfUserRequired(); return sCurrentUser.getMediaStorageDirectory(); } @@ -318,7 +319,7 @@ public class Environment { * @see #isExternalStorageRemovable() */ public static File getExternalStorageDirectory() { - throwIfSystem(); + throwIfUserRequired(); return sCurrentUser.getExternalStorageDirectory(); } @@ -465,7 +466,7 @@ public class Environment { * using it such as with {@link File#mkdirs File.mkdirs()}. */ public static File getExternalStoragePublicDirectory(String type) { - throwIfSystem(); + throwIfUserRequired(); return sCurrentUser.getExternalStoragePublicDirectory(type); } @@ -474,7 +475,7 @@ public class Environment { * @hide */ public static File getExternalStorageAndroidDataDir() { - throwIfSystem(); + throwIfUserRequired(); return sCurrentUser.getExternalStorageAndroidDataDir(); } @@ -483,7 +484,7 @@ public class Environment { * @hide */ public static File getExternalStorageAppDataDirectory(String packageName) { - throwIfSystem(); + throwIfUserRequired(); return sCurrentUser.getExternalStorageAppDataDirectory(packageName); } @@ -492,7 +493,7 @@ public class Environment { * @hide */ public static File getExternalStorageAppMediaDirectory(String packageName) { - throwIfSystem(); + throwIfUserRequired(); return sCurrentUser.getExternalStorageAppMediaDirectory(packageName); } @@ -501,7 +502,7 @@ public class Environment { * @hide */ public static File getExternalStorageAppObbDirectory(String packageName) { - throwIfSystem(); + throwIfUserRequired(); return sCurrentUser.getExternalStorageAppObbDirectory(packageName); } @@ -510,7 +511,7 @@ public class Environment { * @hide */ public static File getExternalStorageAppFilesDirectory(String packageName) { - throwIfSystem(); + throwIfUserRequired(); return sCurrentUser.getExternalStorageAppFilesDirectory(packageName); } @@ -519,7 +520,7 @@ public class Environment { * @hide */ public static File getExternalStorageAppCacheDirectory(String packageName) { - throwIfSystem(); + throwIfUserRequired(); return sCurrentUser.getExternalStorageAppCacheDirectory(packageName); } @@ -650,9 +651,15 @@ public class Environment { } } - private static void throwIfSystem() { - if (Process.myUid() == Process.SYSTEM_UID) { - Log.wtf(TAG, "Static storage paths aren't available from AID_SYSTEM", new Throwable()); + /** {@hide} */ + public static void setUserRequired(boolean userRequired) { + sUserRequired = userRequired; + } + + private static void throwIfUserRequired() { + if (sUserRequired) { + Log.wtf(TAG, "Path requests must specify a user by using UserEnvironment", + new Throwable()); } } diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index a30fc3b323f8..681c21da57f1 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -26,6 +26,7 @@ import android.content.pm.IPackageManager; import android.content.res.Configuration; import android.media.AudioService; import android.net.wifi.p2p.WifiP2pService; +import android.os.Environment; import android.os.Handler; import android.os.HandlerThread; import android.os.Looper; @@ -1055,6 +1056,8 @@ public class SystemServer { // as efficient as possible with its memory usage. VMRuntime.getRuntime().setTargetHeapUtilization(0.8f); + Environment.setUserRequired(true); + System.loadLibrary("android_servers"); init1(args); } |