<commit_before>package sk.henrichg.phoneprofilesplus;

import android.content.Context;
import android.content.Intent;
import android.support.v4.content.WakefulBroadcastReceiver;
import android.telephony.TelephonyManager;

import java.util.Date;

public abstract class PhoneCallReceiver extends WakefulBroadcastReceiver {

	static TelephonyManager telephony;
    //The receiver will be recreated whenever android feels like it.
    //We need a static variable to remember data between instantiations
    static PhonecallStartEndDetector listener;
    //String outgoingSavedNumber;
    protected Context savedContext;


    @Override
    public void onReceive(Context context, Intent intent) {
        savedContext = context;
        
        if (onStartReceive())
        {
        	if (telephony == null)
        		telephony = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE); 
        	
	        if(listener == null){
	            listener = new PhonecallStartEndDetector();
	        }

	        //We listen to two intents.  The new outgoing call only tells us of an outgoing call.  We use it to get the number.
	        if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) {
	            listener.setOutgoingNumber(intent.getExtras().getString(Intent.EXTRA_PHONE_NUMBER));
	            return;
	        }
	
            listener.onCallStateChanged(intent);

        }
        onEndReceive();
    }
        

    //Derived classes should override these to respond to specific events of interest
    protected abstract boolean onStartReceive();
    protected abstract void onIncomingCallStarted(String number, Date start);
    protected abstract void onOutgoingCallStarted(String number, Date start);
    protected abstract void onOutgoingCallAnswered(String number, Date start);
    protected abstract void onIncomingCallAnswered(String number, Date start);
    protected abstract void onIncomingCallEnded(String number, Date start, Date end); 
    protected abstract void onOutgoingCallEnded(String number, Date start, Date end);<commit_msg>Cahnges about set ringer mode (priority mode); adde call of AudioManager.setMode(MODE_NORMAL) on call end<commit_after>package sk.henrichg.phoneprofilesplus;

import android.content.Context;
import android.content.Intent;
import android.support.v4.content.WakefulBroadcastReceiver;
import android.telephony.TelephonyManager;

import java.util.Date;

public abstract class PhoneCallReceiver extends WakefulBroadcastReceiver {

	static TelephonyManager telephony;
    //The receiver will be recreated whenever android feels like it.
    //We need a static variable to remember data between instantiations
    static PhonecallStartEndDetector listener;
    //String outgoingSavedNumber;
    protected Context savedContext;


    @Override
    public void onReceive(Context context, Intent intent) {

        savedContext = context.getApplicationContext();
        
        if (onStartReceive())
        {
        	if (telephony == null)
        		telephony = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE); 
        	
	        if(listener == null){
	            listener = new PhonecallStartEndDetector();
	        }

	        //We listen to two intents.  The new outgoing call only tells us of an outgoing call.  We use it to get the number.
	        if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) {
	            listener.setOutgoingNumber(intent.getExtras().getString(Intent.EXTRA_PHONE_NUMBER));
	            return;
	        }
	
            listener.onCallStateChanged(intent);

        }
        onEndReceive();
    }
        

    //Derived classes should override these to respond to specific events of interest
    protected abstract boolean onStartReceive();
    protected abstract void onIncomingCallStarted(String number, Date start);
    protected abstract void onOutgoingCallStarted(String number, Date start);
    protected abstract void onOutgoingCallAnswered(String number, Date start);
    protected abstract void onIncomingCallAnswered(String number, Date start);
    protected abstract void onIncomingCallEnded(String number, Date start, Date end); 
    protected abstract void onOutgoingCallEnded(String number, Date start, Date end);
{'fraction_non_alphanumeric': 0.06635404454865182, 'fraction_numerical': 0.0004689331770222743, 'mean_word_length': 3.4207253886010363, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2280989', 'n_tokens_mistral': 1115, 'n_tokens_neox': 1060, 'n_words': 334}