You can check permissions, you just can't get its own Context because it is in another process.
The permission check functions on Context are for *you* to check whether *someone else* has a permission. The checkCalling and enforceCalling versions of these assume you are in the dispatching of an IPC call (from an IBinder, typically through an aidl interface) and check whether the uid of the caller process has the permission you are checking. The other ones let you explicitly specify the uid to check for if you are doing this elsewhere by explicitly passing in the uid/pid (retrieved from within the IPC with Binder.getCallingUid/Pid()). At the lowest level, you can use the PackageManager directly to see if a particular uid is holding a permission, and if needed map from a package name to a uid. (Though note if you are using package names, this means you must be getting that package name from the other side, and often this is not actually secure.) On Thu, Jan 13, 2011 at 11:00 AM, Kumar Bibek <[email protected]> wrote: > If your service is a part of a different application, then you can't. If > it's the same application, then the service itself would have your > application's context. > > Kumar Bibek > http://techdroid.kbeanie.com > http://www.kbeanie.com > > > > > On Fri, Jan 14, 2011 at 12:29 AM, androiddevelopers <[email protected]>wrote: > >> Hi, >> >> i have a service , which application binds to it. >> i need to check the permissions of the calling application. >> >> can i retrieve the calling applications context without the calling >> apllication passing it to my service . >> >> Newbie >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected]<android-developers%[email protected]> >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en > > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Dianne Hackborn Android framework engineer [email protected] 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. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

