Android仿系统provision应用实现开机向导

5 篇文章 0 订阅
2 篇文章 0 订阅

背景:TV首次开机实现遥控对焦、连接wifi等指导性功能

应用需要的功能 :
1.设置相关属性让自己早于Launcher起来;
2.设置开机引导已经走完的标记位。

1. AndroidManifest.xml配置

<!-- 添加权限 For miscellaneous settings -->
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />

<activity
            android:name="xxxxxxx"
            android:configChanges="locale|keyboard|keyboardHidden|navigation|layoutDirection"
            android:exported="true"
            android:excludeFromRecents="true"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar">
            <intent-filter android:priority="1">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.HOME" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.SETUP_WIZARD" />
            </intent-filter>

        </activity>

2.保存开机引导状态

开机引导结束后设置

public void setupSys() {
        // Add a persistent setting to allow other apps to know the device has been provisioned.
        // 添加持久设置以允许其他应用程序知道设备已配置。
        Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1);
         //这个标记位标识当前用户已经走完引导流程,如果不设置这个值,Home键、锁屏等将不可用
        Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 1);
        // Mediatek Android Patch Begin
        Settings.Secure.putInt(getContentResolver(), Settings.Secure.TV_USER_SETUP_COMPLETE, 1);
        // Mediatek Android Patch End
		// 从PackageManager中禁用该Activity。
        // remove this activity from the package manager.
        PackageManager pm = getPackageManager();
        ComponentName name = new ComponentName(this, GuideMainActivity.class);
        pm.setComponentEnabledSetting(name, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                PackageManager.DONT_KILL_APP);
        finish();

    }

注意点 : 开机引导app需要push到system/priv-app目录下
Android.mk配置 LOCAL_PRIVILEGED_MODULE := true

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值