Add support for user profiles to the Storage Settings.

This adds new preferences for each profile (such as the work
profile) and defines a new view for viewing the storage
breakdown for the individual profile. The functionality closely
mimics the presentation on the main view, but without the system-wide
breakdown and without any additional users/profiles.

Bug: 34715777
Test: Settings Robotests

Change-Id: I19d449b648c6566331fd02e45c2e45f8c74ea7e7
This commit is contained in:
Daniel Nishi
2017-02-15 15:25:48 -08:00
parent 182e6ce2c7
commit 9f60f42a94
15 changed files with 553 additions and 62 deletions

View File

@@ -65,6 +65,7 @@ import android.os.ServiceManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.os.storage.StorageManager;
import android.os.storage.VolumeInfo;
import android.preference.PreferenceFrameLayout;
import android.provider.ContactsContract.CommonDataKinds;
import android.provider.ContactsContract.Contacts;
@@ -1258,4 +1259,21 @@ public final class Utils extends com.android.settingslib.Utils {
(user.profileGroupId != UserInfo.NO_PROFILE_GROUP_ID
&& user.profileGroupId == profile.profileGroupId);
}
/**
* Tries to initalize a volume with the given bundle. If it is a valid, private, and readable
* {@link VolumeInfo}, it is returned. If it is not valid, null is returned.
*/
@Nullable
public static VolumeInfo maybeInitializeVolume(StorageManager sm, Bundle bundle) {
final String volumeId = bundle.getString(VolumeInfo.EXTRA_VOLUME_ID,
VolumeInfo.ID_PRIVATE_INTERNAL);
VolumeInfo volume = sm.findVolumeById(volumeId);
return isVolumeValid(volume) ? volume : null;
}
private static boolean isVolumeValid(VolumeInfo volume) {
return (volume != null) && (volume.getType() == VolumeInfo.TYPE_PRIVATE)
&& volume.isMountedReadable();
}
}