Merge "Do the same size-configuration bucketing on both server and client" into sc-dev
This commit is contained in:
@@ -25,6 +25,7 @@ import android.os.PersistableBundle;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Singleton;
|
||||
import android.view.RemoteAnimationDefinition;
|
||||
import android.window.SizeConfigurationBuckets;
|
||||
|
||||
import com.android.internal.policy.IKeyguardDismissCallback;
|
||||
|
||||
@@ -104,12 +105,9 @@ public class ActivityClient {
|
||||
}
|
||||
}
|
||||
|
||||
void reportSizeConfigurations(IBinder token, int[] horizontalSizeConfiguration,
|
||||
int[] verticalSizeConfigurations, int[] smallestSizeConfigurations) {
|
||||
void reportSizeConfigurations(IBinder token, SizeConfigurationBuckets sizeConfigurations) {
|
||||
try {
|
||||
getActivityClientController().reportSizeConfigurations(token,
|
||||
horizontalSizeConfiguration, verticalSizeConfigurations,
|
||||
smallestSizeConfigurations);
|
||||
getActivityClientController().reportSizeConfigurations(token, sizeConfigurations);
|
||||
} catch (RemoteException e) {
|
||||
e.rethrowFromSystemServer();
|
||||
}
|
||||
|
||||
@@ -158,7 +158,6 @@ import android.util.Pair;
|
||||
import android.util.PrintWriterPrinter;
|
||||
import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
import android.util.SparseIntArray;
|
||||
import android.util.SuperNotCalledException;
|
||||
import android.util.UtilConfig;
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
@@ -180,6 +179,7 @@ import android.view.contentcapture.IContentCaptureManager;
|
||||
import android.view.contentcapture.IContentCaptureOptionsCallback;
|
||||
import android.view.translation.TranslationSpec;
|
||||
import android.webkit.WebView;
|
||||
import android.window.SizeConfigurationBuckets;
|
||||
import android.window.SplashScreen;
|
||||
import android.window.SplashScreenView;
|
||||
|
||||
@@ -604,6 +604,8 @@ public final class ActivityThread extends ClientTransactionHandler
|
||||
@LifecycleState
|
||||
private int mLifecycleState = PRE_ON_CREATE;
|
||||
|
||||
private SizeConfigurationBuckets mSizeConfigurations;
|
||||
|
||||
@VisibleForTesting
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
||||
public ActivityClientRecord() {
|
||||
@@ -3764,23 +3766,8 @@ public final class ActivityThread extends ClientTransactionHandler
|
||||
if (configurations == null) {
|
||||
return;
|
||||
}
|
||||
SparseIntArray horizontal = new SparseIntArray();
|
||||
SparseIntArray vertical = new SparseIntArray();
|
||||
SparseIntArray smallest = new SparseIntArray();
|
||||
for (int i = configurations.length - 1; i >= 0; i--) {
|
||||
Configuration config = configurations[i];
|
||||
if (config.screenHeightDp != Configuration.SCREEN_HEIGHT_DP_UNDEFINED) {
|
||||
vertical.put(config.screenHeightDp, 0);
|
||||
}
|
||||
if (config.screenWidthDp != Configuration.SCREEN_WIDTH_DP_UNDEFINED) {
|
||||
horizontal.put(config.screenWidthDp, 0);
|
||||
}
|
||||
if (config.smallestScreenWidthDp != Configuration.SMALLEST_SCREEN_WIDTH_DP_UNDEFINED) {
|
||||
smallest.put(config.smallestScreenWidthDp, 0);
|
||||
}
|
||||
}
|
||||
ActivityClient.getInstance().reportSizeConfigurations(r.token, horizontal.copyKeys(),
|
||||
vertical.copyKeys(), smallest.copyKeys());
|
||||
r.mSizeConfigurations = new SizeConfigurationBuckets(configurations);
|
||||
ActivityClient.getInstance().reportSizeConfigurations(r.token, r.mSizeConfigurations);
|
||||
}
|
||||
|
||||
private void deliverNewIntents(ActivityClientRecord r, List<ReferrerIntent> intents) {
|
||||
@@ -5773,7 +5760,10 @@ public final class ActivityThread extends ClientTransactionHandler
|
||||
// onConfigurationChanged.
|
||||
// TODO(b/173090263): Use diff instead after the improvement of AssetManager and
|
||||
// ResourcesImpl constructions.
|
||||
final int diff = activity.mCurrentConfig.diffPublicOnly(newConfig);
|
||||
int diff = activity.mCurrentConfig.diffPublicOnly(newConfig);
|
||||
final ActivityClientRecord cr = getActivityClient(activityToken);
|
||||
diff = SizeConfigurationBuckets.filterDiff(diff, activity.mCurrentConfig, newConfig,
|
||||
cr != null ? cr.mSizeConfigurations : null);
|
||||
|
||||
if (diff == 0) {
|
||||
if (!shouldUpdateWindowMetricsBounds(activity.mCurrentConfig, newConfig)
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.os.PersistableBundle;
|
||||
import android.view.RemoteAnimationDefinition;
|
||||
import android.window.SizeConfigurationBuckets;
|
||||
|
||||
import com.android.internal.policy.IKeyguardDismissCallback;
|
||||
|
||||
@@ -49,8 +50,8 @@ interface IActivityClientController {
|
||||
oneway void activityDestroyed(in IBinder token);
|
||||
oneway void activityRelaunched(in IBinder token);
|
||||
|
||||
oneway void reportSizeConfigurations(in IBinder token, in int[] horizontalSizeConfiguration,
|
||||
in int[] verticalSizeConfigurations, in int[] smallestWidthConfigurations);
|
||||
oneway void reportSizeConfigurations(in IBinder token,
|
||||
in SizeConfigurationBuckets sizeConfigurations);
|
||||
boolean moveActivityTaskToBack(in IBinder token, boolean nonRoot);
|
||||
boolean shouldUpRecreateTask(in IBinder token, in String destAffinity);
|
||||
boolean navigateUpTo(in IBinder token, in Intent target, int resultCode,
|
||||
|
||||
19
core/java/android/window/SizeConfigurationBuckets.aidl
Normal file
19
core/java/android/window/SizeConfigurationBuckets.aidl
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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.window;
|
||||
|
||||
parcelable SizeConfigurationBuckets;
|
||||
282
core/java/android/window/SizeConfigurationBuckets.java
Normal file
282
core/java/android/window/SizeConfigurationBuckets.java
Normal file
@@ -0,0 +1,282 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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.window;
|
||||
|
||||
import static android.content.pm.ActivityInfo.CONFIG_SCREEN_SIZE;
|
||||
import static android.content.pm.ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Parcelable;
|
||||
import android.util.SparseIntArray;
|
||||
|
||||
import com.android.internal.util.DataClass;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Contains size-configuration buckets used to prevent excessive configuration changes during
|
||||
* resize.
|
||||
*
|
||||
* These configurations are collected from application's resources based on size-sensitive
|
||||
* qualifiers. For example, layout-w800dp will be added to mHorizontalSizeConfigurations as 800
|
||||
* and drawable-sw400dp will be added to both as 400.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@DataClass(genAidl = true)
|
||||
public final class SizeConfigurationBuckets implements Parcelable {
|
||||
|
||||
/** Horizontal (screenWidthDp) buckets */
|
||||
@Nullable
|
||||
private final int[] mHorizontal;
|
||||
|
||||
/** Vertical (screenHeightDp) buckets */
|
||||
@Nullable
|
||||
private final int[] mVertical;
|
||||
|
||||
/** Smallest (smallestScreenWidthDp) buckets */
|
||||
@Nullable
|
||||
private final int[] mSmallest;
|
||||
|
||||
public SizeConfigurationBuckets(Configuration[] sizeConfigurations) {
|
||||
SparseIntArray horizontal = new SparseIntArray();
|
||||
SparseIntArray vertical = new SparseIntArray();
|
||||
SparseIntArray smallest = new SparseIntArray();
|
||||
for (int i = sizeConfigurations.length - 1; i >= 0; i--) {
|
||||
Configuration config = sizeConfigurations[i];
|
||||
if (config.screenHeightDp != Configuration.SCREEN_HEIGHT_DP_UNDEFINED) {
|
||||
vertical.put(config.screenHeightDp, 0);
|
||||
}
|
||||
if (config.screenWidthDp != Configuration.SCREEN_WIDTH_DP_UNDEFINED) {
|
||||
horizontal.put(config.screenWidthDp, 0);
|
||||
}
|
||||
if (config.smallestScreenWidthDp != Configuration.SMALLEST_SCREEN_WIDTH_DP_UNDEFINED) {
|
||||
smallest.put(config.smallestScreenWidthDp, 0);
|
||||
}
|
||||
}
|
||||
mHorizontal = horizontal.copyKeys();
|
||||
mVertical = vertical.copyKeys();
|
||||
mSmallest = smallest.copyKeys();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the changes between two configurations but don't count changes in sizes if they don't
|
||||
* cross boundaries that are important to the app.
|
||||
*
|
||||
* This is a static helper to deal with null `buckets`. When no buckets have been specified,
|
||||
* this actually filters out all 3 size-configs. This is legacy behavior.
|
||||
*/
|
||||
public static int filterDiff(int diff, Configuration oldConfig, Configuration newConfig,
|
||||
@Nullable SizeConfigurationBuckets buckets) {
|
||||
if (buckets == null) {
|
||||
return diff & ~(CONFIG_SCREEN_SIZE | CONFIG_SMALLEST_SCREEN_SIZE);
|
||||
}
|
||||
if ((diff & CONFIG_SCREEN_SIZE) != 0) {
|
||||
final boolean crosses = buckets.crossesHorizontalSizeThreshold(oldConfig.screenWidthDp,
|
||||
newConfig.screenWidthDp)
|
||||
|| buckets.crossesVerticalSizeThreshold(oldConfig.screenHeightDp,
|
||||
newConfig.screenHeightDp);
|
||||
if (!crosses) {
|
||||
diff &= ~CONFIG_SCREEN_SIZE;
|
||||
}
|
||||
}
|
||||
if ((diff & CONFIG_SMALLEST_SCREEN_SIZE) != 0) {
|
||||
final int oldSmallest = oldConfig.smallestScreenWidthDp;
|
||||
final int newSmallest = newConfig.smallestScreenWidthDp;
|
||||
if (!buckets.crossesSmallestSizeThreshold(oldSmallest, newSmallest)) {
|
||||
diff &= ~CONFIG_SMALLEST_SCREEN_SIZE;
|
||||
}
|
||||
}
|
||||
return diff;
|
||||
}
|
||||
|
||||
private boolean crossesHorizontalSizeThreshold(int firstDp, int secondDp) {
|
||||
return crossesSizeThreshold(mHorizontal, firstDp, secondDp);
|
||||
}
|
||||
|
||||
private boolean crossesVerticalSizeThreshold(int firstDp, int secondDp) {
|
||||
return crossesSizeThreshold(mVertical, firstDp, secondDp);
|
||||
}
|
||||
|
||||
private boolean crossesSmallestSizeThreshold(int firstDp, int secondDp) {
|
||||
return crossesSizeThreshold(mSmallest, firstDp, secondDp);
|
||||
}
|
||||
|
||||
/**
|
||||
* The purpose of this method is to decide whether the activity needs to be relaunched upon
|
||||
* changing its size. In most cases the activities don't need to be relaunched, if the resize
|
||||
* is small, all the activity content has to do is relayout itself within new bounds. There are
|
||||
* cases however, where the activity's content would be completely changed in the new size and
|
||||
* the full relaunch is required.
|
||||
*
|
||||
* The activity will report to us vertical and horizontal thresholds after which a relaunch is
|
||||
* required. These thresholds are collected from the application resource qualifiers. For
|
||||
* example, if application has layout-w600dp resource directory, then it needs a relaunch when
|
||||
* we resize from width of 650dp to 550dp, as it crosses the 600dp threshold. However, if
|
||||
* it resizes width from 620dp to 700dp, it won't be relaunched as it stays on the same side
|
||||
* of the threshold.
|
||||
*/
|
||||
private static boolean crossesSizeThreshold(int[] thresholds, int firstDp,
|
||||
int secondDp) {
|
||||
if (thresholds == null) {
|
||||
return false;
|
||||
}
|
||||
for (int i = thresholds.length - 1; i >= 0; i--) {
|
||||
final int threshold = thresholds[i];
|
||||
if ((firstDp < threshold && secondDp >= threshold)
|
||||
|| (firstDp >= threshold && secondDp < threshold)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Arrays.toString(mHorizontal) + " " + Arrays.toString(mVertical) + " "
|
||||
+ Arrays.toString(mSmallest);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Code below generated by codegen v1.0.22.
|
||||
//
|
||||
// DO NOT MODIFY!
|
||||
// CHECKSTYLE:OFF Generated code
|
||||
//
|
||||
// To regenerate run:
|
||||
// $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/window/SizeConfigurationBuckets.java
|
||||
//
|
||||
// To exclude the generated code from IntelliJ auto-formatting enable (one-time):
|
||||
// Settings > Editor > Code Style > Formatter Control
|
||||
//@formatter:off
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new SizeConfigurationBuckets.
|
||||
*
|
||||
* @param horizontal
|
||||
* Horizontal (screenWidthDp) buckets
|
||||
* @param vertical
|
||||
* Vertical (screenHeightDp) buckets
|
||||
* @param smallest
|
||||
* Smallest (smallestScreenWidthDp) buckets
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public SizeConfigurationBuckets(
|
||||
@Nullable int[] horizontal,
|
||||
@Nullable int[] vertical,
|
||||
@Nullable int[] smallest) {
|
||||
this.mHorizontal = horizontal;
|
||||
this.mVertical = vertical;
|
||||
this.mSmallest = smallest;
|
||||
|
||||
// onConstructed(); // You can define this method to get a callback
|
||||
}
|
||||
|
||||
/**
|
||||
* Horizontal (screenWidthDp) buckets
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public @Nullable int[] getHorizontal() {
|
||||
return mHorizontal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vertical (screenHeightDp) buckets
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public @Nullable int[] getVertical() {
|
||||
return mVertical;
|
||||
}
|
||||
|
||||
/**
|
||||
* Smallest (smallestScreenWidthDp) buckets
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public @Nullable int[] getSmallest() {
|
||||
return mSmallest;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataClass.Generated.Member
|
||||
public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
|
||||
// You can override field parcelling by defining methods like:
|
||||
// void parcelFieldName(Parcel dest, int flags) { ... }
|
||||
|
||||
byte flg = 0;
|
||||
if (mHorizontal != null) flg |= 0x1;
|
||||
if (mVertical != null) flg |= 0x2;
|
||||
if (mSmallest != null) flg |= 0x4;
|
||||
dest.writeByte(flg);
|
||||
if (mHorizontal != null) dest.writeIntArray(mHorizontal);
|
||||
if (mVertical != null) dest.writeIntArray(mVertical);
|
||||
if (mSmallest != null) dest.writeIntArray(mSmallest);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataClass.Generated.Member
|
||||
public int describeContents() { return 0; }
|
||||
|
||||
/** @hide */
|
||||
@SuppressWarnings({"unchecked", "RedundantCast"})
|
||||
@DataClass.Generated.Member
|
||||
/* package-private */ SizeConfigurationBuckets(@NonNull android.os.Parcel in) {
|
||||
// You can override field unparcelling by defining methods like:
|
||||
// static FieldType unparcelFieldName(Parcel in) { ... }
|
||||
|
||||
byte flg = in.readByte();
|
||||
int[] horizontal = (flg & 0x1) == 0 ? null : in.createIntArray();
|
||||
int[] vertical = (flg & 0x2) == 0 ? null : in.createIntArray();
|
||||
int[] smallest = (flg & 0x4) == 0 ? null : in.createIntArray();
|
||||
|
||||
this.mHorizontal = horizontal;
|
||||
this.mVertical = vertical;
|
||||
this.mSmallest = smallest;
|
||||
|
||||
// onConstructed(); // You can define this method to get a callback
|
||||
}
|
||||
|
||||
@DataClass.Generated.Member
|
||||
public static final @NonNull Parcelable.Creator<SizeConfigurationBuckets> CREATOR
|
||||
= new Parcelable.Creator<SizeConfigurationBuckets>() {
|
||||
@Override
|
||||
public SizeConfigurationBuckets[] newArray(int size) {
|
||||
return new SizeConfigurationBuckets[size];
|
||||
}
|
||||
|
||||
@Override
|
||||
public SizeConfigurationBuckets createFromParcel(@NonNull android.os.Parcel in) {
|
||||
return new SizeConfigurationBuckets(in);
|
||||
}
|
||||
};
|
||||
|
||||
@DataClass.Generated(
|
||||
time = 1615845864280L,
|
||||
codegenVersion = "1.0.22",
|
||||
sourceFile = "frameworks/base/core/java/android/window/SizeConfigurationBuckets.java",
|
||||
inputSignatures = "private final @android.annotation.Nullable int[] mHorizontal\nprivate final @android.annotation.Nullable int[] mVertical\nprivate final @android.annotation.Nullable int[] mSmallest\npublic static int filterDiff(int,android.content.res.Configuration,android.content.res.Configuration,android.window.SizeConfigurationBuckets)\nprivate boolean crossesHorizontalSizeThreshold(int,int)\nprivate boolean crossesVerticalSizeThreshold(int,int)\nprivate boolean crossesSmallestSizeThreshold(int,int)\nprivate static boolean crossesSizeThreshold(int[],int,int)\npublic @java.lang.Override java.lang.String toString()\nclass SizeConfigurationBuckets extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genAidl=true)")
|
||||
@Deprecated
|
||||
private void __metadata() {}
|
||||
|
||||
|
||||
//@formatter:on
|
||||
// End of generated code
|
||||
|
||||
}
|
||||
@@ -823,12 +823,6 @@
|
||||
"group": "WM_DEBUG_STATES",
|
||||
"at": "com\/android\/server\/wm\/Task.java"
|
||||
},
|
||||
"-1159577965": {
|
||||
"message": "Focus requested for input consumer=%s",
|
||||
"level": "VERBOSE",
|
||||
"group": "WM_DEBUG_FOCUS_LIGHT",
|
||||
"at": "com\/android\/server\/wm\/InputMonitor.java"
|
||||
},
|
||||
"-1156118957": {
|
||||
"message": "Updated config=%s",
|
||||
"level": "DEBUG",
|
||||
@@ -2479,12 +2473,6 @@
|
||||
"group": "WM_DEBUG_RESIZE",
|
||||
"at": "com\/android\/server\/wm\/WindowState.java"
|
||||
},
|
||||
"690411811": {
|
||||
"message": "goodToGo(): No apps to animate",
|
||||
"level": "DEBUG",
|
||||
"group": "WM_DEBUG_REMOTE_ANIMATIONS",
|
||||
"at": "com\/android\/server\/wm\/RemoteAnimationController.java"
|
||||
},
|
||||
"691515534": {
|
||||
"message": " Commit wallpaper becoming invisible: %s",
|
||||
"level": "VERBOSE",
|
||||
@@ -2605,12 +2593,6 @@
|
||||
"group": "WM_DEBUG_REMOTE_ANIMATIONS",
|
||||
"at": "com\/android\/server\/wm\/RemoteAnimationController.java"
|
||||
},
|
||||
"883475718": {
|
||||
"message": "Report configuration: %s %s %s",
|
||||
"level": "VERBOSE",
|
||||
"group": "WM_DEBUG_CONFIGURATION",
|
||||
"at": "com\/android\/server\/wm\/ActivityClientController.java"
|
||||
},
|
||||
"892244061": {
|
||||
"message": "Waiting for drawn %s: removed=%b visible=%b mHasSurface=%b drawState=%d",
|
||||
"level": "INFO",
|
||||
@@ -2917,6 +2899,12 @@
|
||||
"group": "WM_DEBUG_FOCUS_LIGHT",
|
||||
"at": "com\/android\/server\/wm\/WindowState.java"
|
||||
},
|
||||
"1305412562": {
|
||||
"message": "Report configuration: %s %s",
|
||||
"level": "VERBOSE",
|
||||
"group": "WM_DEBUG_CONFIGURATION",
|
||||
"at": "com\/android\/server\/wm\/ActivityClientController.java"
|
||||
},
|
||||
"1316533291": {
|
||||
"message": "State movement: %s from:%s to:%s reason:%s",
|
||||
"level": "VERBOSE",
|
||||
|
||||
@@ -65,6 +65,7 @@ import android.os.Trace;
|
||||
import android.service.voice.VoiceInteractionManagerInternal;
|
||||
import android.util.Slog;
|
||||
import android.view.RemoteAnimationDefinition;
|
||||
import android.window.SizeConfigurationBuckets;
|
||||
|
||||
import com.android.internal.app.AssistUtils;
|
||||
import com.android.internal.policy.IKeyguardDismissCallback;
|
||||
@@ -74,8 +75,6 @@ import com.android.server.Watchdog;
|
||||
import com.android.server.uri.NeededUriGrants;
|
||||
import com.android.server.vr.VrManagerInternal;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Server side implementation for the client activity to interact with system.
|
||||
*
|
||||
@@ -244,16 +243,14 @@ class ActivityClientController extends IActivityClientController.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportSizeConfigurations(IBinder token, int[] horizontalSizeConfiguration,
|
||||
int[] verticalSizeConfigurations, int[] smallestSizeConfigurations) {
|
||||
ProtoLog.v(WM_DEBUG_CONFIGURATION, "Report configuration: %s %s %s",
|
||||
token, Arrays.toString(horizontalSizeConfiguration),
|
||||
Arrays.toString(verticalSizeConfigurations));
|
||||
public void reportSizeConfigurations(IBinder token,
|
||||
SizeConfigurationBuckets sizeConfigurations) {
|
||||
ProtoLog.v(WM_DEBUG_CONFIGURATION, "Report configuration: %s %s",
|
||||
token, sizeConfigurations);
|
||||
synchronized (mGlobalLock) {
|
||||
final ActivityRecord r = ActivityRecord.isInRootTaskLocked(token);
|
||||
if (r != null) {
|
||||
r.setSizeConfigurations(horizontalSizeConfiguration, verticalSizeConfigurations,
|
||||
smallestSizeConfigurations);
|
||||
r.setSizeConfigurations(sizeConfigurations);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,6 +316,7 @@ import android.view.WindowManager.LayoutParams;
|
||||
import android.view.WindowManager.TransitionOldType;
|
||||
import android.view.animation.Animation;
|
||||
import android.window.IRemoteTransition;
|
||||
import android.window.SizeConfigurationBuckets;
|
||||
import android.window.SplashScreenView.SplashScreenViewParcelable;
|
||||
import android.window.TaskSnapshot;
|
||||
import android.window.WindowContainerToken;
|
||||
@@ -563,12 +564,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
||||
// The locusId associated with this activity, if set.
|
||||
private LocusId mLocusId;
|
||||
|
||||
// These configurations are collected from application's resources based on size-sensitive
|
||||
// qualifiers. For example, layout-w800dp will be added to mHorizontalSizeConfigurations as 800
|
||||
// and drawable-sw400dp will be added to both as 400.
|
||||
private int[] mVerticalSizeConfigurations;
|
||||
private int[] mHorizontalSizeConfigurations;
|
||||
private int[] mSmallestSizeConfigurations;
|
||||
private SizeConfigurationBuckets mSizeConfigurations;
|
||||
|
||||
/**
|
||||
* The precomputed display insets for resolving configuration. It will be non-null if
|
||||
@@ -1176,52 +1172,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
||||
info.applicationInfo = aInfo;
|
||||
}
|
||||
|
||||
private boolean crossesHorizontalSizeThreshold(int firstDp, int secondDp) {
|
||||
return crossesSizeThreshold(mHorizontalSizeConfigurations, firstDp, secondDp);
|
||||
}
|
||||
|
||||
private boolean crossesVerticalSizeThreshold(int firstDp, int secondDp) {
|
||||
return crossesSizeThreshold(mVerticalSizeConfigurations, firstDp, secondDp);
|
||||
}
|
||||
|
||||
private boolean crossesSmallestSizeThreshold(int firstDp, int secondDp) {
|
||||
return crossesSizeThreshold(mSmallestSizeConfigurations, firstDp, secondDp);
|
||||
}
|
||||
|
||||
/**
|
||||
* The purpose of this method is to decide whether the activity needs to be relaunched upon
|
||||
* changing its size. In most cases the activities don't need to be relaunched, if the resize
|
||||
* is small, all the activity content has to do is relayout itself within new bounds. There are
|
||||
* cases however, where the activity's content would be completely changed in the new size and
|
||||
* the full relaunch is required.
|
||||
*
|
||||
* The activity will report to us vertical and horizontal thresholds after which a relaunch is
|
||||
* required. These thresholds are collected from the application resource qualifiers. For
|
||||
* example, if application has layout-w600dp resource directory, then it needs a relaunch when
|
||||
* we resize from width of 650dp to 550dp, as it crosses the 600dp threshold. However, if
|
||||
* it resizes width from 620dp to 700dp, it won't be relaunched as it stays on the same side
|
||||
* of the threshold.
|
||||
*/
|
||||
private static boolean crossesSizeThreshold(int[] thresholds, int firstDp,
|
||||
int secondDp) {
|
||||
if (thresholds == null) {
|
||||
return false;
|
||||
}
|
||||
for (int i = thresholds.length - 1; i >= 0; i--) {
|
||||
final int threshold = thresholds[i];
|
||||
if ((firstDp < threshold && secondDp >= threshold)
|
||||
|| (firstDp >= threshold && secondDp < threshold)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void setSizeConfigurations(int[] horizontalSizeConfiguration,
|
||||
int[] verticalSizeConfigurations, int[] smallestSizeConfigurations) {
|
||||
mHorizontalSizeConfigurations = horizontalSizeConfiguration;
|
||||
mVerticalSizeConfigurations = verticalSizeConfigurations;
|
||||
mSmallestSizeConfigurations = smallestSizeConfigurations;
|
||||
void setSizeConfigurations(SizeConfigurationBuckets sizeConfigurations) {
|
||||
mSizeConfigurations = sizeConfigurations;
|
||||
}
|
||||
|
||||
private void scheduleActivityMovedToDisplay(int displayId, Configuration config) {
|
||||
@@ -7797,26 +7749,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
||||
// Determine what has changed. May be nothing, if this is a config that has come back from
|
||||
// the app after going idle. In that case we just want to leave the official config object
|
||||
// now in the activity and do nothing else.
|
||||
final Configuration currentConfig = getConfiguration();
|
||||
int changes = lastReportedConfig.diff(currentConfig);
|
||||
// We don't want to use size changes if they don't cross boundaries that are important to
|
||||
// the app.
|
||||
if ((changes & CONFIG_SCREEN_SIZE) != 0) {
|
||||
final boolean crosses = crossesHorizontalSizeThreshold(lastReportedConfig.screenWidthDp,
|
||||
currentConfig.screenWidthDp)
|
||||
|| crossesVerticalSizeThreshold(lastReportedConfig.screenHeightDp,
|
||||
currentConfig.screenHeightDp);
|
||||
if (!crosses) {
|
||||
changes &= ~CONFIG_SCREEN_SIZE;
|
||||
}
|
||||
}
|
||||
if ((changes & CONFIG_SMALLEST_SCREEN_SIZE) != 0) {
|
||||
final int oldSmallest = lastReportedConfig.smallestScreenWidthDp;
|
||||
final int newSmallest = currentConfig.smallestScreenWidthDp;
|
||||
if (!crossesSmallestSizeThreshold(oldSmallest, newSmallest)) {
|
||||
changes &= ~CONFIG_SMALLEST_SCREEN_SIZE;
|
||||
}
|
||||
}
|
||||
int changes = lastReportedConfig.diff(getConfiguration());
|
||||
changes = SizeConfigurationBuckets.filterDiff(
|
||||
changes, lastReportedConfig, getConfiguration(), mSizeConfigurations);
|
||||
// We don't want window configuration to cause relaunches.
|
||||
if ((changes & CONFIG_WINDOW_CONFIGURATION) != 0) {
|
||||
changes &= ~CONFIG_WINDOW_CONFIGURATION;
|
||||
|
||||
Reference in New Issue
Block a user