android.os.Environment#getUserSystemDirectory ( )源码实例Demo

下面列出了android.os.Environment#getUserSystemDirectory ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

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);
    }
}
 
源代码2 项目: Study_Android_Demo   文件: DatabaseHelper.java
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();
    }
}
 
源代码3 项目: android_9.0.0_r45   文件: PersistentDataStore.java
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");
}
 
源代码4 项目: android_9.0.0_r45   文件: UserManagerService.java
/**
 * 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();
    }
}
 
源代码5 项目: android_9.0.0_r45   文件: UserManagerService.java
@GuardedBy("mAppRestrictionsLock")
private static Bundle readApplicationRestrictionsLAr(String packageName, int userId) {
    AtomicFile restrictionsFile =
            new AtomicFile(new File(Environment.getUserSystemDirectory(userId),
                    packageToRestrictionsFileName(packageName)));
    return readApplicationRestrictionsLAr(restrictionsFile);
}
 
源代码6 项目: android_9.0.0_r45   文件: UserManagerService.java
@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);
}
 
源代码7 项目: Study_Android_Demo   文件: DatabaseHelper.java
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();
    }
}
 
源代码8 项目: android_9.0.0_r45   文件: FingerprintsUserState.java
private static File getFileForUser(int userId) {
    return new File(Environment.getUserSystemDirectory(userId), FINGERPRINT_FILE);
}
 
private static File getWallpaperDir(int userId) {
    return Environment.getUserSystemDirectory(userId);
}
 
源代码10 项目: android_9.0.0_r45   文件: UserDataPreparer.java
@VisibleForTesting
protected File getUserSystemDirectory(int userId) {
    return Environment.getUserSystemDirectory(userId);
}
 
源代码11 项目: android_9.0.0_r45   文件: InstantAppRegistry.java
private static @NonNull File getInstantApplicationsDir(int userId) {
    return new File(Environment.getUserSystemDirectory(userId),
            INSTANT_APPS_FOLDER);
}
 
@VisibleForTesting
protected File getUserSystemDirectory(int userId) {
    return Environment.getUserSystemDirectory(userId);
}