Determine if running on a rooted device

后端 未结 24 2560
無奈伤痛
無奈伤痛 2020-11-22 06:43

My app has a certain piece of functionality that will only work on a device where root is available. Rather than having this feature fail when it is used (and then show an a

24条回答
  •  萌比男神i
    2020-11-22 06:50

    if [[ "`adb shell which su | grep -io "permission denied"`" != "permission denied" ]]; then
       echo "Yes. Rooted device."
     else
       echo "No. Device not rooted. Only limited tasks can be performed. Done."
        zenity --warning --title="Device Not Rooted" --text="The connected Android Device is NOT ROOTED. Only limited tasks can be performed." --no-wrap
    fi
    

提交回复
热议问题