Android P Keyguard Scrim快速灭屏亮屏闪亮

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();
}

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值