<commit_before>package com.vaguehope.onosendai.storage;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;

import com.vaguehope.onosendai.util.LogWrapper;

public class DbClient {

	protected final LogWrapper log = new LogWrapper();

	private final Context context;
	protected Runnable dbIsReady = null;
	protected DbInterface mBoundDbService;
	private boolean boundToService = false;


	public DbClient (final Context context, final String name) {
		this(context, name, null);
	}

	public DbClient (final Context context, final String name, final Runnable dbIsReady) {
		this.context = context;
		this.log.setPrefix(name);
		this.dbIsReady = dbIsReady;
		bindDbService();
	}

	public void dispose () {
		unbindDbService();
	}

	@Override
	protected void finalize () {
		unbindDbService();
	}

	public void clearReadyListener () {
		this.dbIsReady = null;
	}

	public DbInterface getDb () {
		return this.mBoundDbService;
	}

	private final ServiceConnection mDbServiceConnection = new ServiceConnection() {

		@Override
		public void onServiceConnected (final ComponentName className, final IBinder service) {
			DbClient.this.mBoundDbService = ((DbService.LocalBinder) service).getService();
			if (DbClient.this.mBoundDbService == null) {
				DbClient.this.log.e("Got service call back, but mBoundDbService==null.  Expect more error messags!");
			}
			if (DbClient.this.dbIsReady != null) DbClient.this.dbIsReady.run();
		}

		@Override
		public void onServiceDisconnected (final ComponentName className) {
			// This is called when the connection with the service has been
			// unexpectedly disconnected -- that is, its process crashed.
			// Because it is running in our same process, we should never
			// see this happen.

			DbClient.this.mBoundDbService = null;
			DbClient.this.log.w("DbService unexpectadly disconnected.");
		}<commit_msg>call parent finalize()<commit_after>package com.vaguehope.onosendai.storage;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;

import com.vaguehope.onosendai.util.LogWrapper;

public class DbClient {

	protected final LogWrapper log = new LogWrapper();

	private final Context context;
	protected Runnable dbIsReady = null;
	protected DbInterface mBoundDbService;
	private boolean boundToService = false;


	public DbClient (final Context context, final String name) {
		this(context, name, null);
	}

	public DbClient (final Context context, final String name, final Runnable dbIsReady) {
		this.context = context;
		this.log.setPrefix(name);
		this.dbIsReady = dbIsReady;
		bindDbService();
	}

	public void dispose () {
		unbindDbService();
	}

	@Override
	protected void finalize () {
		unbindDbService();
		try {
			super.finalize();
		}
		catch (Throwable e) {
			throw new IllegalStateException(e);
		}
	}

	public void clearReadyListener () {
		this.dbIsReady = null;
	}

	public DbInterface getDb () {
		return this.mBoundDbService;
	}

	private final ServiceConnection mDbServiceConnection = new ServiceConnection() {

		@Override
		public void onServiceConnected (final ComponentName className, final IBinder service) {
			DbClient.this.mBoundDbService = ((DbService.LocalBinder) service).getService();
			if (DbClient.this.mBoundDbService == null) {
				DbClient.this.log.e("Got service call back, but mBoundDbService==null.  Expect more error messags!");
			}
			if (DbClient.this.dbIsReady != null) DbClient.this.dbIsReady.run();
		}

		@Override
		public void onServiceDisconnected (final ComponentName className) {
			// This is called when the connection with the service has been
			// unexpectedly disconnected -- that is, its process crashed.
			// Because it is running in our same process, we should never
			// see this happen.

			DbClient.this.mBoundDbService = null;
			DbClient.this.log.w("DbService unexpectadly disconnected.");
		}
{'fraction_non_alphanumeric': 0.0939580764488286, 'fraction_numerical': 0.0, 'mean_word_length': 4.408, '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': '6814158', 'n_tokens_mistral': 1313, 'n_tokens_neox': 1167, 'n_words': 340}