Android 7.1 异常删除data文件导致HOME键失效

平台
RK3288 + Android 7.1

问题
使用SU命令删除了/data/system/users目录下的文件后重启, HOME 无法正常返回主界面.

system_process I/WindowManager: Not starting activity because user setup is in progress: Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10200000 (has extras) }

分析
|-- frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java

    private void startActivityAsUser(Intent intent, UserHandle handle) {
        if (isUserSetupComplete()) {
            mContext.startActivityAsUser(intent, handle);
        } else {
            Slog.i(TAG, "Not starting activity because user setup is in progress: " + intent);
        }
    }

    boolean isUserSetupComplete() {
        return Settings.Secure.getIntForUser(mContext.getContentResolver(),
                Settings.Secure.USER_SETUP_COMPLETE, 0, UserHandle.USER_CURRENT) != 0;
    }

Settings.Secure.USER_SETUP_COMPLETE 的值为 0?

方法1:
命令查看数据库设置的值: settings get secure user_setup_complete, 结果输出为 0

方法2:
cat /data/system/users/0/settings_secure.xml | grep user_setup



解决
使用命令设置为1:

settings put secure user_setup_complete 1

PS

以上相关命令需要有系统权限
建议仅在调试过程使用.
相关代码:
user_setup_complete 默认值设置:
|-- frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java

            loadBooleanSetting(stmt, Settings.Secure.USER_SETUP_COMPLETE,
                    R.bool.def_user_setup_complete);


|-- frameworks/base/packages/SettingsProvider/res/values/defaults.xml

    false

值的修改:
|-- packages/apps/Provision/src/com/android/provision/DefaultActivity.java

public class DefaultActivity extends Activity {

    @Override
    protected void onCreate(Bundle icicle) {
        super.onCreate(icicle);

        // Add a persistent setting to allow other apps to know the device has been provisioned.
        Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1);
        Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 1);

        // remove this activity from the package manager.
        PackageManager pm = getPackageManager();
        ComponentName name = new ComponentName(this, DefaultActivity.class);
        pm.setComponentEnabledSetting(name, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                PackageManager.DONT_KILL_APP);
        
        ...
        finish();
        
    }
 

你可能感兴趣的:(Rockchip)