<commit_before>package com.plugin.gcm;

import com.google.android.gcm.GCMBaseIntentService;

import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.util.Log;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.Set;

import com.datum.hotline.plugin.hlpush.localnotification.TriggerReceiver;
import com.datum.hotline.plugin.hlpush.notification.Manager;

@SuppressLint("NewApi")
public class GCMIntentService extends GCMBaseIntentService {

    //public static final int NOTIFICATION_ID = 237;
    public static final int NOTIFICATION_ID = 1;

    private static String LOGTAG = "PushPlugin-GCMIntentService";
    static final String TAG = "HotlineNotifications";

    //public static final String MESSAGE = "message";
    public static final String MESSAGE = "msg";

    public GCMIntentService() {
        super("GCMIntentService");
    }

    @Override
    public void onRegistered(Context context, String regId) {
        Log.d(LOGTAG, "onRegistered: " + regId);
        NotificationService.getInstance(context).onRegistered(regId);
    }

    @Override
    public void onUnregistered(Context context, String regId) {
        Log.d(LOGTAG, "onUnregistered - regId: " + regId);
    }

    @Override
    protected void onMessage(Context context, Intent intent) {
        boolean isAppInForeground = NotificationService.getInstance(context).isForeground();

        Bundle extras = intent.getExtras();
        if (extras != null) {

            // If in background, create notification to display in notification center
            if (!isAppInForeground) {
                /*if (extras.getString(MESSAGE) != null && extras.getString(MESSAGE).length() != 0) {
                    createNotification(context, extras);
                }*/
                //createNotification(context, extras);
                Log.d(LOGTAG, "onMessage: " + extras.toString());
                String payload = extras.getString("payload");
                JSONObject data = null;

                /*if(payload != null){
                    try {
                        JSONObject t = new JSONObject(payload);
                        data = t.getJSONObject("data");
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
                String msg = "";
                try {
                    msg = data.getString(MESSAGE);
                } catch (JSONException e) {
                    e.printStackTrace();
                }*/
                //if (extras.getString(MESSAGE) != null && extras.getString(MESSAGE).length() != 0){
                //if (data != null && data.getString(MESSAGE) != null && data.getString(MESSAGE).length() != 0){
                if (data != null && msg != null && msg.length() != 0){
                    JSONObject appends = ToJson(extras);
                    try {
                        appends.put("id",1);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    Manager.getInstance(context).append(1, appends,TriggerReceiver.class);<commit_msg>fixed<commit_after>package com.plugin.gcm;

import com.google.android.gcm.GCMBaseIntentService;

import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.util.Log;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.Set;

import com.datum.hotline.plugin.hlpush.localnotification.TriggerReceiver;
import com.datum.hotline.plugin.hlpush.notification.Manager;

@SuppressLint("NewApi")
public class GCMIntentService extends GCMBaseIntentService {

    //public static final int NOTIFICATION_ID = 237;
    public static final int NOTIFICATION_ID = 1;

    private static String LOGTAG = "PushPlugin-GCMIntentService";
    static final String TAG = "HotlineNotifications";

    //public static final String MESSAGE = "message";
    public static final String MESSAGE = "msg";

    public GCMIntentService() {
        super("GCMIntentService");
    }

    @Override
    public void onRegistered(Context context, String regId) {
        Log.d(LOGTAG, "onRegistered: " + regId);
        NotificationService.getInstance(context).onRegistered(regId);
    }

    @Override
    public void onUnregistered(Context context, String regId) {
        Log.d(LOGTAG, "onUnregistered - regId: " + regId);
    }

    @Override
    protected void onMessage(Context context, Intent intent) {
        boolean isAppInForeground = NotificationService.getInstance(context).isForeground();

        Bundle extras = intent.getExtras();
        if (extras != null) {

            // If in background, create notification to display in notification center
            if (!isAppInForeground) {
                /*if (extras.getString(MESSAGE) != null && extras.getString(MESSAGE).length() != 0) {
                    createNotification(context, extras);
                }*/
                //createNotification(context, extras);
                Log.d(LOGTAG, "onMessage: " + extras.toString());
                String payload = extras.getString("payload");
                JSONObject data = null;

                String msg = "";
                /*if(payload != null){
                    try {
                        JSONObject t = new JSONObject(payload);
                        data = t.getJSONObject("data");
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
                try {
                    msg = data.getString(MESSAGE);
                } catch (JSONException e) {
                    e.printStackTrace();
                }*/
                //if (extras.getString(MESSAGE) != null && extras.getString(MESSAGE).length() != 0){
                //if (data != null && data.getString(MESSAGE) != null && data.getString(MESSAGE).length() != 0){
                if (data != null && msg != null && msg.length() != 0){
                    JSONObject appends = ToJson(extras);
                    try {
                        appends.put("id",1);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    Manager.getInstance(context).append(1, appends,TriggerReceiver.class);
{'fraction_non_alphanumeric': 0.10809214412285884, 'fraction_numerical': 0.0032486709982279976, 'mean_word_length': 2.099771167048055, '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': '1197525', 'n_tokens_mistral': 1789, 'n_tokens_neox': 1678, 'n_words': 389}