<commit_before>/*

Copyright 2010 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
 */

package org.openqa.selenium.android.app;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;

import org.openqa.selenium.android.AndroidWebDriver;
import org.openqa.selenium.android.Logger;
import org.openqa.selenium.android.server.JettyService;

/**
 * Main application activity.
 */
public class MainActivity extends Activity {

  private boolean bound;
  private JettyService jettyService;
  private Intent jettyIntent;
  public static final String DEBUG_MODE_ARG = "debug";
  private static Activity thisActivity;

  private static AndroidWebDriver driver;

  private ServiceConnection mConnection = new ServiceConnection() {
    public void onServiceConnected(ComponentName className, IBinder service) {
      bound = true;
      jettyService = ((org.openqa.selenium.android.server.WebDriverBinder) service).getService();
    }

    public void onServiceDisconnected(ComponentName arg0) {
      bound = false;
    }
  };

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getIntent().hasExtra(DEBUG_MODE_ARG)) {
      String debugArg = getIntent().getStringExtra(DEBUG_MODE_ARG);
      Logger.setDebugMode(Boolean.parseBoolean(debugArg));
    }

    new Thread(new Runnable() {
      public void run() {
        jettyIntent = new Intent(MainActivity.this, JettyService.class);
        bindService(jettyIntent, mConnection, Context.BIND_AUTO_CREATE);
      }
    }).start();

    org.openqa.selenium.android.Logger.log(android.util.Log.DEBUG, "MAINACTIVITY", "Thread: " + Thread.currentThread().getName());
    thisActivity = this;
  }

  @Override
  protected void onDestroy() {
    if (bound) {
      unbindService(mConnection);
      bound = false;
    }
    if (jettyService != null) {
      jettyService.stopService(jettyIntent);
    }
    stopService(jettyIntent);
    this.getWindow().closeAllPanels();
    super.onDestroy();
  }

  public static AndroidWebDriver createDriver() {
    driver = new AndroidWebDriver(thisActivity);
    return driver;
  }
}<commit_msg>DouniaBerrada: Removing uneeded logging in Android's main activity.<commit_after>/*

Copyright 2010 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
 */

package org.openqa.selenium.android.app;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;

import org.openqa.selenium.android.AndroidWebDriver;
import org.openqa.selenium.android.Logger;
import org.openqa.selenium.android.server.JettyService;

/**
 * Main application activity.
 */
public class MainActivity extends Activity {

  private boolean bound;
  private JettyService jettyService;
  private Intent jettyIntent;
  public static final String DEBUG_MODE_ARG = "debug";
  private static Activity thisActivity;

  private static AndroidWebDriver driver;

  private ServiceConnection mConnection = new ServiceConnection() {
    public void onServiceConnected(ComponentName className, IBinder service) {
      bound = true;
      jettyService = ((org.openqa.selenium.android.server.WebDriverBinder) service).getService();
    }

    public void onServiceDisconnected(ComponentName arg0) {
      bound = false;
    }
  };

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getIntent().hasExtra(DEBUG_MODE_ARG)) {
      String debugArg = getIntent().getStringExtra(DEBUG_MODE_ARG);
      Logger.setDebugMode(Boolean.parseBoolean(debugArg));
    }

    new Thread(new Runnable() {
      public void run() {
        jettyIntent = new Intent(MainActivity.this, JettyService.class);
        bindService(jettyIntent, mConnection, Context.BIND_AUTO_CREATE);
      }
    }).start();
    thisActivity = this;
  }

  @Override
  protected void onDestroy() {
    if (bound) {
      unbindService(mConnection);
      bound = false;
    }
    if (jettyService != null) {
      jettyService.stopService(jettyIntent);
    }
    stopService(jettyIntent);
    this.getWindow().closeAllPanels();
    super.onDestroy();
  }

  public static AndroidWebDriver createDriver() {
    driver = new AndroidWebDriver(thisActivity);
    return driver;
  }
}
{'fraction_non_alphanumeric': 0.0896877269426289, 'fraction_numerical': 0.0032679738562091504, 'mean_word_length': 4.1103896103896105, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4045732', 'n_tokens_mistral': 1555, 'n_tokens_neox': 1493, 'n_words': 433}