mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-13 04:25:00 -05:00
remove logging from library
This commit is contained in:
parent
5d88672609
commit
1ed532b6e2
@ -18,7 +18,6 @@ package org.openintents.openpgp.util;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -128,15 +127,7 @@ public class OpenPgpApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void executeApiAsync(int operationId, Bundle params, InputStream is, OutputStream os, IOpenPgpCallback callback) {
|
private void executeApiAsync(int operationId, Bundle params, InputStream is, OutputStream os, IOpenPgpCallback callback) {
|
||||||
OpenPgpAsyncTask task = new OpenPgpAsyncTask(operationId, params, is, os, callback);
|
new OpenPgpAsyncTask(operationId, params, is, os, callback).execute((Void[]) null);
|
||||||
|
|
||||||
// don't serialize async tasks!
|
|
||||||
// http://commonsware.com/blog/2012/04/20/asynctask-threading-regression-confirmed.html
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
|
||||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null);
|
|
||||||
} else {
|
|
||||||
task.execute((Void[]) null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Bundle executeApi(int operationId, Bundle params, InputStream is, OutputStream os) {
|
private Bundle executeApi(int operationId, Bundle params, InputStream is, OutputStream os) {
|
||||||
|
@ -23,6 +23,7 @@ public class OpenPgpConstants {
|
|||||||
public static final int API_VERSION = 1;
|
public static final int API_VERSION = 1;
|
||||||
public static final String SERVICE_INTENT = "org.openintents.openpgp.IOpenPgpService";
|
public static final String SERVICE_INTENT = "org.openintents.openpgp.IOpenPgpService";
|
||||||
|
|
||||||
|
|
||||||
/* Bundle params */
|
/* Bundle params */
|
||||||
public static final String PARAMS_API_VERSION = "api_version";
|
public static final String PARAMS_API_VERSION = "api_version";
|
||||||
// request ASCII Armor for output
|
// request ASCII Armor for output
|
||||||
|
@ -23,18 +23,17 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.ServiceConnection;
|
import android.content.ServiceConnection;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
public class OpenPgpServiceConnection {
|
public class OpenPgpServiceConnection {
|
||||||
private Context mApplicationContext;
|
private Context mApplicationContext;
|
||||||
|
|
||||||
private IOpenPgpService mService;
|
|
||||||
private boolean mBound;
|
private boolean mBound;
|
||||||
private String mCryptoProviderPackageName;
|
private IOpenPgpService mService;
|
||||||
|
private String mProviderPackageName;
|
||||||
|
|
||||||
public OpenPgpServiceConnection(Context context, String cryptoProviderPackageName) {
|
public OpenPgpServiceConnection(Context context, String providerPackageName) {
|
||||||
this.mApplicationContext = context.getApplicationContext();
|
this.mApplicationContext = context.getApplicationContext();
|
||||||
this.mCryptoProviderPackageName = cryptoProviderPackageName;
|
this.mProviderPackageName = providerPackageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IOpenPgpService getService() {
|
public IOpenPgpService getService() {
|
||||||
@ -45,50 +44,45 @@ public class OpenPgpServiceConnection {
|
|||||||
return mBound;
|
return mBound;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServiceConnection mCryptoServiceConnection = new ServiceConnection() {
|
private ServiceConnection mServiceConnection = new ServiceConnection() {
|
||||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||||
mService = IOpenPgpService.Stub.asInterface(service);
|
mService = IOpenPgpService.Stub.asInterface(service);
|
||||||
Log.d(OpenPgpConstants.TAG, "connected to service");
|
|
||||||
mBound = true;
|
mBound = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
mService = null;
|
mService = null;
|
||||||
Log.d(OpenPgpConstants.TAG, "disconnected from service");
|
|
||||||
mBound = false;
|
mBound = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If not already bound, bind!
|
* If not already bound, bind to service!
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean bindToService() {
|
public boolean bindToService() {
|
||||||
// if not already connected
|
// if not already bound...
|
||||||
if (mService == null && !mBound) {
|
if (mService == null && !mBound) {
|
||||||
try {
|
try {
|
||||||
Log.d(OpenPgpConstants.TAG, "not bound yet");
|
|
||||||
|
|
||||||
Intent serviceIntent = new Intent();
|
Intent serviceIntent = new Intent();
|
||||||
serviceIntent.setAction(IOpenPgpService.class.getName());
|
serviceIntent.setAction(IOpenPgpService.class.getName());
|
||||||
serviceIntent.setPackage(mCryptoProviderPackageName);
|
// NOTE: setPackage is very important to restrict the intent to this provider only!
|
||||||
mApplicationContext.bindService(serviceIntent, mCryptoServiceConnection,
|
serviceIntent.setPackage(mProviderPackageName);
|
||||||
|
mApplicationContext.bindService(serviceIntent, mServiceConnection,
|
||||||
Context.BIND_AUTO_CREATE);
|
Context.BIND_AUTO_CREATE);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.d(OpenPgpConstants.TAG, "Exception on binding", e);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.d(OpenPgpConstants.TAG, "already bound");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unbindFromService() {
|
public void unbindFromService() {
|
||||||
mApplicationContext.unbindService(mCryptoServiceConnection);
|
mApplicationContext.unbindService(mServiceConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package org.openintents.openpgp.util;
|
package org.openintents.openpgp.util;
|
||||||
|
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -82,21 +81,21 @@ public class ParcelFileDescriptorUtil {
|
|||||||
}
|
}
|
||||||
mOut.flush(); // just to be safe
|
mOut.flush(); // just to be safe
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(OpenPgpConstants.TAG, "TransferThread" + getId() + ": writing failed", e);
|
//Log.e(OpenPgpConstants.TAG, "TransferThread" + getId() + ": writing failed", e);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
mIn.close();
|
mIn.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(OpenPgpConstants.TAG, "TransferThread" + getId(), e);
|
//Log.e(OpenPgpConstants.TAG, "TransferThread" + getId(), e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
mOut.close();
|
mOut.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(OpenPgpConstants.TAG, "TransferThread" + getId(), e);
|
//Log.e(OpenPgpConstants.TAG, "TransferThread" + getId(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mListener != null) {
|
if (mListener != null) {
|
||||||
Log.d(OpenPgpConstants.TAG, "TransferThread " + getId() + " finished!");
|
//Log.d(OpenPgpConstants.TAG, "TransferThread " + getId() + " finished!");
|
||||||
mListener.onThreadFinished(this);
|
mListener.onThreadFinished(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,18 +23,17 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.ServiceConnection;
|
import android.content.ServiceConnection;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
public class OpenPgpServiceConnection {
|
public class OpenPgpServiceConnection {
|
||||||
private Context mApplicationContext;
|
private Context mApplicationContext;
|
||||||
|
|
||||||
private IOpenPgpService mService;
|
|
||||||
private boolean mBound;
|
private boolean mBound;
|
||||||
private String mCryptoProviderPackageName;
|
private IOpenPgpService mService;
|
||||||
|
private String mProviderPackageName;
|
||||||
|
|
||||||
public OpenPgpServiceConnection(Context context, String cryptoProviderPackageName) {
|
public OpenPgpServiceConnection(Context context, String providerPackageName) {
|
||||||
this.mApplicationContext = context.getApplicationContext();
|
this.mApplicationContext = context.getApplicationContext();
|
||||||
this.mCryptoProviderPackageName = cryptoProviderPackageName;
|
this.mProviderPackageName = providerPackageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IOpenPgpService getService() {
|
public IOpenPgpService getService() {
|
||||||
@ -45,50 +44,45 @@ public class OpenPgpServiceConnection {
|
|||||||
return mBound;
|
return mBound;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServiceConnection mCryptoServiceConnection = new ServiceConnection() {
|
private ServiceConnection mServiceConnection = new ServiceConnection() {
|
||||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||||
mService = IOpenPgpService.Stub.asInterface(service);
|
mService = IOpenPgpService.Stub.asInterface(service);
|
||||||
Log.d(OpenPgpConstants.TAG, "connected to service");
|
|
||||||
mBound = true;
|
mBound = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
mService = null;
|
mService = null;
|
||||||
Log.d(OpenPgpConstants.TAG, "disconnected from service");
|
|
||||||
mBound = false;
|
mBound = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If not already bound, bind!
|
* If not already bound, bind to service!
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean bindToService() {
|
public boolean bindToService() {
|
||||||
// if not already connected
|
// if not already bound...
|
||||||
if (mService == null && !mBound) {
|
if (mService == null && !mBound) {
|
||||||
try {
|
try {
|
||||||
Log.d(OpenPgpConstants.TAG, "not bound yet");
|
|
||||||
|
|
||||||
Intent serviceIntent = new Intent();
|
Intent serviceIntent = new Intent();
|
||||||
serviceIntent.setAction(IOpenPgpService.class.getName());
|
serviceIntent.setAction(IOpenPgpService.class.getName());
|
||||||
serviceIntent.setPackage(mCryptoProviderPackageName);
|
// NOTE: setPackage is very important to restrict the intent to this provider only!
|
||||||
mApplicationContext.bindService(serviceIntent, mCryptoServiceConnection,
|
serviceIntent.setPackage(mProviderPackageName);
|
||||||
|
mApplicationContext.bindService(serviceIntent, mServiceConnection,
|
||||||
Context.BIND_AUTO_CREATE);
|
Context.BIND_AUTO_CREATE);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.d(OpenPgpConstants.TAG, "Exception on binding", e);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.d(OpenPgpConstants.TAG, "already bound");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unbindFromService() {
|
public void unbindFromService() {
|
||||||
mApplicationContext.unbindService(mCryptoServiceConnection);
|
mApplicationContext.unbindService(mServiceConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package org.openintents.openpgp.util;
|
package org.openintents.openpgp.util;
|
||||||
|
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -82,21 +81,21 @@ public class ParcelFileDescriptorUtil {
|
|||||||
}
|
}
|
||||||
mOut.flush(); // just to be safe
|
mOut.flush(); // just to be safe
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(OpenPgpConstants.TAG, "TransferThread" + getId() + ": writing failed", e);
|
//Log.e(OpenPgpConstants.TAG, "TransferThread" + getId() + ": writing failed", e);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
mIn.close();
|
mIn.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(OpenPgpConstants.TAG, "TransferThread" + getId(), e);
|
//Log.e(OpenPgpConstants.TAG, "TransferThread" + getId(), e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
mOut.close();
|
mOut.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(OpenPgpConstants.TAG, "TransferThread" + getId(), e);
|
//Log.e(OpenPgpConstants.TAG, "TransferThread" + getId(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mListener != null) {
|
if (mListener != null) {
|
||||||
Log.d(OpenPgpConstants.TAG, "TransferThread " + getId() + " finished!");
|
//Log.d(OpenPgpConstants.TAG, "TransferThread " + getId() + " finished!");
|
||||||
mListener.onThreadFinished(this);
|
mListener.onThreadFinished(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user