Merge "Optimize some binder calls when recents configuration changes" into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
6783384eb1
@@ -99,6 +99,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
|
|||||||
private RecentsPackageMonitor mPackageMonitor;
|
private RecentsPackageMonitor mPackageMonitor;
|
||||||
private long mLastTabKeyEventTime;
|
private long mLastTabKeyEventTime;
|
||||||
private int mLastDeviceOrientation = Configuration.ORIENTATION_UNDEFINED;
|
private int mLastDeviceOrientation = Configuration.ORIENTATION_UNDEFINED;
|
||||||
|
private int mLastDisplayDensity;
|
||||||
private boolean mFinishedOnStartup;
|
private boolean mFinishedOnStartup;
|
||||||
private boolean mIgnoreAltTabRelease;
|
private boolean mIgnoreAltTabRelease;
|
||||||
private boolean mIsVisible;
|
private boolean mIsVisible;
|
||||||
@@ -276,7 +277,9 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
|
|||||||
getWindow().getAttributes().privateFlags |=
|
getWindow().getAttributes().privateFlags |=
|
||||||
WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY;
|
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);
|
mFocusTimerDuration = getResources().getInteger(R.integer.recents_auto_advance_duration);
|
||||||
mIterateTrigger = new DozeTrigger(mFocusTimerDuration, new Runnable() {
|
mIterateTrigger = new DozeTrigger(mFocusTimerDuration, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@@ -427,11 +430,13 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
|
|||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
|
|
||||||
// Notify of the config change
|
// Notify of the config change
|
||||||
int newDeviceOrientation = Utilities.getAppConfiguration(this).orientation;
|
Configuration newDeviceConfiguration = Utilities.getAppConfiguration(this);
|
||||||
int numStackTasks = mRecentsView.getStack().getStackTaskCount();
|
int numStackTasks = mRecentsView.getStack().getStackTaskCount();
|
||||||
EventBus.getDefault().send(new ConfigurationChangedEvent(false /* fromMultiWindow */,
|
EventBus.getDefault().send(new ConfigurationChangedEvent(false /* fromMultiWindow */,
|
||||||
(mLastDeviceOrientation != newDeviceOrientation), numStackTasks > 0));
|
mLastDeviceOrientation != newDeviceConfiguration.orientation,
|
||||||
mLastDeviceOrientation = newDeviceOrientation;
|
mLastDisplayDensity != newDeviceConfiguration.densityDpi, numStackTasks > 0));
|
||||||
|
mLastDeviceOrientation = newDeviceConfiguration.orientation;
|
||||||
|
mLastDisplayDensity = newDeviceConfiguration.densityDpi;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -454,7 +459,8 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
|
|||||||
int numStackTasks = stack.getStackTaskCount();
|
int numStackTasks = stack.getStackTaskCount();
|
||||||
|
|
||||||
EventBus.getDefault().send(new ConfigurationChangedEvent(true /* fromMultiWindow */,
|
EventBus.getDefault().send(new ConfigurationChangedEvent(true /* fromMultiWindow */,
|
||||||
false /* fromDeviceOrientationChange */, numStackTasks > 0));
|
false /* fromDeviceOrientationChange */, false /* fromDisplayDensityChange */,
|
||||||
|
numStackTasks > 0));
|
||||||
EventBus.getDefault().send(new MultiWindowStateChangedEvent(isInMultiWindowMode, stack));
|
EventBus.getDefault().send(new MultiWindowStateChangedEvent(isInMultiWindowMode, stack));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -560,7 +560,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
|
|||||||
com.android.internal.R.dimen.navigation_bar_height);
|
com.android.internal.R.dimen.navigation_bar_height);
|
||||||
mNavBarWidth = res.getDimensionPixelSize(
|
mNavBarWidth = res.getDimensionPixelSize(
|
||||||
com.android.internal.R.dimen.navigation_bar_width);
|
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,
|
R.dimen.recents_task_view_header_height,
|
||||||
R.dimen.recents_task_view_header_height,
|
R.dimen.recents_task_view_header_height,
|
||||||
|
|||||||
@@ -25,12 +25,14 @@ public class ConfigurationChangedEvent extends EventBus.AnimatedEvent {
|
|||||||
|
|
||||||
public final boolean fromMultiWindow;
|
public final boolean fromMultiWindow;
|
||||||
public final boolean fromDeviceOrientationChange;
|
public final boolean fromDeviceOrientationChange;
|
||||||
|
public final boolean fromDisplayDensityChange;
|
||||||
public final boolean hasStackTasks;
|
public final boolean hasStackTasks;
|
||||||
|
|
||||||
public ConfigurationChangedEvent(boolean fromMultiWindow, boolean fromDeviceOrientationChange,
|
public ConfigurationChangedEvent(boolean fromMultiWindow, boolean fromDeviceOrientationChange,
|
||||||
boolean hasStackTasks) {
|
boolean fromDisplayDensityChange, boolean hasStackTasks) {
|
||||||
this.fromMultiWindow = fromMultiWindow;
|
this.fromMultiWindow = fromMultiWindow;
|
||||||
this.fromDeviceOrientationChange = fromDeviceOrientationChange;
|
this.fromDeviceOrientationChange = fromDeviceOrientationChange;
|
||||||
|
this.fromDisplayDensityChange = fromDisplayDensityChange;
|
||||||
this.hasStackTasks = hasStackTasks;
|
this.hasStackTasks = hasStackTasks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -950,18 +950,6 @@ public class SystemServicesProxy {
|
|||||||
return displayRect;
|
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.
|
* Returns the window rect for the RecentsActivity, based on the dimensions of the home stack.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -193,8 +193,10 @@ public class RecentsViewTouchHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final void onBusEvent(ConfigurationChangedEvent event) {
|
public final void onBusEvent(ConfigurationChangedEvent event) {
|
||||||
|
if (event.fromDisplayDensityChange) {
|
||||||
updateSnapAlgorithm();
|
updateSnapAlgorithm();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles dragging touch events
|
* Handles dragging touch events
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ public class SystemBarScrimViews {
|
|||||||
|
|
||||||
private boolean mHasNavBarScrim;
|
private boolean mHasNavBarScrim;
|
||||||
private boolean mShouldAnimateNavBarScrim;
|
private boolean mShouldAnimateNavBarScrim;
|
||||||
|
private boolean mHasTransposedNavBar;
|
||||||
|
private boolean mHasDockedTasks;
|
||||||
private int mNavBarScrimEnterDuration;
|
private int mNavBarScrimEnterDuration;
|
||||||
|
|
||||||
public SystemBarScrimViews(RecentsActivity activity) {
|
public SystemBarScrimViews(RecentsActivity activity) {
|
||||||
@@ -50,6 +51,8 @@ public class SystemBarScrimViews {
|
|||||||
mNavBarScrimView.forceHasOverlappingRendering(false);
|
mNavBarScrimView.forceHasOverlappingRendering(false);
|
||||||
mNavBarScrimEnterDuration = activity.getResources().getInteger(
|
mNavBarScrimEnterDuration = activity.getResources().getInteger(
|
||||||
R.integer.recents_nav_bar_scrim_enter_duration);
|
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.
|
* @return Whether to show the nav bar scrim.
|
||||||
*/
|
*/
|
||||||
private boolean isNavBarScrimRequired(boolean hasStackTasks) {
|
private boolean isNavBarScrimRequired(boolean hasStackTasks) {
|
||||||
SystemServicesProxy ssp = Recents.getSystemServices();
|
return hasStackTasks && !mHasTransposedNavBar && !mHasDockedTasks;
|
||||||
return hasStackTasks && !ssp.hasTransposedNavBar() && !ssp.hasDockedTask();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**** EventBus events ****/
|
/**** EventBus events ****/
|
||||||
@@ -142,10 +144,14 @@ public class SystemBarScrimViews {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final void onBusEvent(ConfigurationChangedEvent event) {
|
public final void onBusEvent(ConfigurationChangedEvent event) {
|
||||||
|
if (event.fromDeviceOrientationChange) {
|
||||||
|
mHasNavBarScrim = Recents.getSystemServices().hasTransposedNavBar();
|
||||||
|
}
|
||||||
animateScrimToCurrentNavBarState(event.hasStackTasks);
|
animateScrimToCurrentNavBarState(event.hasStackTasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void onBusEvent(MultiWindowStateChangedEvent event) {
|
public final void onBusEvent(MultiWindowStateChangedEvent event) {
|
||||||
|
mHasDockedTasks = event.inMultiWindow;
|
||||||
animateScrimToCurrentNavBarState(event.stack.getStackTaskCount() > 0);
|
animateScrimToCurrentNavBarState(event.stack.getStackTaskCount() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -345,11 +345,11 @@ public class TaskStackLayoutAlgorithm {
|
|||||||
mCb = cb;
|
mCb = cb;
|
||||||
mFreeformLayoutAlgorithm = new FreeformWorkspaceLayoutAlgorithm(context);
|
mFreeformLayoutAlgorithm = new FreeformWorkspaceLayoutAlgorithm(context);
|
||||||
mMinMargin = res.getDimensionPixelSize(R.dimen.recents_layout_min_margin);
|
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_phone,
|
||||||
R.dimen.recents_layout_top_margin_tablet,
|
R.dimen.recents_layout_top_margin_tablet,
|
||||||
R.dimen.recents_layout_top_margin_tablet_xlarge);
|
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_phone,
|
||||||
R.dimen.recents_layout_side_margin_tablet,
|
R.dimen.recents_layout_side_margin_tablet,
|
||||||
R.dimen.recents_layout_side_margin_tablet_xlarge);
|
R.dimen.recents_layout_side_margin_tablet_xlarge);
|
||||||
@@ -375,14 +375,14 @@ public class TaskStackLayoutAlgorithm {
|
|||||||
res.getDimensionPixelSize(R.dimen.recents_layout_bottom_peek_size);
|
res.getDimensionPixelSize(R.dimen.recents_layout_bottom_peek_size);
|
||||||
mMinTranslationZ = res.getDimensionPixelSize(R.dimen.recents_layout_z_min);
|
mMinTranslationZ = res.getDimensionPixelSize(R.dimen.recents_layout_z_min);
|
||||||
mMaxTranslationZ = res.getDimensionPixelSize(R.dimen.recents_layout_z_max);
|
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_port,
|
||||||
R.dimen.recents_layout_initial_top_offset_phone_land,
|
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,
|
||||||
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_port,
|
||||||
R.dimen.recents_layout_initial_bottom_offset_phone_land,
|
R.dimen.recents_layout_initial_bottom_offset_phone_land,
|
||||||
R.dimen.recents_layout_initial_bottom_offset_tablet,
|
R.dimen.recents_layout_initial_bottom_offset_tablet,
|
||||||
@@ -1005,7 +1005,8 @@ public class TaskStackLayoutAlgorithm {
|
|||||||
int sideMargin = getScaleForExtent(windowRect, displayRect, mBaseSideMargin, mMinMargin,
|
int sideMargin = getScaleForExtent(windowRect, displayRect, mBaseSideMargin, mMinMargin,
|
||||||
WIDTH);
|
WIDTH);
|
||||||
int targetStackWidth = taskStackBounds.width() - 2 * sideMargin;
|
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
|
// If we are in landscape, calculate the width of the stack in portrait and ensure that
|
||||||
// we are not larger than that size
|
// we are not larger than that size
|
||||||
Rect portraitDisplayRect = new Rect(0, 0,
|
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.
|
* 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) {
|
int tabletResId, int xlargeTabletResId) {
|
||||||
return getDimensionForDevice(res, phoneResId, phoneResId, tabletResId, tabletResId,
|
return getDimensionForDevice(ctx, phoneResId, phoneResId, tabletResId, tabletResId,
|
||||||
xlargeTabletResId, xlargeTabletResId);
|
xlargeTabletResId, xlargeTabletResId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves resources that are constant regardless of the current configuration of the device.
|
* 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 tabletPortResId, int tabletLandResId, int xlargeTabletPortResId,
|
||||||
int xlargeTabletLandResId) {
|
int xlargeTabletLandResId) {
|
||||||
RecentsConfiguration config = Recents.getConfiguration();
|
RecentsConfiguration config = Recents.getConfiguration();
|
||||||
boolean isLandscape = Recents.getSystemServices().getDisplayOrientation() ==
|
Resources res = ctx.getResources();
|
||||||
|
boolean isLandscape = Utilities.getAppConfiguration(ctx).orientation ==
|
||||||
Configuration.ORIENTATION_LANDSCAPE;
|
Configuration.ORIENTATION_LANDSCAPE;
|
||||||
if (config.isXLargeScreen) {
|
if (config.isXLargeScreen) {
|
||||||
return res.getDimensionPixelSize(isLandscape
|
return res.getDimensionPixelSize(isLandscape
|
||||||
|
|||||||
@@ -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
|
// 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 for the display, and not the current configuration.
|
||||||
Resources res = getResources();
|
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,
|
||||||
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_tablet_land,
|
||||||
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_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,
|
R.dimen.recents_task_view_header_button_padding,
|
||||||
R.dimen.recents_task_view_header_button_padding,
|
R.dimen.recents_task_view_header_button_padding,
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import android.view.ViewDebug;
|
|||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.recents.Recents;
|
import com.android.systemui.recents.Recents;
|
||||||
import com.android.systemui.recents.misc.SystemServicesProxy;
|
import com.android.systemui.recents.misc.SystemServicesProxy;
|
||||||
|
import com.android.systemui.recents.misc.Utilities;
|
||||||
import com.android.systemui.recents.model.Task;
|
import com.android.systemui.recents.model.Task;
|
||||||
|
|
||||||
|
|
||||||
@@ -132,7 +133,7 @@ public class TaskViewThumbnail extends View {
|
|||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
|
|
||||||
SystemServicesProxy ssp = Recents.getSystemServices();
|
SystemServicesProxy ssp = Recents.getSystemServices();
|
||||||
mOrientation = ssp.getDisplayOrientation();
|
mOrientation = Utilities.getAppConfiguration(mContext).orientation;
|
||||||
mDisplayRect = ssp.getDisplayRect();
|
mDisplayRect = ssp.getDisplayRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user