BroadcastReceiver registered by system_process but broadcasted by application

269 views
Skip to first unread message

nguyenvuthiennga

unread,
Mar 25, 2010, 1:23:13 PM3/25/10
to android-platform
Hi,
I am trying to imitate how Alarm application interacting with
AlarmManagerService.

I create a BroadcastReceiver B which is registered by system_process:

IntentFilter filter = new
IntentFilter(TIME_ALERT_ACTION);
mContext.registerReceiver(this, filter, null, null);

An application A then calls a service of a system. This service after
executes some work then set pending broadcast to B:
PendingIntent sender = PendingIntent.getBroadcast(mContext,
IntentCounter, intent, PendingIntent.FLAG_ONE_SHOT);
...
am.set(AlarmManager.RTC_WAKEUP, time, sender);

However, I got this error:
"Permission Denial: getIntentSender() from pid=248, uid=10009, (need
uid=1000) is not allowed to send as package android".

Can anyone help me with this?

Thanks in advance,

Nga

nguyenvuthiennga

unread,
Mar 29, 2010, 4:03:55 AM3/29/10
to android-platform
Did anyone get the same problem?

On Mar 25, 7:23 pm, nguyenvuthiennga <nguyenvuthien...@gmail.com>
wrote:

Christopher Tate

unread,
Mar 29, 2010, 10:48:24 AM3/29/10
to android-...@googlegroups.com
It sounds like your code in the system process is still running under
application A's binder identity when trying to set the broadcast
intent. You've forgotten that binder incalls run with the calling
process's identity unless your code explicitly clears that state with
Binder.clearCallingIdentity().

Try putting this in your binder method implementation, around the code
that sets up the broadcast:

long oldId = Binder.clearCallingIdentity();
// ... code to set up the broadcast here
Binder.restoreCallingIdentity(oldId);

--
chris tate
android framework enginer

> --
> You received this message because you are subscribed to the Google Groups "android-platform" group.
> To post to this group, send email to android-...@googlegroups.com.
> To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.
>
>

nguyenvuthiennga

unread,
Mar 30, 2010, 6:57:34 AM3/30/10
to android-platform
Hi Chris,

It works! Thanks a lot!
You are so great! :)

Nga

On Mar 29, 4:48 pm, Christopher Tate <ct...@google.com> wrote:
> It sounds like your code in the system process is still running under
> application A's binder identity when trying to set the broadcast
> intent.  You've forgotten that binder incalls run with the calling
> process's identity unless your code explicitly clears that state with
> Binder.clearCallingIdentity().
>
> Try putting this in your binder method implementation, around the code
> that sets up the broadcast:
>
> long oldId = Binder.clearCallingIdentity();
> // ... code to set up the broadcast here
> Binder.restoreCallingIdentity(oldId);
>
> --
> chris tate
> android framework enginer
>
> On Thu, Mar 25, 2010 at 10:23 AM, nguyenvuthiennga
>

Reply all
Reply to author
Forward
0 new messages