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文件,后面再介绍这个。

相关推荐
2501_915918412 小时前
掌握 iOS 26 App 运行状况,多工具协作下的监控策略
android·ios·小程序·https·uni-app·iphone·webview
2501_915909065 小时前
iOS 混淆实战,多工具组合完成 IPA 混淆与加固(源码 + 成品 + 运维一体化方案)
android·运维·ios·小程序·uni-app·iphone·webview
*才华有限公司*6 小时前
安卓前后端连接教程
android
氦客7 小时前
Android Compose中的附带效应
android·compose·effect·jetpack·composable·附带效应·side effect
雨白7 小时前
Kotlin 协程的灵魂:结构化并发详解
android·kotlin
我命由我123457 小时前
Android 开发问题:getLeft、getRight、getTop、getBottom 方法返回的值都为 0
android·java·java-ee·android studio·android jetpack·android-studio·android runtime
Modu_MrLiu7 小时前
Android实战进阶 - 用户闲置超时自动退出登录功能详解
android·超时保护·实战进阶·长时间未操作超时保护·闲置超时
Jeled8 小时前
Android 网络层最佳实践:Retrofit + OkHttp 封装与实战
android·okhttp·kotlin·android studio·retrofit
信田君95278 小时前
瑞莎星瑞(Radxa Orion O6) 基于 Android OS 使用 NPU的图片模糊查找APP 开发
android·人工智能·深度学习·神经网络