package ru.spbau.bluecharm;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
import android.util.Log;

public class CallsNotifier extends BroadcastReceiver {
	public static final String TAG = "CALLS_NOTIFIER";
	
	@Override
	public void onReceive(Context context, Intent intent) {
		IBinder binder = peekService(context, new Intent(context, BlueCharmService.class));
		if (binder != null) {
			Messenger messenger = new Messenger(binder);
			Message msg = Message.obtain(null, BlueCharmService.MSG_NOTIFY_LISTENERS, 0, 0);
			try {
				messenger.send(msg);
			} catch (RemoteException e) {
				Log.e(TAG, e.getLocalizedMessage());
			}
		} else {
			Log.d(TAG, "BlueCharmService isn't running");
		}
	}
}

@@ -127,16 +127,42 @@
 Intent;%0A
+import android.os.Bundle;%0A
 import a
@@ -271,16 +271,59 @@
 eption;%0A
+import android.telephony.TelephonyManager;%0A
 import a
@@ -759,16 +759,163 @@
  0, 0);%0A
+%09%09%09Bundle bundle = new Bundle();%0A%09%09%09bundle.putString(null, intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER));%0A%09%09%09msg.setData(bundle);%0A
 %09%09%09try %7B

Call Notification