MTK在android P上會出現在設定鎖屏滑動時候,會出現快速滅屏亮屏閃亮現象。
在開發者模式關掉動畫時不會出現此問題(Keyguard Scrim動畫問題)
解決辦法:setDuration(0),使keyguard scrim動畫關閉,邏輯請打上callback檢視。
堆棧列印參考: Android源碼開發基本指令
/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
protected void updateScrims() {
setScrimInFrontAlpha(mCurrentInFrontAlpha);
setScrimBehindAlpha(mCurrentBehindAlpha);
dispatchScrimsVisible();
}
private void setScrimBehindAlpha(float alpha) {
setScrimAlpha(mScrimBehind, alpha);
}
private void setScrimInFrontAlpha(float alpha) {
setScrimAlpha(mScrimInFront, alpha);
}
private void setScrimAlpha(ScrimView scrim, float alpha) {
if (alpha == 0f) {
scrim.setClickable(false);
} else {
// Eat touch events (unless dozing or pulsing).
scrim.setClickable(mState != ScrimState.AOD && mState != ScrimState.PULSING);
}
updateScrim(scrim, alpha);
}
private void updateScrim(ScrimView scrim, float alpha) {
...
if (wantsAlphaUpdate || wantsTintUpdate) {
if (mAnimateChange) {
startScrimAnimation(scrim, currentAlpha);
} else {
// update the alpha directly
updateScrimColor(scrim, alpha, getCurrentScrimTint(scrim));
onFinished();
}
} else {
onFinished();
}
}
private void startScrimAnimation(final View scrim, float current) {
ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f);
final int initialScrimTint = scrim instanceof ScrimView ? ((ScrimView) scrim).getTint() :
Color.TRANSPARENT;
anim.addUpdateListener(animation -> {
final float startAlpha = (Float) scrim.getTag(TAG_START_ALPHA);
final float animAmount = (float) animation.getAnimatedValue();
final int finalScrimTint = getCurrentScrimTint(scrim);
final float finalScrimAlpha = getCurrentScrimAlpha(scrim);
float alpha = MathUtils.lerp(startAlpha, finalScrimAlpha, animAmount);
alpha = MathUtils.constrain(alpha, 0f, 1f);
int tint = ColorUtils.blendARGB(initialScrimTint, finalScrimTint, animAmount);
updateScrimColor(scrim, alpha, tint);
dispatchScrimsVisible();
});
anim.setInterpolator(mInterpolator);
anim.setStartDelay(mAnimationDelay);
anim.setDuration(mAnimationDuration); //setDuration(0),使keyguard scrim動畫關閉,就不會出現android p快速滅屏出現閃屏
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
onFinished();
scrim.setTag(TAG_KEY_ANIM, null);
dispatchScrimsVisible();
if (!mDeferFinishedListener && mOnAnimationFinished != null) {
mOnAnimationFinished.run();
mOnAnimationFinished = null;
}
}
});
// Cache alpha values because we might want to update this animator in the future if
// the user expands the panel while the animation is still running.
scrim.setTag(TAG_START_ALPHA, current);
scrim.setTag(TAG_END_ALPHA, getCurrentScrimAlpha(scrim));
scrim.setTag(TAG_KEY_ANIM, anim);
anim.start();
}