<commit_before>package com.seattletestbed;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;

/*
 * 
 * Based on: http://www.localytics.com/docs/android-market-campaign-analytics/
 * 
 * 
 */

public class ReferralReceiver extends BroadcastReceiver
{
    @Override
    public void onReceive(Context context, Intent intent)
    {
        // Workaround for Android security issue: http://code.google.com/p/android/issues/detail?id=16006
        try
        {
            final Bundle extras = intent.getExtras();
            if (extras != null) {
                extras.containsKey(null);
            }
        }
        catch (final Exception e) {
            return;
        }
 
	Log.i(Common.LOG_TAG, "Refrec started");
        Map<String, String> referralParams = new HashMap<String, String>();
 
        // Return if this is not the right intent.
        if (! intent.getAction().equals("com.android.vending.INSTALL_REFERRER")) { //$NON-NLS-1$
            return;
        }
 
	Log.i(Common.LOG_TAG, "Refrec right intent");
        String referrer = intent.getStringExtra("referrer"); //$NON-NLS-1$
        if( referrer == null || referrer.length() == 0) {
            return;
        }
 	Log.d(Common.LOG_TAG, "Refrec referrer");

        try
        {    // Remove any url encoding
            referrer = URLDecoder.decode(referrer, "x-www-form-urlencoded"); //$NON-NLS-1$
        }
        catch (UnsupportedEncodingException e) { return; }
 	Log.i(Common.LOG_TAG, "Refrec right encoding");

        // Parse the query string, extracting the relevant data
        String[] params = referrer.split("&"); // $NON-NLS-1$
        for (String param : params)
        {
            String[] pair = param.split("="); // $NON-NLS-1$
            referralParams.put(pair[0], pair[1]);<commit_msg>Use UTF-8 for decoding referral link  * Addresses issue where android application would crash when referral intent is delivered<commit_after>package com.seattletestbed;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;

/*
 * 
 * Based on: http://www.localytics.com/docs/android-market-campaign-analytics/
 * 
 * 
 */

public class ReferralReceiver extends BroadcastReceiver
{
    @Override
    public void onReceive(Context context, Intent intent)
    {
        // Workaround for Android security issue: http://code.google.com/p/android/issues/detail?id=16006
        try
        {
            final Bundle extras = intent.getExtras();
            if (extras != null) {
                extras.containsKey(null);
            }
        }
        catch (final Exception e) {
            return;
        }
 
	Log.i(Common.LOG_TAG, "Refrec started");
        Map<String, String> referralParams = new HashMap<String, String>();
 
        // Return if this is not the right intent.
        if (! intent.getAction().equals("com.android.vending.INSTALL_REFERRER")) { //$NON-NLS-1$
            return;
        }
 
	Log.i(Common.LOG_TAG, "Refrec right intent");
        String referrer = intent.getStringExtra("referrer"); //$NON-NLS-1$
        if( referrer == null || referrer.length() == 0) {
            return;
        }
 	Log.d(Common.LOG_TAG, "Refrec referrer");

        try
        {    // Remove any url encoding
            referrer = URLDecoder.decode(referrer, "utf-8"); //$NON-NLS-1$
        }
        catch (UnsupportedEncodingException e) { return; }
 	Log.i(Common.LOG_TAG, "Refrec right encoding");

        // Parse the query string, extracting the relevant data
        String[] params = referrer.split("&"); // $NON-NLS-1$
        for (String param : params)
        {
            String[] pair = param.split("="); // $NON-NLS-1$
            referralParams.put(pair[0], pair[1]);
{'fraction_non_alphanumeric': 0.12600663192799622, 'fraction_numerical': 0.006631927996210327, 'mean_word_length': 2.4586404586404584, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 3, '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': '2499331', 'n_tokens_mistral': 1270, 'n_tokens_neox': 1227, 'n_words': 284}