From 9f07fdb39a42ad661fcd9d12353da3bf002f1a0d Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 11 Feb 2016 10:13:10 +0100 Subject: [PATCH] Revert "Remove open file percentage" This reverts commit 2181221a7945b82bdd8e8cd565e2254153a7509b. --- .../eu/faircode/netguard/SinkholeService.java | 19 +++++++++++++++++++ app/src/main/res/layout/traffic.xml | 10 ++++++++++ 2 files changed, 29 insertions(+) diff --git a/app/src/main/java/eu/faircode/netguard/SinkholeService.java b/app/src/main/java/eu/faircode/netguard/SinkholeService.java index 03db77d7..24c6aa7b 100644 --- a/app/src/main/java/eu/faircode/netguard/SinkholeService.java +++ b/app/src/main/java/eu/faircode/netguard/SinkholeService.java @@ -637,6 +637,25 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS if (filter && loglevel <= Log.WARN) { int[] count = jni_get_session_count(); remoteViews.setTextViewText(R.id.tvSessions, count[0] + "/" + count[1] + "/" + count[2]); + + File proc = new File("/proc/sys/fs/file-nr"); + BufferedReader br = null; + try { + br = new BufferedReader(new FileReader(proc)); + String line = br.readLine(); + String[] filenr = line.split("\\s+"); + if (filenr.length == 3) { + int perc = Integer.parseInt(filenr[0]) * 100 / Integer.parseInt(filenr[2]); + remoteViews.setTextViewText(R.id.tvFiles, perc + "%"); + } + } catch (Throwable ignored) { + } finally { + if (br != null) + try { + br.close(); + } catch (IOException ignored) { + } + } } // Show notification diff --git a/app/src/main/res/layout/traffic.xml b/app/src/main/res/layout/traffic.xml index 3127056b..9e106242 100644 --- a/app/src/main/res/layout/traffic.xml +++ b/app/src/main/res/layout/traffic.xml @@ -68,6 +68,16 @@ android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Info" android:textSize="10sp" /> + +