Reload stats

This commit is contained in:
M66B 2015-12-11 10:36:35 +01:00
parent f2038c2cfe
commit 08630ecc6c
4 changed files with 19 additions and 3 deletions

View File

@ -286,7 +286,7 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere
SinkholeService.reload("other", "setting changed", this);
} else if ("show_stats".equals(name))
;
SinkholeService.reloadStats("setting changed", this);
else if ("stats_base".equals(name))
getPreferenceScreen().findPreference(name).setTitle(getString(R.string.setting_stats_base, prefs.getString(name, "5")));

View File

@ -24,6 +24,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.VpnService;
import android.os.PowerManager;
import android.preference.PreferenceManager;
import android.util.Log;
@ -63,6 +64,10 @@ public class Receiver extends BroadcastReceiver {
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
Util.sendCrashReport(ex, context);
}
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
if (pm.isInteractive())
SinkholeService.reloadStats("receiver", context);
}
}

View File

@ -93,7 +93,7 @@ public class SinkholeService extends VpnService {
private static final int MSG_STATS_STOP = 2;
private static final int MSG_STATS_UPDATE = 3;
private enum Command {start, reload, stop}
private enum Command {start, reload, stop, stats}
private static volatile PowerManager.WakeLock wlInstance = null;
@ -222,6 +222,11 @@ public class SinkholeService extends VpnService {
stopForeground(true);
}
break;
case stats:
stopStats();
startStats();
break;
}
// Update main view
@ -867,4 +872,11 @@ public class SinkholeService extends VpnService {
intent.putExtra(EXTRA_REASON, reason);
context.startService(intent);
}
public static void reloadStats(String reason, Context context) {
Intent intent = new Intent(context, SinkholeService.class);
intent.putExtra(EXTRA_COMMAND, Command.stats);
intent.putExtra(EXTRA_REASON, reason);
context.startService(intent);
}
}

View File

@ -18,7 +18,6 @@
android:layout_alignParentTop="true"
android:gravity="center_horizontal">
<TextView
android:id="@+id/tvTx"
android:layout_width="wrap_content"