Jeff Sharkey | 8dedad3 | 2017-01-09 18:21:21 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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 android.app.usage; |
| 18 | |
Jeff Sharkey | a4d34d9 | 2017-04-27 11:21:41 -0600 | [diff] [blame] | 19 | import android.annotation.BytesLong; |
Jeff Sharkey | 8dedad3 | 2017-01-09 18:21:21 -0700 | [diff] [blame] | 20 | import android.os.Parcel; |
| 21 | import android.os.Parcelable; |
| 22 | import android.os.UserHandle; |
| 23 | |
| 24 | /** |
| 25 | * Shared/external storage statistics for a {@link UserHandle} on a single |
| 26 | * storage volume. |
| 27 | * |
| 28 | * @see StorageStatsManager |
| 29 | */ |
| 30 | public final class ExternalStorageStats implements Parcelable { |
| 31 | /** {@hide} */ public long totalBytes; |
| 32 | /** {@hide} */ public long audioBytes; |
| 33 | /** {@hide} */ public long videoBytes; |
| 34 | /** {@hide} */ public long imageBytes; |
Jeff Sharkey | 0034788 | 2017-04-17 16:44:12 -0600 | [diff] [blame] | 35 | /** {@hide} */ public long appBytes; |
Jeff Sharkey | c8b29ac | 2017-07-06 11:29:06 -0600 | [diff] [blame] | 36 | /** {@hide} */ public long obbBytes; |
Jeff Sharkey | 8dedad3 | 2017-01-09 18:21:21 -0700 | [diff] [blame] | 37 | |
| 38 | /** |
| 39 | * Return the total bytes used by all files in the shared/external storage |
| 40 | * hosted on this volume. |
Jeff Sharkey | fd65813 | 2017-05-03 11:38:01 -0600 | [diff] [blame] | 41 | * <p> |
| 42 | * This value only includes data which is isolated for each user on a |
| 43 | * multiuser device. Any OBB data shared between users is not accounted in |
| 44 | * this value. |
Jeff Sharkey | 8dedad3 | 2017-01-09 18:21:21 -0700 | [diff] [blame] | 45 | */ |
Jeff Sharkey | a4d34d9 | 2017-04-27 11:21:41 -0600 | [diff] [blame] | 46 | public @BytesLong long getTotalBytes() { |
Jeff Sharkey | 8dedad3 | 2017-01-09 18:21:21 -0700 | [diff] [blame] | 47 | return totalBytes; |
| 48 | } |
| 49 | |
| 50 | /** |
Jeff Sharkey | fd65813 | 2017-05-03 11:38:01 -0600 | [diff] [blame] | 51 | * Return the total bytes used by all audio files in the shared/external |
| 52 | * storage hosted on this volume. |
| 53 | * <p> |
| 54 | * This value only includes data which is isolated for each user on a |
| 55 | * multiuser device. This value does not include any app files which are all |
| 56 | * accounted under {@link #getAppBytes()}. |
Jeff Sharkey | 8dedad3 | 2017-01-09 18:21:21 -0700 | [diff] [blame] | 57 | */ |
Jeff Sharkey | a4d34d9 | 2017-04-27 11:21:41 -0600 | [diff] [blame] | 58 | public @BytesLong long getAudioBytes() { |
Jeff Sharkey | 8dedad3 | 2017-01-09 18:21:21 -0700 | [diff] [blame] | 59 | return audioBytes; |
| 60 | } |
| 61 | |
| 62 | /** |
Jeff Sharkey | fd65813 | 2017-05-03 11:38:01 -0600 | [diff] [blame] | 63 | * Return the total bytes used by all video files in the shared/external |
| 64 | * storage hosted on this volume. |
| 65 | * <p> |
| 66 | * This value only includes data which is isolated for each user on a |
| 67 | * multiuser device. This value does not include any app files which are all |
| 68 | * accounted under {@link #getAppBytes()}. |
Jeff Sharkey | 8dedad3 | 2017-01-09 18:21:21 -0700 | [diff] [blame] | 69 | */ |
Jeff Sharkey | a4d34d9 | 2017-04-27 11:21:41 -0600 | [diff] [blame] | 70 | public @BytesLong long getVideoBytes() { |
Jeff Sharkey | 8dedad3 | 2017-01-09 18:21:21 -0700 | [diff] [blame] | 71 | return videoBytes; |
| 72 | } |
| 73 | |
| 74 | /** |
Jeff Sharkey | fd65813 | 2017-05-03 11:38:01 -0600 | [diff] [blame] | 75 | * Return the total bytes used by all image files in the shared/external |
| 76 | * storage hosted on this volume. |
| 77 | * <p> |
| 78 | * This value only includes data which is isolated for each user on a |
| 79 | * multiuser device. This value does not include any app files which are all |
| 80 | * accounted under {@link #getAppBytes()}. |
Jeff Sharkey | 8dedad3 | 2017-01-09 18:21:21 -0700 | [diff] [blame] | 81 | */ |
Jeff Sharkey | a4d34d9 | 2017-04-27 11:21:41 -0600 | [diff] [blame] | 82 | public @BytesLong long getImageBytes() { |
Jeff Sharkey | 8dedad3 | 2017-01-09 18:21:21 -0700 | [diff] [blame] | 83 | return imageBytes; |
| 84 | } |
| 85 | |
Jeff Sharkey | 0034788 | 2017-04-17 16:44:12 -0600 | [diff] [blame] | 86 | /** |
| 87 | * Return the total bytes used by app files in the shared/external storage |
| 88 | * hosted on this volume. |
| 89 | * <p> |
| 90 | * This data is already accounted against individual apps as returned |
| 91 | * through {@link StorageStats}. |
Jeff Sharkey | fd65813 | 2017-05-03 11:38:01 -0600 | [diff] [blame] | 92 | * <p> |
| 93 | * This value only includes data which is isolated for each user on a |
| 94 | * multiuser device. |
Jeff Sharkey | 0034788 | 2017-04-17 16:44:12 -0600 | [diff] [blame] | 95 | */ |
Jeff Sharkey | a4d34d9 | 2017-04-27 11:21:41 -0600 | [diff] [blame] | 96 | public @BytesLong long getAppBytes() { |
Jeff Sharkey | 0034788 | 2017-04-17 16:44:12 -0600 | [diff] [blame] | 97 | return appBytes; |
| 98 | } |
| 99 | |
Jeff Sharkey | 8dedad3 | 2017-01-09 18:21:21 -0700 | [diff] [blame] | 100 | /** {@hide} */ |
Jeff Sharkey | c8b29ac | 2017-07-06 11:29:06 -0600 | [diff] [blame] | 101 | public @BytesLong long getObbBytes() { |
| 102 | return obbBytes; |
| 103 | } |
| 104 | |
| 105 | /** {@hide} */ |
Jeff Sharkey | 8dedad3 | 2017-01-09 18:21:21 -0700 | [diff] [blame] | 106 | public ExternalStorageStats() { |
| 107 | } |
| 108 | |
| 109 | /** {@hide} */ |
| 110 | public ExternalStorageStats(Parcel in) { |
| 111 | this.totalBytes = in.readLong(); |
| 112 | this.audioBytes = in.readLong(); |
| 113 | this.videoBytes = in.readLong(); |
| 114 | this.imageBytes = in.readLong(); |
Jeff Sharkey | 0034788 | 2017-04-17 16:44:12 -0600 | [diff] [blame] | 115 | this.appBytes = in.readLong(); |
Jeff Sharkey | c8b29ac | 2017-07-06 11:29:06 -0600 | [diff] [blame] | 116 | this.obbBytes = in.readLong(); |
Jeff Sharkey | 8dedad3 | 2017-01-09 18:21:21 -0700 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | @Override |
| 120 | public int describeContents() { |
| 121 | return 0; |
| 122 | } |
| 123 | |
| 124 | @Override |
| 125 | public void writeToParcel(Parcel dest, int flags) { |
| 126 | dest.writeLong(totalBytes); |
| 127 | dest.writeLong(audioBytes); |
| 128 | dest.writeLong(videoBytes); |
| 129 | dest.writeLong(imageBytes); |
Jeff Sharkey | 0034788 | 2017-04-17 16:44:12 -0600 | [diff] [blame] | 130 | dest.writeLong(appBytes); |
Jeff Sharkey | c8b29ac | 2017-07-06 11:29:06 -0600 | [diff] [blame] | 131 | dest.writeLong(obbBytes); |
Jeff Sharkey | 8dedad3 | 2017-01-09 18:21:21 -0700 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | public static final Creator<ExternalStorageStats> CREATOR = new Creator<ExternalStorageStats>() { |
| 135 | @Override |
| 136 | public ExternalStorageStats createFromParcel(Parcel in) { |
| 137 | return new ExternalStorageStats(in); |
| 138 | } |
| 139 | |
| 140 | @Override |
| 141 | public ExternalStorageStats[] newArray(int size) { |
| 142 | return new ExternalStorageStats[size]; |
| 143 | } |
| 144 | }; |
| 145 | } |