SmsReceiverpublic class SmsReceiver extends android.content.BroadcastReceiver Handle incoming SMSes. Just dispatches the work off to a Service. |
Fields Summary |
---|
static final Object | mStartingServiceSync | static PowerManager.WakeLock | mStartingService |
Methods Summary |
---|
public static void | beginStartingService(android.content.Context context, android.content.Intent intent)Start the service to process the current event notifications, acquiring
the wake lock before returning to ensure that the service will run.
synchronized (mStartingServiceSync) {
if (mStartingService == null) {
PowerManager pm =
(PowerManager)context.getSystemService(Context.POWER_SERVICE);
mStartingService = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
"StartingAlertService");
mStartingService.setReferenceCounted(false);
}
mStartingService.acquire();
context.startService(intent);
}
| public static void | finishStartingService(android.app.Service service, int startId)Called back by the service when it has finished processing notifications,
releasing the wake lock if the service is now stopping.
synchronized (mStartingServiceSync) {
if (mStartingService != null) {
if (service.stopSelfResult(startId)) {
mStartingService.release();
}
}
}
| public void | onReceive(android.content.Context context, android.content.Intent intent)
onReceiveWithPrivilege(context, intent, false);
| protected void | onReceiveWithPrivilege(android.content.Context context, android.content.Intent intent, boolean privileged)
// If 'privileged' is false, it means that the intent was delivered to the base
// no-permissions receiver class. If we get an SMS_RECEIVED message that way, it
// means someone has tried to spoof the message by delivering it outside the normal
// permission-checked route, so we just ignore it.
if (!privileged && intent.getAction().equals(Intents.SMS_RECEIVED_ACTION)) {
return;
}
intent.setClass(context, SmsReceiverService.class);
intent.putExtra("result", getResultCode());
beginStartingService(context, intent);
|
|