mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-02-07 10:30:14 -05:00
Prepare ApgCon for asymetric enc and clean up
This commit is contained in:
parent
8b35229650
commit
9c06bb03b6
@ -53,35 +53,34 @@ public class ApgCon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ApgCon(Context ctx) {
|
public ApgCon(Context ctx) {
|
||||||
Log.d(TAG, "EncryptionService created");
|
Log.v(TAG, "EncryptionService created");
|
||||||
mContext = ctx;
|
mContext = ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** try to connect to the apg service */
|
/** try to connect to the apg service */
|
||||||
private boolean connect() {
|
private boolean connect() {
|
||||||
Log.d(TAG, "trying to bind the apgService to context");
|
Log.v(TAG, "trying to bind the apgService to context");
|
||||||
|
|
||||||
if (apgService != null) {
|
if (apgService != null) {
|
||||||
Log.d(TAG, "allready connected");
|
Log.v(TAG, "allready connected");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mContext.bindService(new Intent(IApgService.class.getName()), apgConnection, Context.BIND_AUTO_CREATE);
|
mContext.bindService(new Intent(IApgService.class.getName()), apgConnection, Context.BIND_AUTO_CREATE);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.d(TAG, "could not bind APG service");
|
Log.v(TAG, "could not bind APG service");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wait_count = 0;
|
int wait_count = 0;
|
||||||
while (apgService == null && wait_count++ < 15) {
|
while (apgService == null && wait_count++ < 15) {
|
||||||
Log.d(TAG, "sleeping 1 second to wait for apg");
|
Log.v(TAG, "sleeping 1 second to wait for apg");
|
||||||
android.os.SystemClock.sleep(1000);
|
android.os.SystemClock.sleep(1000);
|
||||||
}
|
}
|
||||||
;
|
|
||||||
|
|
||||||
if (wait_count >= 15) {
|
if (wait_count >= 15) {
|
||||||
Log.d(TAG, "slept waiting for nothing!");
|
Log.v(TAG, "slept waiting for nothing!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +90,7 @@ public class ApgCon {
|
|||||||
private boolean initialize() {
|
private boolean initialize() {
|
||||||
if (apgService == null) {
|
if (apgService == null) {
|
||||||
if (!connect()) {
|
if (!connect()) {
|
||||||
Log.d(TAG, "connection to apg service failed");
|
Log.v(TAG, "connection to apg service failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -129,12 +128,12 @@ public class ApgCon {
|
|||||||
warning_list.addAll(pReturn.getStringArrayList("WARNINGS"));
|
warning_list.addAll(pReturn.getStringArrayList("WARNINGS"));
|
||||||
return ret;
|
return ret;
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
Log.d(TAG, e.getMessage());
|
Log.e(TAG, e.getMessage());
|
||||||
error_list.add("CLASS: " + e.getMessage());
|
error_list.add("CLASS: " + e.getMessage());
|
||||||
pReturn.putInt("CLASS_ERROR", error.CALL_NOT_KNOWN.ordinal());
|
pReturn.putInt("CLASS_ERROR", error.CALL_NOT_KNOWN.ordinal());
|
||||||
return false;
|
return false;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.d(TAG, ""+e.getMessage());
|
Log.e(TAG, "" + e.getMessage());
|
||||||
error_list.add("CLASS: " + e.getMessage());
|
error_list.add("CLASS: " + e.getMessage());
|
||||||
pReturn.putInt("CLASS_ERROR", error.GENERIC.ordinal());
|
pReturn.putInt("CLASS_ERROR", error.GENERIC.ordinal());
|
||||||
return false;
|
return false;
|
||||||
@ -146,6 +145,14 @@ public class ApgCon {
|
|||||||
args.putString(key, val);
|
args.putString(key, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void set_arg(String key, String vals[]) {
|
||||||
|
ArrayList<String> list = new ArrayList<String>();
|
||||||
|
for (String val : vals) {
|
||||||
|
list.add(val);
|
||||||
|
}
|
||||||
|
args.putStringArrayList(key, list);
|
||||||
|
}
|
||||||
|
|
||||||
public void set_arg(String key, boolean val) {
|
public void set_arg(String key, boolean val) {
|
||||||
args.putBoolean(key, val);
|
args.putBoolean(key, val);
|
||||||
}
|
}
|
||||||
@ -154,6 +161,14 @@ public class ApgCon {
|
|||||||
args.putInt(key, val);
|
args.putInt(key, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void set_arg(String key, int vals[]) {
|
||||||
|
ArrayList<Integer> list = new ArrayList<Integer>();
|
||||||
|
for (int val : vals) {
|
||||||
|
list.add(val);
|
||||||
|
}
|
||||||
|
args.putIntegerArrayList(key, list);
|
||||||
|
}
|
||||||
|
|
||||||
public void clear_args() {
|
public void clear_args() {
|
||||||
args.clear();
|
args.clear();
|
||||||
}
|
}
|
||||||
@ -188,8 +203,22 @@ public class ApgCon {
|
|||||||
return result.getString("RESULT");
|
return result.getString("RESULT");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disconnect() {
|
public void clear_errors() {
|
||||||
Log.d(TAG, "disconnecting apgService");
|
error_list.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear_warnings() {
|
||||||
|
warning_list.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
clear_errors();
|
||||||
|
clear_warnings();
|
||||||
|
clear_args();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disconnect() {
|
||||||
|
Log.v(TAG, "disconnecting apgService");
|
||||||
if (apgService != null) {
|
if (apgService != null) {
|
||||||
mContext.unbindService(apgConnection);
|
mContext.unbindService(apgConnection);
|
||||||
apgService = null;
|
apgService = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user