解决 Android8.1 MTK 平台 屏幕锁定设置加密后,重启开机动画走两次需输入两次密码的问题

看了设置中走的界面 CryptKeeper,重启需要输入密码的界面就是刚刚的 activity

private static final String DECRYPT_STATE = "trigger_restart_framework";

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.d(TAG, "onCreate()");
        // If we are not encrypted or encrypting, get out quickly.
        final String state = SystemProperties.get("vold.decrypt");
        Log.e(TAG, "state="+state);//trigger_restart_min_framework-->trigger_restart_framework
        if (!isDebugView() && ("".equals(state) || DECRYPT_STATE.equals(state))) {
            disableCryptKeeperComponent(this);
            // Typically CryptKeeper is launched as the home app.  We didn't
            // want to be running, so need to finish this activity.  We can count
            // on the activity manager re-launching the new home app upon finishing
            // this one, since this will leave the activity stack empty.
            // NOTE: This is really grungy.  I think it would be better for the
            // activity manager to explicitly launch the crypt keeper instead of
            // home in the situation where we need to decrypt the device
            finish();
            return;
        }
}

可以看到和 trigger_restart_framework 有关,加密导致 framework 重启

解决办法

vendor\mediatek\proprietary\hardware\fstab\mtxxxx\fstab.in


/* Can overwrite FDE setting by defining __MTK_FDE_NO_FORCE and __MTK_FDE_TYPE_FILE in this file */
/* For example, you can un-comment the following line to disable FDE for all projects in this platform. */
//#define __MTK_FDE_NO_FORCE
#ifdef __MTK_FDE_NO_FORCE
  #define FLAG_FDE_AUTO encryptable //可选模式
#else
  #define FLAG_FDE_AUTO encryptable
  //#define FLAG_FDE_AUTO forceencrypt //原来的强制加密
#endif

经我测试将 define __MTK_FDE_NO_FORCE 注释放开,重新编译烧写后一直卡在开机动画,后来将注释恢复,将 else 中也改成 encryptable 测试完美解决

参考文章
如何关闭M版本上默认数据加密?
关于android9.0上开启了加密后,开机动画会播放两次的问题

你可能感兴趣的:(Android8.1,源码修改)