Merge "Optimize some binder calls when recents configuration changes" into nyc-dev

This commit is contained in:
TreeHugger Robot
2016-04-19 06:09:36 +00:00
committed by Android (Google) Code Review
9 changed files with 42 additions and 35 deletions

View File

@@ -99,6 +99,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
private RecentsPackageMonitor mPackageMonitor;
private long mLastTabKeyEventTime;
private int mLastDeviceOrientation = Configuration.ORIENTATION_UNDEFINED;
private int mLastDisplayDensity;
private boolean mFinishedOnStartup;
private boolean mIgnoreAltTabRelease;
private boolean mIsVisible;
@@ -276,7 +277,9 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
getWindow().getAttributes().privateFlags |=
WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY;
mLastDeviceOrientation = Utilities.getAppConfiguration(this).orientation;
Configuration appConfiguration = Utilities.getAppConfiguration(this);
mLastDeviceOrientation = appConfiguration.orientation;
mLastDisplayDensity = appConfiguration.densityDpi;
mFocusTimerDuration = getResources().getInteger(R.integer.recents_auto_advance_duration);
mIterateTrigger = new DozeTrigger(mFocusTimerDuration, new Runnable() {
@Override
@@ -427,11 +430,13 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
super.onConfigurationChanged(newConfig);
// Notify of the config change
int newDeviceOrientation = Utilities.getAppConfiguration(this).orientation;
Configuration newDeviceConfiguration = Utilities.getAppConfiguration(this);
int numStackTasks = mRecentsView.getStack().getStackTaskCount();
EventBus.getDefault().send(new ConfigurationChangedEvent(false /* fromMultiWindow */,
(mLastDeviceOrientation != newDeviceOrientation), numStackTasks > 0));
mLastDeviceOrientation = newDeviceOrientation;
mLastDeviceOrientation != newDeviceConfiguration.orientation,
mLastDisplayDensity != newDeviceConfiguration.densityDpi, numStackTasks > 0));
mLastDeviceOrientation = newDeviceConfiguration.orientation;
mLastDisplayDensity = newDeviceConfiguration.densityDpi;
}
@Override
@@ -454,7 +459,8 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
int numStackTasks = stack.getStackTaskCount();
EventBus.getDefault().send(new ConfigurationChangedEvent(true /* fromMultiWindow */,
false /* fromDeviceOrientationChange */, numStackTasks > 0));
false /* fromDeviceOrientationChange */, false /* fromDisplayDensityChange */,
numStackTasks > 0));
EventBus.getDefault().send(new MultiWindowStateChangedEvent(isInMultiWindowMode, stack));
}

View File

@@ -560,7 +560,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
com.android.internal.R.dimen.navigation_bar_height);
mNavBarWidth = res.getDimensionPixelSize(
com.android.internal.R.dimen.navigation_bar_width);
mTaskBarHeight = TaskStackLayoutAlgorithm.getDimensionForDevice(res,
mTaskBarHeight = TaskStackLayoutAlgorithm.getDimensionForDevice(mContext,
R.dimen.recents_task_view_header_height,
R.dimen.recents_task_view_header_height,
R.dimen.recents_task_view_header_height,

View File

@@ -25,12 +25,14 @@ public class ConfigurationChangedEvent extends EventBus.AnimatedEvent {
public final boolean fromMultiWindow;
public final boolean fromDeviceOrientationChange;
public final boolean fromDisplayDensityChange;
public final boolean hasStackTasks;
public ConfigurationChangedEvent(boolean fromMultiWindow, boolean fromDeviceOrientationChange,
boolean hasStackTasks) {
boolean fromDisplayDensityChange, boolean hasStackTasks) {
this.fromMultiWindow = fromMultiWindow;
this.fromDeviceOrientationChange = fromDeviceOrientationChange;
this.fromDisplayDensityChange = fromDisplayDensityChange;
this.hasStackTasks = hasStackTasks;
}
}

View File

@@ -950,18 +950,6 @@ public class SystemServicesProxy {
return displayRect;
}
/**
* Returns the current display orientation.
*/
public int getDisplayOrientation() {
// Because of multi-window, the configuration orientation does not necessarily reflect the
// orientation of the display, instead we just use the display's real-size.
Rect displayRect = getDisplayRect();
return displayRect.width() > displayRect.height()
? Configuration.ORIENTATION_LANDSCAPE
: Configuration.ORIENTATION_PORTRAIT;
}
/**
* Returns the window rect for the RecentsActivity, based on the dimensions of the home stack.
*/

View File

@@ -193,7 +193,9 @@ public class RecentsViewTouchHandler {
}
public final void onBusEvent(ConfigurationChangedEvent event) {
updateSnapAlgorithm();
if (event.fromDisplayDensityChange) {
updateSnapAlgorithm();
}
}
/**

View File

@@ -41,7 +41,8 @@ public class SystemBarScrimViews {
private boolean mHasNavBarScrim;
private boolean mShouldAnimateNavBarScrim;
private boolean mHasTransposedNavBar;
private boolean mHasDockedTasks;
private int mNavBarScrimEnterDuration;
public SystemBarScrimViews(RecentsActivity activity) {
@@ -50,6 +51,8 @@ public class SystemBarScrimViews {
mNavBarScrimView.forceHasOverlappingRendering(false);
mNavBarScrimEnterDuration = activity.getResources().getInteger(
R.integer.recents_nav_bar_scrim_enter_duration);
mHasNavBarScrim = Recents.getSystemServices().hasTransposedNavBar();
mHasDockedTasks = Recents.getSystemServices().hasDockedTask();
}
/**
@@ -101,8 +104,7 @@ public class SystemBarScrimViews {
* @return Whether to show the nav bar scrim.
*/
private boolean isNavBarScrimRequired(boolean hasStackTasks) {
SystemServicesProxy ssp = Recents.getSystemServices();
return hasStackTasks && !ssp.hasTransposedNavBar() && !ssp.hasDockedTask();
return hasStackTasks && !mHasTransposedNavBar && !mHasDockedTasks;
}
/**** EventBus events ****/
@@ -142,10 +144,14 @@ public class SystemBarScrimViews {
}
public final void onBusEvent(ConfigurationChangedEvent event) {
if (event.fromDeviceOrientationChange) {
mHasNavBarScrim = Recents.getSystemServices().hasTransposedNavBar();
}
animateScrimToCurrentNavBarState(event.hasStackTasks);
}
public final void onBusEvent(MultiWindowStateChangedEvent event) {
mHasDockedTasks = event.inMultiWindow;
animateScrimToCurrentNavBarState(event.stack.getStackTaskCount() > 0);
}

View File

@@ -345,11 +345,11 @@ public class TaskStackLayoutAlgorithm {
mCb = cb;
mFreeformLayoutAlgorithm = new FreeformWorkspaceLayoutAlgorithm(context);
mMinMargin = res.getDimensionPixelSize(R.dimen.recents_layout_min_margin);
mBaseTopMargin = getDimensionForDevice(res,
mBaseTopMargin = getDimensionForDevice(context,
R.dimen.recents_layout_top_margin_phone,
R.dimen.recents_layout_top_margin_tablet,
R.dimen.recents_layout_top_margin_tablet_xlarge);
mBaseSideMargin = getDimensionForDevice(res,
mBaseSideMargin = getDimensionForDevice(context,
R.dimen.recents_layout_side_margin_phone,
R.dimen.recents_layout_side_margin_tablet,
R.dimen.recents_layout_side_margin_tablet_xlarge);
@@ -375,14 +375,14 @@ public class TaskStackLayoutAlgorithm {
res.getDimensionPixelSize(R.dimen.recents_layout_bottom_peek_size);
mMinTranslationZ = res.getDimensionPixelSize(R.dimen.recents_layout_z_min);
mMaxTranslationZ = res.getDimensionPixelSize(R.dimen.recents_layout_z_max);
mBaseInitialTopOffset = getDimensionForDevice(res,
mBaseInitialTopOffset = getDimensionForDevice(context,
R.dimen.recents_layout_initial_top_offset_phone_port,
R.dimen.recents_layout_initial_top_offset_phone_land,
R.dimen.recents_layout_initial_top_offset_tablet,
R.dimen.recents_layout_initial_top_offset_tablet,
R.dimen.recents_layout_initial_top_offset_tablet,
R.dimen.recents_layout_initial_top_offset_tablet);
mBaseInitialBottomOffset = getDimensionForDevice(res,
mBaseInitialBottomOffset = getDimensionForDevice(context,
R.dimen.recents_layout_initial_bottom_offset_phone_port,
R.dimen.recents_layout_initial_bottom_offset_phone_land,
R.dimen.recents_layout_initial_bottom_offset_tablet,
@@ -1005,7 +1005,8 @@ public class TaskStackLayoutAlgorithm {
int sideMargin = getScaleForExtent(windowRect, displayRect, mBaseSideMargin, mMinMargin,
WIDTH);
int targetStackWidth = taskStackBounds.width() - 2 * sideMargin;
if (ssp.getDisplayOrientation() == Configuration.ORIENTATION_LANDSCAPE) {
if (Utilities.getAppConfiguration(mContext).orientation
== Configuration.ORIENTATION_LANDSCAPE) {
// If we are in landscape, calculate the width of the stack in portrait and ensure that
// we are not larger than that size
Rect portraitDisplayRect = new Rect(0, 0,
@@ -1022,20 +1023,21 @@ public class TaskStackLayoutAlgorithm {
/**
* Retrieves resources that are constant regardless of the current configuration of the device.
*/
public static int getDimensionForDevice(Resources res, int phoneResId,
public static int getDimensionForDevice(Context ctx, int phoneResId,
int tabletResId, int xlargeTabletResId) {
return getDimensionForDevice(res, phoneResId, phoneResId, tabletResId, tabletResId,
return getDimensionForDevice(ctx, phoneResId, phoneResId, tabletResId, tabletResId,
xlargeTabletResId, xlargeTabletResId);
}
/**
* Retrieves resources that are constant regardless of the current configuration of the device.
*/
public static int getDimensionForDevice(Resources res, int phonePortResId, int phoneLandResId,
public static int getDimensionForDevice(Context ctx, int phonePortResId, int phoneLandResId,
int tabletPortResId, int tabletLandResId, int xlargeTabletPortResId,
int xlargeTabletLandResId) {
RecentsConfiguration config = Recents.getConfiguration();
boolean isLandscape = Recents.getSystemServices().getDisplayOrientation() ==
Resources res = ctx.getResources();
boolean isLandscape = Utilities.getAppConfiguration(ctx).orientation ==
Configuration.ORIENTATION_LANDSCAPE;
if (config.isXLargeScreen) {
return res.getDimensionPixelSize(isLandscape

View File

@@ -284,14 +284,14 @@ public class TaskViewHeader extends FrameLayout
// Update the dimensions of everything in the header. We do this because we need to use
// resources for the display, and not the current configuration.
Resources res = getResources();
int headerBarHeight = TaskStackLayoutAlgorithm.getDimensionForDevice(res,
int headerBarHeight = TaskStackLayoutAlgorithm.getDimensionForDevice(getContext(),
R.dimen.recents_task_view_header_height,
R.dimen.recents_task_view_header_height,
R.dimen.recents_task_view_header_height,
R.dimen.recents_task_view_header_height_tablet_land,
R.dimen.recents_task_view_header_height,
R.dimen.recents_task_view_header_height_tablet_land);
int headerButtonPadding = TaskStackLayoutAlgorithm.getDimensionForDevice(res,
int headerButtonPadding = TaskStackLayoutAlgorithm.getDimensionForDevice(getContext(),
R.dimen.recents_task_view_header_button_padding,
R.dimen.recents_task_view_header_button_padding,
R.dimen.recents_task_view_header_button_padding,

View File

@@ -38,6 +38,7 @@ import android.view.ViewDebug;
import com.android.systemui.R;
import com.android.systemui.recents.Recents;
import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.misc.Utilities;
import com.android.systemui.recents.model.Task;
@@ -132,7 +133,7 @@ public class TaskViewThumbnail extends View {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
SystemServicesProxy ssp = Recents.getSystemServices();
mOrientation = ssp.getDisplayOrientation();
mOrientation = Utilities.getAppConfiguration(mContext).orientation;
mDisplayRect = ssp.getDisplayRect();
}