Android Widget - Permission Denial

Asked

Viewed 168 times

3

I’m having a permission problem that’s gone a little overboard. Inside a widget I inserted a button, that when pressing I receive the following message:

04-13 14:10:44.340: E/databaseutils(2362): 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

04-13 14:28:19.370: E/databaseutils(2362): at com.android.server.am.Activitymanagerservice.handleIncomingUser(Activitymanagerservice.java:13140)

04-13 14:28:19.370: E/databaseutils(2362): at android.app.Activitymanager.handleIncomingUser(Activitymanager.java:2038)

04-13 14:28:19.370: E/Databaseutils(2362): at com.android.providers.settings.Settingsprovider.callFromPackage(Settingsprovider.java:607)

04-13 14:28:19.370: E/Databaseutils(2362): at android.content.Contentprovider$Transport.call(Contentprovider.java:279)

04-13 14:28:19.370: E/databaseutils(2362): at android.content.Contentprovidernative.onTransact(Contentprovidernative.java:273)

04-13 14:28:19.370: E/Databaseutils(2362): at android.os.Binder.execTransact(Binder.java:388)

04-13 14:28:19.370: E/Databaseutils(2362): at Dalvik.system.Nativestart.run(Native Method)

04-13 14:28:19.570: E/Enterprisecontainermanager(2362): Containerpolicy Service is not yet ready!!!

It works as follows: In the Widget class (Widgetapp), in the onUpdate() method I have the following lines (lines in question of the problem):

rv = new RemoteViews(context.getPackageName(),R.layout.widget_layout);
Intent intentSync = new Intent(context, Sincroniza.class);
PendingIntent piS = PendingIntent.getActivity(context, 0, intentSync, 0);        
rv.setOnClickPendingIntent(R.id.widget_Btn_Atualiza, piS);

In Activity Synchronize I have the following lines in the onCreate method():

    this.runOnUiThread(new Runnable() {
        
        @Override
        public void run() {
            Intent intentService = new Intent(getApplicationContext(), AWidget.class);
            startService(intentService);
            
            Toast.makeText(getApplicationContext(), "Widget Atualizado!", Toast.LENGTH_LONG).show();
            
        }
    });


    finish();

That is, on the lines above: loads the Activity, makes the service call and closes. For those who work with Widget knows that the setOnClickPendingIntent() makes necessary call of a Pendingintent.

About permission INTERACT_ACROSS_USERS_FULL, no use putting the uses Permissions, first that is not even in the default list of sdk, have to insert manual. Second that does not help.

In short, my widget (which is based on Broadcastreceiver by Android default), loads a Remoteviews from the layout and inserts an event from the desired button (setOnClickPendingIntent). This event loads an Activity, which executes a Service and then closes the same Activity.

INTERESTING: All this works normal for a period, after a few minutes it stops working.

DETAIL: The Service Awidget.class I use in an Alarmmanager and works smoothly.

1 answer

2

Hello, I researched a little and found several people with the same problem as yours asking for clarification on stackoverflow.with, where the best answer can be accessed here. She says the following:

android.permission.INTERACT_ACROSS_USERS_FULL is a subscription level permission. Your application will not be able to use it before it has the same signature as the system.

What is not possible unless you are the creator of the system or get a certificate for your application.

In other words, this unfortunately is out of bounds for most developers.

Follow other links that may be useful:

I hope I’ve helped, any questions ask in the comments.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.