Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
179 views
in Technique[技术] by (71.8m points)

android - Security Exception when trying to access a Picasa image on device running 4.2

in my app i let the user select an image from the gallery and had no problems doing this pre 4.2 but now when I select an image that is synced from my google+ account which i guess is a Picasa image I get this error

11-25 20:31:52.508: E/AndroidRuntime(17387): java.lang.RuntimeException: An error occured while executing doInBackground()
11-25 20:31:52.508: E/AndroidRuntime(17387):    at android.os.AsyncTask$3.done(AsyncTask.java:299)
11-25 20:31:52.508: E/AndroidRuntime(17387):    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
11-25 20:31:52.508: E/AndroidRuntime(17387):    at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
11-25 20:31:52.508: E/AndroidRuntime(17387):    at java.util.concurrent.FutureTask.run(FutureTask.java:239)
11-25 20:31:52.508: E/AndroidRuntime(17387):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
11-25 20:31:52.508: E/AndroidRuntime(17387):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
11-25 20:31:52.508: E/AndroidRuntime(17387):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
11-25 20:31:52.508: E/AndroidRuntime(17387):    at java.lang.Thread.run(Thread.java:856)
11-25 20:31:52.508: E/AndroidRuntime(17387): Caused by: java.lang.SecurityException: Permission Denial: opening provider com.android.gallery3d.provider.GalleryProvider from ProcessRecord{42817d60 17387:com.tyczj.bowling/u0a10087} (pid=17387, uid=10087) requires com.google.android.gallery3d.permission.GALLERY_PROVIDER or com.google.android.gallery3d.permission.GALLERY_PROVIDER
11-25 20:31:52.508: E/AndroidRuntime(17387):    at android.os.Parcel.readException(Parcel.java:1425)
11-25 20:31:52.508: E/AndroidRuntime(17387):    at android.os.Parcel.readException(Parcel.java:1379)
11-25 20:31:52.508: E/AndroidRuntime(17387):    at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:2530)
11-25 20:31:52.508: E/AndroidRuntime(17387):    at android.app.ActivityThread.acquireProvider(ActivityThread.java:4460)
11-25 20:31:52.508: E/AndroidRuntime(17387):    at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2002)
11-25 20:31:52.508: E/AndroidRuntime(17387):    at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1101)
11-25 20:31:52.508: E/AndroidRuntime(17387):    at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:708)
11-25 20:31:52.508: E/AndroidRuntime(17387):    at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:614)
11-25 20:31:52.508: E/AndroidRuntime(17387):    at android.content.ContentResolver.openInputStream(ContentResolver.java:449)
11-25 20:31:52.508: E/AndroidRuntime(17387):    at com.tyczj.bowling.BowlersListFragment$LoadImage.doInBackground(BowlersListFragment.java:390)
11-25 20:31:52.508: E/AndroidRuntime(17387):    at com.tyczj.bowling.BowlersListFragment$LoadImage.doInBackground(BowlersListFragment.java:1)
11-25 20:31:52.508: E/AndroidRuntime(17387):    at android.os.AsyncTask$2.call(AsyncTask.java:287)
11-25 20:31:52.508: E/AndroidRuntime(17387):    at   java.util.concurrent.FutureTask.run(FutureTask.java:234)
11-25 20:31:52.508: E/AndroidRuntime(17387):    ... 4 more

So I put in com.google.android.gallery3d.permission.GALLERY_PROVIDER in my manifest but I still get that error so what else do I have to do? This is the first time I am seeing this and have found no information online about this issue.

If this is going to be a problem can I just have the gallery show images that are on the device and exclude Picasa images?

Like I said I did not have this problem before 4.2 or maybe it has to do with a recent google+ update?

EDIT:

It only gives me the error after i get out of the app and try to start it again. So if I am in the app and select the image to show the first time it works fine until I exit. I store the Uri in my database to load when it starts

here is my Manifest permissions

<uses-permission android:name="com.tyczj.bowling.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="com.google.android.gallery3d.permission.GALLERY_PROVIDER" />
<uses-permission android:name="android.permission.INTERNET" />
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I had a similar problem implementing ACTION_SEND and ACTION_SEND_MULTIPLE in my app (also in Android 4.2.x). If I went to the gallery, selected one or more Picasa images, then chose "share", then chose my app from the picker, my app would throw the same SecurityException as above. Any attempt to use a query/load method from ContentResolver would throw.

I also tried adding the GALLERY_PROVIDER permission, but it didn't help (also, I looked in Instagram's manifest; It doesn't have this permission listed).

Eventually, on a whim, I took out android:launchMode="singleTask" from my entity, and low and behold, everything worked.

I have no idea why a single-task app would be barred from sharing in this way. Bug? Feature?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...