Browse Source

i2pd 2.33.0-63, tabulation, gradle configuration

Signed-off-by: R4SAS <r4sas@i2pmail.org>
pull/18/head
R4SAS 4 years ago
parent
commit
d4110e64d9
Signed by: r4sas
GPG Key ID: 66F6C87B98EBCFE2
  1. 21
      app/build.gradle
  2. 2
      app/jni/i2pd
  3. 7
      app/src/main/java/org/purplei2p/i2pd/DaemonSingleton.java
  4. 20
      app/src/main/java/org/purplei2p/i2pd/ForegroundService.java
  5. 43
      app/src/main/java/org/purplei2p/i2pd/I2PDActivity.java
  6. 1
      app/src/main/java/org/purplei2p/i2pd/I2PDPermsAskerActivity.java
  7. 2
      app/src/main/java/org/purplei2p/i2pd/I2PDPermsExplanationActivity.java
  8. 7
      app/src/main/java/org/purplei2p/i2pd/NetworkStateChangeReceiver.java
  9. 2
      app/src/main/res/values/strings.xml
  10. 2
      build.gradle
  11. 4
      gradle/wrapper/gradle-wrapper.properties
  12. 1
      settings.gradle

21
app/build.gradle

@ -3,7 +3,7 @@ plugins {
} }
dependencies { dependencies {
implementation 'androidx.core:core:1.0.2' implementation 'androidx.core:core:1.3.0'
} }
android { android {
@ -14,8 +14,8 @@ android {
applicationId "org.purplei2p.i2pd" applicationId "org.purplei2p.i2pd"
targetSdkVersion 29 targetSdkVersion 29
minSdkVersion 14 minSdkVersion 14
versionCode 23210 versionCode 23300
versionName "2.32.1" versionName "2.33.0-63-g2648f1ba"
setProperty("archivesBaseName", archivesBaseName + "-" + versionName) setProperty("archivesBaseName", archivesBaseName + "-" + versionName)
ndk { ndk {
@ -39,14 +39,13 @@ android {
enable true enable true
reset() reset()
include "armeabi-v7a", "arm64-v8a", "x86", "x86_64" include "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
//include "armeabi-v7a", "x86"
universalApk true universalApk true
} }
} }
signingConfigs { signingConfigs {
orignal { release {
storeFile file("i2pdapk.jks") storeFile file('i2pdapk.jks')
storePassword "android" storePassword "android"
keyAlias "i2pdapk" keyAlias "i2pdapk"
keyPassword "android" keyPassword "android"
@ -55,10 +54,12 @@ android {
buildTypes { buildTypes {
release { release {
minifyEnabled false signingConfig signingConfigs.release
signingConfig signingConfigs.orignal
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
} }
debug {
jniDebuggable = true
}
} }
externalNativeBuild { externalNativeBuild {
@ -68,8 +69,8 @@ android {
} }
compileOptions { compileOptions {
sourceCompatibility = '1.8' sourceCompatibility = "1.8"
targetCompatibility = '1.8' targetCompatibility = "1.8"
} }
} }

2
app/jni/i2pd

@ -1 +1 @@
Subproject commit 6735b2686b6c13a36546dd794ee49b4d583565e0 Subproject commit 2648f1ba89d5032262a72ca8b2d2d8a70e441b9a

7
app/src/main/java/org/purplei2p/i2pd/DaemonSingleton.java

@ -2,6 +2,7 @@ package org.purplei2p.i2pd;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import android.os.Environment; import android.os.Environment;
import android.util.Log; import android.util.Log;
@ -89,7 +90,9 @@ public class DaemonSingleton {
public int getStatusStringResourceId() { public int getStatusStringResourceId() {
return statusStringResourceId; return statusStringResourceId;
} }
}; }
;
private volatile State state = State.uninitialized; private volatile State state = State.uninitialized;
@ -170,7 +173,7 @@ public class DaemonSingleton {
if (isStartedOkay()) { if (isStartedOkay()) {
try { try {
I2PD_JNI.stopDaemon(); I2PD_JNI.stopDaemon();
} catch(Throwable tr) { } catch (Throwable tr) {
Log.e(TAG, "", tr); Log.e(TAG, "", tr);
} }

20
app/src/main/java/org/purplei2p/i2pd/ForegroundService.java

@ -10,12 +10,14 @@ import android.content.Intent;
import android.os.Binder; import android.os.Binder;
import android.os.Build; import android.os.Build;
import android.os.IBinder; import android.os.IBinder;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationCompat;
import android.util.Log; import android.util.Log;
public class ForegroundService extends Service { public class ForegroundService extends Service {
private static final String TAG="FgService"; private static final String TAG = "FgService";
private volatile boolean shown; private volatile boolean shown;
@ -30,7 +32,7 @@ public class ForegroundService extends Service {
showNotification(); showNotification();
} }
} catch (Throwable tr) { } catch (Throwable tr) {
Log.e(TAG,"error ignored",tr); Log.e(TAG, "error ignored", tr);
} }
} }
}; };
@ -55,7 +57,7 @@ public class ForegroundService extends Service {
@Override @Override
public void onCreate() { public void onCreate() {
notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
synchronized (this) { synchronized (this) {
DaemonSingleton.getInstance().addStateChangeListener(daemonStateUpdatedListener); DaemonSingleton.getInstance().addStateChangeListener(daemonStateUpdatedListener);
@ -85,7 +87,7 @@ public class ForegroundService extends Service {
// Tell the user we stopped. // Tell the user we stopped.
//Toast.makeText(this, R.string.i2pd_service_stopped, Toast.LENGTH_SHORT).show(); //Toast.makeText(this, R.string.i2pd_service_stopped, Toast.LENGTH_SHORT).show();
shown=false; shown = false;
} }
@Override @Override
@ -116,8 +118,10 @@ public class ForegroundService extends Service {
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, channelId) NotificationCompat.Builder builder = new NotificationCompat.Builder(this, channelId)
.setOngoing(true) .setOngoing(true)
.setSmallIcon(R.drawable.itoopie_notification_icon); // the status icon .setSmallIcon(R.drawable.itoopie_notification_icon); // the status icon
if(Build.VERSION.SDK_INT >= 16) builder = builder.setPriority(Notification.PRIORITY_DEFAULT); if (Build.VERSION.SDK_INT >= 16)
if(Build.VERSION.SDK_INT >= 21) builder = builder.setCategory(Notification.CATEGORY_SERVICE); builder = builder.setPriority(Notification.PRIORITY_DEFAULT);
if (Build.VERSION.SDK_INT >= 21)
builder = builder.setCategory(Notification.CATEGORY_SERVICE);
Notification notification = builder Notification notification = builder
.setTicker(text) // the status text .setTicker(text) // the status text
.setWhen(System.currentTimeMillis()) // the time stamp .setWhen(System.currentTimeMillis()) // the time stamp
@ -139,8 +143,8 @@ public class ForegroundService extends Service {
NotificationChannel chan = new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_LOW); NotificationChannel chan = new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_LOW);
//chan.setLightColor(Color.PURPLE); //chan.setLightColor(Color.PURPLE);
chan.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE); chan.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
NotificationManager service = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager service = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if(service!=null)service.createNotificationChannel(chan); if (service != null) service.createNotificationChannel(chan);
else Log.e(TAG, "error: NOTIFICATION_SERVICE is null"); else Log.e(TAG, "error: NOTIFICATION_SERVICE is null");
return channelId; return channelId;
} }

43
app/src/main/java/org/purplei2p/i2pd/I2PDActivity.java

@ -77,7 +77,7 @@ public class I2PDActivity extends Activity {
if (textView == null) if (textView == null)
return; return;
Throwable tr = daemon.getLastThrowable(); Throwable tr = daemon.getLastThrowable();
if (tr!=null) { if (tr != null) {
textView.setText(throwableToString(tr)); textView.setText(throwableToString(tr));
return; return;
} }
@ -86,7 +86,7 @@ public class I2PDActivity extends Activity {
String graceStr = DaemonSingleton.State.gracefulShutdownInProgress.equals(state) ? String.format(": %s %s", formatGraceTimeRemaining(), getText(R.string.remaining)) : ""; String graceStr = DaemonSingleton.State.gracefulShutdownInProgress.equals(state) ? String.format(": %s %s", formatGraceTimeRemaining(), getText(R.string.remaining)) : "";
textView.setText(String.format("%s%s%s", getText(state.getStatusStringResourceId()), startResultStr, graceStr)); textView.setText(String.format("%s%s%s", getText(state.getStatusStringResourceId()), startResultStr, graceStr));
} catch (Throwable tr) { } catch (Throwable tr) {
Log.e(TAG,"error ignored",tr); Log.e(TAG, "error ignored", tr);
} }
}); });
} }
@ -100,7 +100,7 @@ public class I2PDActivity extends Activity {
synchronized (graceStartedMillis_LOCK) { synchronized (graceStartedMillis_LOCK) {
remainingSeconds = Math.round(Math.max(0, graceStartedMillis + GRACEFUL_DELAY_MILLIS - System.currentTimeMillis()) / 1000.0D); remainingSeconds = Math.round(Math.max(0, graceStartedMillis + GRACEFUL_DELAY_MILLIS - System.currentTimeMillis()) / 1000.0D);
} }
long remainingMinutes = (long)Math.floor(remainingSeconds / 60.0D); long remainingMinutes = (long) Math.floor(remainingSeconds / 60.0D);
long remSec = remainingSeconds - remainingMinutes * 60; long remSec = remainingSeconds - remainingMinutes * 60;
return remainingMinutes + ":" + (remSec / 10) + remSec % 10; return remainingMinutes + ":" + (remSec / 10) + remSec % 10;
} }
@ -147,14 +147,13 @@ public class I2PDActivity extends Activity {
//cancelGracefulStop0(); //cancelGracefulStop0();
try { try {
doUnbindService(); doUnbindService();
} catch(Throwable tr) { } catch (Throwable tr) {
Log.e(TAG, "", tr); Log.e(TAG, "", tr);
} }
} }
@Override @Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
{
if (requestCode == MY_PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE) { if (requestCode == MY_PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED)
Log.e(TAG, "WR_EXT_STORAGE perm granted"); Log.e(TAG, "WR_EXT_STORAGE perm granted");
@ -254,7 +253,7 @@ public class I2PDActivity extends Activity {
// as you specify a parent activity in AndroidManifest.xml. // as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId(); int id = item.getItemId();
switch(id) { switch (id) {
case R.id.action_stop: case R.id.action_stop:
i2pdStop(); i2pdStop();
return true; return true;
@ -346,14 +345,13 @@ public class I2PDActivity extends Activity {
rescheduleGraceStop(null, gracefulStopAtMillis); rescheduleGraceStop(null, gracefulStopAtMillis);
} else } else
i2pdStop(); i2pdStop();
} catch(Throwable tr) { } catch (Throwable tr) {
Log.e(TAG, "", tr); Log.e(TAG, "", tr);
} }
}, "gracInit").start(); }, "gracInit").start();
} }
private void cancelGracefulStop() private void cancelGracefulStop() {
{
cancelGracefulStop0(); cancelGracefulStop0();
new Thread(() -> { new Thread(() -> {
try { try {
@ -363,7 +361,7 @@ public class I2PDActivity extends Activity {
runOnUiThread(() -> Toast.makeText(this, R.string.shutdown_canceled, Toast.LENGTH_SHORT).show()); runOnUiThread(() -> Toast.makeText(this, R.string.shutdown_canceled, Toast.LENGTH_SHORT).show());
} else } else
i2pdStop(); i2pdStop();
} catch(Throwable tr) { } catch (Throwable tr) {
Log.e(TAG, "", tr); Log.e(TAG, "", tr);
} }
}, "gracCancel").start(); }, "gracCancel").start();
@ -373,7 +371,7 @@ public class I2PDActivity extends Activity {
if (gracefulQuitTimerOld != null) if (gracefulQuitTimerOld != null)
gracefulQuitTimerOld.cancel(); gracefulQuitTimerOld.cancel();
if(daemon.GetTransitTunnelsCount() <= 0) { // no tunnels left if (daemon.GetTransitTunnelsCount() <= 0) { // no tunnels left
Log.d(TAG, "no transit tunnels left, stopping"); Log.d(TAG, "no transit tunnels left, stopping");
i2pdStop(); i2pdStop();
} }
@ -403,7 +401,7 @@ public class I2PDActivity extends Activity {
private void setGracefulQuitTimer(Timer gracefulQuitTimer) { private void setGracefulQuitTimer(Timer gracefulQuitTimer) {
I2PDActivity.gracefulQuitTimer = gracefulQuitTimer; I2PDActivity.gracefulQuitTimer = gracefulQuitTimer;
runOnUiThread(()-> { runOnUiThread(() -> {
Menu menu = optionsMenu; Menu menu = optionsMenu;
if (menu != null) { if (menu != null) {
MenuItem item = menu.findItem(R.id.action_graceful_stop); MenuItem item = menu.findItem(R.id.action_graceful_stop);
@ -420,8 +418,7 @@ public class I2PDActivity extends Activity {
* Copy the asset at the specified path to this app's data directory. If the * Copy the asset at the specified path to this app's data directory. If the
* asset is a directory, its contents are also copied. * asset is a directory, its contents are also copied.
* *
* @param path * @param path Path to asset, relative to app's assets directory.
* Path to asset, relative to app's assets directory.
*/ */
private void copyAsset(String path) { private void copyAsset(String path) {
AssetManager manager = getAssets(); AssetManager manager = getAssets();
@ -459,8 +456,7 @@ public class I2PDActivity extends Activity {
* Copy the asset file specified by path to app's data directory. Assumes * Copy the asset file specified by path to app's data directory. Assumes
* parent directories have already been created. * parent directories have already been created.
* *
* @param path * @param path Path to asset, relative to app's assets directory.
* Path to asset, relative to app's assets directory.
*/ */
private void copyFileAsset(String path) { private void copyFileAsset(String path) {
File file = new File(i2pdpath, path); File file = new File(i2pdpath, path);
@ -518,7 +514,7 @@ public class I2PDActivity extends Activity {
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
text.append(line); text.append(line);
} }
}finally { } finally {
try { try {
br.close(); br.close();
} catch (IOException e) { } catch (IOException e) {
@ -545,8 +541,7 @@ public class I2PDActivity extends Activity {
Log.e(TAG, "holderFile.delete() returned " + deleteResult + ", absolute path='" + holderFile.getAbsolutePath() + "'"); Log.e(TAG, "holderFile.delete() returned " + deleteResult + ", absolute path='" + holderFile.getAbsolutePath() + "'");
File certPath = new File(i2pdpath, "certificates"); File certPath = new File(i2pdpath, "certificates");
deleteRecursive(certPath); deleteRecursive(certPath);
} } catch (Throwable tr) {
catch (Throwable tr) {
Log.e(TAG, "", tr); Log.e(TAG, "", tr);
} }
@ -566,13 +561,11 @@ public class I2PDActivity extends Activity {
try { try {
writer.close(); writer.close();
} catch (IOException e) { } catch (IOException e) {
Log.e(TAG,"on writer close", e); Log.e(TAG, "on writer close", e);
} }
} }
} } catch (Throwable tr) {
catch (Throwable tr) Log.e(TAG, "on assets copying", tr);
{
Log.e(TAG,"on assets copying", tr);
} }
} }
} }

1
app/src/main/java/org/purplei2p/i2pd/I2PDPermsAskerActivity.java

@ -136,6 +136,7 @@ public class I2PDPermsAskerActivity extends Activity {
} }
private static final int SHOW_EXPLANATION_REQUEST = 1; // The request code private static final int SHOW_EXPLANATION_REQUEST = 1; // The request code
private void showExplanation() { private void showExplanation() {
Intent intent = new Intent(this, I2PDPermsExplanationActivity.class); Intent intent = new Intent(this, I2PDPermsExplanationActivity.class);
startActivityForResult(intent, SHOW_EXPLANATION_REQUEST); startActivityForResult(intent, SHOW_EXPLANATION_REQUEST);

2
app/src/main/java/org/purplei2p/i2pd/I2PDPermsExplanationActivity.java

@ -14,7 +14,7 @@ public class I2PDPermsExplanationActivity extends Activity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_perms_explanation); setContentView(R.layout.activity_perms_explanation);
ActionBar actionBar = getActionBar(); ActionBar actionBar = getActionBar();
if(actionBar!=null)actionBar.setHomeButtonEnabled(false); if (actionBar != null) actionBar.setHomeButtonEnabled(false);
Button button_ok = (Button) findViewById(R.id.button_ok); Button button_ok = (Button) findViewById(R.id.button_ok);
button_ok.setOnClickListener(new View.OnClickListener() { button_ok.setOnClickListener(new View.OnClickListener() {
@Override @Override

7
app/src/main/java/org/purplei2p/i2pd/NetworkStateChangeReceiver.java

@ -14,17 +14,18 @@ public class NetworkStateChangeReceiver extends BroadcastReceiver {
//api level 1 //api level 1
@Override @Override
public void onReceive(final Context context, final Intent intent) { public void onReceive(final Context context, final Intent intent) {
Log.d(TAG,"Network state change"); Log.d(TAG, "Network state change");
try { try {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
assert cm != null;
NetworkInfo activeNetworkInfo = cm.getActiveNetworkInfo(); NetworkInfo activeNetworkInfo = cm.getActiveNetworkInfo();
boolean isConnected = activeNetworkInfo!=null && activeNetworkInfo.isConnected(); boolean isConnected = activeNetworkInfo != null && activeNetworkInfo.isConnected();
// https://developer.android.com/training/monitoring-device-state/connectivity-monitoring.html?hl=ru // https://developer.android.com/training/monitoring-device-state/connectivity-monitoring.html?hl=ru
// boolean isWiFi = activeNetworkInfo!=null && (activeNetworkInfo.getType() == ConnectivityManager.TYPE_WIFI); // boolean isWiFi = activeNetworkInfo!=null && (activeNetworkInfo.getType() == ConnectivityManager.TYPE_WIFI);
I2PD_JNI.onNetworkStateChanged(isConnected); I2PD_JNI.onNetworkStateChanged(isConnected);
} catch (Throwable tr) { } catch (Throwable tr) {
Log.d(TAG,"",tr); Log.d(TAG, "", tr);
} }
} }
} }

2
app/src/main/res/values/strings.xml

@ -20,7 +20,7 @@
<string name="startFailed">Start failed</string> <string name="startFailed">Start failed</string>
<string name="stopped">Application stopped</string> <string name="stopped">Application stopped</string>
<string name="remaining">remaining</string> <string name="remaining">remaining</string>
<string name="ok">OK</string> <string name="ok" translatable="false">OK</string>
<string name="title_activity_i2_pdperms_asker_prompt">Prompt</string> <string name="title_activity_i2_pdperms_asker_prompt">Prompt</string>
<string name="permDenied">SD card write permission denied, you need to allow this to continue</string> <string name="permDenied">SD card write permission denied, you need to allow this to continue</string>

2
build.gradle

@ -5,7 +5,7 @@ buildscript {
google() google()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.4.2' classpath 'com.android.tools.build:gradle:3.6.1'
} }
} }

4
gradle/wrapper/gradle-wrapper.properties vendored

@ -1,6 +1,6 @@
#Tue Aug 20 14:39:08 MSK 2019 #Fri Jun 12 07:37:19 MSK 2020
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

1
settings.gradle

@ -1 +1,2 @@
include ':app' include ':app'
project(":app").name = "i2pd"
Loading…
Cancel
Save