位置: 编程技术 - 正文

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设计模式的应用场景)

  • 研发支出属于什么现金流量项目
  • 车辆购置税退税计算
  • 纳税怎么算
  • 律师异地立案费用
  • 利润总额和净利润相同说明什么
  • 无营业执照是否可以先办场所码
  • 预收账款怎样清零
  • 劳务公司核定征收怎么交税的
  • 专票红冲后还需重新开票吗
  • 零申报企业年报资产总额怎么填
  • 税务机关退水利基金怎么做账?
  • 共同投资叫什么
  • 转销无形资产的处置流程
  • 劳务派遣专用发票超过9万怎么办理
  • 处置固定资产增值税税率
  • 酒店行业税负率怎么算
  • 境外个人汇入汇款规定
  • 现金流量表的填写视频
  • 工会财务任务是什么
  • 贷款服务开票开具要求
  • 固定资产出租需要交什么税
  • win10专业版如何改为家庭版
  • 酒店布草间有摄像头吗
  • 配股的基本含义是什么
  • wordpress访问速度优化
  • 电脑legacy是什么意思
  • 暂估入库怎么暂估
  • php设计思路
  • sec是什么文件
  • php中的类型提示是什么
  • 公司整体收购缴税
  • 固定资产一次性扣除申报表怎么填
  • php怎么读取txt
  • vue学起来困难吗
  • spring获取bean的完全限定类名
  • react生命周期详解
  • 休产假期间社保个人部分怎么办
  • 以前年度损益调整是什么意思
  • 补交当年的增值税
  • day02-HTML02
  • 事业单位结余资金管理办法
  • 承兑汇票提前承兑手续费
  • 进项税额转出可以为负数吗
  • 资本公积根据什么填列
  • 借条这样写才有效
  • 工程咨询服务发展的指导意见有哪些
  • 发票可以付款前开吗
  • 无偿调入的固定资产怎么记账
  • 发票使用范围指什么
  • MySQL中使用FREDATED引擎实现跨数据库服务器、跨实例访问
  • 收回应收账款赊账怎么算
  • 发放奖金怎么做账
  • 合理损耗怎么算
  • 哪些业务可以开专票
  • 对公账户提取备用金怎么做账
  • 保险公司业务员误导客户的后果
  • 会计档案销毁方案怎么写
  • ug实体命令怎么使用
  • linux不常用命令
  • centos7安装完成后无法启动
  • linux做代理服务器的方法
  • mac终端输入代码有什么影响
  • 一岁的宝宝可以喝枸杞水吗
  • load its core dll
  • linux系统fedora
  • 联想笔记本win7装win10
  • linux系统有哪几个
  • 使用css实现全兼容的方法
  • jQuery实现ajax调用WCF服务的方法(附带demo下载)
  • nodejs excel转json
  • python中的__dict__
  • jquery validator
  • activity的作用和生命周期
  • jquery删除dom
  • python xml 解析
  • 快速解决偏头痛的6个方法
  • Android应用程序可以直接在ios中安装运行吗
  • jQuery ajax应用总结
  • 内蒙古国税局官网
  • 发生技术入股递增怎么办
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设