Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

插件获取不到插件manifest声明的权限列表 #824

Closed
Tomgogo opened this issue Feb 23, 2022 · 6 comments · Fixed by #835
Closed

插件获取不到插件manifest声明的权限列表 #824

Tomgogo opened this issue Feb 23, 2022 · 6 comments · Fixed by #835

Comments

@Tomgogo
Copy link

Tomgogo commented Feb 23, 2022

插件跟宿主运行在主进程,在插件manifest文件声明了一些权限(有permission和uses-permission),但在插件调用如下getPermissions获取的权限列表为空,宿主和插件包名一样,包名传的没问题。请问插件是不支持获取权限列表吗?
PluginApp extends Application() {
override void onCreate() {
super.onCreate();
PluginContext.setAppContext(this);
}
}
public PermissionInfo[] getPermissions(String packageName){
return PluginContext.getAppContext().getPackageManager().getPackageInfo(
packageName, 4096).permissions;//requestedPermissions获取也为null
}

@BBNO
Copy link

BBNO commented Feb 25, 2022

请问这个问题怎么解决? @shifujun

@shifujun
Copy link
Collaborator

你们可能是刚接触Android插件框架这个领域。目前还没有技术能使插件Manifest中注册的权限生效。

Android系统不允许动态更新Manifest中的内容。所以所有的插件框架都是在解耦代码逻辑和Manifest的关系,使插件在固定的Manifest下尽可能动态更新其他的部分。

@BBNO
Copy link

BBNO commented Feb 25, 2022

但是我在宿主中Manifest注册了所需要的权限,还是会报权限null的问题。 @shifujun

@BBNO
Copy link

BBNO commented Feb 25, 2022

报错日志:
java.lang.IllegalStateException: Runtime.hostContext.pack…ONS).requestedPermissions must not be null

shifujun added a commit to shifujun/Shadow that referenced this issue Feb 25, 2022
不返回插件Manifest中注册的权限,因为它们也不会生效。

Tencent#824
@shifujun
Copy link
Collaborator

getPackageInfo获取宿主的权限,可以先试一下这样修改:shifujun@ca32b3e

我还没有测试。

@Tomgogo
Copy link
Author

Tomgogo commented Feb 28, 2022

报错日志: java.lang.IllegalStateException: Runtime.hostContext.pack…ONS).requestedPermissions must not be null

getPackageInfo获取宿主的权限,可以先试一下这样修改:shifujun@ca32b3e

我还没有测试。

其实就是要这样的实现,上面没有表述太清楚,插件中的权限宿主中也会声明。

shifujun added a commit that referenced this issue Mar 1, 2022
不返回插件Manifest中注册的权限,因为它们也不会生效。

#824
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants