android safe mode

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

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
add a comment
1 Answer
active oldest votes
up vote
down vote
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 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


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


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集群后,访问: NameNo...
  • qianshangding0708
  • qianshangding0708
  • 2015年08月17日 12:33
  • 4249

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

  • 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


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


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