Debian Codegraph @

core/java/android/app/servertransaction/ConfigurationChangeItem.java

raw symbols SCIP
1 /*
2 * Copyright 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
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 * App configuration change message.
29 * @hide
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 // ObjectPoolItem implementation
48
49 private ConfigurationChangeItem() {}
50
51 /** Obtain an instance initialized with provided params. */
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 // Parcelable implementation
70
71 /** Write to Parcel. */
72 @Override
73 public void writeToParcel(Parcel dest, int flags) {
74 dest.writeTypedObject(mConfiguration, flags);
75 }
76
77 /** Read from Parcel. */
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 }