Limit content provider access

by AndroidKing » Tue, 14 Jul 2009 09:27:43 GMT


Sponsored Links
 is there an easy way to limit my content provider access to only one
or more packages
I don't want other packages to access my data

I looked at   grantUriPermission  but its not straight forward and it
doesn't work

any ideas?
--~--~---------~--~----~------------~-------~--~----~



Limit content provider access

by Dianne Hackborn » Tue, 14 Jul 2009 14:23:39 GMT


 By far the easiest way is to do this based on app certificates -- just use
android:readPermission and android:writePermission in the manifest, and
declare the permission you are using there with <permission> to be
android:protectionLevel="signature".  Then only apps signed with the same
certificate as your own will be able to get the permission, and thus able to
read/write the provider.






-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Limit content provider access

by AndroidKing » Tue, 14 Jul 2009 23:38:10 GMT


 Thanks for the reply

That doesn't really help
I want to limit the access based on the package name.
The package name will have different signature from my App.
I added android:readPermission and android:writePermission to the
content provider
but what is the use, any package can add these two permissions and
still access the content provider
I think Android is missing the access limitation...

any other way???





--~--~---------~--~----~------------~-------~--~----~



Limit content provider access

by Dianne Hackborn » Wed, 15 Jul 2009 00:00:05 GMT


 You can limit who can get the permissions based on certificate, to control
who can get the permission, using android:protectionLevel="signature".

The package name is not secure at all -- anyone can write an app with a
particular package name, you have no idea what app it actually is based on
that.  If you really want to do this based on package name, you can
implement the security check yourself at the points of call into your
content provider (such as the query() method) -- you can use
Binder.getCallingUid() to find out who is calling you and the PackageManager
to find the package(s) associated with that.  The platform doesn't provide
any easy way to to this, though, because it is does not provide any actual
security.








-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Install % drop again?

My app went from 62% to 56% in one day....  Say it all...

-- 

2. Scope of Singletons

My application consists, for the most part, of an appwidget and a
service.  The service is triggered by an alarm which kicks it to update
the widget's remote views.

I use a singleton class to track the phone's location.  The service
accesses the singleton's instance to get the current location when the
alarm is triggered.  If the widget has been configured to track the
location dynamically, a different alarm on its own interval will trigger
the location instance to be updated with current data.  This way the
service simply has to access the singleton's instance to get the latest
location information.  All this is fine and good and appears to be
working well.

One of my users is claiming that after some period of time using my
widget, the widget no longer knows the location.  The only way this can
happen is my location instance was deleted and recreated.  I'm now
wondering whether the scope of singleton is caught up in lifecycle
issues.

I know, by hard experience and asking alot of questions, that I cannot
assume that the appwidget remains in scope. I also cannot assume that my
service remains in scope.  Both of these components can be killed at
anytime by Android.  I get that.  But does that mean that my singleton
can be taken out of scope as well?

-- 
Jake Colman -- Android Tinkerer

-- 

3. Sync to google calendar

4. Adding EditText custom context menu items *before* system defaults

5. Amazon appstore

6. Application Stats on Android Market

7. How to Obfuscate Android project source in eclipse