android.os.storage.StorageManager#convert ( )源码实例Demo

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

源代码1 项目: AndroidComponentPlugin   文件: ApplicationInfo.java
@SuppressWarnings("unchecked")
private ApplicationInfo(Parcel source) {
    super(source);
    taskAffinity = source.readString();
    permission = source.readString();
    processName = source.readString();
    className = source.readString();
    theme = source.readInt();
    flags = source.readInt();
    privateFlags = source.readInt();
    requiresSmallestWidthDp = source.readInt();
    compatibleWidthLimitDp = source.readInt();
    largestWidthLimitDp = source.readInt();
    if (source.readInt() != 0) {
        storageUuid = new UUID(source.readLong(), source.readLong());
        volumeUuid = StorageManager.convert(storageUuid);
    }
    scanSourceDir = source.readString();
    scanPublicSourceDir = source.readString();
    sourceDir = source.readString();
    publicSourceDir = source.readString();
    splitNames = source.readStringArray();
    splitSourceDirs = source.readStringArray();
    splitPublicSourceDirs = source.readStringArray();
    splitDependencies = source.readSparseArray(null);
    nativeLibraryDir = source.readString();
    secondaryNativeLibraryDir = source.readString();
    nativeLibraryRootDir = source.readString();
    nativeLibraryRootRequiresIsa = source.readInt() != 0;
    primaryCpuAbi = source.readString();
    secondaryCpuAbi = source.readString();
    resourceDirs = source.readStringArray();
    seInfo = source.readString();
    seInfoUser = source.readString();
    sharedLibraryFiles = source.readStringArray();
    dataDir = source.readString();
    deviceProtectedDataDir = source.readString();
    credentialProtectedDataDir = source.readString();
    uid = source.readInt();
    minSdkVersion = source.readInt();
    targetSdkVersion = source.readInt();
    versionCode = source.readInt();
    enabled = source.readInt() != 0;
    enabledSetting = source.readInt();
    installLocation = source.readInt();
    manageSpaceActivityName = source.readString();
    backupAgentName = source.readString();
    descriptionRes = source.readInt();
    uiOptions = source.readInt();
    fullBackupContent = source.readInt();
    networkSecurityConfigRes = source.readInt();
    category = source.readInt();
    targetSandboxVersion = source.readInt();
}
 
源代码2 项目: AndroidComponentPlugin   文件: ApplicationInfo.java
@SuppressWarnings("unchecked")
private ApplicationInfo(Parcel source) {
    super(source);
    taskAffinity = source.readString();
    permission = source.readString();
    processName = source.readString();
    className = source.readString();
    theme = source.readInt();
    flags = source.readInt();
    privateFlags = source.readInt();
    requiresSmallestWidthDp = source.readInt();
    compatibleWidthLimitDp = source.readInt();
    largestWidthLimitDp = source.readInt();
    if (source.readInt() != 0) {
        storageUuid = new UUID(source.readLong(), source.readLong());
        volumeUuid = StorageManager.convert(storageUuid);
    }
    scanSourceDir = source.readString();
    scanPublicSourceDir = source.readString();
    sourceDir = source.readString();
    publicSourceDir = source.readString();
    splitNames = source.readStringArray();
    splitSourceDirs = source.readStringArray();
    splitPublicSourceDirs = source.readStringArray();
    splitDependencies = source.readSparseArray(null);
    nativeLibraryDir = source.readString();
    secondaryNativeLibraryDir = source.readString();
    nativeLibraryRootDir = source.readString();
    nativeLibraryRootRequiresIsa = source.readInt() != 0;
    primaryCpuAbi = source.readString();
    secondaryCpuAbi = source.readString();
    resourceDirs = source.readStringArray();
    seInfo = source.readString();
    seInfoUser = source.readString();
    sharedLibraryFiles = source.readStringArray();
    dataDir = source.readString();
    deviceProtectedDataDir = source.readString();
    credentialProtectedDataDir = source.readString();
    uid = source.readInt();
    minSdkVersion = source.readInt();
    targetSdkVersion = source.readInt();
    setVersionCode(source.readLong());
    enabled = source.readInt() != 0;
    enabledSetting = source.readInt();
    installLocation = source.readInt();
    manageSpaceActivityName = source.readString();
    backupAgentName = source.readString();
    descriptionRes = source.readInt();
    uiOptions = source.readInt();
    fullBackupContent = source.readInt();
    networkSecurityConfigRes = source.readInt();
    category = source.readInt();
    targetSandboxVersion = source.readInt();
    classLoaderName = source.readString();
    splitClassLoaderNames = source.readStringArray();
    compileSdkVersion = source.readInt();
    compileSdkVersionCodename = source.readString();
    appComponentFactory = source.readString();
    mHiddenApiPolicy = source.readInt();
}
 
源代码3 项目: AndroidComponentPlugin   文件: ApplicationInfo.java
@SuppressWarnings("unchecked")
private ApplicationInfo(Parcel source) {
    super(source);
    taskAffinity = source.readString();
    permission = source.readString();
    processName = source.readString();
    className = source.readString();
    theme = source.readInt();
    flags = source.readInt();
    privateFlags = source.readInt();
    requiresSmallestWidthDp = source.readInt();
    compatibleWidthLimitDp = source.readInt();
    largestWidthLimitDp = source.readInt();
    if (source.readInt() != 0) {
        storageUuid = new UUID(source.readLong(), source.readLong());
        volumeUuid = StorageManager.convert(storageUuid);
    }
    scanSourceDir = source.readString();
    scanPublicSourceDir = source.readString();
    sourceDir = source.readString();
    publicSourceDir = source.readString();
    splitNames = source.readStringArray();
    splitSourceDirs = source.readStringArray();
    splitPublicSourceDirs = source.readStringArray();
    splitDependencies = source.readSparseArray(null);
    nativeLibraryDir = source.readString();
    secondaryNativeLibraryDir = source.readString();
    nativeLibraryRootDir = source.readString();
    nativeLibraryRootRequiresIsa = source.readInt() != 0;
    primaryCpuAbi = source.readString();
    secondaryCpuAbi = source.readString();
    resourceDirs = source.readStringArray();
    seInfo = source.readString();
    seInfoUser = source.readString();
    sharedLibraryFiles = source.readStringArray();
    dataDir = source.readString();
    deviceProtectedDataDir = source.readString();
    credentialProtectedDataDir = source.readString();
    uid = source.readInt();
    minSdkVersion = source.readInt();
    targetSdkVersion = source.readInt();
    versionCode = source.readInt();
    enabled = source.readInt() != 0;
    enabledSetting = source.readInt();
    installLocation = source.readInt();
    manageSpaceActivityName = source.readString();
    backupAgentName = source.readString();
    descriptionRes = source.readInt();
    uiOptions = source.readInt();
    fullBackupContent = source.readInt();
    networkSecurityConfigRes = source.readInt();
    category = source.readInt();
    targetSandboxVersion = source.readInt();
    classLoaderName = source.readString();
    splitClassLoaderNames = source.readStringArray();
}
 
源代码4 项目: AndroidComponentPlugin   文件: ApplicationInfo.java
@SuppressWarnings("unchecked")
private ApplicationInfo(Parcel source) {
    super(source);
    taskAffinity = source.readString();
    permission = source.readString();
    processName = source.readString();
    className = source.readString();
    theme = source.readInt();
    flags = source.readInt();
    privateFlags = source.readInt();
    requiresSmallestWidthDp = source.readInt();
    compatibleWidthLimitDp = source.readInt();
    largestWidthLimitDp = source.readInt();
    if (source.readInt() != 0) {
        storageUuid = new UUID(source.readLong(), source.readLong());
        volumeUuid = StorageManager.convert(storageUuid);
    }
    scanSourceDir = source.readString();
    scanPublicSourceDir = source.readString();
    sourceDir = source.readString();
    publicSourceDir = source.readString();
    splitNames = source.readStringArray();
    splitSourceDirs = source.readStringArray();
    splitPublicSourceDirs = source.readStringArray();
    splitDependencies = source.readSparseArray(null);
    nativeLibraryDir = source.readString();
    secondaryNativeLibraryDir = source.readString();
    nativeLibraryRootDir = source.readString();
    nativeLibraryRootRequiresIsa = source.readInt() != 0;
    primaryCpuAbi = source.readString();
    secondaryCpuAbi = source.readString();
    resourceDirs = source.readStringArray();
    seInfo = source.readString();
    seInfoUser = source.readString();
    sharedLibraryFiles = source.readStringArray();
    sharedLibraryInfos = source.createTypedArrayList(SharedLibraryInfo.CREATOR);
    dataDir = source.readString();
    deviceProtectedDataDir = source.readString();
    credentialProtectedDataDir = source.readString();
    uid = source.readInt();
    minSdkVersion = source.readInt();
    targetSdkVersion = source.readInt();
    setVersionCode(source.readLong());
    enabled = source.readInt() != 0;
    enabledSetting = source.readInt();
    installLocation = source.readInt();
    manageSpaceActivityName = source.readString();
    backupAgentName = source.readString();
    descriptionRes = source.readInt();
    uiOptions = source.readInt();
    fullBackupContent = source.readInt();
    networkSecurityConfigRes = source.readInt();
    category = source.readInt();
    targetSandboxVersion = source.readInt();
    classLoaderName = source.readString();
    splitClassLoaderNames = source.readStringArray();
    compileSdkVersion = source.readInt();
    compileSdkVersionCodename = source.readString();
    appComponentFactory = source.readString();
    iconRes = source.readInt();
    roundIconRes = source.readInt();
    mHiddenApiPolicy = source.readInt();
    hiddenUntilInstalled = source.readInt() != 0;
    zygotePreloadName = source.readString();
}
 
/**
 * Core logic that checks the storage state of every mounted private volume.
 * Since this can do heavy I/O, callers should invoke indirectly using
 * {@link #MSG_CHECK}.
 */
@WorkerThread
private void check() {
    final StorageManager storage = getContext().getSystemService(StorageManager.class);
    final int seq = mSeq.get();

    // Check every mounted private volume to see if they're low on space
    for (VolumeInfo vol : storage.getWritablePrivateVolumes()) {
        final File file = vol.getPath();
        final long fullBytes = storage.getStorageFullBytes(file);
        final long lowBytes = storage.getStorageLowBytes(file);

        // Automatically trim cached data when nearing the low threshold;
        // when it's within 150% of the threshold, we try trimming usage
        // back to 200% of the threshold.
        if (file.getUsableSpace() < (lowBytes * 3) / 2) {
            final PackageManagerService pms = (PackageManagerService) ServiceManager
                    .getService("package");
            try {
                pms.freeStorage(vol.getFsUuid(), lowBytes * 2, 0);
            } catch (IOException e) {
                Slog.w(TAG, e);
            }
        }

        // Send relevant broadcasts and show notifications based on any
        // recently noticed state transitions.
        final UUID uuid = StorageManager.convert(vol.getFsUuid());
        final State state = findOrCreateState(uuid);
        final long totalBytes = file.getTotalSpace();
        final long usableBytes = file.getUsableSpace();

        int oldLevel = state.level;
        int newLevel;
        if (mForceLevel != State.LEVEL_UNKNOWN) {
            // When in testing mode, use unknown old level to force sending
            // of any relevant broadcasts.
            oldLevel = State.LEVEL_UNKNOWN;
            newLevel = mForceLevel;
        } else if (usableBytes <= fullBytes) {
            newLevel = State.LEVEL_FULL;
        } else if (usableBytes <= lowBytes) {
            newLevel = State.LEVEL_LOW;
        } else if (StorageManager.UUID_DEFAULT.equals(uuid) && !isBootImageOnDisk()
                && usableBytes < BOOT_IMAGE_STORAGE_REQUIREMENT) {
            newLevel = State.LEVEL_LOW;
        } else {
            newLevel = State.LEVEL_NORMAL;
        }

        // Log whenever we notice drastic storage changes
        if ((Math.abs(state.lastUsableBytes - usableBytes) > DEFAULT_LOG_DELTA_BYTES)
                || oldLevel != newLevel) {
            EventLogTags.writeStorageState(uuid.toString(), oldLevel, newLevel,
                    usableBytes, totalBytes);
            state.lastUsableBytes = usableBytes;
        }

        updateNotifications(vol, oldLevel, newLevel);
        updateBroadcasts(vol, oldLevel, newLevel, seq);

        state.level = newLevel;
    }

    // Loop around to check again in future; we don't remove messages since
    // there might be an immediate request pending.
    if (!mHandler.hasMessages(MSG_CHECK)) {
        mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_CHECK),
                DEFAULT_CHECK_INTERVAL);
    }
}
 
private void updateNotifications(VolumeInfo vol, int oldLevel, int newLevel) {
    final Context context = getContext();
    final UUID uuid = StorageManager.convert(vol.getFsUuid());

    if (State.isEntering(State.LEVEL_LOW, oldLevel, newLevel)) {
        Intent lowMemIntent = new Intent(StorageManager.ACTION_MANAGE_STORAGE);
        lowMemIntent.putExtra(StorageManager.EXTRA_UUID, uuid);
        lowMemIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        final CharSequence title = context.getText(
                com.android.internal.R.string.low_internal_storage_view_title);

        final CharSequence details;
        if (StorageManager.UUID_DEFAULT.equals(uuid)) {
            details = context.getText(isBootImageOnDisk()
                    ? com.android.internal.R.string.low_internal_storage_view_text
                    : com.android.internal.R.string.low_internal_storage_view_text_no_boot);
        } else {
            details = context.getText(
                    com.android.internal.R.string.low_internal_storage_view_text);
        }

        PendingIntent intent = PendingIntent.getActivityAsUser(context, 0, lowMemIntent, 0,
                null, UserHandle.CURRENT);
        Notification notification =
                new Notification.Builder(context, SystemNotificationChannels.ALERTS)
                        .setSmallIcon(com.android.internal.R.drawable.stat_notify_disk_full)
                        .setTicker(title)
                        .setColor(context.getColor(
                            com.android.internal.R.color.system_notification_accent_color))
                        .setContentTitle(title)
                        .setContentText(details)
                        .setContentIntent(intent)
                        .setStyle(new Notification.BigTextStyle()
                              .bigText(details))
                        .setVisibility(Notification.VISIBILITY_PUBLIC)
                        .setCategory(Notification.CATEGORY_SYSTEM)
                        .extend(new Notification.TvExtender()
                                .setChannelId(TV_NOTIFICATION_CHANNEL_ID))
                        .build();
        notification.flags |= Notification.FLAG_NO_CLEAR;
        mNotifManager.notifyAsUser(uuid.toString(), SystemMessage.NOTE_LOW_STORAGE,
                notification, UserHandle.ALL);
    } else if (State.isLeaving(State.LEVEL_LOW, oldLevel, newLevel)) {
        mNotifManager.cancelAsUser(uuid.toString(), SystemMessage.NOTE_LOW_STORAGE,
                UserHandle.ALL);
    }
}
 
源代码7 项目: android_9.0.0_r45   文件: ApplicationInfo.java
@SuppressWarnings("unchecked")
private ApplicationInfo(Parcel source) {
    super(source);
    taskAffinity = source.readString();
    permission = source.readString();
    processName = source.readString();
    className = source.readString();
    theme = source.readInt();
    flags = source.readInt();
    privateFlags = source.readInt();
    requiresSmallestWidthDp = source.readInt();
    compatibleWidthLimitDp = source.readInt();
    largestWidthLimitDp = source.readInt();
    if (source.readInt() != 0) {
        storageUuid = new UUID(source.readLong(), source.readLong());
        volumeUuid = StorageManager.convert(storageUuid);
    }
    scanSourceDir = source.readString();
    scanPublicSourceDir = source.readString();
    sourceDir = source.readString();
    publicSourceDir = source.readString();
    splitNames = source.readStringArray();
    splitSourceDirs = source.readStringArray();
    splitPublicSourceDirs = source.readStringArray();
    splitDependencies = source.readSparseArray(null);
    nativeLibraryDir = source.readString();
    secondaryNativeLibraryDir = source.readString();
    nativeLibraryRootDir = source.readString();
    nativeLibraryRootRequiresIsa = source.readInt() != 0;
    primaryCpuAbi = source.readString();
    secondaryCpuAbi = source.readString();
    resourceDirs = source.readStringArray();
    seInfo = source.readString();
    seInfoUser = source.readString();
    sharedLibraryFiles = source.readStringArray();
    dataDir = source.readString();
    deviceProtectedDataDir = source.readString();
    credentialProtectedDataDir = source.readString();
    uid = source.readInt();
    minSdkVersion = source.readInt();
    targetSdkVersion = source.readInt();
    setVersionCode(source.readLong());
    enabled = source.readInt() != 0;
    enabledSetting = source.readInt();
    installLocation = source.readInt();
    manageSpaceActivityName = source.readString();
    backupAgentName = source.readString();
    descriptionRes = source.readInt();
    uiOptions = source.readInt();
    fullBackupContent = source.readInt();
    networkSecurityConfigRes = source.readInt();
    category = source.readInt();
    targetSandboxVersion = source.readInt();
    classLoaderName = source.readString();
    splitClassLoaderNames = source.readStringArray();
    compileSdkVersion = source.readInt();
    compileSdkVersionCodename = source.readString();
    appComponentFactory = source.readString();
    mHiddenApiPolicy = source.readInt();
    hiddenUntilInstalled = source.readInt() != 0;
}