| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.app.servertransaction; |
| 18 |
|
| 19 |
import android.annotation.Nullable; |
| 20 |
import android.app.ClientTransactionHandler; |
| 21 |
import android.content.res.Configuration; |
| 22 |
import android.os.IBinder; |
| 23 |
import android.os.Parcel; |
| 24 |
|
| 25 |
import java.util.Objects; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
public class ConfigurationChangeItem extends ClientTransactionItem { |
| 32 |
|
| 33 |
private Configuration mConfiguration; |
| 34 |
|
| 35 |
@Override |
| 36 |
public void preExecute(android.app.ClientTransactionHandler client, IBinder token) { |
| 37 |
client.updatePendingConfiguration(mConfiguration); |
| 38 |
} |
| 39 |
|
| 40 |
@Override |
| 41 |
public void execute(ClientTransactionHandler client, IBinder token, |
| 42 |
PendingTransactionActions pendingActions) { |
| 43 |
client.handleConfigurationChanged(mConfiguration); |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
private ConfigurationChangeItem() {} |
| 50 |
|
| 51 |
|
| 52 |
public static ConfigurationChangeItem obtain(Configuration config) { |
| 53 |
ConfigurationChangeItem instance = ObjectPool.obtain(ConfigurationChangeItem.class); |
| 54 |
if (instance == null) { |
| 55 |
instance = new ConfigurationChangeItem(); |
| 56 |
} |
| 57 |
instance.mConfiguration = config; |
| 58 |
|
| 59 |
return instance; |
| 60 |
} |
| 61 |
|
| 62 |
@Override |
| 63 |
public void recycle() { |
| 64 |
mConfiguration = null; |
| 65 |
ObjectPool.recycle(this); |
| 66 |
} |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
@Override |
| 73 |
public void writeToParcel(Parcel dest, int flags) { |
| 74 |
dest.writeTypedObject(mConfiguration, flags); |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
private ConfigurationChangeItem(Parcel in) { |
| 79 |
mConfiguration = in.readTypedObject(Configuration.CREATOR); |
| 80 |
} |
| 81 |
|
| 82 |
public static final @android.annotation.NonNull Creator<ConfigurationChangeItem> CREATOR = |
| 83 |
new Creator<ConfigurationChangeItem>() { |
| 84 |
public ConfigurationChangeItem createFromParcel(Parcel in) { |
| 85 |
return new ConfigurationChangeItem(in); |
| 86 |
} |
| 87 |
|
| 88 |
public ConfigurationChangeItem[] newArray(int size) { |
| 89 |
return new ConfigurationChangeItem[size]; |
| 90 |
} |
| 91 |
}; |
| 92 |
|
| 93 |
@Override |
| 94 |
public boolean equals(@Nullable Object o) { |
| 95 |
if (this == o) { |
| 96 |
return true; |
| 97 |
} |
| 98 |
if (o == null || getClass() != o.getClass()) { |
| 99 |
return false; |
| 100 |
} |
| 101 |
final ConfigurationChangeItem other = (ConfigurationChangeItem) o; |
| 102 |
return Objects.equals(mConfiguration, other.mConfiguration); |
| 103 |
} |
| 104 |
|
| 105 |
@Override |
| 106 |
public int hashCode() { |
| 107 |
return mConfiguration.hashCode(); |
| 108 |
} |
| 109 |
|
| 110 |
@Override |
| 111 |
public String toString() { |
| 112 |
return "ConfigurationChangeItem{config=" + mConfiguration + "}"; |
| 113 |
} |
| 114 |
} |