blob: f00e5c29cd7523e36a10970696be0083b5f1800b [file] [log] [blame]
Jeff Sharkey8dedad32017-01-09 18:21:21 -07001/*
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
17package android.app.usage;
18
Jeff Sharkeya4d34d92017-04-27 11:21:41 -060019import android.annotation.BytesLong;
Jeff Sharkey8dedad32017-01-09 18:21:21 -070020import android.os.Parcel;
21import android.os.Parcelable;
22import 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 */
30public 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 Sharkey00347882017-04-17 16:44:12 -060035 /** {@hide} */ public long appBytes;
Jeff Sharkeyc8b29ac2017-07-06 11:29:06 -060036 /** {@hide} */ public long obbBytes;
Jeff Sharkey8dedad32017-01-09 18:21:21 -070037
38 /**
39 * Return the total bytes used by all files in the shared/external storage
40 * hosted on this volume.
Jeff Sharkeyfd658132017-05-03 11:38:01 -060041 * <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 Sharkey8dedad32017-01-09 18:21:21 -070045 */
Jeff Sharkeya4d34d92017-04-27 11:21:41 -060046 public @BytesLong long getTotalBytes() {
Jeff Sharkey8dedad32017-01-09 18:21:21 -070047 return totalBytes;
48 }
49
50 /**
Jeff Sharkeyfd658132017-05-03 11:38:01 -060051 * 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 Sharkey8dedad32017-01-09 18:21:21 -070057 */
Jeff Sharkeya4d34d92017-04-27 11:21:41 -060058 public @BytesLong long getAudioBytes() {
Jeff Sharkey8dedad32017-01-09 18:21:21 -070059 return audioBytes;
60 }
61
62 /**
Jeff Sharkeyfd658132017-05-03 11:38:01 -060063 * 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 Sharkey8dedad32017-01-09 18:21:21 -070069 */
Jeff Sharkeya4d34d92017-04-27 11:21:41 -060070 public @BytesLong long getVideoBytes() {
Jeff Sharkey8dedad32017-01-09 18:21:21 -070071 return videoBytes;
72 }
73
74 /**
Jeff Sharkeyfd658132017-05-03 11:38:01 -060075 * 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 Sharkey8dedad32017-01-09 18:21:21 -070081 */
Jeff Sharkeya4d34d92017-04-27 11:21:41 -060082 public @BytesLong long getImageBytes() {
Jeff Sharkey8dedad32017-01-09 18:21:21 -070083 return imageBytes;
84 }
85
Jeff Sharkey00347882017-04-17 16:44:12 -060086 /**
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 Sharkeyfd658132017-05-03 11:38:01 -060092 * <p>
93 * This value only includes data which is isolated for each user on a
94 * multiuser device.
Jeff Sharkey00347882017-04-17 16:44:12 -060095 */
Jeff Sharkeya4d34d92017-04-27 11:21:41 -060096 public @BytesLong long getAppBytes() {
Jeff Sharkey00347882017-04-17 16:44:12 -060097 return appBytes;
98 }
99
Jeff Sharkey8dedad32017-01-09 18:21:21 -0700100 /** {@hide} */
Jeff Sharkeyc8b29ac2017-07-06 11:29:06 -0600101 public @BytesLong long getObbBytes() {
102 return obbBytes;
103 }
104
105 /** {@hide} */
Jeff Sharkey8dedad32017-01-09 18:21:21 -0700106 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 Sharkey00347882017-04-17 16:44:12 -0600115 this.appBytes = in.readLong();
Jeff Sharkeyc8b29ac2017-07-06 11:29:06 -0600116 this.obbBytes = in.readLong();
Jeff Sharkey8dedad32017-01-09 18:21:21 -0700117 }
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 Sharkey00347882017-04-17 16:44:12 -0600130 dest.writeLong(appBytes);
Jeff Sharkeyc8b29ac2017-07-06 11:29:06 -0600131 dest.writeLong(obbBytes);
Jeff Sharkey8dedad32017-01-09 18:21:21 -0700132 }
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}