Android开机向导定制(1)开机向导加载流程

SetupWizard开机引导是一个系统APP,第一次开机或者恢复出厂设置后,优先于其他APP启动,完成系统设置。

1、打开/vendor/sprd/platform/packages/apps/SetupWizard/AndroidManifest.xml

找到:

XML 复制代码
..........................................
<application     android:label="@string/app_name"
                 android:icon="@mipmap/ic_launcher"
                 android:theme="@style/SudThemeGlifV3.Light"
                 android:uiOptions="none"
                 android:taskAffinity="com.android.wizard"
                 android:name=".SetupWizardApp">
.........................................

先看SetupWizardApp做了什么,在SetupWizardApp的onCreate方法:

XML 复制代码
  @Override
    public void onCreate() {
        super.onCreate();
        if (LOGV) {
            Log.v(TAG, "onCreate()");
        }
        NetworkMonitor.initInstance(this);
        PhoneMonitor.initInstance(this);
        SetupWizardUtils.disableComponentsForMissingFeatures(this);
        SetupWizardUtils.setMobileDataEnabled(this, false); 
        sStatusBarManager = SetupWizardUtils.disableStatusBar(this);
        mHandler.postDelayed(mRadioTimeoutRunnable, SetupWizardApp.RADIO_READY_TIMEOUT);
    }

在开机引导模式下,状态栏、无线数据是被禁止使用的。

继续转到AndroidManifest.xml,找到

XML 复制代码
<activity android:name=".SetupWizardActivity"
                  android:label="@string/activity_label_empty"
                  android:lockTaskMode="normal"
                  android:launchMode="singleTask"
                  android:excludeFromRecents="true"
                  android:configChanges="keyboard|keyboardHidden|mcc|mnc|orientation|screenSize"
                  android:immersive="true"
                  android:exported="false"
                  android:windowSoftInputMode="stateAlwaysHidden"
                  android:theme="@style/NoDisplay">

            <intent-filter android:priority="9">
                <action android:name="android.intent.action.MAIN" />
                <action android:name="android.intent.action.DEVICE_INITIALIZATION_WIZARD" />
                <category android:name="android.intent.category.HOME" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
 </activity>

SetupWizardActivity是主启动Activity,android:priority="9"指名接收优先级最高。

在SetupWizardActivity的onCreate方法:

java 复制代码
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (LOGV) {
            Log.v(TAG, "onCreate savedInstanceState=" + savedInstanceState);
        }
        if (WizardManagerHelper.isUserSetupComplete(this)) {
            SetupWizardUtils.finishSetupWizard(this);
            finish();

        } else {
            onSetupStart();
            SetupWizardUtils.enableComponent(this, WizardManager.class);
            Intent intent = new Intent(ACTION_LOAD);
            if (isPrimaryUser()) {
            intent.putExtra(EXTRA_SCRIPT_URI,
                getString(R.string.lineage_wizard_script_user_uri));
            }
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | FLAG_GRANT_READ_URI_PERMISSION);
			try{
				startActivity(intent);
			}catch(Exception e){
				finish();
			}
            finish();
        }
    }

代码看,开机向导完成后,SetupWizardActivity每次开机重启后并不是不启动,而是判断已经设置完成后,就直接finish了,而开机设置是通过intent传递参数启动后面的设置。

打开strings.xml,找到相应的value:

XML 复制代码
................................................. 
<string name="lineage_wizard_script_user_uri" translatable="false">android.resource://org.lineageos.setupwizard/raw/lineage_wizard_script_user</string>
.............................................

真正后面要执行的是raw资源下的lineage_wizard_script,这是一个xml文件,后面再介绍这个。

相关推荐
coderlin_6 小时前
BI布局拖拽 (1) 深入react-gird-layout源码
android·javascript·react.js
2501_915918416 小时前
Fiddler中文版全面评测:功能亮点、使用场景与中文网资源整合指南
android·ios·小程序·https·uni-app·iphone·webview
wen's8 小时前
React Native安卓刘海屏适配终极方案:仅需修改 AndroidManifest.xml!
android·xml·react native
编程乐学9 小时前
网络资源模板--基于Android Studio 实现的聊天App
android·android studio·大作业·移动端开发·安卓移动开发·聊天app
没有了遇见11 小时前
Android 通过 SO 库安全存储敏感数据,解决接口劫持问题
android
hsx66611 小时前
使用一个 RecyclerView 构建复杂多类型布局
android
hsx66611 小时前
利用 onMeasure、onLayout、onDraw 创建自定义 View
android
守城小轩11 小时前
Chromium 136 编译指南 - Android 篇:开发工具安装(三)
android·数据库·redis
whysqwhw11 小时前
OkHttp平台抽象机制分析
android
hsx66612 小时前
Android 内存泄漏避坑
android