Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/203.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 非出口活动:在模拟器上启动;手机上的安全例外_Android_Android Activity_Android Emulator_Adb_Root - Fatal编程技术网

Android 非出口活动:在模拟器上启动;手机上的安全例外

Android 非出口活动:在模拟器上启动;手机上的安全例外,android,android-activity,android-emulator,adb,root,Android,Android Activity,Android Emulator,Adb,Root,我的项目中有一个非导出活动 如果我尝试在手机上使用adb: adb shell am start -n "packagename/activityname" 我得到一个错误: java.lang.SecurityException: Permission Denial: starting Intent { ... } from null (...) not exported from uid ... 但是,如果我在模拟器上运行相同的命令,那么一切正常。怎么会这样 但是,如果我在模拟器上运行相

我的项目中有一个非导出活动

如果我尝试在手机上使用
adb

adb shell am start -n "packagename/activityname"
我得到一个错误:

java.lang.SecurityException:
Permission Denial: starting Intent { ... } from null (...) not exported from uid ...
但是,如果我在模拟器上运行相同的命令,那么一切正常。怎么会这样

但是,如果我在模拟器上运行相同的命令,那么一切正常。怎么会这样

默认情况下,emulator实例以root运行,这意味着与非根设备相比,有更多的系统进程具有root权限

考虑
ps
命令输出
grep
-ed与
adbd
sh
(即
adb shell ps | grep'adbd'
adb shell ps | grep'sh'
)。您可能会看到以下内容(当然,在您的设备/模拟器上使用不同的
PID
PPID
):

  • 非根设备

    USER     PID   PPID  NAME
    shell    166   1     /sbin/adbd
    ...
    shell    15721 166   /system/bin/sh
    
  • 仿真器

    USER     PID   PPID  NAME
    root     1183  1     /sbin/adbd
    ...
    root     2884  1183  /system/bin/sh
    

sh
进程及其父进程
adbd
,在仿真器上属于
root
,而在非root设备上属于
shell
所有者。尽管属性设置为
false

adb shell
运行的用户帐户在模拟器AFAIK上拥有更大的权限,但
root
用户拥有访问应用程序沙箱的“权限”。