| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.app.servertransaction; |
| 18 |
|
| 19 |
import static android.os.Trace.TRACE_TAG_ACTIVITY_MANAGER; |
| 20 |
|
| 21 |
import android.annotation.NonNull; |
| 22 |
import android.annotation.Nullable; |
| 23 |
import android.app.ActivityThread.ActivityClientRecord; |
| 24 |
import android.app.ClientTransactionHandler; |
| 25 |
import android.os.IBinder; |
| 26 |
import android.os.Parcel; |
| 27 |
import android.os.Trace; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
public class StopActivityItem extends ActivityLifecycleItem { |
| 34 |
|
| 35 |
private static final String TAG = "StopActivityItem"; |
| 36 |
|
| 37 |
private int mConfigChanges; |
| 38 |
|
| 39 |
@Override |
| 40 |
public void execute(ClientTransactionHandler client, ActivityClientRecord r, |
| 41 |
PendingTransactionActions pendingActions) { |
| 42 |
Trace.traceBegin(TRACE_TAG_ACTIVITY_MANAGER, "activityStop"); |
| 43 |
client.handleStopActivity(r, mConfigChanges, pendingActions, |
| 44 |
true , "STOP_ACTIVITY_ITEM"); |
| 45 |
Trace.traceEnd(TRACE_TAG_ACTIVITY_MANAGER); |
| 46 |
} |
| 47 |
|
| 48 |
@Override |
| 49 |
public void postExecute(ClientTransactionHandler client, IBinder token, |
| 50 |
PendingTransactionActions pendingActions) { |
| 51 |
client.reportStop(pendingActions); |
| 52 |
} |
| 53 |
|
| 54 |
@Override |
| 55 |
public int getTargetState() { |
| 56 |
return ON_STOP; |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
private StopActivityItem() {} |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
public static StopActivityItem obtain(int configChanges) { |
| 69 |
StopActivityItem instance = ObjectPool.obtain(StopActivityItem.class); |
| 70 |
if (instance == null) { |
| 71 |
instance = new StopActivityItem(); |
| 72 |
} |
| 73 |
instance.mConfigChanges = configChanges; |
| 74 |
|
| 75 |
return instance; |
| 76 |
} |
| 77 |
|
| 78 |
@Override |
| 79 |
public void recycle() { |
| 80 |
super.recycle(); |
| 81 |
mConfigChanges = 0; |
| 82 |
ObjectPool.recycle(this); |
| 83 |
} |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
@Override |
| 90 |
public void writeToParcel(Parcel dest, int flags) { |
| 91 |
dest.writeInt(mConfigChanges); |
| 92 |
} |
| 93 |
|
| 94 |
|
| 95 |
private StopActivityItem(Parcel in) { |
| 96 |
mConfigChanges = in.readInt(); |
| 97 |
} |
| 98 |
|
| 99 |
public static final @NonNull Creator<StopActivityItem> CREATOR = |
| 100 |
new Creator<StopActivityItem>() { |
| 101 |
public StopActivityItem createFromParcel(Parcel in) { |
| 102 |
return new StopActivityItem(in); |
| 103 |
} |
| 104 |
|
| 105 |
public StopActivityItem[] newArray(int size) { |
| 106 |
return new StopActivityItem[size]; |
| 107 |
} |
| 108 |
}; |
| 109 |
|
| 110 |
@Override |
| 111 |
public boolean equals(@Nullable Object o) { |
| 112 |
if (this == o) { |
| 113 |
return true; |
| 114 |
} |
| 115 |
if (o == null || getClass() != o.getClass()) { |
| 116 |
return false; |
| 117 |
} |
| 118 |
final StopActivityItem other = (StopActivityItem) o; |
| 119 |
return mConfigChanges == other.mConfigChanges; |
| 120 |
} |
| 121 |
|
| 122 |
@Override |
| 123 |
public int hashCode() { |
| 124 |
int result = 17; |
| 125 |
result = 31 * result + mConfigChanges; |
| 126 |
return result; |
| 127 |
} |
| 128 |
|
| 129 |
@Override |
| 130 |
public String toString() { |
| 131 |
return "StopActivityItem{configChanges=" + mConfigChanges + "}"; |
| 132 |
} |
| 133 |
} |