位置: 编程技术 - 正文

Android 4.1.2系统添加重启功能(android4.4.2升级包)

编辑:rootadmin

推荐整理分享Android 4.1.2系统添加重启功能(android4.4.2升级包),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:android os 4.1,android 4.4.2,android 4.4,安卓4.1.2,android os 4.2,android 4.4,android 4.2.2,android os 4.1,内容如对您有帮助,希望把文章链接给更多的朋友!

Android 4.1.2系统添加重启功能(android4.4.2升级包)

转自: * Create the global actions dialog. * @return A new dialog. */private GlobalActionsDialog createDialog() { // Simple toggle style if there's no vibrator, otherwise use a tri-state if (!mHasVibrator) { mSilentModeAction = new SilentModeToggleAction(); } else { mSilentModeAction = new SilentModeTriStateAction(mContext, mAudioManager, mHandler); } mAirplaneModeOn = new ToggleAction( R.drawable.ic_lock_airplane_mode, R.drawable.ic_lock_airplane_mode_off, R.string.global_actions_toggle_airplane_mode, R.string.global_actions_airplane_mode_on_status, R.string.global_actions_airplane_mode_off_status) { void onToggle(boolean on) { if (mHasTelephony && Boolean.parseBoolean( SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE))) { mIsWaitingForEcmExit = true; // Launch ECM exit dialog Intent ecmDialogIntent = new Intent(TelephonyIntents.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS, null); ecmDialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mContext.startActivity(ecmDialogIntent); } else { changeAirplaneModeSystemSetting(on); } } @Override protected void changeStateFromPress(boolean buttonOn) { if (!mHasTelephony) return; // In ECM mode airplane state cannot be changed if (!(Boolean.parseBoolean( SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE)))) { mState = buttonOn ? State.TurningOn : State.TurningOff; mAirplaneState = mState; } } public boolean showDuringKeyguard() { return true; } public boolean showBeforeProvisioning() { return false; } }; onAirplaneModeChanged(); mItems = new ArrayList<Action>(); // first: power off mItems.add( new SinglePressAction( com.android.internal.R.drawable.ic_lock_power_off, R.string.global_action_power_off) { public void onPress() { // shutdown by making sure radio and power are handled accordingly. mWindowManagerFuncs.shutdown(true); } public boolean onLongPress() { mWindowManagerFuncs.rebootSafeMode(true); return true; } public boolean showDuringKeyguard() { return true; } public boolean showBeforeProvisioning() { return true; } });我们可以看到mItems.add函数是添加一个选项,该菜单的第一个选项就是关机选项,我们可以在此之后添加重启选项,代码如下:mItems.add( new SinglePressAction( com.android.internal.R.drawable.ic_lock_power_off, R.string.global_action_reboot) { public void onPress() { // reboot mWindowManagerFuncs.reboot(); } public boolean showDuringKeyguard() { return true; } public boolean showBeforeProvisioning() { return true; } });上面的代码中使用了mWindowManagerFuncs.reboot函数和R.string.global_action_reboot资源,因此我们需要该资源并实现reboot函数。首先在frameworks/base/core/java/android/view/WindowManagerPolicy.java中添加reboot接口:/** * Interface for calling back in to the window manager that is private * between it and the policy. */public interface WindowManagerFuncs { ... /** * Switch the keyboard layout for the given device. * Direction should be &#;1 or -1 to go to the next or previous keyboard layout. */ public void switchKeyboardLayout(int deviceId, int direction); public void shutdown(); public void reboot(); public void rebootSafeMode();}然后在frameworks/base/services/java/com/android/server/wm/WindowManagerService.java中实现该接口:// Called by window manager policy. Not exposed externally.@Overridepublic void shutdown() { ShutdownThread.shutdown(mContext, true);}// Called by window manager policy. Not exposed externally.@Overridepublic void reboot() { ShutdownThread.reboot(mContext, null, true);}// Called by window manager policy. Not exposed externally. @Overridepublic void rebootSafeMode() { ShutdownThread.rebootSafeMode(mContext, true);}接下来,为了在按下重启选项之后,能出现”重启“之类的提示,还需要修改frameworks/base/services/java/com/android/server/pm/ShutdownThread.java中的shutdownInner函数和beginShutdownSequence函数:static void shutdownInner(final Context context, boolean confirm) { // ensure that only one thread is trying to power down. // any additional calls are just returned synchronized (sIsStartedGuard) { if (sIsStarted) { Log.d(TAG, "Request to shutdown already running, returning."); return; } } final int longPressBehavior = context.getResources().getInteger( com.android.internal.R.integer.config_longPressOnPowerBehavior); final int resourceId = mRebootSafeMode ? com.android.internal.R.string.reboot_safemode_confirm : (longPressBehavior == 2 ? com.android.internal.R.string.shutdown_confirm_question : (mReboot ? com.android.internal.R.string.reboot_confirm : com.android.internal.R.string.shutdown_confirm)); Log.d(TAG, "Notifying thread to start shutdown longPressBehavior=" &#; longPressBehavior); if (confirm) { final CloseDialogReceiver closer = new CloseDialogReceiver(context); final AlertDialog dialog = new AlertDialog.Builder(context) .setTitle(mRebootSafeMode ? com.android.internal.R.string.reboot_safemode_title : (mReboot ? com.android.internal.R.string.reboot : com.android.internal.R.string.power_off)) .setMessage(resourceId) .setPositiveButton(com.android.internal.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { beginShutdownSequence(context); } }) .setNegativeButton(com.android.internal.R.string.no, null) .create(); closer.dialog = dialog; dialog.setOnDismissListener(closer); dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG); dialog.show(); } else { beginShutdownSequence(context); }}private static void beginShutdownSequence(Context context) { synchronized (sIsStartedGuard) { if (sIsStarted) { Log.d(TAG, "Shutdown sequence already running, returning."); return; } sIsStarted = true; } // throw up an indeterminate system dialog to indicate radio is // shutting down. ProgressDialog pd = new ProgressDialog(context); pd.setTitle(context.getText(com.android.internal.R.string.power_off)); pd.setMessage(context.getText(com.android.internal.R.string.shutdown_progress)); pd.setIndeterminate(true); pd.setCancelable(false); pd.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG); pd.show(); sInstance.mContext = context; sInstance.mPowerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE); // make sure we never fall asleep again sInstance.mCpuWakeLock = null; try { sInstance.mCpuWakeLock = sInstance.mPowerManager.newWakeLock( PowerManager.PARTIAL_WAKE_LOCK, TAG &#; "-cpu"); sInstance.mCpuWakeLock.setReferenceCounted(false); sInstance.mCpuWakeLock.acquire(); } catch (SecurityException e) { Log.w(TAG, "No permission to acquire wake lock", e); sInstance.mCpuWakeLock = null; } // also make sure the screen stays on for better user experience sInstance.mScreenWakeLock = null; if (sInstance.mPowerManager.isScreenOn()) { try { sInstance.mScreenWakeLock = sInstance.mPowerManager.newWakeLock( PowerManager.FULL_WAKE_LOCK, TAG &#; "-screen"); sInstance.mScreenWakeLock.setReferenceCounted(false); sInstance.mScreenWakeLock.acquire(); } catch (SecurityException e) { Log.w(TAG, "No permission to acquire wake lock", e); sInstance.mScreenWakeLock = null; } } // start the thread that initiates shutdown sInstance.mHandler = new Handler() { }; sInstance.start();}至此关于代码部分的改动全部完成,接下来就需要添加使用到的资源了,就是前面用到的字符串。首先需要在frameworks/base/core/res/res/values/strings.xml中添加一下字符串:<string name="reboot">Reboot</string><string name="reboot_progress">Rebootu</string><string name="reboot_confirm" product="tablet">Your tablet will reboot.</string><string name="reboot_confirm" product="default">Your phone will reboot.</string><!-- label for item that reboot in phone options dialog --><string name="global_action_reboot">Reboot</string>而后需要在frameworks/base/core/res/res/values/public.xml中声明这些资源,否则编译的时候会出现找不到该资源的错误。<java-symbol type="string" name="reboot" /><java-symbol type="string" name="reboot_confirm" /><java-symbol type="string" name="reboot_progress" /><java-symbol type="string" name="global_action_reboot" />至此,全部修改完成,编译烧写即可。

Android设计模式之单例模式 Singleton 一.概述单例模式是设计模式中最简单的一种,但是它没有设计模式中的那种各种对象之间的抽象关系,所以有人不认为它是一种模式,而是一种实现技巧.单

Android ListViewitem滑动出现删除按钮 我自己一个人弄的公司的产品客户端,所以还是想记录下来以免忘记或者丢失...在我的上一篇博文(点击打开链接)是一个文件管理的东西,基础组件也是

Android 4.1.2为通知栏添加wifi开关 摘自:

标签: android4.4.2升级包

本文链接地址:https://www.jiuchutong.com/biancheng/379574.html 转载请保留说明!

上一篇:RecyclerView基本使用(recycleview使用)

下一篇:Android设计模式之单例模式 Singleton(android设计模式的应用场景)

  • 年度减免税限额
  • 销售收入怎么计算销项税额
  • 居间费用如何纳税
  • 企业为自然人什么意思
  • 什么是增值税一般纳税人
  • 商业承兑汇票未到期贴现
  • 收到的普通发票需要认证吗
  • 个体户开运输发票怎么开
  • 房地产企业预缴增值税怎么计算
  • 可变股权转让对价会计处理怎么做?
  • 账外房产按评估入账怎么交税
  • 非正常损失进项税额转出计算公式
  • 财务报表与汇算报表区别
  • 一般纳税人开具房屋租赁费税率
  • 代开的专用发票附加税该怎么申报?
  • 普通发票年份代码有什么具体含义?
  • 对方公司开支票怎么办
  • 公司0转让要交哪些税
  • 工会发放慰问品总金额超过多少需要比价
  • 员工培训费应该怎么算
  • 哪些税计入原材料费用
  • 可转换公司债券可以在一定程度上解决的问题是
  • 外购的礼品送客户怎么做分录小规模
  • thinkphp怎么用
  • 电脑legacy是什么意思
  • 酒店需要的原材料和包装费有哪些
  • 夜晚的地球 (© NASA)
  • 刷票系统能看出来吗
  • 餐费发票怎么做账务处理
  • 巴尼奥斯附近的阿格杨瀑布
  • php正则替换函数怎么写
  • vue中computed作用
  • vue3.0中的ref
  • 个人的无形资产
  • python如何设置窗口背景色
  • 会计账的银行存款与银行存款不一致 是属于账账不符吗
  • 纳什理论是什么
  • 劳务公司获奖感言简短
  • 劳务费和工程劳务费有区别
  • 织梦专题页模板
  • 补开上年发票的税务处理要怎么做?
  • 帝国cms首页调用显示标题图片代码
  • 母公司借款给子公司如何做账
  • 管理费用的范畴
  • 资产负债表中其他流动资产包括哪些
  • 小微企业的认定标准企业所得税
  • 住房补贴需要交个税吗
  • 工程进度节点奖励考核
  • 收取的招标资料费增值税税率
  • 在建工程如何结转到产品
  • 合并报表时抵消内部交易包含的未实现损益的影响包括
  • 住宿发票项目有哪些
  • 月末未完工半成品的分录
  • 企业取得土地使用权会计处理
  • 旅行社开什么票
  • 公司基本户可以取现金吗
  • Mac下mysql 5.7.13 安装配置方法图文教程
  • win10文字模糊怎么调整
  • u盘安装winpe
  • 事件查看器中"TermService" 服务的性能库问题处理
  • camrec是什么文件
  • linux ftpd
  • centos怎么安装软件包
  • lsass exe
  • android中的布局分为6种,分别是
  • centos上安装邮件服务器
  • nodejs 异步任务队列
  • npm安装nodemodules
  • c#委托的理解
  • jqueryui dialog
  • Unity3d C# Socket 下载文件 (同步向)
  • javascript的返回值
  • python中创建类对象
  • 农村集体土地承包法
  • 智云发票集中管理云平台官网
  • 增值税税控开票软件
  • 减免税的三种方式
  • 福建地税网上办事大厅
  • 郑州国税局投诉电话
  • 江苏国税局官网登录
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设