Hi,
I'm playing with calling Java from Tasker, so far it looks fairly convenient to use but I stumbled upon a permissionning issue when trying to send an intent. I know that Tasker has built-in functionality for this but perhaps this problem is not intent-specific. Moreover the same should have been solved in Tasker somehow. Any ideas?
Here is the code:
J (5)
A1: Java Function [ Return:i Class Or Object:Intent Function:new
{Intent} () Param:"nl.mpcjanssen.simpletask.START_WITH_FILTER" Param: Param: Param: Param: ]
A2: Java Function [ Return: Class Or Object:i Function:setAction
{Intent} (String) Param:"nl.mpcjanssen.simpletask.START_WITH_FILTER" Param: Param: Param: Param: ]
A3: Java Function [ Return: Class Or Object:i Function:putExtra
{Intent} (String, String) Param:"SORTS" Param:"+!completed" Param: Param: Param: ]
A4: Java Function [ Return: Class Or Object:i Function:addCategory
{Intent} (String) Param:"android.intent.category.DEFAULT" Param: Param: Param: Param: ]
A5: [X] Java Function [ Return:(ActivityManager)am Class Or Object:CONTEXT Function:getSystemService
{Object} (String) Param:"activity" Param: Param: Param: Param: ]
A6: [X] Java Function [ Return: Class Or Object:am Function:switchUser
{boolean} (int) Param:-2 Param: Param: Param: Param: ]
A7: Java Function [ Return: Class Or Object:CONTEXT Function:startActivity
{} (Intent) Param:i Param: Param: Param: Param: ]
In logcat I can see the following:
12-31 19:24:01.076 1236 1404 I InputReader: Touch event's action is 0x1 (deviceType=0) [pCnt=1, s=] when=3221957244000
12-31 19:24:01.076 1236 1403 I InputDispatcher: Delivering touch to: action: 0x1, toolType: 1
12-31 19:24:01.076 1236 2752 W ActivityManager: Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL
12-31 19:24:01.086 1236 2752 E DatabaseUtils: Writing exception to parcel
12-31 19:24:01.086 1236 2752 E DatabaseUtils: java.lang.SecurityException: Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL|
12-31 19:24:01.086 1236 2752 E DatabaseUtils: at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:15031)
12-31 19:24:01.086 1236 2752 E DatabaseUtils: at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:2492)
12-31 19:24:01.086 1236 2752 E DatabaseUtils: at com.android.providers.settings.SettingsProvider.call(SettingsProvider.java:688)
12-31 19:24:01.086 1236 2752 E DatabaseUtils: at android.content.ContentProvider$Transport.call(ContentProvider.java:325)
12-31 19:24:01.086 1236 2752 E DatabaseUtils: at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:275)
12-31 19:24:01.086 1236 2752 E DatabaseUtils: at android.os.Binder.execTransact(Binder.java:404)
12-31 19:24:01.086 1236 2752 E DatabaseUtils: at dalvik.system.NativeStart.run(Native Method)
12-31 19:24:01.166 6755 18099 W Tasker : 19.24.01#E: warning: Java Function: java.lang.reflect.InvocationTargetException
I know that Tasker has built-in functionality for this but perhaps this problem is not intent-specific. Moreover the same should have been solved in Tasker somehow. Any ideas?
I know that Tasker has built-in functionality for this but perhaps this problem is not intent-specific. Moreover the same should have been solved in Tasker somehow. Any ideas?
If I remember right, android.permission.INTERACT_ACROSS_USERS_FULL is only granted to system apps.
Yes, google says it's granted only to system apps. I am wondering why Tasker does not get the same error when sending intents.
Yes, google says it's granted only to system apps. I am wondering why Tasker does not get the same error when sending intents.
Tasker doesn't have any function to set user.
I see, Tasker does not set user. Then the questions is why action below works? Does it have anything to do with context used in my Java calls or something like that? Essentially both should do the same thing.A1: Send Intent [ Action:nl.mpcjanssen.simpletask.START_WITH_FILTER Cat:Default Mime Type: Data: Extra:SORTS:+!completed Extra: Package: Class: Target:Activity ]
I see, Tasker does not set user. Then the questions is why action below works? Does it have anything to do with context used in my Java calls or something like that? Essentially both should do the same thing.A1: Send Intent [ Action:nl.mpcjanssen.simpletask.START_WITH_FILTER Cat:Default Mime Type: Data: Extra:SORTS:+!completed Extra: Package: Class: Target:Activity ]
Sorry, I don't understand why it wouldn't since it's apparently an intent to a 3rd Party app ?
I had assumed the permission denial was coming from the switchUser call at A6.
I had assumed the permission denial was coming from the switchUser call at A6.
In fact I'm sure of it, since -2 is the parameter and mention in the error.
It seems my original report caused some confusion. I attempted to switch users after I got that permission denial error. As you can see below, -2 appears even for simple startActivity call i.e.for action
Ah, I finally get it. You are asking why one way of sending the intent doesn't do that :-)
Maybe it's due to some flags Tasker automatically adds to the intent:
...
The first two are compulsory because it's a service which is sending the intent.
Btw is it possible to access static fields like android.content.Intent.FLAG_ACTIVITY_NEW_TASK from Tasker?
Btw is it possible to access static fields like android.content.Intent.FLAG_ACTIVITY_NEW_TASK from Tasker?You can use the reflection characteristic of JAVA at present. See my previous post here.
... and I hope to add the capability for Tasker 4.7.