Loading core/java/android/app/Activity.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -7151,6 +7151,11 @@ public class Activity extends ContextThemeWrapper writer.println(mChangingConfigurations); writer.println(mChangingConfigurations); writer.print(innerPrefix); writer.print("mCurrentConfig="); writer.print(innerPrefix); writer.print("mCurrentConfig="); writer.println(mCurrentConfig); writer.println(mCurrentConfig); if (getResources().hasOverrideDisplayAdjustments()) { writer.print(innerPrefix); writer.print("FixedRotationAdjustments="); writer.println(getResources().getDisplayAdjustments().getFixedRotationAdjustments()); } mFragments.dumpLoaders(innerPrefix, fd, writer, args); mFragments.dumpLoaders(innerPrefix, fd, writer, args); mFragments.getFragmentManager().dump(innerPrefix, fd, writer, args); mFragments.getFragmentManager().dump(innerPrefix, fd, writer, args); Loading core/java/android/app/ActivityThread.java +59 −1 Original line number Original line Diff line number Diff line Loading @@ -156,6 +156,8 @@ import android.util.proto.ProtoOutputStream; import android.view.Choreographer; import android.view.Choreographer; import android.view.ContextThemeWrapper; import android.view.ContextThemeWrapper; import android.view.Display; import android.view.Display; import android.view.DisplayAdjustments; import android.view.DisplayAdjustments.FixedRotationAdjustments; import android.view.ThreadedRenderer; import android.view.ThreadedRenderer; import android.view.View; import android.view.View; import android.view.ViewDebug; import android.view.ViewDebug; Loading Loading @@ -215,6 +217,7 @@ import java.util.Objects; import java.util.TimeZone; import java.util.TimeZone; import java.util.concurrent.Executor; import java.util.concurrent.Executor; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; final class RemoteServiceException extends AndroidRuntimeException { final class RemoteServiceException extends AndroidRuntimeException { public RemoteServiceException(String msg) { public RemoteServiceException(String msg) { Loading Loading @@ -405,6 +408,9 @@ public final class ActivityThread extends ClientTransactionHandler { @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) private final ResourcesManager mResourcesManager; private final ResourcesManager mResourcesManager; /** The active adjustments that override the {@link DisplayAdjustments} in resources. */ private ArrayList<Pair<IBinder, Consumer<DisplayAdjustments>>> mActiveRotationAdjustments; // Registry of remote cancellation transports pending a reply with reply handles. // Registry of remote cancellation transports pending a reply with reply handles. @GuardedBy("this") @GuardedBy("this") private @Nullable Map<SafeCancellationTransport, CancellationSignal> mRemoteCancellations; private @Nullable Map<SafeCancellationTransport, CancellationSignal> mRemoteCancellations; Loading Loading @@ -541,6 +547,12 @@ public final class ActivityThread extends ClientTransactionHandler { @UnsupportedAppUsage @UnsupportedAppUsage boolean mPreserveWindow; boolean mPreserveWindow; /** * If non-null, the activity is launching with a specified rotation, the adjustments should * be consumed before activity creation. */ FixedRotationAdjustments mPendingFixedRotationAdjustments; @LifecycleState @LifecycleState private int mLifecycleState = PRE_ON_CREATE; private int mLifecycleState = PRE_ON_CREATE; Loading @@ -557,7 +569,7 @@ public final class ActivityThread extends ClientTransactionHandler { PersistableBundle persistentState, List<ResultInfo> pendingResults, PersistableBundle persistentState, List<ResultInfo> pendingResults, List<ReferrerIntent> pendingNewIntents, boolean isForward, List<ReferrerIntent> pendingNewIntents, boolean isForward, ProfilerInfo profilerInfo, ClientTransactionHandler client, ProfilerInfo profilerInfo, ClientTransactionHandler client, IBinder assistToken) { IBinder assistToken, FixedRotationAdjustments fixedRotationAdjustments) { this.token = token; this.token = token; this.assistToken = assistToken; this.assistToken = assistToken; this.ident = ident; this.ident = ident; Loading @@ -575,6 +587,7 @@ public final class ActivityThread extends ClientTransactionHandler { this.overrideConfig = overrideConfig; this.overrideConfig = overrideConfig; this.packageInfo = client.getPackageInfoNoCheck(activityInfo.applicationInfo, this.packageInfo = client.getPackageInfoNoCheck(activityInfo.applicationInfo, compatInfo); compatInfo); mPendingFixedRotationAdjustments = fixedRotationAdjustments; init(); init(); } } Loading Loading @@ -3233,6 +3246,44 @@ public final class ActivityThread extends ClientTransactionHandler { sendMessage(H.CLEAN_UP_CONTEXT, cci); sendMessage(H.CLEAN_UP_CONTEXT, cci); } } @Override public void handleFixedRotationAdjustments(@NonNull IBinder token, @Nullable FixedRotationAdjustments fixedRotationAdjustments) { final Consumer<DisplayAdjustments> override = fixedRotationAdjustments != null ? displayAdjustments -> displayAdjustments.setFixedRotationAdjustments( fixedRotationAdjustments) : null; if (!mResourcesManager.overrideTokenDisplayAdjustments(token, override)) { // No resources are associated with the token. return; } if (mActivities.get(token) == null) { // Only apply the override to application for activity token because the appearance of // activity is usually more sensitive to the application resources. return; } // Apply the last override to application resources for compatibility. Because the Resources // of Display can be from application, e.g. // applicationContext.getSystemService(DisplayManager.class).getDisplay(displayId) // and the deprecated usage: // applicationContext.getSystemService(WindowManager.class).getDefaultDisplay(); final Consumer<DisplayAdjustments> appOverride; if (mActiveRotationAdjustments == null) { mActiveRotationAdjustments = new ArrayList<>(2); } if (override != null) { mActiveRotationAdjustments.add(Pair.create(token, override)); appOverride = override; } else { mActiveRotationAdjustments.removeIf(adjustmentsPair -> adjustmentsPair.first == token); appOverride = mActiveRotationAdjustments.isEmpty() ? null : mActiveRotationAdjustments.get(mActiveRotationAdjustments.size() - 1).second; } mInitialApplication.getResources().overrideDisplayAdjustments(appOverride); } /** Core implementation of activity launch. */ /** Core implementation of activity launch. */ private Activity performLaunchActivity(ActivityClientRecord r, Intent customIntent) { private Activity performLaunchActivity(ActivityClientRecord r, Intent customIntent) { ActivityInfo aInfo = r.activityInfo; ActivityInfo aInfo = r.activityInfo; Loading Loading @@ -3446,6 +3497,13 @@ public final class ActivityThread extends ClientTransactionHandler { ContextImpl appContext = ContextImpl.createActivityContext( ContextImpl appContext = ContextImpl.createActivityContext( this, r.packageInfo, r.activityInfo, r.token, displayId, r.overrideConfig); this, r.packageInfo, r.activityInfo, r.token, displayId, r.overrideConfig); // The rotation adjustments must be applied before creating the activity, so the activity // can get the adjusted display info during creation. if (r.mPendingFixedRotationAdjustments != null) { handleFixedRotationAdjustments(r.token, r.mPendingFixedRotationAdjustments); r.mPendingFixedRotationAdjustments = null; } final DisplayManagerGlobal dm = DisplayManagerGlobal.getInstance(); final DisplayManagerGlobal dm = DisplayManagerGlobal.getInstance(); // For debugging purposes, if the activity's package name contains the value of // For debugging purposes, if the activity's package name contains the value of // the "debug.use-second-display" system property as a substring, then show // the "debug.use-second-display" system property as a substring, then show Loading core/java/android/app/ClientTransactionHandler.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.content.res.Configuration; import android.os.IBinder; import android.os.IBinder; import android.util.MergedConfiguration; import android.util.MergedConfiguration; import android.view.DisplayAdjustments.FixedRotationAdjustments; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.content.ReferrerIntent; import com.android.internal.content.ReferrerIntent; Loading Loading @@ -167,6 +168,10 @@ public abstract class ClientTransactionHandler { /** Deliver app configuration change notification. */ /** Deliver app configuration change notification. */ public abstract void handleConfigurationChanged(Configuration config); public abstract void handleConfigurationChanged(Configuration config); /** Apply addition adjustments to override display information. */ public abstract void handleFixedRotationAdjustments(IBinder token, FixedRotationAdjustments fixedRotationAdjustments); /** /** * Get {@link android.app.ActivityThread.ActivityClientRecord} instance that corresponds to the * Get {@link android.app.ActivityThread.ActivityClientRecord} instance that corresponds to the * provided token. * provided token. Loading core/java/android/app/ResourcesManager.java +30 −0 Original line number Original line Diff line number Diff line Loading @@ -59,6 +59,7 @@ import java.util.Collection; import java.util.List; import java.util.List; import java.util.Objects; import java.util.Objects; import java.util.WeakHashMap; import java.util.WeakHashMap; import java.util.function.Consumer; import java.util.function.Predicate; import java.util.function.Predicate; /** @hide */ /** @hide */ Loading Loading @@ -1296,6 +1297,35 @@ public class ResourcesManager { } } } } /** * Overrides the display adjustments of all resources which are associated with the given token. * * @param token The token that owns the resources. * @param override The operation to override the existing display adjustments. If it is null, * the override adjustments will be cleared. * @return {@code true} if the override takes effect. */ public boolean overrideTokenDisplayAdjustments(IBinder token, @Nullable Consumer<DisplayAdjustments> override) { boolean handled = false; synchronized (this) { final ActivityResources tokenResources = mActivityResourceReferences.get(token); if (tokenResources == null) { return false; } final ArrayList<WeakReference<Resources>> resourcesRefs = tokenResources.activityResources; for (int i = resourcesRefs.size() - 1; i >= 0; i--) { final Resources res = resourcesRefs.get(i).get(); if (res != null) { res.overrideDisplayAdjustments(override); handled = true; } } } return handled; } private class UpdateHandler implements Resources.UpdateCallbacks { private class UpdateHandler implements Resources.UpdateCallbacks { /** /** Loading core/java/android/app/servertransaction/FixedRotationAdjustmentsItem.java 0 → 100644 +112 −0 Original line number Original line Diff line number Diff line /* * Copyright 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.app.servertransaction; import android.app.ClientTransactionHandler; import android.os.IBinder; import android.os.Parcel; import android.view.DisplayAdjustments.FixedRotationAdjustments; import java.util.Objects; /** * The request to update display adjustments for a rotated activity or window token. * @hide */ public class FixedRotationAdjustmentsItem extends ClientTransactionItem { /** The token who may have {@link android.content.res.Resources}. */ private IBinder mToken; /** * The adjustments for the display adjustments of resources. If it is null, the existing * rotation adjustments will be dropped to restore natural state. */ private FixedRotationAdjustments mFixedRotationAdjustments; private FixedRotationAdjustmentsItem() {} /** Obtain an instance initialized with provided params. */ public static FixedRotationAdjustmentsItem obtain(IBinder token, FixedRotationAdjustments fixedRotationAdjustments) { FixedRotationAdjustmentsItem instance = ObjectPool.obtain(FixedRotationAdjustmentsItem.class); if (instance == null) { instance = new FixedRotationAdjustmentsItem(); } instance.mToken = token; instance.mFixedRotationAdjustments = fixedRotationAdjustments; return instance; } @Override public void execute(ClientTransactionHandler client, IBinder token, PendingTransactionActions pendingActions) { client.handleFixedRotationAdjustments(mToken, mFixedRotationAdjustments); } @Override public void recycle() { mToken = null; mFixedRotationAdjustments = null; ObjectPool.recycle(this); } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeStrongBinder(mToken); dest.writeTypedObject(mFixedRotationAdjustments, flags); } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final FixedRotationAdjustmentsItem other = (FixedRotationAdjustmentsItem) o; return Objects.equals(mToken, other.mToken) && Objects.equals(mFixedRotationAdjustments, other.mFixedRotationAdjustments); } @Override public int hashCode() { int result = 17; result = 31 * result + Objects.hashCode(mToken); result = 31 * result + Objects.hashCode(mFixedRotationAdjustments); return result; } private FixedRotationAdjustmentsItem(Parcel in) { mToken = in.readStrongBinder(); mFixedRotationAdjustments = in.readTypedObject(FixedRotationAdjustments.CREATOR); } public static final Creator<FixedRotationAdjustmentsItem> CREATOR = new Creator<FixedRotationAdjustmentsItem>() { public FixedRotationAdjustmentsItem createFromParcel(Parcel in) { return new FixedRotationAdjustmentsItem(in); } public FixedRotationAdjustmentsItem[] newArray(int size) { return new FixedRotationAdjustmentsItem[size]; } }; } Loading
core/java/android/app/Activity.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -7151,6 +7151,11 @@ public class Activity extends ContextThemeWrapper writer.println(mChangingConfigurations); writer.println(mChangingConfigurations); writer.print(innerPrefix); writer.print("mCurrentConfig="); writer.print(innerPrefix); writer.print("mCurrentConfig="); writer.println(mCurrentConfig); writer.println(mCurrentConfig); if (getResources().hasOverrideDisplayAdjustments()) { writer.print(innerPrefix); writer.print("FixedRotationAdjustments="); writer.println(getResources().getDisplayAdjustments().getFixedRotationAdjustments()); } mFragments.dumpLoaders(innerPrefix, fd, writer, args); mFragments.dumpLoaders(innerPrefix, fd, writer, args); mFragments.getFragmentManager().dump(innerPrefix, fd, writer, args); mFragments.getFragmentManager().dump(innerPrefix, fd, writer, args); Loading
core/java/android/app/ActivityThread.java +59 −1 Original line number Original line Diff line number Diff line Loading @@ -156,6 +156,8 @@ import android.util.proto.ProtoOutputStream; import android.view.Choreographer; import android.view.Choreographer; import android.view.ContextThemeWrapper; import android.view.ContextThemeWrapper; import android.view.Display; import android.view.Display; import android.view.DisplayAdjustments; import android.view.DisplayAdjustments.FixedRotationAdjustments; import android.view.ThreadedRenderer; import android.view.ThreadedRenderer; import android.view.View; import android.view.View; import android.view.ViewDebug; import android.view.ViewDebug; Loading Loading @@ -215,6 +217,7 @@ import java.util.Objects; import java.util.TimeZone; import java.util.TimeZone; import java.util.concurrent.Executor; import java.util.concurrent.Executor; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; final class RemoteServiceException extends AndroidRuntimeException { final class RemoteServiceException extends AndroidRuntimeException { public RemoteServiceException(String msg) { public RemoteServiceException(String msg) { Loading Loading @@ -405,6 +408,9 @@ public final class ActivityThread extends ClientTransactionHandler { @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) private final ResourcesManager mResourcesManager; private final ResourcesManager mResourcesManager; /** The active adjustments that override the {@link DisplayAdjustments} in resources. */ private ArrayList<Pair<IBinder, Consumer<DisplayAdjustments>>> mActiveRotationAdjustments; // Registry of remote cancellation transports pending a reply with reply handles. // Registry of remote cancellation transports pending a reply with reply handles. @GuardedBy("this") @GuardedBy("this") private @Nullable Map<SafeCancellationTransport, CancellationSignal> mRemoteCancellations; private @Nullable Map<SafeCancellationTransport, CancellationSignal> mRemoteCancellations; Loading Loading @@ -541,6 +547,12 @@ public final class ActivityThread extends ClientTransactionHandler { @UnsupportedAppUsage @UnsupportedAppUsage boolean mPreserveWindow; boolean mPreserveWindow; /** * If non-null, the activity is launching with a specified rotation, the adjustments should * be consumed before activity creation. */ FixedRotationAdjustments mPendingFixedRotationAdjustments; @LifecycleState @LifecycleState private int mLifecycleState = PRE_ON_CREATE; private int mLifecycleState = PRE_ON_CREATE; Loading @@ -557,7 +569,7 @@ public final class ActivityThread extends ClientTransactionHandler { PersistableBundle persistentState, List<ResultInfo> pendingResults, PersistableBundle persistentState, List<ResultInfo> pendingResults, List<ReferrerIntent> pendingNewIntents, boolean isForward, List<ReferrerIntent> pendingNewIntents, boolean isForward, ProfilerInfo profilerInfo, ClientTransactionHandler client, ProfilerInfo profilerInfo, ClientTransactionHandler client, IBinder assistToken) { IBinder assistToken, FixedRotationAdjustments fixedRotationAdjustments) { this.token = token; this.token = token; this.assistToken = assistToken; this.assistToken = assistToken; this.ident = ident; this.ident = ident; Loading @@ -575,6 +587,7 @@ public final class ActivityThread extends ClientTransactionHandler { this.overrideConfig = overrideConfig; this.overrideConfig = overrideConfig; this.packageInfo = client.getPackageInfoNoCheck(activityInfo.applicationInfo, this.packageInfo = client.getPackageInfoNoCheck(activityInfo.applicationInfo, compatInfo); compatInfo); mPendingFixedRotationAdjustments = fixedRotationAdjustments; init(); init(); } } Loading Loading @@ -3233,6 +3246,44 @@ public final class ActivityThread extends ClientTransactionHandler { sendMessage(H.CLEAN_UP_CONTEXT, cci); sendMessage(H.CLEAN_UP_CONTEXT, cci); } } @Override public void handleFixedRotationAdjustments(@NonNull IBinder token, @Nullable FixedRotationAdjustments fixedRotationAdjustments) { final Consumer<DisplayAdjustments> override = fixedRotationAdjustments != null ? displayAdjustments -> displayAdjustments.setFixedRotationAdjustments( fixedRotationAdjustments) : null; if (!mResourcesManager.overrideTokenDisplayAdjustments(token, override)) { // No resources are associated with the token. return; } if (mActivities.get(token) == null) { // Only apply the override to application for activity token because the appearance of // activity is usually more sensitive to the application resources. return; } // Apply the last override to application resources for compatibility. Because the Resources // of Display can be from application, e.g. // applicationContext.getSystemService(DisplayManager.class).getDisplay(displayId) // and the deprecated usage: // applicationContext.getSystemService(WindowManager.class).getDefaultDisplay(); final Consumer<DisplayAdjustments> appOverride; if (mActiveRotationAdjustments == null) { mActiveRotationAdjustments = new ArrayList<>(2); } if (override != null) { mActiveRotationAdjustments.add(Pair.create(token, override)); appOverride = override; } else { mActiveRotationAdjustments.removeIf(adjustmentsPair -> adjustmentsPair.first == token); appOverride = mActiveRotationAdjustments.isEmpty() ? null : mActiveRotationAdjustments.get(mActiveRotationAdjustments.size() - 1).second; } mInitialApplication.getResources().overrideDisplayAdjustments(appOverride); } /** Core implementation of activity launch. */ /** Core implementation of activity launch. */ private Activity performLaunchActivity(ActivityClientRecord r, Intent customIntent) { private Activity performLaunchActivity(ActivityClientRecord r, Intent customIntent) { ActivityInfo aInfo = r.activityInfo; ActivityInfo aInfo = r.activityInfo; Loading Loading @@ -3446,6 +3497,13 @@ public final class ActivityThread extends ClientTransactionHandler { ContextImpl appContext = ContextImpl.createActivityContext( ContextImpl appContext = ContextImpl.createActivityContext( this, r.packageInfo, r.activityInfo, r.token, displayId, r.overrideConfig); this, r.packageInfo, r.activityInfo, r.token, displayId, r.overrideConfig); // The rotation adjustments must be applied before creating the activity, so the activity // can get the adjusted display info during creation. if (r.mPendingFixedRotationAdjustments != null) { handleFixedRotationAdjustments(r.token, r.mPendingFixedRotationAdjustments); r.mPendingFixedRotationAdjustments = null; } final DisplayManagerGlobal dm = DisplayManagerGlobal.getInstance(); final DisplayManagerGlobal dm = DisplayManagerGlobal.getInstance(); // For debugging purposes, if the activity's package name contains the value of // For debugging purposes, if the activity's package name contains the value of // the "debug.use-second-display" system property as a substring, then show // the "debug.use-second-display" system property as a substring, then show Loading
core/java/android/app/ClientTransactionHandler.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.content.res.Configuration; import android.os.IBinder; import android.os.IBinder; import android.util.MergedConfiguration; import android.util.MergedConfiguration; import android.view.DisplayAdjustments.FixedRotationAdjustments; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.content.ReferrerIntent; import com.android.internal.content.ReferrerIntent; Loading Loading @@ -167,6 +168,10 @@ public abstract class ClientTransactionHandler { /** Deliver app configuration change notification. */ /** Deliver app configuration change notification. */ public abstract void handleConfigurationChanged(Configuration config); public abstract void handleConfigurationChanged(Configuration config); /** Apply addition adjustments to override display information. */ public abstract void handleFixedRotationAdjustments(IBinder token, FixedRotationAdjustments fixedRotationAdjustments); /** /** * Get {@link android.app.ActivityThread.ActivityClientRecord} instance that corresponds to the * Get {@link android.app.ActivityThread.ActivityClientRecord} instance that corresponds to the * provided token. * provided token. Loading
core/java/android/app/ResourcesManager.java +30 −0 Original line number Original line Diff line number Diff line Loading @@ -59,6 +59,7 @@ import java.util.Collection; import java.util.List; import java.util.List; import java.util.Objects; import java.util.Objects; import java.util.WeakHashMap; import java.util.WeakHashMap; import java.util.function.Consumer; import java.util.function.Predicate; import java.util.function.Predicate; /** @hide */ /** @hide */ Loading Loading @@ -1296,6 +1297,35 @@ public class ResourcesManager { } } } } /** * Overrides the display adjustments of all resources which are associated with the given token. * * @param token The token that owns the resources. * @param override The operation to override the existing display adjustments. If it is null, * the override adjustments will be cleared. * @return {@code true} if the override takes effect. */ public boolean overrideTokenDisplayAdjustments(IBinder token, @Nullable Consumer<DisplayAdjustments> override) { boolean handled = false; synchronized (this) { final ActivityResources tokenResources = mActivityResourceReferences.get(token); if (tokenResources == null) { return false; } final ArrayList<WeakReference<Resources>> resourcesRefs = tokenResources.activityResources; for (int i = resourcesRefs.size() - 1; i >= 0; i--) { final Resources res = resourcesRefs.get(i).get(); if (res != null) { res.overrideDisplayAdjustments(override); handled = true; } } } return handled; } private class UpdateHandler implements Resources.UpdateCallbacks { private class UpdateHandler implements Resources.UpdateCallbacks { /** /** Loading
core/java/android/app/servertransaction/FixedRotationAdjustmentsItem.java 0 → 100644 +112 −0 Original line number Original line Diff line number Diff line /* * Copyright 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.app.servertransaction; import android.app.ClientTransactionHandler; import android.os.IBinder; import android.os.Parcel; import android.view.DisplayAdjustments.FixedRotationAdjustments; import java.util.Objects; /** * The request to update display adjustments for a rotated activity or window token. * @hide */ public class FixedRotationAdjustmentsItem extends ClientTransactionItem { /** The token who may have {@link android.content.res.Resources}. */ private IBinder mToken; /** * The adjustments for the display adjustments of resources. If it is null, the existing * rotation adjustments will be dropped to restore natural state. */ private FixedRotationAdjustments mFixedRotationAdjustments; private FixedRotationAdjustmentsItem() {} /** Obtain an instance initialized with provided params. */ public static FixedRotationAdjustmentsItem obtain(IBinder token, FixedRotationAdjustments fixedRotationAdjustments) { FixedRotationAdjustmentsItem instance = ObjectPool.obtain(FixedRotationAdjustmentsItem.class); if (instance == null) { instance = new FixedRotationAdjustmentsItem(); } instance.mToken = token; instance.mFixedRotationAdjustments = fixedRotationAdjustments; return instance; } @Override public void execute(ClientTransactionHandler client, IBinder token, PendingTransactionActions pendingActions) { client.handleFixedRotationAdjustments(mToken, mFixedRotationAdjustments); } @Override public void recycle() { mToken = null; mFixedRotationAdjustments = null; ObjectPool.recycle(this); } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeStrongBinder(mToken); dest.writeTypedObject(mFixedRotationAdjustments, flags); } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final FixedRotationAdjustmentsItem other = (FixedRotationAdjustmentsItem) o; return Objects.equals(mToken, other.mToken) && Objects.equals(mFixedRotationAdjustments, other.mFixedRotationAdjustments); } @Override public int hashCode() { int result = 17; result = 31 * result + Objects.hashCode(mToken); result = 31 * result + Objects.hashCode(mFixedRotationAdjustments); return result; } private FixedRotationAdjustmentsItem(Parcel in) { mToken = in.readStrongBinder(); mFixedRotationAdjustments = in.readTypedObject(FixedRotationAdjustments.CREATOR); } public static final Creator<FixedRotationAdjustmentsItem> CREATOR = new Creator<FixedRotationAdjustmentsItem>() { public FixedRotationAdjustmentsItem createFromParcel(Parcel in) { return new FixedRotationAdjustmentsItem(in); } public FixedRotationAdjustmentsItem[] newArray(int size) { return new FixedRotationAdjustmentsItem[size]; } }; }