systemonupgradeneeded怎么用

当前位置: &
求翻译:install or upgrade an existing system是什么意思?
install or upgrade an existing system
问题补充:
安装或升级现有的系统
把一个现有的系统安装或者升级
安装或升级一个现有系统
安装或升级现有的系统
安装或升级一个现有系统
我来回答:
参考资料:
* 验证码:
登录后回答可以获得积分奖励,并可以查看和管理所有的回答。 |
我要翻译和提问
请输入您需要翻译的文本!4588人阅读
Android OTA(MTK)(32)
1.首先,我们了解一下进入进入系统更新的操作步骤;设置--&关于手机--&系统更新
& & &&①设置界面进入系统更新的设置界面为设置模块下DeviceInfoSettings.java类,所对应preference为Device_info_settings.xml中如下:
&&&& &com.android.settings.XXUpdatePreference android:key=&system_update_settings&
&&&&&&&&& android:title=&@string/system_update_settings_list_item_title&
&&&&&&&&& android:summary=&@string/system_update_settings_list_item_summary&&
&&&&&&&&& &intent android:action=&android.settings.SYSTEM_UPDATE_SETTINGS& /&
&&&& &/com.android.settings.XXUpdatePreference&
& & & &&②我们在DeviceInfoSettings.java中对该preference进行监听,当用户触发点击事件时发出广播,XXX应用会接收该广播并启动XXX做出下一步处理。如下所示:
&&&&&&& else if (preference.getKey().equals(KEY_DMSW_UPDATE)) {
&&&&&&&&&&& // /M: for DMSW to broadcast @{
&&&&&&&&&&& Intent i = new Intent();
&&&&&&&&&&& i.setAction(&com.mediatek.DMSWUPDATE&);
&&&&&&&&&&& getActivity().sendBroadcast(i);
&&&&&&&&&&& // /@}
2.一般来说,由于Android原生态的系统更新体验一般,我们手机中的系统更新应用都是厂商定制的,也就是说我们点击系统更新时一般进入的都是厂商定制的系统更新应用,这里我们先不赘述,随后的博文中会针对原生中的系统更新应用进行一个分析。
& & ①这里我们跳过,只在厂商定制的应用中选择本地升级,然后进入设置警告界面SystemUpgradeChooserActivity.java(升级过程中,请不要移除电池,SIM卡和存储卡。。。。。。),然后我们通过点击确定并进入升级提醒界面(升级将在两到五分钟完成。。。。。。),部分代码如下:
&&&&&&&&& case R.id.okButton:
& & & &&& & & &//是否挂在SDCard
&&&&&&&&&&&&&& if (!hasSDCard()) {
&&&&&&&&&&&&&&&&&&& showToast(R.string.no_sd_card);
&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&& }
& & & & & &&& &//更新包是否存在
&&&&&&&&&&&&&& if (file == null || !file.exists()) {
&&&&&&&&&&&&&&&&&&& showToast(R.string.no_update_file);&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&& }
& & & & & & &&&//进入升级提醒界面 & &&&
&&&&&&&&&&&&&& Intent intent = new Intent(SystemUpgradeChooserActivity.this,UpdateToStart.class);
&&&&&&&&&&&&&& startActivity(intent);&&&&&&&&&
&&&&&&&&&&&&&&
& & ②此时我们通过intent进入到升级提醒界面UpdateToStart.java,这里我们点击确定开始安装更新包,详细代码如下:
buttonOkUp.setOnClickListener(new OnClickListener() {
&&&&&&&&&&&&&& @Override
&&&&&&&&&&&&&& public void onClick(View v) {
&&&&&&&&&&&&&&&&&&& try {
& & & & & & & & & & &&& &//是否挂在SDCard
&&&&&&&&&&&&&&&&&&&&&&&& if (!hasSDCard()) {
&&&&&&&&&&&&&&&&&&&&&&&&&&&&& showToast(R.string.no_sd_card);
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&&&&& }
& & & & & & & & & & & &&&//更新文件是否存在
&&&&&&&&&&&&&&&&&&&&&&&& File file = new File(Environment.getExternalStorageDirectory() + &/dload/update.zip&);
&&&&&&&&&&&&&&&&&&&&&&&& if (file == null || !file.exists()) {
&&&&&&&&&&&&&&&&&&&&&&&&&&&&& showToast(R.string.no_update_file);
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&&&&& }
& & & & & & & & & & & &&&//安装更新包,这是上层系统新的关键
&&&&&&&&&&&&&&&&&&&&&&&& RecoverySystem.installPackage(getApplicationContext(), file);
&&&&&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&&&&&& catch (Exception e) {
&&&&&&&&&&&&&&&&&&& &&& //
&&&&&&&&&&&&&&&&&&& }&&&&
&&&&&&&&&&&&&& }
&&&&&&&&& });
3.上面我们了解了,通过调用RecoverySystem.installPackage()方法尽心安装更新包。具体方法如下:
&&&& *为了安装更新包将会重启设备,此外要调用该方法需要在清单文件中增加REBOOT权限
&&&& * 参数 context 上下文
&&&& * 参数 packageFile& 封装更新包路径等信息的file对象.
&&& public static void installPackage(Context context, File packageFile)
&&&&&&& throws IOException {
&&&&&&& String filename = packageFile.getCanonicalPath();
&&&&&&& Log.w(TAG, &!!! REBOOTING TO INSTALL & + filename + & !!!&);
& & & & //参数拼接,该参数最终会写入BCB,也就是说设备重启进入Recovery模式后,Recovery.cpp将会解析该参数,并且根据参数做出操作,它将会被传入到bootcommand(context,arg)函数中去。
&&&&&&& String arg = &--update_package=& + filename +
&&&&&&&&&&& &\n--locale=& + Locale.getDefault().toString();
&&&&&&& bootCommand(context, arg);
4.下面是对bootCommand进行分析。
&&& private static void bootCommand(Context context, String arg) throws IOException {
&&&&&&&&RECOVERY_DIR.mkdirs();&&// 创建/cache/recovery目录
&&&&&&&&COMMAND_FILE.delete();&&// 删除command文件,进行初始化
&&&&&&&&LOG_FILE.delete();//删除log文件,进行初始化
&&&&&&& Log.d(TAG,&Preapre to write command: & + arg +&\n&);
&&&&&&&&WriteByFdSync(COMMAND_FILE,arg);//将参数写入到command文件中
&&&&&&& Log.d(TAG,&Success to write command: & + arg +&\n&);
&&&&&&& Log.d(TAG,&Current build type is: & + Build.TYPE +&\n&);
&&&&&&&&ReadInAndPrint(COMMAND_FILE);//读取command文件,并打印log
&&&&&&& // Having written the command file, go ahead and reboot
&&&&&&& PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);//从系统服务中获得PowerManager实例
&&&&&&& pm.reboot(&recovery&);//重启
&&&&&&& Log.d(TAG,&!!! pm.reboot failed !!!\n&);
&&&&&&& throw new IOException(&Reboot failed (no permissions?)&);
&&& 下面的方法调用流程为PowerManager:reboot(&recovery&)--&PowerManagerService:reboot(reason)
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& --&PowerManagerService:shtudownOrRebootInternal(false,confirm,reason,wait)
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& --&PowerManagerService:shutdownOrRebootInternal(...)
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& --&ShutdownThread:reboot(mContext, reason, confirm);
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& --&ShutdownThread:run():running()......
&&& @Override // Binder call
&&& public void&reboot(boolean confirm, String reason, boolean wait) {
&&&&&&& mContext.enforceCallingOrSelfPermission(android.Manifest.permission.REBOOT, null);
&&&&&&& Slog.i(TAG, &reboot call pid: & + Binder.getCallingPid() + & uid: & + Binder.getCallingUid());
&&&&&&& final long ident = Binder.clearCallingIdentity();
&&&&&&& try {
&&&&&&&&&&& shutdownOrRebootInternal(false, confirm, reason, wait);
&&&&&&& } finally {
&&&&&&&&&&& Binder.restoreCallingIdentity(ident);
&&& private void&shutdownOrRebootInternal(final boolean shutdown, final boolean confirm,
&&&&&&&&&&& final String reason, boolean wait) {
&&&&&&& if (mHandler == null || !mSystemReady) {
&&&&&&&&&&& throw new IllegalStateException(&Too early to call shutdown() or reboot()&);
&&&&&&& Runnable runnable = new Runnable() {
&&&&&&&&&&& @Override
&&&&&&&&&&& public void run() {
&&&&&&&&&&&&&&& synchronized (this) {
&&&&&&&&&&&&&&&&&&& if (shutdown) {
&&&&&&&&&&&&&&&&&&&&&&& ShutdownThread.shutdown(mContext, confirm);
&&&&&&&&&&&&&&&&&&& } else {
&&&&&&&&&&&&&&&&&&&&&&& ShutdownThread.reboot(mContext, reason, confirm);
&&&&&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&& }
&&&&&&&&&&& }
&&&&&&& };
&&&&&&& // ShutdownThread must run on a looper capable of displaying the UI.
&&&&&&& Message msg = Message.obtain(mHandler, runnable);
&&&&&&& msg.setAsynchronous(true);
&&&&&&& mHandler.sendMessage(msg);
&&&&&&& // PowerManager.reboot() is documented not to return so just wait for the inevitable.
&&&&&&& if (wait) {
&&&&&&&&&&& synchronized (runnable) {
&&&&&&&&&&&&&&& while (true) {
&&&&&&&&&&&&&&&&&&& try {
&&&&&&&&&&&&&&&&&&&&&&& runnable.wait();
&&&&&&&&&&&&&&&&&&& } catch (InterruptedException e) {
&&&&&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&& }
&&&&&&&&&&& }
&&& public static void&reboot(final Context context, String reason, boolean confirm) {
&&&&&&& mReboot =
&&&&&&& mRebootSafeMode =
&&&&&&& mRebootReason =
&&&&&&& Log.d(TAG, &reboot&);
&&&&&&& if (mSpew) {
&&&&&&&&&&& StackTraceElement[] stack = new Throwable().getStackTrace();
&&&&&&&&&&& for (StackTraceElement element : stack)
&&&&&&&&&&& {
&&&&&&&&&&&&&&& Log.d(TAG, & &&&& |----& + element.toString());
&&&&&&&&&&& }
&&&&&&& shutdownInner(context, confirm);
&&& 这里在run方法下的,running方法中将重启原因写入系统属性文件中去。
&&& 。。。。。。
&&&&&&&&&& {
&&&&&&&&&&& String reason = (mReboot ? &1& : &0&) + (mRebootReason != null ? mRebootReason : &&);
&&&&&&&&&&& SystemProperties.set(SHUTDOWN_ACTION_PROPERTY, reason);
&&& 。。。。。。
& & 最后,重启设备。
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:984998次
积分:9906
积分:9906
排名:第1713名
原创:135篇
转载:77篇
译文:13篇
评论:122条
(1)(9)(1)(3)(2)(13)(11)(9)(6)(8)(8)(6)(5)(14)(28)(89)(6)(1)(2)(2)(1)我手机充电后出现upgrade
system是什么原因
全部答案(共1个回答)
firewear upgrade的缩写,即为固件升级。用于升级手机里的相机操作系统。
折腾第一步:试图进入Recovery “上音量键+电源键+Home键”失效;电源键开机失效,ODIN“下音量键+电源键+Home键”还是正常。
只能拿到手机店去修了
  sys只是用来标明这是一个系统文件,即计算机文件扩展名,如tcpip.sys  System指的是软件系统,它可以包含一些用例,并界定系统的边界,边界之内的...
答: 怎样取消值机呢?手机APP
答: 美国苹果公司的新款手机,全触屏的智能机,在中国卖的很贵。
答: 手机购买还是找正规卖家
天猫等网站
答: 可能被设置了禁言你IP接入吧
大家还关注
确定举报此问题
举报原因(必选):
广告或垃圾信息
激进时政或意识形态话题
不雅词句或人身攻击
侵犯他人隐私
其它违法和不良信息
报告,这不是个问题
报告原因(必选):
这不是个问题
这个问题分类似乎错了
这个不是我熟悉的地区
相关问答:123456789101112131415}

我要回帖

更多关于 fwupgrade 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信