package com.ibm.mil.smartringer;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;

public class IncomingCallReceiver extends BroadcastReceiver {
    private static final String TAG = IncomingCallReceiver.class.getName();

    private static PhoneStateListener phoneStateListener;

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.i(TAG, "Received system event for change in phone state");

        // register phone state listener only once
        if (phoneStateListener == null) {
            Log.i(TAG, "Phone state listener is being initialized");
            phoneStateListener = new IncomingCallPhoneStateListener(context);
            TelephonyManager telephonyManager = (TelephonyManager)
                    context.getSystemService(Context.TELEPHONY_SERVICE);
            telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
        }
    }

    private static class IncomingCallPhoneStateListener extends PhoneStateListener {
        private Context mContext;
        private boolean isInitialRing = true;

        public IncomingCallPhoneStateListener(Context context) {
            mContext = context;
        }

        @Override
        public void onCallStateChanged(int state, String incomingNumber) {
            if (state == TelephonyManager.CALL_STATE_RINGING && isInitialRing) {
                mContext.startService(new Intent(mContext, RingerAdjusterService.class));

                // prevents CALL_STATE_RINGING from being triggered multiple times
                isInitialRing = false;
            }
        }
    }

}

@@ -687,77 +687,8 @@
 ) %7B%0A
-            Log.i(TAG, %22Phone state listener is being initialized%22);%0A
     
@@ -1106,24 +1106,16 @@
         
-private 
 Context 
@@ -1132,24 +1132,16 @@
         
-private 
 boolean 
@@ -1171,23 +1171,16 @@
         
-public 
 Incoming

Remove unnecessary access modifiers from nested private class