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.SecurityException:
Permission Denial: starting Intent { ... } from null (...) not exported from uid ...
But, if I run the same command on an emulator, then everything works Okay. How comes?
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):
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
.