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.app.usage.ExternalStorageStats; 18 import android.app.usage.StorageStats; 19 import android.app.usage.StorageStatsManager; 20 import android.content.Context; 21 import android.os.UserHandle; 22 23 import java.io.IOException; 24 25 public class StorageStatsManagerCompat { 26 private final StorageStatsManager mManager; 27 StorageStatsManagerCompat(Context context)28 public StorageStatsManagerCompat(Context context) { 29 mManager = context.getSystemService(StorageStatsManager.class); 30 } 31 StorageStatsManagerCompat(StorageStatsManager manager)32 public StorageStatsManagerCompat(StorageStatsManager manager) { 33 this.mManager = manager; 34 } 35 getCacheQuotaBytes(String volumeUuid, int uid)36 public long getCacheQuotaBytes(String volumeUuid, int uid) { 37 return this.mManager.getCacheQuotaBytes(volumeUuid, uid); 38 } 39 getTotalBytes(String fsUuid)40 public long getTotalBytes(String fsUuid) throws IOException { 41 return mManager.getTotalBytes(fsUuid); 42 } 43 getFreeBytes(String fsUuid)44 public long getFreeBytes(String fsUuid) throws IOException { 45 return mManager.getFreeBytes(fsUuid); 46 } 47 48 queryExternalStatsForUser(String uuid, UserHandle user)49 public ExternalStorageStats queryExternalStatsForUser(String uuid, UserHandle user) 50 throws IOException { 51 return mManager.queryExternalStatsForUser(uuid, user); 52 } 53 queryStatsForUser(String uuid, UserHandle user)54 public StorageStats queryStatsForUser(String uuid, UserHandle user) throws IOException { 55 return mManager.queryStatsForUser(uuid, user); 56 } 57 } 58