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?
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 outputgrep
-ed withadbd
andsh
(i.e.adb shell ps | grep 'adbd'
andadb shell ps | grep 'sh'
, respectively). You might see the following (with differentPID
andPPID
on your device/emulator, of course):Non-rooted device
Emulator
sh
process, so is its parent processadbd
, is owned byroot
on an emulator, in contrast to theshell
owner on a non-rooted device. And aroot
user has a "permission" to access your app's sandbox, despite theandroid:exported
attribute set tofalse
.