appactions-fitness-kotlin
appactions-fitness-kotlin copied to clipboard
java.lang.SecurityException: Caller must own content://.....MySliceProvider
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;
}`
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
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.