| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.app; |
| 18 |
|
| 19 |
import android.annotation.IntDef; |
| 20 |
import android.content.ComponentName; |
| 21 |
import android.os.Parcel; |
| 22 |
import android.os.Parcelable; |
| 23 |
|
| 24 |
import java.io.PrintWriter; |
| 25 |
import java.lang.annotation.Retention; |
| 26 |
import java.lang.annotation.RetentionPolicy; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
public class WaitResult implements Parcelable { |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
@Retention(RetentionPolicy.SOURCE) |
| 42 |
@IntDef(prefix = {"LAUNCH_STATE_"}, value = { |
| 43 |
LAUNCH_STATE_UNKNOWN, |
| 44 |
LAUNCH_STATE_COLD, |
| 45 |
LAUNCH_STATE_WARM, |
| 46 |
LAUNCH_STATE_HOT, |
| 47 |
LAUNCH_STATE_RELAUNCH |
| 48 |
}) |
| 49 |
public @interface LaunchState { |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
public static final int LAUNCH_STATE_UNKNOWN = 0; |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
public static final int LAUNCH_STATE_COLD = 1; |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
public static final int LAUNCH_STATE_WARM = 2; |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
public static final int LAUNCH_STATE_HOT = 3; |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
public static final int LAUNCH_STATE_RELAUNCH = 4; |
| 78 |
|
| 79 |
public static final int INVALID_DELAY = -1; |
| 80 |
public int result; |
| 81 |
public boolean timeout; |
| 82 |
public ComponentName who; |
| 83 |
public long totalTime; |
| 84 |
public @LaunchState int launchState; |
| 85 |
|
| 86 |
public WaitResult() { |
| 87 |
} |
| 88 |
|
| 89 |
@Override |
| 90 |
public int describeContents() { |
| 91 |
return 0; |
| 92 |
} |
| 93 |
|
| 94 |
@Override |
| 95 |
public void writeToParcel(Parcel dest, int flags) { |
| 96 |
dest.writeInt(result); |
| 97 |
dest.writeInt(timeout ? 1 : 0); |
| 98 |
ComponentName.writeToParcel(who, dest); |
| 99 |
dest.writeLong(totalTime); |
| 100 |
dest.writeInt(launchState); |
| 101 |
} |
| 102 |
|
| 103 |
public static final @android.annotation.NonNull Parcelable.Creator<WaitResult> CREATOR |
| 104 |
= new Parcelable.Creator<WaitResult>() { |
| 105 |
@Override |
| 106 |
public WaitResult createFromParcel(Parcel source) { |
| 107 |
return new WaitResult(source); |
| 108 |
} |
| 109 |
|
| 110 |
@Override |
| 111 |
public WaitResult[] newArray(int size) { |
| 112 |
return new WaitResult[size]; |
| 113 |
} |
| 114 |
}; |
| 115 |
|
| 116 |
private WaitResult(Parcel source) { |
| 117 |
result = source.readInt(); |
| 118 |
timeout = source.readInt() != 0; |
| 119 |
who = ComponentName.readFromParcel(source); |
| 120 |
totalTime = source.readLong(); |
| 121 |
launchState = source.readInt(); |
| 122 |
} |
| 123 |
|
| 124 |
public void dump(PrintWriter pw, String prefix) { |
| 125 |
pw.println(prefix + "WaitResult:"); |
| 126 |
pw.println(prefix + " result=" + result); |
| 127 |
pw.println(prefix + " timeout=" + timeout); |
| 128 |
pw.println(prefix + " who=" + who); |
| 129 |
pw.println(prefix + " totalTime=" + totalTime); |
| 130 |
pw.println(prefix + " launchState=" + launchState); |
| 131 |
} |
| 132 |
|
| 133 |
public static String launchStateToString(@LaunchState int type) { |
| 134 |
switch (type) { |
| 135 |
case LAUNCH_STATE_COLD: |
| 136 |
return "COLD"; |
| 137 |
case LAUNCH_STATE_WARM: |
| 138 |
return "WARM"; |
| 139 |
case LAUNCH_STATE_HOT: |
| 140 |
return "HOT"; |
| 141 |
case LAUNCH_STATE_RELAUNCH: |
| 142 |
return "RELAUNCH"; |
| 143 |
default: |
| 144 |
return "UNKNOWN (" + type + ")"; |
| 145 |
} |
| 146 |
} |
| 147 |
} |