Non-exported Activities: Launched On Emulators; Securityexception On Phones
I have a non-exported activity in my project. If I try to launch it on my phone using adb: adb shell am start -n 'packagename/activityname' I get the error: java.lang.SecurityExce
Solution 1:
But, if I run the same command on an emulator, then everything works Okay. How comes?
An emulator instance runs as root by default, meaning that more system processes has root rights compared to a non-rooted device.
Consider the ps command output grep-ed with adbd and sh (i.e. adb shell ps | grep 'adbd' and adb shell ps | grep 'sh', respectively). You might see the following (with different PID and PPID on your device/emulator, of course):
Non-rooted device
USER PID PPID NAME shell 166 1 /sbin/adbd ... shell 15721 166 /system/bin/shEmulator
USERPIDPPIDNAMEroot1183 1/sbin/adbd...root2884 1183/system/bin/sh
sh process, so is its parent process adbd, is owned by root on an emulator, in contrast to the shell owner on a non-rooted device. And a root user has a "permission" to access your app's sandbox, despite the android:exported attribute set to false.
Post a Comment for "Non-exported Activities: Launched On Emulators; Securityexception On Phones"