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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user