0

The following question is related to Android versions 6 and above.

I have done some coding which is working on every device like motoG, Nexus, Pixel etc but the code throws SecurityException in Samsung devices.

The Exception message is

UiAutomatorTestRunner: java.lang.SecurityException: Unable to find app for caller android.app.ApplicationThreadProxy@a70d2 (pid=25949) when getting content provider settings

I did a try catch on Samsung Galaxy S5 and it worked. But for Samsung J7, this exception is also thrown somewhere else in the code. I don't think adding a try catch block is the right approach here.

The code where the exception is thrown is:

Intent intent = AndroidServicesUtil.getPackageManager().getLaunchIntentForPackage(packageName);

The exception stack is: >

java.lang.SecurityException: Unable to find app for caller android.app.ApplicationThreadProxy@123375c (pid=6375) when getting content provider settings
at android.os.Parcel.readException(Parcel.java:1621)
at android.os.Parcel.readException(Parcel.java:1574)
at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:4292)
at android.app.ActivityThread.acquireProvider(ActivityThread.java:6570)
at android.app.ContextImpl$ApplicationContentResolver.acquireProvider(ContextImpl.java:2388)
at android.content.ContentResolver.acquireProvider(ContentResolver.java:1505)
at android.provider.Settings$NameValueCache.lazyGetProvider(Settings.java:1431)
at android.provider.Settings$NameValueCache.getStringForUser(Settings.java:1505)
at android.provider.Settings$Secure.getStringForUser(Settings.java:8662)
at android.provider.Settings$Secure.getIntForUser(Settings.java:8732)
at android.provider.Settings$Secure.getInt(Settings.java:8722)
at android.app.ApplicationPackageManager.getHiddenList(ApplicationPackageManager.java:814)
at android.app.ApplicationPackageManager.isHidden(ApplicationPackageManager.java:859)
at android.app.ApplicationPackageManager.queryIntentActivitiesAsUser(ApplicationPackageManager.java:925)
at android.app.ApplicationPackageManager.queryIntentActivities(ApplicationPackageManager.java:907)
at android.app.ApplicationPackageManager.getLaunchIntentForPackage(ApplicationPackageManager.java:302)
at com.myclass.launchApp(SessionManager.java:595)

Can anyone help me in understanding why is the SecurityException thrown only in Samsung devices for Android version >= 6.

Thanks.

  • Please edit your question and provide a [mcve]. This would include the entire Java stack traces (not just the error message) and your Java code that is triggering the crash. – CommonsWare Jan 20 '18 at 14:21
  • I understand your query but my question is not related to my code, but is a general question. (as the exception is thrown in different places of the code for different devices) Why is SecurityException thrown only in Samsung device and not in any other device for Android vs >=6? Is there something extra that we need to do for Samsung device? – Mohit Agrawal Jan 22 '18 at 07:18
  • "Why is SecurityException thrown only in Samsung device and not in any other device for Android vs >=6?" -- first, you haven't tested all possible Android 6.0+ devices, so you do not necessarily know the precise list of devices on which this code fails. As to why it fails, we cannot answer that, because you have not provided a [mcve] as requested in my original comment. Device manufacturers and custom ROM developers are welcome to change Android; the question is whether the bug is in your code or in their changes. – CommonsWare Jan 22 '18 at 11:44
  • Updated with the stack trace and the code where i am getting Security Exception. – Mohit Agrawal Jan 24 '18 at 11:35
  • Possibly the value of `packageName` that you are passing is invalid, though I would expect a different error message here. If this code fails for known-good package names, then the blame falls on Samsung (for changing Android in a way that broke `getLaunchIntentForPackage()`) and possibly Google (for not having a CTS test case that covers this scenario, if the device shipped with this bug). – CommonsWare Jan 24 '18 at 12:11

1 Answers1

-1

If your device is running over Android version >= 6, for that you have to add run time permission because these android versions are taking permission from run time only instead of manifest file.

Those versions are below 6, they will automatically access the permissions from the manifest file. If you are adding run time permissions, your problem will be resolved.