Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 94e602d7 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android Git Automerger
Browse files

am 1b50e4ea: am ca2a6374: Merge "Environment should only warn when asked." into jb-mr2-dev

* commit '1b50e4ea':
  Environment should only warn when asked.
parents 6168317f 1b50e4ea
Loading
Loading
Loading
Loading
+19 −12
Original line number Diff line number Diff line
@@ -52,6 +52,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();

@@ -228,7 +229,7 @@ public class Environment {
     * @hide
     */
    public static File getMediaStorageDirectory() {
        throwIfSystem();
        throwIfUserRequired();
        return sCurrentUser.getMediaStorageDirectory();
    }

@@ -323,7 +324,7 @@ public class Environment {
     * @see #isExternalStorageRemovable()
     */
    public static File getExternalStorageDirectory() {
        throwIfSystem();
        throwIfUserRequired();
        return sCurrentUser.getExternalStorageDirectory();
    }

@@ -470,7 +471,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);
    }

@@ -479,7 +480,7 @@ public class Environment {
     * @hide
     */
    public static File getExternalStorageAndroidDataDir() {
        throwIfSystem();
        throwIfUserRequired();
        return sCurrentUser.getExternalStorageAndroidDataDir();
    }
    
@@ -488,7 +489,7 @@ public class Environment {
     * @hide
     */
    public static File getExternalStorageAppDataDirectory(String packageName) {
        throwIfSystem();
        throwIfUserRequired();
        return sCurrentUser.getExternalStorageAppDataDirectory(packageName);
    }
    
@@ -497,7 +498,7 @@ public class Environment {
     * @hide
     */
    public static File getExternalStorageAppMediaDirectory(String packageName) {
        throwIfSystem();
        throwIfUserRequired();
        return sCurrentUser.getExternalStorageAppMediaDirectory(packageName);
    }
    
@@ -506,7 +507,7 @@ public class Environment {
     * @hide
     */
    public static File getExternalStorageAppObbDirectory(String packageName) {
        throwIfSystem();
        throwIfUserRequired();
        return sCurrentUser.getExternalStorageAppObbDirectory(packageName);
    }
    
@@ -515,7 +516,7 @@ public class Environment {
     * @hide
     */
    public static File getExternalStorageAppFilesDirectory(String packageName) {
        throwIfSystem();
        throwIfUserRequired();
        return sCurrentUser.getExternalStorageAppFilesDirectory(packageName);
    }

@@ -524,7 +525,7 @@ public class Environment {
     * @hide
     */
    public static File getExternalStorageAppCacheDirectory(String packageName) {
        throwIfSystem();
        throwIfUserRequired();
        return sCurrentUser.getExternalStorageAppCacheDirectory(packageName);
    }
    
@@ -655,9 +656,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());
        }
    }

+3 −0
Original line number Diff line number Diff line
@@ -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;
@@ -1113,6 +1114,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);
    }