1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 import android.annotation.NonNull; 18 import android.annotation.Nullable; 19 import android.os.storage.DiskInfo; 20 21 import java.util.ArrayList; 22 import java.util.List; 23 24 public class DiskInfoCompat { 25 private final DiskInfo mDiskInfo; 26 public final String mId; 27 public long mSize; 28 public int mVolumeCount; 29 DiskInfoCompat(DiskInfo diskInfo)30 DiskInfoCompat(DiskInfo diskInfo) { 31 this.mDiskInfo = diskInfo; 32 this.mId = diskInfo.id; 33 this.mSize = diskInfo.size; 34 this.mVolumeCount = diskInfo.volumeCount; 35 } 36 convert(List<DiskInfo> infos)37 static List<DiskInfoCompat> convert(List<DiskInfo> infos) { 38 List<DiskInfoCompat> list = new ArrayList<>(); 39 for (DiskInfo info : infos) { 40 list.add(new DiskInfoCompat(info)); 41 } 42 return list; 43 } 44 isAdoptable()45 public boolean isAdoptable() { 46 return mDiskInfo.isAdoptable(); 47 } 48 49 public @NonNull getId()50 String getId() { 51 return mDiskInfo.getId(); 52 } 53 54 public static final String EXTRA_DISK_ID = "android.os.storage.extra.DISK_ID"; 55 56 public @Nullable getDescription()57 String getDescription() { 58 return mDiskInfo.getDescription(); 59 } 60 } 61