Browse Source

change version code, log levels, stopping message

Signed-off-by: R4SAS <r4sas@i2pmail.org>
pull/44/head
R4SAS 3 years ago
parent
commit
ae3016e4b7
Signed by: r4sas
GPG Key ID: 66F6C87B98EBCFE2
  1. 6
      app/build.gradle
  2. 10
      app/src/main/java/org/purplei2p/i2pd/DaemonWrapper.java
  3. 2
      app/src/main/java/org/purplei2p/i2pd/ForegroundService.java
  4. 23
      app/src/main/java/org/purplei2p/i2pd/I2PDActivity.java
  5. 2
      app/src/main/java/org/purplei2p/i2pd/NetworkStateChangeReceiver.java
  6. 4
      app/src/main/java/org/purplei2p/i2pd/SettingsActivity.java
  7. 2
      app/src/main/res/values-ru/strings.xml
  8. 2
      app/src/main/res/values/strings.xml

6
app/build.gradle

@ -14,9 +14,9 @@ android {
applicationId "org.purplei2p.i2pd" applicationId "org.purplei2p.i2pd"
targetSdkVersion 29 targetSdkVersion 29
minSdkVersion 16 minSdkVersion 16
versionCode 24101 versionCode 2410001
versionName "2.41.0.1" versionName "2.41.0.1"
setProperty("archivesBaseName", archivesBaseName + "-" + versionName) archivesBaseName += "-$versionName"
ndkVersion "21.4.7075529" ndkVersion "21.4.7075529"
ndk { ndk {
@ -83,7 +83,7 @@ android.applicationVariants.all { variant ->
def baseAbiVersionCode = project.ext.abiCodes.get(output.getFilter(OutputFile.ABI)) def baseAbiVersionCode = project.ext.abiCodes.get(output.getFilter(OutputFile.ABI))
if (baseAbiVersionCode != null) { if (baseAbiVersionCode != null) {
output.versionCodeOverride = baseAbiVersionCode + variant.versionCode output.versionCodeOverride = baseAbiVersionCode * 10 + variant.versionCode
} }
} }
} }

10
app/src/main/java/org/purplei2p/i2pd/DaemonWrapper.java

@ -128,7 +128,7 @@ public class DaemonWrapper {
private String daemonStartResult = "N/A"; private String daemonStartResult = "N/A";
private void fireStateUpdate1(State oldValue, State newValue) { private void fireStateUpdate1(State oldValue, State newValue) {
Log.i(TAG, "daemon state change: " + state); Log.d(TAG, "daemon state change: " + state);
for (StateUpdateListener listener : stateUpdateListeners) { for (StateUpdateListener listener : stateUpdateListeners) {
try { try {
listener.daemonStateUpdate(oldValue, newValue); listener.daemonStateUpdate(oldValue, newValue);
@ -186,7 +186,7 @@ public class DaemonWrapper {
synchronized (DaemonWrapper.this) { synchronized (DaemonWrapper.this) {
I2PD_JNI.setDataDir(i2pdpath); // (Environment.getExternalStorageDirectory().getAbsolutePath() + "/i2pd"); I2PD_JNI.setDataDir(i2pdpath); // (Environment.getExternalStorageDirectory().getAbsolutePath() + "/i2pd");
Log.d(TAG, "setting webconsole language to " + appLocale); Log.i(TAG, "setting webconsole language to " + appLocale);
I2PD_JNI.setLanguage(appLocale); I2PD_JNI.setLanguage(appLocale);
daemonStartResult = I2PD_JNI.startDaemon(); daemonStartResult = I2PD_JNI.startDaemon();
@ -351,7 +351,7 @@ public class DaemonWrapper {
} }
boolean deleteResult = fileOrDirectory.delete(); boolean deleteResult = fileOrDirectory.delete();
if (!deleteResult) if (!deleteResult)
Log.e(TAG, "fileOrDirectory.delete() returned " + deleteResult + ", absolute path='" + fileOrDirectory.getAbsolutePath() + "'"); Log.d(TAG, "fileOrDirectory.delete() returned " + deleteResult + ", absolute path='" + fileOrDirectory.getAbsolutePath() + "'");
} }
private void registerNetworkCallback(){ private void registerNetworkCallback(){
@ -373,14 +373,14 @@ public class DaemonWrapper {
public void onAvailable(Network network) { public void onAvailable(Network network) {
super.onAvailable(network); super.onAvailable(network);
I2PD_JNI.onNetworkStateChanged(true); I2PD_JNI.onNetworkStateChanged(true);
Log.i(TAG, "NetworkCallback.onAvailable"); Log.d(TAG, "NetworkCallback.onAvailable");
} }
@Override @Override
public void onLost(Network network) { public void onLost(Network network) {
super.onLost(network); super.onLost(network);
I2PD_JNI.onNetworkStateChanged(false); I2PD_JNI.onNetworkStateChanged(false);
Log.i(TAG, " NetworkCallback.onLost"); Log.d(TAG, " NetworkCallback.onLost");
} }
} }
} }

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

@ -84,7 +84,7 @@ public class ForegroundService extends Service {
@Override @Override
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
Log.i("ForegroundService", "Received start id " + startId + ": " + intent); Log.d("ForegroundService", "Received start id " + startId + ": " + intent);
return START_STICKY; return START_STICKY;
} }

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

@ -107,7 +107,7 @@ public class I2PDActivity extends Activity {
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
Log.i(TAG, "onCreate"); Log.d(TAG, "onCreate");
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
@ -173,11 +173,10 @@ public class I2PDActivity extends Activity {
{ {
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.w(TAG, "WR_EXT_STORAGE perm granted");
else { else {
Log.e(TAG, "WR_EXT_STORAGE perm declined, stopping i2pd"); Log.e(TAG, "WR_EXT_STORAGE perm declined, stopping i2pd");
i2pdStop(); i2pdStop();
//TODO must work w/o this perm, ask orignal
} }
} }
} }
@ -318,14 +317,14 @@ public class I2PDActivity extends Activity {
} }
private void onReloadTunnelsConfig() { private void onReloadTunnelsConfig() {
Log.d(TAG, "reloading tunnels"); Log.i(TAG, "reloading tunnels");
daemon.reloadTunnelsConfigs(); daemon.reloadTunnelsConfigs();
Toast.makeText(this, R.string.tunnels_reloading, Toast.LENGTH_SHORT).show(); Toast.makeText(this, R.string.tunnels_reloading, Toast.LENGTH_SHORT).show();
} }
private void i2pdStop() { private void i2pdStop() {
cancelGracefulStop0(); cancelGracefulStop0();
Log.d(TAG, "stopping"); Log.i(TAG, "stopping");
textView.setText(getText(R.string.stopping)); textView.setText(getText(R.string.stopping));
new Thread(() -> { new Thread(() -> {
try { try {
@ -351,7 +350,7 @@ public class I2PDActivity extends Activity {
Toast.makeText(this, R.string.graceful_stop_is_in_progress, Toast.LENGTH_SHORT).show(); Toast.makeText(this, R.string.graceful_stop_is_in_progress, Toast.LENGTH_SHORT).show();
new Thread(() -> { new Thread(() -> {
try { try {
Log.d(TAG, "graceful stopping"); Log.i(TAG, "graceful stopping");
if (daemon.isStartedOkay()) { if (daemon.isStartedOkay()) {
daemon.stopAcceptingTunnels(); daemon.stopAcceptingTunnels();
long gracefulStopAtMillis; long gracefulStopAtMillis;
@ -373,7 +372,7 @@ public class I2PDActivity extends Activity {
cancelGracefulStop0(); cancelGracefulStop0();
new Thread(() -> { new Thread(() -> {
try { try {
Log.d(TAG, "canceling graceful stop"); Log.i(TAG, "canceling graceful stop");
if (daemon.isStartedOkay()) { if (daemon.isStartedOkay()) {
daemon.startAcceptingTunnels(); daemon.startAcceptingTunnels();
runOnUiThread(() -> Toast.makeText(this, R.string.shutdown_canceled, Toast.LENGTH_SHORT).show()); runOnUiThread(() -> Toast.makeText(this, R.string.shutdown_canceled, Toast.LENGTH_SHORT).show());
@ -390,7 +389,7 @@ public class I2PDActivity extends Activity {
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.i(TAG, "no transit tunnels left, stopping");
i2pdStop(); i2pdStop();
return; return;
} }
@ -436,7 +435,7 @@ public class I2PDActivity extends Activity {
@SuppressLint("BatteryLife") @SuppressLint("BatteryLife")
private void openBatteryOptimizationDialogIfNeeded() { private void openBatteryOptimizationDialogIfNeeded() {
boolean questionEnabled = getPreferences().getBoolean(getBatteryOptimizationPreferenceKey(), true); boolean questionEnabled = getPreferences().getBoolean(getBatteryOptimizationPreferenceKey(), true);
Log.i(TAG, "BATT_OPTIM_questionEnabled==" + questionEnabled); Log.d(TAG, "BATT_OPTIM_questionEnabled==" + questionEnabled);
if (!isKnownIgnoringBatteryOptimizations() if (!isKnownIgnoringBatteryOptimizations()
&& android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M
&& questionEnabled) { && questionEnabled) {
@ -466,14 +465,14 @@ public class I2PDActivity extends Activity {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
final PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE); final PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
if (pm == null) { if (pm == null) {
Log.i(TAG, "BATT_OPTIM: POWER_SERVICE==null"); Log.d(TAG, "BATT_OPTIM: POWER_SERVICE==null");
return false; return false;
} }
boolean ignoring = pm.isIgnoringBatteryOptimizations(getPackageName()); boolean ignoring = pm.isIgnoringBatteryOptimizations(getPackageName());
Log.i(TAG, "BATT_OPTIM: ignoring==" + ignoring); Log.d(TAG, "BATT_OPTIM: ignoring==" + ignoring);
return ignoring; return ignoring;
} else { } else {
Log.i(TAG, "BATT_OPTIM: old SDK version==" + Build.VERSION.SDK_INT); Log.d(TAG, "BATT_OPTIM: old SDK version==" + Build.VERSION.SDK_INT);
return false; return false;
} }
} }

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

@ -21,7 +21,7 @@ public class NetworkStateChangeReceiver extends BroadcastReceiver {
I2PD_JNI.onNetworkStateChanged(isConnected); I2PD_JNI.onNetworkStateChanged(isConnected);
} catch (Throwable tr) { } catch (Throwable tr) {
Log.d(TAG, "", tr); Log.e(TAG, "", tr);
} }
} }
} }

4
app/src/main/java/org/purplei2p/i2pd/SettingsActivity.java

@ -78,7 +78,7 @@ public class SettingsActivity extends Activity {
} }
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
Log.i(TAG, "onCreate"); Log.d(TAG, "onCreate");
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings); setContentView(R.layout.activity_settings);
Objects.requireNonNull(getActionBar()).setDisplayHomeAsUpEnabled(true); Objects.requireNonNull(getActionBar()).setDisplayHomeAsUpEnabled(true);
@ -99,7 +99,7 @@ public class SettingsActivity extends Activity {
if (!onBoot.createNewFile()) if (!onBoot.createNewFile())
Log.d(TAG, "Cant create new wile on: "+onBoot.getAbsolutePath()); Log.d(TAG, "Cant create new wile on: "+onBoot.getAbsolutePath());
} catch (Exception e) { } catch (Exception e) {
Log.d(TAG, "error: " + e.toString()); Log.e(TAG, "error: " + e.toString());
} }
} }
} else { } else {

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

@ -56,5 +56,5 @@
<string name="services">Внутренние сервисы</string> <string name="services">Внутренние сервисы</string>
<string name="services_http_proxy">HTTP Прокси</string> <string name="services_http_proxy">HTTP Прокси</string>
<string name="services_socks_proxy">SOCKS5 Прокси</string> <string name="services_socks_proxy">SOCKS5 Прокси</string>
<string name="stopping">Остановка приложения</string> <string name="stopping">Остановка приложения...</string>
</resources> </resources>

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

@ -24,7 +24,7 @@
<string name="startedOkay">Application started</string> <string name="startedOkay">Application started</string>
<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="stopping">Application stopping</string> <string name="stopping">Application stopping...</string>
<string name="remaining">remaining</string> <string name="remaining">remaining</string>
<string name="ok" translatable="false">OK</string> <string name="ok" translatable="false">OK</string>

Loading…
Cancel
Save