1 /*
2  * Copyright (C) 2016 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 package com.android.settingslib.deviceinfo;
18 
19 import android.app.usage.StorageStatsManager;
20 import android.os.storage.VolumeInfo;
21 
22 import java.io.IOException;
23 import java.util.List;
24 
25 /**
26  * StorageVolumeProvider provides access to the storage volumes on a device for free space
27  * calculations.
28  */
29 public interface StorageVolumeProvider {
30     /**
31      * Returns the number of bytes of total storage on the primary storage.
32      */
getPrimaryStorageSize()33     long getPrimaryStorageSize();
34 
35     /**
36      * Returns a list of VolumeInfos for the device.
37      */
getVolumes()38     List<VolumeInfo> getVolumes();
39 
40     /**
41      * Returns the emulated volume for a given private volume.
42      */
findEmulatedForPrivate(VolumeInfo privateVolume)43     VolumeInfo findEmulatedForPrivate(VolumeInfo privateVolume);
44 
45     /**
46      * Returns the total bytes for a given storage volume.
47      *
48      * @pre The volume is a private volume and is readable.
49      */
getTotalBytes(StorageStatsManager stats, VolumeInfo volume)50     long getTotalBytes(StorageStatsManager stats, VolumeInfo volume) throws IOException;
51 
52     /**
53      * Returns the free bytes for a given storage volume.
54      *
55      * @pre The volume is a private volume and is readable.
56      */
getFreeBytes(StorageStatsManager stats, VolumeInfo volume)57     long getFreeBytes(StorageStatsManager stats, VolumeInfo volume) throws IOException;
58 }
59