Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/312.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
Java 颤振Android隔离进程JNI服务失败:EACCES(权限被拒绝)_Java_Android_Flutter_Java Native Interface - Fatal编程技术网

Java 颤振Android隔离进程JNI服务失败:EACCES(权限被拒绝)

Java 颤振Android隔离进程JNI服务失败:EACCES(权限被拒绝),java,android,flutter,java-native-interface,Java,Android,Flutter,Java Native Interface,是否有办法避免从颤振活动继承的不必要的权限要求? FileUtils: Failed to chmod(/data/user/0/com.example.demo/app_flutter): android.system.ErrnoException: chmod failed: EACCES (Permission denied) 目标是使用JNI从颤振加载一个隔离的过程。 该库有一个抽象类com.foo.bar.MyClass,它将在构造函数中调用startService() public

是否有办法避免从颤振活动继承的不必要的权限要求?

FileUtils: Failed to chmod(/data/user/0/com.example.demo/app_flutter): android.system.ErrnoException: chmod failed: EACCES (Permission denied)
目标是使用JNI从颤振加载一个隔离的过程。

该库有一个抽象类
com.foo.bar.MyClass
,它将在构造函数中调用
startService()

public class MyClass {
    private Context mContext;
    private MyService mServiceBinder;

    private boolean mBound;

    private ServiceConnection mConnection = new ServiceConnection() {
        public void onServiceConnected(ComponentName className, IBinder iBinder) {
            mService = MyService.Stub.asInterface(iBinder);
            mBound = true;
        }

        public void onServiceDisconnected(ComponentName className) {
            mService = null;
            mBound = false;
        }

    };

    public MyClass(Context context) {
        mContext = context;

        Intent intent = new Intent(mContext, MyService.class);
        boolean bind_rt = mContext.bindService(intent, mConnection, mContext.BIND_AUTO_CREATE);
        if (bind_rt) {
            mContext.startService(intent);
        }
    }
}
MyService
将加载
libhello jni.so
对于
int intFromJNI(int模式)

同样的AAR也适用于Kotlin/Java项目,但会在颤振演示项目中产生问题

隔离进程的服务由ActivityManager加载:

1188  1210 I ActivityManager: Start proc 9700:com.example.demo/u0i310 for service com.example.demo/com.foo.bar.MyService
9700  9700 I om.example.dem: Late-enabling -Xcheck:jni
9700  9700 W om.example.demo: type=1400 audit(0.0:107772): avc: denied { getattr } for path="/data/data/com.example.demo" dev="sda45" ino=7077964 scontext=u:r:isolated_app:s0:c54,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c188,c258,c512,c768 tclass=dir permissive=0
在logcat中,我们可以看到
app\u flift
的权限问题,而friend导致了失败

9700  9716 W FileUtils: Failed to chmod(/data/user/0/com.example.demo/app_flutter): android.system.ErrnoException: chmod failed: EACCES (Permission denied)
9700  9700 D com.foo.bar.MyClass: onBind()
9700  9718 I ResourceExtractor: No extracted resources found
9700  9700 W com.example.demo: type=1400 audit(0.0:107773): avc: denied { getattr } for comm=4173796E635461736B202331 path="/data/data/com.example.demo" dev="sda45" ino=7077964 scontext=u:r:isolated_app:s0:c54,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c188,c258,c512,c768 tclass=dir permissive=0
9700  9700 I chatty  : uid=99310(u0_i310) com.example.demo identical 5 lines
9700  9700 W com.example.demo: type=1400 audit(0.0:107779): avc: denied { getattr } for comm=4173796E635461736B202331 path="/data/data/com.example.demo" dev="sda45" ino=7077964 scontext=u:r:isolated_app:s0:c54,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c188,c258,c512,c768 tclass=dir permissive=0
9700  9718 W ResourceExtractor: Failed to write resource timestamp
9700  9716 W ContextImpl: Failed to ensure /data/user/0/com.example.demo/files: mkdir failed: EACCES (Permission denied)
9700  9716 W ContextImpl: Failed to ensure /data/user/0/com.example.demo/code_cache: mkdir failed: EACCES (Permission denied)
9700  9716 W ContextImpl: Failed to update user.inode_code_cache: stat failed: EACCES (Permission denied)
9700  9716 W FileUtils: Failed to chmod(/data/user/0/com.example.demo/app_flutter): android.system.ErrnoException: chmod failed: EACCES (Permission denied)

多谢各位! -乔尔

9700  9716 W FileUtils: Failed to chmod(/data/user/0/com.example.demo/app_flutter): android.system.ErrnoException: chmod failed: EACCES (Permission denied)
9700  9700 D com.foo.bar.MyClass: onBind()
9700  9718 I ResourceExtractor: No extracted resources found
9700  9700 W com.example.demo: type=1400 audit(0.0:107773): avc: denied { getattr } for comm=4173796E635461736B202331 path="/data/data/com.example.demo" dev="sda45" ino=7077964 scontext=u:r:isolated_app:s0:c54,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c188,c258,c512,c768 tclass=dir permissive=0
9700  9700 I chatty  : uid=99310(u0_i310) com.example.demo identical 5 lines
9700  9700 W com.example.demo: type=1400 audit(0.0:107779): avc: denied { getattr } for comm=4173796E635461736B202331 path="/data/data/com.example.demo" dev="sda45" ino=7077964 scontext=u:r:isolated_app:s0:c54,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c188,c258,c512,c768 tclass=dir permissive=0
9700  9718 W ResourceExtractor: Failed to write resource timestamp
9700  9716 W ContextImpl: Failed to ensure /data/user/0/com.example.demo/files: mkdir failed: EACCES (Permission denied)
9700  9716 W ContextImpl: Failed to ensure /data/user/0/com.example.demo/code_cache: mkdir failed: EACCES (Permission denied)
9700  9716 W ContextImpl: Failed to update user.inode_code_cache: stat failed: EACCES (Permission denied)
9700  9716 W FileUtils: Failed to chmod(/data/user/0/com.example.demo/app_flutter): android.system.ErrnoException: chmod failed: EACCES (Permission denied)