24

Background

I have a rooted device, which is Galaxy S3 I9300 , with Samsung stock based ROM, based on Android 4.3.

I never had any problems running an app i'm working on with this device.

The problem

ever since yesterday (and I didn't change anything on the device), each time I open the app, it shows for a very short time, closes itself without any crash dialog yet it shows the next log:

01-30 09:27:18.325: E/DatabaseUtils(2366): Writing exception to parcel
01-30 09:27:18.325: E/DatabaseUtils(2366): 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
01-30 09:27:18.325: E/DatabaseUtils(2366):  at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:13140)
01-30 09:27:18.325: E/DatabaseUtils(2366):  at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:2038)
01-30 09:27:18.325: E/DatabaseUtils(2366):  at com.android.providers.settings.SettingsProvider.callFromPackage(SettingsProvider.java:607)
01-30 09:27:18.325: E/DatabaseUtils(2366):  at android.content.ContentProvider$Transport.call(ContentProvider.java:279)
01-30 09:27:18.325: E/DatabaseUtils(2366):  at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:273)
01-30 09:27:18.325: E/DatabaseUtils(2366):  at android.os.Binder.execTransact(Binder.java:388)
01-30 09:27:18.325: E/DatabaseUtils(2366):  at dalvik.system.NativeStart.run(Native Method)

it doesn't even get to the code of the class that extends Application ...

What I've found

It seems that this problem is very common (many have reported about it), but I can't find any solution and why it occurs, other than having a rooted device.

People also say the permission that is written here is actually a system permission, but I never even heard of it, let alone use it (not even sure what it is).

Problem is, the app I'm working on doesn't have anything related to root, plus it worked just a few days ago.

I've tried to re-install the ROM (Omega ROM v54) and also disable anything related to xposed framework. it didn't help.

The question

How do I fix this issue? How would I know other users won't have this problem?

Is it even related to rooted devices?


EDIT: i thought i've found an answer that fixes it, by choosing "revoke USB debugging..." on the developers section of the settings screen. it seemed to work at first, but later the problem returned and clicking it didn't do anything helpful anymore...


EDIT: I think it's just a bug on the app itself or the ROM, since I can't reproduce it anymore. It's quite weird since I'm quite sure I've tried to debug the app and put a breakpoint on the onCreate method of the acitivity (and maybe of the application class itself) and it didn't stop there.

android developer
  • 114,585
  • 152
  • 739
  • 1,270
  • If you have a rooted device, you can execute system permission. What happens if you add the required permission to your manifest? Does it still cause the error? Maybe try adding ACRA into your Android project and see if it can trace the error for you. [ACRA](http://www.acra.ch/) can be found here. – ChuongPham Mar 27 '14 at 03:01
  • I'm beginning to think it's all because of a bug that causes the current activity to finish, without really crashing. However, it's weird because I remember I've tried to debug and put a breakpoint on the activity, and saw it didn't even stop on "onCreate()" method. Now I have no idea if the issue is fixed, but I can't reproduce the issue anymore. I have no idea what is going on now. Maybe it's also because I've updated the ROM on my device that I can't see this issue anymore. – android developer Mar 27 '14 at 06:22
  • Okay. Let's leave this post open and see if anyone else have the same error as you. ;) – ChuongPham Mar 27 '14 at 11:37
  • I would just add that permission temporarily – Taylor Courtney Feb 11 '16 at 20:24
  • Have you looked at this question? http://stackoverflow.com/a/28134444/3585278 – Danieboy Jul 21 '16 at 11:05
  • @Danieboy What does permission provide? Isn't it shown to the user? I don't think anything on the app requires this. After all, it happened only on a custom rom on my device, but not on others. – android developer Jul 22 '16 at 06:47
  • To be completely honest it just did seem like a relevant question that might help with this problem. Sorry if it didn't provide any help. – Danieboy Jul 22 '16 at 07:01
  • @Danieboy It was a long time ago. I don't have this issue anymore. Was just curious about this permission now that you've written about it again. – android developer Jul 22 '16 at 07:12
  • Would you mind sharing your manifest? – Jonas Köritz Nov 21 '16 at 08:29
  • @JonasKöritz I can't. I don't even remember on which app I had this issue. – android developer Nov 22 '16 at 08:11
  • It's outdated. I don't have this issue anymore. – android developer Mar 31 '17 at 20:05

4 Answers4

1
01-30 09:27:18.325: E/DatabaseUtils(2366): 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

This error comes from where you get/set any user/system settings in your app. This particular error log is showing your settings get/set (from your app code) is calling from user 0 (USER_OWNER), but the setting you're changing is for user -2 (USER_CURRENT).

You can't change other users' settings without the permission android.permission.INTERACT_ACROSS_USERS_FULL.

You're probably not considering the case of having different userID's (between calling userID and userID whom the setting is for) in your code and calling set/get settings with the incorrect userID (I don't know why they're different when this happened - for ex, it might happen when there are more than one user accounts on the device).

You need to modify the code to take the correct userID into logic and call the settings set/get for the appropriate userID (the calling userID and the userID for whom the settings is modified for should be the same).

iVoid
  • 701
  • 3
  • 14
  • I'm going to close this question thread because I don't have this device anymore and even when I had, at some point it stopped having this issue. – android developer Mar 31 '17 at 20:05
0

You can try moving the apk to /system/app/ and checking if there it works, because there it will be executed as user 0. After that maybe you can compare both logs (working one and regular one) to see where does the app stops.

To install it from your shell:

adb remount
adb push yourApp.apk /system/app/
adb reboot
Guillermo Merino
  • 3,197
  • 2
  • 17
  • 34
  • the app isn't using any special permission. it doesn't need to be a system app. in any case, I think it was just a bug on the app or the ROM itself as i can't reproduce this issue anymore. – android developer Mar 30 '14 at 11:59
  • @androiddeveloper : i am facing this issue from past few days , but not able to find any solutions or work around. Can you please let me know how you fixed this issue. – Roll no1 Jan 02 '15 at 10:08
  • @Rollno1 I didn't fix anything. This sort of fixed itself over time. Maybe it's a matter of SDK updates, or of the IDE, or of the Android OS itself. I'm sorry I can't help on that. – android developer Jan 02 '15 at 11:13
  • @androiddeveloper: I find the issue ,as i am using library with custom permission and which i miss to add in main project. – Roll no1 Jan 06 '15 at 12:13
0

Move your apk to /system/app/. It will not be executed as user 0, but it will allow you to use this permission:

android.permission.INTERACT_ACROSS_USERS_FULL
Onik
  • 19,396
  • 14
  • 68
  • 91
Swing
  • 858
  • 1
  • 8
  • 21
0

I experienced this SecurityException on an Android Wear watch and it happened when I executed a notification action. I also cannot reproduced it but noticed, that it only happens, when I reinstalled the app by using the IDE or adb install. I never saw it on a proper build signed by my Google Play key.

Pete
  • 197
  • 4
  • 11