package ru.spbau.bluecharm;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
import android.telephony.TelephonyManager;
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);
			Bundle bundle = new Bundle();
			bundle.putString(null, intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER));
			msg.setData(bundle);
			try {
				messenger.send(msg);
			} catch (RemoteException e) {
				Log.e(TAG, e.getLocalizedMessage());
			}
		} else {
			Log.d(TAG, "BlueCharmService isn't running");
		}
	}
}

@@ -627,16 +627,214 @@
 null) %7B%0A
+%09%09%09Log.d(TAG, %22Intent received: %22 + intent.getStringExtra(TelephonyManager.EXTRA_STATE));%0A%09%09%09if (intent.getStringExtra(TelephonyManager.EXTRA_STATE).equals(TelephonyManager.EXTRA_STATE_RINGING)) %7B%0A%09
 %09%09%09Messe
@@ -873,16 +873,17 @@
 inder);%0A
+%09
 %09%09%09Messa
@@ -958,16 +958,17 @@
  0, 0);%0A
+%09
 %09%09%09Bundl
@@ -995,16 +995,17 @@
 e();%0A%09%09%09
+%09
 bundle.p
@@ -1018,16 +1018,27 @@
 ng(null,
+ %22Call: %22 +
  intent.
@@ -1097,16 +1097,17 @@
 R));%0A%09%09%09
+%09
 msg.setD
@@ -1119,16 +1119,17 @@
 undle);%0A
+%09
 %09%09%09try %7B
@@ -1133,16 +1133,17 @@
 y %7B%0A%09%09%09%09
+%09
 messenge
@@ -1155,16 +1155,17 @@
 d(msg);%0A
+%09
 %09%09%09%7D cat
@@ -1185,24 +1185,25 @@
 eption e) %7B%0A
+%09
 %09%09%09%09Log.e(TA
@@ -1231,16 +1231,22 @@
 age());%0A
+%09%09%09%09%7D%0A
 %09%09%09%7D%0A%09%09%7D

Call prefix in a notification