<commit_before>package com.xamoom.android.xamoomcontentblocks;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
import android.support.annotation.Nullable;
import android.support.v4.media.MediaMetadataCompat;
import android.support.v4.media.session.MediaButtonReceiver;
import android.support.v4.media.session.MediaSessionCompat;
import android.support.v4.media.session.PlaybackStateCompat;
import android.support.v7.app.NotificationCompat;
import android.util.Log;

import com.xamoom.android.xamoomsdk.R;

import java.util.ArrayList;
import java.util.HashMap;

public class AudioPlayerService extends Service {
  private static final String TAG = AudioPlayerService.class.getSimpleName();
  private static final int NOTIFICATION_ID = 1;
  private static final int SEEK_TIME = 30000;

  public static final int MSG_REGISTER_CLIENT = 1;
  public static final int MSG_UNREGISTER_CLIENT = 2;
  public static final int MSG_SET_URL = 3;
  public static final int MSG_ACTION_SEEK_FORWARD = 4;
  public static final int MSG_ACTION_SEEK_BACKWARD = 5;
  public static final int MSG_ACTION_PAUSE = 6;
  public static final int MSG_AUDIO_EVENT_STARTED = 7;
  public static final int MSG_AUDIO_EVENT_PAUSED = 8;
  public static final int MSG_AUDIO_EVENT_FINISHED = 9;
  public static final int MSG_AUDIO_EVENT_UPDATE_PROGRESS = 10;
  public static final int MSG_AUDIO_EVENT_UPDATE_LOADING = 11;

  private ArrayList<Messenger> clients = new ArrayList<Messenger>();
  private HashMap<MediaFile, Messenger> mediaFileMessengers = new HashMap<>();
  private AudioPlayer audioPlayer;
  private MediaSessionCompat mediaSession;
  private AudioManager audioManager;
  final Messenger messenger = new Messenger(new IncomingHandler());

  class IncomingHandler extends Handler {
    @Override
    public void handleMessage(final Message msg) {
      int position;
      switch (msg.what) {
        case MSG_REGISTER_CLIENT:
          Log.v(TAG, "Register Client");
          clients.add(msg.replyTo);
          break;
        case MSG_UNREGISTER_CLIENT:
          Log.v(TAG, "Unregister Client");
          clients.remove(msg.replyTo);
          break;
        case MSG_SET_URL:
          position = msg.getData().getInt("POS");
          String url = msg.getData().getString("URL");
          String title = msg.getData().getString("TITLE");
          String artist = msg.getData().getString("ARTIST");

          MediaFile mediaFile = audioPlayer.createMediaFile(Uri.parse(url), position, title,
              artist, null);
          mediaFileMessengers.put(mediaFile, msg.replyTo);

          mediaFile.setEventListener(mediaFileEventListener);

          if (requestAudioFocus()) {
            Log.v(TAG, "AudioFocus granted, start playing");
            mediaFile.start();
          } else {
            Log.v(TAG, "AudioFocus not granted");
          }
          break;
        case MSG_ACTION_PAUSE:
          audioPlayer.getCurrentMediaFile().pause();
          break;
        case MSG_ACTION_SEEK_FORWARD:
          mediaFile = audioPlayer.getCurrentMediaFile();
          if (mediaFile != null) {
            audioPlayer.getCurrentMediaFile().seekForward(SEEK_TIME);
          }
          break;
        case MSG_ACTION_SEEK_BACKWARD:
          mediaFile = audioPlayer.getCurrentMediaFile();
          if (mediaFile != null) {
            audioPlayer.getCurrentMediaFile().seekBackward(SEEK_TIME);
          }
          break;
        default:
          super.handleMessage(msg);
      }
    }
  }

  @Nullable
  @Override
  public IBinder onBind(Intent intent) {
    return messenger.getBinder();
  }

  @Override
  public void onCreate() {
    super.onCreate();
    audioPlayer = new AudioPlayer(getApplicationContext());
    ComponentName componentName = new ComponentName(getApplicationContext(),
        MediaButtonReceiver.class);
    mediaSession = new MediaSessionCompat(getApplicationContext(), TAG, componentName,
        null);
    mediaSession.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS |
        MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);

    Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
    mediaButtonIntent.setClass(this, MediaButtonReceiver.class);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0,
        mediaButtonIntent, 0);
    mediaSession.setMediaButtonReceiver(pendingIntent);

    mediaSession.setCallback(mediaSessionCallback);

    audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

    registerBecomingNoisyReceiver();
  }

  @Override
  public int onStartCommand(Intent intent, int flags, int startId) {
    Log.v(TAG, "onStartCommand " + intent);
    MediaButtonReceiver.handleIntent(mediaSession, intent);
    return START_STICKY;
  }
<commit_msg>Change service to not sticky<commit_after>package com.xamoom.android.xamoomcontentblocks;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
import android.support.annotation.Nullable;
import android.support.v4.media.MediaMetadataCompat;
import android.support.v4.media.session.MediaButtonReceiver;
import android.support.v4.media.session.MediaSessionCompat;
import android.support.v4.media.session.PlaybackStateCompat;
import android.support.v7.app.NotificationCompat;
import android.util.Log;

import com.xamoom.android.xamoomsdk.R;

import java.util.ArrayList;
import java.util.HashMap;

public class AudioPlayerService extends Service {
  private static final String TAG = AudioPlayerService.class.getSimpleName();
  private static final int NOTIFICATION_ID = 1;
  private static final int SEEK_TIME = 30000;

  public static final int MSG_REGISTER_CLIENT = 1;
  public static final int MSG_UNREGISTER_CLIENT = 2;
  public static final int MSG_SET_URL = 3;
  public static final int MSG_ACTION_SEEK_FORWARD = 4;
  public static final int MSG_ACTION_SEEK_BACKWARD = 5;
  public static final int MSG_ACTION_PAUSE = 6;
  public static final int MSG_AUDIO_EVENT_STARTED = 7;
  public static final int MSG_AUDIO_EVENT_PAUSED = 8;
  public static final int MSG_AUDIO_EVENT_FINISHED = 9;
  public static final int MSG_AUDIO_EVENT_UPDATE_PROGRESS = 10;
  public static final int MSG_AUDIO_EVENT_UPDATE_LOADING = 11;

  private ArrayList<Messenger> clients = new ArrayList<Messenger>();
  private HashMap<MediaFile, Messenger> mediaFileMessengers = new HashMap<>();
  private AudioPlayer audioPlayer;
  private MediaSessionCompat mediaSession;
  private AudioManager audioManager;
  final Messenger messenger = new Messenger(new IncomingHandler());

  class IncomingHandler extends Handler {
    @Override
    public void handleMessage(final Message msg) {
      int position;
      switch (msg.what) {
        case MSG_REGISTER_CLIENT:
          Log.v(TAG, "Register Client");
          clients.add(msg.replyTo);
          break;
        case MSG_UNREGISTER_CLIENT:
          Log.v(TAG, "Unregister Client");
          clients.remove(msg.replyTo);
          break;
        case MSG_SET_URL:
          position = msg.getData().getInt("POS");
          String url = msg.getData().getString("URL");
          String title = msg.getData().getString("TITLE");
          String artist = msg.getData().getString("ARTIST");

          MediaFile mediaFile = audioPlayer.createMediaFile(Uri.parse(url), position, title,
              artist, null);
          mediaFileMessengers.put(mediaFile, msg.replyTo);

          mediaFile.setEventListener(mediaFileEventListener);

          if (requestAudioFocus()) {
            Log.v(TAG, "AudioFocus granted, start playing");
            mediaFile.start();
          } else {
            Log.v(TAG, "AudioFocus not granted");
          }
          break;
        case MSG_ACTION_PAUSE:
          audioPlayer.getCurrentMediaFile().pause();
          break;
        case MSG_ACTION_SEEK_FORWARD:
          mediaFile = audioPlayer.getCurrentMediaFile();
          if (mediaFile != null) {
            audioPlayer.getCurrentMediaFile().seekForward(SEEK_TIME);
          }
          break;
        case MSG_ACTION_SEEK_BACKWARD:
          mediaFile = audioPlayer.getCurrentMediaFile();
          if (mediaFile != null) {
            audioPlayer.getCurrentMediaFile().seekBackward(SEEK_TIME);
          }
          break;
        default:
          super.handleMessage(msg);
      }
    }
  }

  @Nullable
  @Override
  public IBinder onBind(Intent intent) {
    return messenger.getBinder();
  }

  @Override
  public void onCreate() {
    super.onCreate();
    audioPlayer = new AudioPlayer(getApplicationContext());
    ComponentName componentName = new ComponentName(getApplicationContext(),
        MediaButtonReceiver.class);
    mediaSession = new MediaSessionCompat(getApplicationContext(), TAG, componentName,
        null);
    mediaSession.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS |
        MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);

    Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
    mediaButtonIntent.setClass(this, MediaButtonReceiver.class);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0,
        mediaButtonIntent, 0);
    mediaSession.setMediaButtonReceiver(pendingIntent);

    mediaSession.setCallback(mediaSessionCallback);

    audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

    registerBecomingNoisyReceiver();
  }

  @Override
  public int onStartCommand(Intent intent, int flags, int startId) {
    Log.v(TAG, "onStartCommand " + intent);
    MediaButtonReceiver.handleIntent(mediaSession, intent);
    return START_NOT_STICKY;
  }

{'fraction_non_alphanumeric': 0.08682606657290201, 'fraction_numerical': 0.004875761837787154, 'mean_word_length': 3.7215582115980523, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '5455896', 'n_tokens_mistral': 3038, 'n_tokens_neox': 2966, 'n_words': 658}