android safe mode

转载 2016年05月31日 10:20:48

http://android.stackexchange.com/questions/131188/entering-safe-mode-from-adb-shell

My question is similar to this one, but I don’t necessarily have a powered off device.

How can I enter Android’ safe mode (or make it boot into safe mode the next time) from within my recovery image?

I suppose it is possible to mimic the actions the actual Android system would do when you select safe mode from the reboot menu. However, I don’t even know what selecting safe mode actually causes Android to do with the system.

adb recovery-mode safe-mode
shareimprove this question
asked Dec 10 ‘15 at 12:59

Frederick Nord
1536
add a comment
1 Answer
active oldest votes
up vote
4
down vote
accepted
Note: The solution is tested on Android 4.2.1, 5.0.2 and 5.1.1.

The value for the system property persist.sys.safemode determines whether the phone should boot into safe mode or in normal mode.

When booted into Android OS, provided root access, the value can be changed as

adb shell su -c 'setprop persist.sys.safemode 1'
adb shell su -c 'echo "1" > /data/property/persist.sys.safemode' #alternative 

When booted into a custom recovery, given the data and optionally, system partition are mounted, do

adb shell busybox printf "1" > /data/property/persist.sys.safemode         #works if recovery has Busybox. If Android OS has busybox then system/xbin/busybox would work
adb shell echo "1" > /data/property/persist.sys.safemode                   #alternative
adb shell chmod 600 /data/property/persist.sys.safemode    

#required; changes the permission of file to rw——-, identical to rest of the files under /data/property
It is to be noted that, if you’ve never booted into safe mode since last factory reset, the file persist.sys.safemode wouldn’t be found.

Android resets the content of said file at every reboot, so you need not to worry about getting stuck at safe mode. However, for the purpose of fail-safe requirement, change the value to 0 or empty the file (NULL), should you ever get stuck.

In a nutshell, the property that you set is stored in a file, hence it remains persistent when you shutdown the device. You can see your value inside the file from recovery mode, provided that you’ve not booted into Android again after editing the property. Now, once you begin to boot into Android OS, Android et al reads the file, and based on the content, prepares the safe/ordinary mode for you. After reading the file, it resets the content of the file, so the next time you reboot, it would always be in ordinary mode.

I, in my experiments, noticed that Android would boot into safe mode even if the value is any positive or negative integer or even a decimal value.

I got a good hint from source code of ShutdownThread.java that safe mode requires a system property to be set. However, I reached the final conclusion using a comment by pylerSM and a post from ZiT777.

shareimprove this answer
edited Dec 10 ‘15 at 20:28
answered Dec 10 ‘15 at 19:41

Firelord
9,64482768

You can test this on your own. Set the prop, reboot the device but pull out the battery at OEM logo. Boot into recovery and check the file’s content. Now boot into Android normally but run adb shell getprop | grep persist.sys.safemode or adb shell su -c echo /data/property/persist.sys.safemode continuously during boot animation. You would see that the value changes from 1 to nothing (NULL). // In fact, full restart is not needed to boot into safe mode. Once the prop is set, even a soft reset would boot into safe mode. – Firelord Dec 10 ‘15 at 20:06

iphone 进入安全模式 怎么解决?exit safe mode解决方法

很多果粉问iphone5s exit safe mode怎么解决?是什么意思?绿茶小编带来了iphone5s出现exit safe mode解决方法以及相关介绍,希望对各位机友有所帮助。 ...
  • u011661836
  • u011661836
  • 2016年05月31日 18:27
  • 1822

Hbase分布式安装

1 Hbase集群需要依赖Hadoop集群和zookeeper集群 ,首先需要确保上述两项安装成功。(hbase对hadoop的版本有要求,具体匹配信息可以参考hbase官方文档,本文使用hadoop...
  • majian_1987
  • majian_1987
  • 2014年05月05日 13:54
  • 800

HDFS block丢失过多进入安全模式(safe mode)的解决方法

HDFS block丢失过多进入安全模式(Safe mode)的解决方法 背景及现象描述(Background and Symptom)    因磁盘空间不足,内存不足,系统掉电等其他原因导致d...
  • czp11210
  • czp11210
  • 2017年08月04日 22:02
  • 626

Hadoop之机房down机后...

由于公司机房异常断电,导致测试环境的hadoop集群数据全部down掉。重启hadoop集群后,访问:http://xxx.xxx.xxx.xx:50070/dfshealth.html NameNo...
  • qianshangding0708
  • qianshangding0708
  • 2015年08月17日 12:33
  • 4249

SAFe 从概念到实践 开发人员的“敏捷”之我见

敏捷开发并不是一个新概念,在过去十多年里,敏捷开发方法论已成为国外开发团队的主流思想。敏捷开发真正走进中国,是从5年前开始。因为敏捷方法论中提到了一些在传统软件开发方法中没有注意到的思想,这些思想是真...
  • bamboolsu
  • bamboolsu
  • 2015年06月19日 11:21
  • 2424

版本控制软件Visual Source safe使用小结 (配合上文)

安装sourcesafe软件 1.创建Source Safe服务器步骤              a.运行Visual Source safe 6.0 Admin,菜单Tools下选择Create...
  • GoodShot
  • GoodShot
  • 2016年01月04日 22:56
  • 2730

Android NDK: 怎么减少APK大小

Android NDK: How to Reduce Binaries Size – The Algolia Blog  Julien | January 10, 2013 | Pr...
  • u013316124
  • u013316124
  • 2015年12月09日 17:30
  • 209

大型敏捷框架SAFe的Program层

敏捷开发Scrum加上XP已经在小团队领域是所向无敌,一统江湖。 SAFe是在探讨大规模的敏捷开发如何进行。Scrum of Scrum解决了如何让多个Scrum  team协调一致,听指挥的开发...
  • IBelieve1974
  • IBelieve1974
  • 2017年03月16日 15:53
  • 529

大规模敏捷框架SAFe版本4与版本3区别

1. 原来的Arch Epic改名叫Enabler 2.  新增了 VSE (Value Stream Engineer)  The chief feature scrum master facili...
  • IBelieve1974
  • IBelieve1974
  • 2017年03月16日 16:51
  • 1291

模拟银行家算法实验-----一不小心暴露自己是河北工业大学的

操作系统----模拟银行家算法         简介:2015级,大三狗,菜,人傻,哈哈,不过喜欢编程啦。贴个实验时做的算法,挺有意思。 如有需求,请做参考,什么换换参数名字呀,函数名字呀,调换代码...
  • i_head_no_back
  • i_head_no_back
  • 2017年12月27日 21:22
  • 118
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:android safe mode
举报原因:
原因补充:

(最多只允许输入30个字)