linux系统导航怎么刷安卓系统升级,自定义Android系统升级流程

流程#

参考链接###

创建系统升级app###

一、使用AndroidStudio创建系统app。

二、声明权限,具备读写外置存储设备的权限以及重启设备的权限。

三、修改配置文件,添加coreApp = true,android:sharedUserId = android.uid.system,将app声明为系统app。

四、在窗口添加一个按钮,并添加其点击响应事件。

五、在按钮响应事件中,调用RecoverySystem.installPackage(Context,File),其中FIie就是你的Update.zip升级包的位置。

六、调用完成后,将会自动进入升级模式。

将app拷贝到系统路径下###

参考内置系统app流程文章

制作Update.zip升级包###

一、通常来说,android源码已经自带了制作工具,只需要进入android源码目录即可。

二、输入如下命令

1、 . build/envsetup.sh

2、 lunch (选择你的update.zip打包的配置,也可以进行第二步,直接来到第三步)。

3、 make otapackage

三、执行完上面命令后,就完成了打包工作,将生成的update.zip拷贝到指定的设备目录下即可。

原理#

1、 系统升级在系统设置中关于选项里面,这段的源码位于

源码目录/packages/apps/Settings/src/com/android/settings/DeviceInfoSettings.java

通过阅读源码可以知道,系统升级选项在找不到系统升级应用的时候,会从选项里面进行删除。

public static boolean updatePreferenceToSpecificActivityOrRemove(Context context,

PreferenceGroup parentPreferenceGroup, String preferenceKey, int flags) {

Preference preference = parentPreferenceGroup.findPreference(preferenceKey);

if (preference == null) {

return false;

}

Intent intent = preference.getIntent();

if (intent != null) {

// Find the activity that is in the system image

PackageManager pm = context.getPackageManager();

List list = pm.queryIntentActivities(intent, 0);

int listSize = list.size();

for (int i = 0; i < listSize; i++) {

ResolveInfo resolveInfo = list.get(i);

if ((resolveInfo.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM)

!= 0) {

// Replace the intent with this specific activity

preference.setIntent(new Intent().setClassName(

resolveInfo.activityInfo.packageName,

resolveInfo.activityInfo.name));

if ((flags & UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY) != 0) {

// Set the preference title to the activity's label

preference.setTitle(resolveInfo.loadLabel(pm));

}

return true;

}

}

}

// Did not find a matching activity, so remove the preference

parentPreferenceGroup.removePreference(preference);

return false;

}

二、 根据上面这段源码可知,系统升级app不但需要具备相应的action,还必须是系统app才会被检测到,并且被显示出来。可在如下路径下的文件查看到需要的action

源码目录/packages/apps/Settings/res/xml/device_info_settings.xml

可能遇到的问题#

在内置升级的过程中,唯一遇到的问题就是在打包的时候由于py脚本缩进问题导致无法成功打包,网络上查询之后才知道的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值