Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

java.lang.SecurityException: Caller must own content://.....MySliceProvider #9

Open
donkii opened this issue Jul 2, 2019 · 2 comments

Comments

@donkii
Copy link

donkii commented Jul 2, 2019

I am trying to implement assistant into my own app, I am getting

java.lang.SecurityException: Caller must own content://at.oeamtc.android.oeamtclib.MySliceProvider

This is the part where it is crashing, on SliceManager.getInstance(context)
.grantSlicePermission(assistantPackage, sliceProviderUri);

`private void grantAssistantPermissions() {
Context context = getApplicationContext();
Uri sliceProviderUri =
new Uri.Builder()
.scheme(ContentResolver.SCHEME_CONTENT)
.authority(OeamtcSliceProvider.SLICE_AUTHORITY)
.build();

    String assistantPackage = getAssistantPackage(context);
    if (assistantPackage == null) {
        return;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        SliceManager.getInstance(context)
                .grantSlicePermission(assistantPackage, sliceProviderUri);
    }
}

private String getAssistantPackage(Context context) {
    PackageManager packageManager = context.getPackageManager();
    List<ResolveInfo> resolveInfoList = packageManager.queryIntentServices(
            new Intent(VoiceInteractionService.SERVICE_INTERFACE), 0);
    if (resolveInfoList.isEmpty()) {
        return null;
    }
    return resolveInfoList.get(0).serviceInfo.packageName;
}`
@dzuluaga
Copy link
Contributor

dzuluaga commented Jul 2, 2019

Please try first Fitness App and make sure you're able to run display the Slice successfully. This exercise will help you isolate what step might be missing in your app. My hunch is that one of the steps in the requirements is missing. https://github.com/actions-on-google/appactions-fitness-kotlin#requirements

If after running these steps you're still facing issues, we would have established a baseline to troubleshoot. Thanks!

Issue reported and handled by Engineering.
https://issuetracker.google.com/issues/137210421
https://stackoverflow.com/questions/56848225/java-lang-securityexception-caller-must-own-content-mysliceprovider?noredirect=1#comment100278874_56848225

@donkii
Copy link
Author

donkii commented Jul 3, 2019

With both Fitness App and my own app, when i try to run slices, google assistant is stuck loading: imgur.com/oFEgYZ3 . Opening deeplinks is working fine on both. And when I try: "Start running in fit actions" only google results are showing, so my only way to make it work is using App Actions Test Tool.

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

No branches or pull requests

2 participants