get rid of buggy new-version check which prevents merging of new hosts files. More refactoring of interactive SAM Auth interface.

This commit is contained in:
idk
2022-05-19 18:29:31 -04:00
parent 82b92caa55
commit cd12d84d47
2 changed files with 85 additions and 79 deletions

View File

@ -63,7 +63,6 @@ class InitActivities {
Util.i("Initializing the I2P resources");
unzipResourceToDir(R.raw.certificates_zip, "certificates");
if (checkNewVersion()) {
List<Properties> lProps = Util.getPropertiesFromPreferences(ctx);
Properties props = lProps.get(0);
@ -144,7 +143,6 @@ class InitActivities {
File netDBDir = new File(myDir, "netDB");
netDBDir.mkdir();
//unzipResourceToDir(R.raw.netdb_zip, "netDB");
}
// Set up the locations so settings can find them
System.setProperty("i2p.dir.base", myDir);

View File

@ -38,7 +38,7 @@ public class AndroidSAMSecureSession implements SAMSecureSessionInterface {
@Override
public void run() {
AlertDialog.Builder builder = new AlertDialog.Builder(mCtx.getApplicationContext());
AlertDialog.Builder builder = new AlertDialog.Builder(getApplicationContext());
builder.setTitle(mCtx.getResources().getString(R.string.settings_confirm_sam));
builder.setMessage(mCtx.getResources().getString(R.string.settings_confirm_sam));
@ -46,7 +46,6 @@ public class AndroidSAMSecureSession implements SAMSecureSessionInterface {
builder.setPositiveButton(mCtx.getResources().getString(R.string.settings_confirm_allow_sam), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// set result=true and close the dialog
result = 1;
dialog.dismiss();
}
@ -56,7 +55,6 @@ public class AndroidSAMSecureSession implements SAMSecureSessionInterface {
@Override
public void onClick(DialogInterface dialog, int which) {
// set result=false
result = 0;
dialog.dismiss();
}
@ -66,21 +64,31 @@ public class AndroidSAMSecureSession implements SAMSecureSessionInterface {
alert.show();
}
public boolean isResult() {
private synchronized void waitForResult() {
for (int i=0;i<60;i++) {
if (result != - 1)
break;
Util.i("Waiting on user to approve SAM connection");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
return false;
Util.e("SAMSecureSession Error", e);
}
}
}
private boolean isResult() {
if (result == 0)
return false;
if (result == 1)
return true;
return false;
}
public boolean checkResult() {
waitForResult();
return isResult();
}
}
public Context getApplicationContext() {
return mCtx.getApplicationContext();
@ -91,6 +99,6 @@ public class AndroidSAMSecureSession implements SAMSecureSessionInterface {
Handler handler = new Handler(Looper.getMainLooper());
SAMSecureRunnable ssr = new SAMSecureRunnable();
handler.post(ssr);
return ssr.isResult();
return ssr.checkResult();
}
}