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 package android.app.usage;
18 
19 import android.annotation.CurrentTimeMillisLong;
20 import android.annotation.NonNull;
21 import android.os.Parcel;
22 import android.os.Parcelable;
23 
24 /**
25  * A pair of {package, estimated launch time} to denote the estimated launch time for a given
26  * package.
27  * Used as a vehicle of data across the binder IPC.
28  *
29  * @hide
30  */
31 public final class AppLaunchEstimateInfo implements Parcelable {
32 
33     public final String packageName;
34     @CurrentTimeMillisLong
35     public final long estimatedLaunchTime;
36 
AppLaunchEstimateInfo(Parcel in)37     private AppLaunchEstimateInfo(Parcel in) {
38         packageName = in.readString();
39         estimatedLaunchTime = in.readLong();
40     }
41 
AppLaunchEstimateInfo(String packageName, @CurrentTimeMillisLong long estimatedLaunchTime)42     public AppLaunchEstimateInfo(String packageName,
43             @CurrentTimeMillisLong long estimatedLaunchTime) {
44         this.packageName = packageName;
45         this.estimatedLaunchTime = estimatedLaunchTime;
46     }
47 
48     @Override
describeContents()49     public int describeContents() {
50         return 0;
51     }
52 
53     @Override
writeToParcel(Parcel dest, int flags)54     public void writeToParcel(Parcel dest, int flags) {
55         dest.writeString(packageName);
56         dest.writeLong(estimatedLaunchTime);
57     }
58 
59     @NonNull
60     public static final Creator<AppLaunchEstimateInfo> CREATOR =
61             new Creator<AppLaunchEstimateInfo>() {
62                 @Override
63                 public AppLaunchEstimateInfo createFromParcel(Parcel source) {
64                     return new AppLaunchEstimateInfo(source);
65                 }
66 
67                 @Override
68                 public AppLaunchEstimateInfo[] newArray(int size) {
69                     return new AppLaunchEstimateInfo[size];
70                 }
71             };
72 }
73