Java Code Examples for android.os.Environment#getUserSystemDirectory()

The following examples show how to use android.os.Environment#getUserSystemDirectory() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
public InputMethodFileManager(HashMap<String, InputMethodInfo> methodMap, int userId) {
    if (methodMap == null) {
        throw new NullPointerException("methodMap is null");
    }
    mMethodMap = methodMap;
    final File systemDir = userId == UserHandle.USER_OWNER
            ? new File(Environment.getDataDirectory(), SYSTEM_PATH)
            : Environment.getUserSystemDirectory(userId);
    final File inputMethodDir = new File(systemDir, INPUT_METHOD_PATH);
    if (!inputMethodDir.mkdirs()) {
        Slog.w(TAG, "Couldn't create dir.: " + inputMethodDir.getAbsolutePath());
    }
    final File subtypeFile = new File(inputMethodDir, ADDITIONAL_SUBTYPES_FILE_NAME);
    mAdditionalInputMethodSubtypeFile = new AtomicFile(subtypeFile);
    if (!subtypeFile.exists()) {
        // If "subtypes.xml" doesn't exist, create a blank file.
        writeAdditionalInputMethodSubtypes(
                mAdditionalSubtypesMap, mAdditionalInputMethodSubtypeFile, methodMap);
    } else {
        readAdditionalInputMethodSubtypes(
                mAdditionalSubtypesMap, mAdditionalInputMethodSubtypeFile);
    }
}
 
Example 2
static String dbNameForUser(final int userHandle) {
    // The owner gets the unadorned db name;
    if (userHandle == UserHandle.USER_SYSTEM) {
        return DATABASE_NAME;
    } else {
        // Place the database in the user-specific data tree so that it's
        // cleaned up automatically when the user is deleted.
        File databaseFile = new File(
                Environment.getUserSystemDirectory(userHandle), DATABASE_NAME);
        // If databaseFile doesn't exist, database can be kept in memory. It's safe because the
        // database will be migrated and disposed of immediately after onCreate finishes
        if (!databaseFile.exists()) {
            Log.i(TAG, "No previous database file exists - running in in-memory mode");
            return null;
        }
        return databaseFile.getPath();
    }
}
 
Example 3
public PersistentDataStore(Context context, int userId) {
    mContext = context;
    File userDir = Environment.getUserSystemDirectory(userId);
    if (!userDir.exists()) {
        if (!userDir.mkdirs()) {
            throw new IllegalStateException("User dir cannot be created: " + userDir);
        }
    }
    mAtomicFile = new AtomicFile(new File(userDir, "tv-input-manager-state.xml"), "tv-input-state");
}
 
Example 4
/**
 * Removes the app restrictions file for a specific package and user id, if it exists.
 */
private static void cleanAppRestrictionsForPackageLAr(String pkg, int userId) {
    File dir = Environment.getUserSystemDirectory(userId);
    File resFile = new File(dir, packageToRestrictionsFileName(pkg));
    if (resFile.exists()) {
        resFile.delete();
    }
}
 
Example 5
@GuardedBy("mAppRestrictionsLock")
private static Bundle readApplicationRestrictionsLAr(String packageName, int userId) {
    AtomicFile restrictionsFile =
            new AtomicFile(new File(Environment.getUserSystemDirectory(userId),
                    packageToRestrictionsFileName(packageName)));
    return readApplicationRestrictionsLAr(restrictionsFile);
}
 
Example 6
@GuardedBy("mAppRestrictionsLock")
private static void writeApplicationRestrictionsLAr(String packageName,
        Bundle restrictions, int userId) {
    AtomicFile restrictionsFile = new AtomicFile(
            new File(Environment.getUserSystemDirectory(userId),
                    packageToRestrictionsFileName(packageName)));
    writeApplicationRestrictionsLAr(restrictions, restrictionsFile);
}
 
Example 7
static String dbNameForUser(final int userHandle) {
    // The owner gets the unadorned db name;
    if (userHandle == UserHandle.USER_OWNER) {
        return DATABASE_NAME;
    } else {
        // Place the database in the user-specific data tree so that it's
        // cleaned up automatically when the user is deleted.
        File databaseFile = new File(
                Environment.getUserSystemDirectory(userHandle), DATABASE_NAME);
        return databaseFile.getPath();
    }
}
 
Example 8
private static File getFileForUser(int userId) {
    return new File(Environment.getUserSystemDirectory(userId), FINGERPRINT_FILE);
}
 
Example 9
private static File getWallpaperDir(int userId) {
    return Environment.getUserSystemDirectory(userId);
}
 
Example 10
@VisibleForTesting
protected File getUserSystemDirectory(int userId) {
    return Environment.getUserSystemDirectory(userId);
}
 
Example 11
private static @NonNull File getInstantApplicationsDir(int userId) {
    return new File(Environment.getUserSystemDirectory(userId),
            INSTANT_APPS_FOLDER);
}
 
Example 12
@VisibleForTesting
protected File getUserSystemDirectory(int userId) {
    return Environment.getUserSystemDirectory(userId);
}