问题现象:
系统自动旋转屏幕已经关闭,手握手机横屏后在握成竖屏,右下角多出一个自动旋转按钮会闪烁两下,
点击后系统又自动变成横屏了。
解决办法:
在 SystemUI 中搜索 rotate 相关找到 ic_sysbar_rotate_button.xml
vendor\mediatek\proprietary\packages\apps\SystemUI\src\com\android\systemui\statusbar\phone\NavigationBarView.java
final RotationContextButton rotateSuggestionButton = new RotationContextButton( R.id.rotate_suggestion, R.drawable.ic_sysbar_rotate_button); final ContextualButton accessibilityButton = new ContextualButton(R.id.accessibility_button, R.drawable.ic_sysbar_accessibility_button); mContextualButtonGroup.addButton(imeSwitcherButton); if (!isGesturalMode) { mContextualButtonGroup.addButton(rotateSuggestionButton); } mContextualButtonGroup.addButton(accessibilityButton); mOverviewProxyService = Dependency.get(OverviewProxyService.class); mRecentsOnboarding = new RecentsOnboarding(context, mOverviewProxyService); mFloatingRotationButton = new FloatingRotationButton(context); mRotationButtonController = new RotationButtonController(context, R.style.RotateButtonCCWStart90, isGesturalMode ? mFloatingRotationButton : rotateSuggestionButton);
真正控制的地方在这里, setRotateSuggestionButtonState 直接 return
vendor\mediatek\proprietary\packages\apps\SystemUI\src\com\android\systemui\statusbar\phone\RotationButtonController.java
void setRotateSuggestionButtonState(final boolean visible, final boolean force) { // add start android.util.Log.d("RotationButtonController", " setRotateSuggestionButtonState return"); if (true) { return; }//add end // At any point the the button can become invisible because an a11y service became active. // Similarly, a call to make the button visible may be rejected because an a11y service is // active. Must account for this. // Rerun a show animation to indicate change but don't rerun a hide animation if (!visible && !mRotationButton.isVisible()) return; final View view = mRotationButton.getCurrentView(); if (view == null) return; final KeyButtonDrawable currentDrawable = mRotationButton.getImageDrawable(); if (currentDrawable == null) return; // Clear any pending suggestion flag as it has either been nullified or is being shown mPendingRotationSuggestion = false; mMainThreadHandler.removeCallbacks(mCancelPendingRotationProposal); .....