diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/InfluxDB2x/Worker/InfluxDB2xUploadWorker.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/InfluxDB2x/Worker/InfluxDB2xUploadWorker.java index 55115321..0782ff88 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/InfluxDB2x/Worker/InfluxDB2xUploadWorker.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/InfluxDB2x/Worker/InfluxDB2xUploadWorker.java @@ -65,17 +65,17 @@ public Result doWork() { } BufferedReader br; try { - br = new BufferedReader(new FileReader(input.getParameter().getLineProtocolFile())); + br = new BufferedReader(new FileReader(input.getParameter().getLineProtocolFilePath())); } catch (FileNotFoundException | NullPointerException e) { Log.d(TAG,e.toString()); return Result.failure(output); } List points = br.lines().collect(Collectors.toList()); try { - Log.d(TAG, String.format("doWork: uploading %s", input.getParameter().getLineProtocolFile())); + Log.d(TAG, String.format("doWork: uploading %s", input.getParameter().getLineProtocolFilePath())); influx.writeRecords(points); } catch (IOException e) { - Log.d(TAG, String.format("doWork: upload of %s failed!", input.getParameter().getLineProtocolFile())); + Log.d(TAG, String.format("doWork: upload of %s failed!", input.getParameter().getLineProtocolFilePath())); return Result.failure(output); } diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Inputs/Inputs.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Inputs/Inputs.java index 12203af5..bda00df5 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Inputs/Inputs.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Inputs/Inputs.java @@ -115,7 +115,6 @@ public void writeToParcel(@NonNull Parcel dest, int flags) { dest.writeString(sequenceUUID); dest.writeString(measurementUUID); dest.writeString(testUUID); - dest.writeParcelable(parameter, flags); } public Data.Builder getInputAsDataBuilder(int i, String packageName) { diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Fragments/Iperf3Fragment.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Fragments/Iperf3Fragment.java index 9c1b8d64..69ee3980 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Fragments/Iperf3Fragment.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Fragments/Iperf3Fragment.java @@ -311,8 +311,8 @@ public void onClick(View view) { iperf3Input.getParameter().updatePaths(); iperf3Input.setTimestamp(new Timestamp(System.currentTimeMillis())); - File logFile = new File(iperf3Input.getParameter().getLogfile()); - File rawPath = new File(Iperf3Parameter.rawDirPath); + File logFile = new File(iperf3Input.getParameter().getRawLogFilePath()); + File rawPath = new File(iperf3Input.getParameter().getRawDirPath()); if(!rawPath.exists()) { rawPath.mkdirs(); diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Worker/Iperf3ExecutorWorker.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Worker/Iperf3ExecutorWorker.java index f1af4024..79d99623 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Worker/Iperf3ExecutorWorker.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Worker/Iperf3ExecutorWorker.java @@ -77,8 +77,8 @@ public Iperf3ExecutorWorker(@NonNull Context context, @NonNull WorkerParameters public ListenableFuture startRemoteWork() { return CallbackToFutureAdapter.getFuture(completer -> { Log.d(TAG, "startRemoteWork: tags: "+this.getTags()); - File logFile = new File(iperf3Input.getParameter().getLogfile()); - File rawPath = new File(Iperf3Parameter.rawDirPath); + File logFile = new File(iperf3Input.getParameter().getRawLogFilePath()); + File rawPath = new File(iperf3Input.getParameter().getRawDirPath()); if(!rawPath.exists()) { rawPath.mkdirs(); diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Worker/Iperf3MonitorWorker.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Worker/Iperf3MonitorWorker.java index 7a0210a0..cf72312e 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Worker/Iperf3MonitorWorker.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Worker/Iperf3MonitorWorker.java @@ -111,7 +111,7 @@ public Iperf3MonitorWorker(@NonNull Context context, @NonNull WorkerParameters w notificationLayout.setViewVisibility(R.id.notification_direction, GONE); setForegroundAsync(createForegroundInfo(notificationLayout)); - this.pathToFile = iperf3Input.getParameter().getLogfile(); + this.pathToFile = iperf3Input.getParameter().getRawLogFilePath(); Log.d(TAG, "Iperf3MonitorWorker: pathToFile: "+this.pathToFile); this.file = new File(this.pathToFile); } diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Worker/Iperf3ToLineProtocolWorker.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Worker/Iperf3ToLineProtocolWorker.java index 4ab5490e..8346e2eb 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Worker/Iperf3ToLineProtocolWorker.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Worker/Iperf3ToLineProtocolWorker.java @@ -186,11 +186,11 @@ public Result doWork() { } } - File path = new File(Iperf3Parameter.lineProtocolDirPath); + File path = new File(iperf3Input.getParameter().getRawDirPath()); if(!path.exists()){ path.mkdirs(); } - File iperf3File = new File(iperf3Input.getParameter().getLineProtocolFile()); + File iperf3File = new File(iperf3Input.getParameter().getLineProtocolDirPath()); if (!iperf3File.exists()) { try { iperf3File.createNewFile(); @@ -201,7 +201,7 @@ public Result doWork() { FileOutputStream iperf3Stream = null; try { - iperf3Stream = new FileOutputStream(iperf3Input.getParameter().getLineProtocolFile(), true); + iperf3Stream = new FileOutputStream(iperf3Input.getParameter().getLineProtocolDirPath(), true); } catch (FileNotFoundException e) { Toast.makeText(getApplicationContext(), "logfile not created", Toast.LENGTH_SHORT).show(); Log.d(TAG,e.toString()); diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Worker/Iperf3UploadWorker.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Worker/Iperf3UploadWorker.java index 54e9cbcf..aae60667 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Worker/Iperf3UploadWorker.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Worker/Iperf3UploadWorker.java @@ -65,17 +65,17 @@ public Result doWork() { } BufferedReader br; try { - br = new BufferedReader(new FileReader(iperf3Input.getParameter().getLineProtocolFile())); + br = new BufferedReader(new FileReader(iperf3Input.getParameter().getLineProtocolFilePath())); } catch (FileNotFoundException | NullPointerException e) { Log.d(TAG,e.toString()); return Result.failure(output); } List points = br.lines().collect(Collectors.toList()); try { - Log.d(TAG, String.format("doWork: uploading %s", iperf3Input.getParameter().getLineProtocolFile())); + Log.d(TAG, String.format("doWork: uploading %s", iperf3Input.getParameter().getLineProtocolFilePath())); influx.writeRecords(points); } catch (IOException e) { - Log.d(TAG, String.format("doWork: upload of %s failed!", iperf3Input.getParameter().getLineProtocolFile())); + Log.d(TAG, String.format("doWork: upload of %s failed!", iperf3Input.getParameter().getLineProtocolFilePath())); return Result.failure(output); } diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/MQTT/Handler/Iperf3Handler.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/MQTT/Handler/Iperf3Handler.java index c1af87f9..fd817f10 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/MQTT/Handler/Iperf3Handler.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/MQTT/Handler/Iperf3Handler.java @@ -63,7 +63,7 @@ public void parsePayload(String payload) throws JSONException { Iperf3RunResult iperf3RunResult = new Iperf3RunResult(iperf3Input.getTestUUID(), -100, false, iperf3Input, new java.sql.Timestamp(System.currentTimeMillis())); iperf3RunResultDao.insert(iperf3RunResult); - File logFile = new File(iperf3Input.getParameter().getLogfile()); + File logFile = new File(iperf3Input.getParameter().getRawLogFilePath()); if(logFile.exists()) { logFile.delete(); } diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/MQTT/Handler/PingHandler.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/MQTT/Handler/PingHandler.java index bb65c70d..15c20f52 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/MQTT/Handler/PingHandler.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/MQTT/Handler/PingHandler.java @@ -48,7 +48,7 @@ public void parsePayload(String payload) throws JSONException { PingParameter pingParameter = new PingParameter(params, testUUID); if(pingParameter == null) continue; PingInput pingInput = new PingInput(pingParameter, testUUID, sequenceUUID, measurementUUUID,campaignUUID); - File logFile = new File(pingInput.getParameter().getLogfile()); + File logFile = new File(pingInput.getParameter().getLineProtocolFilePath()); if(logFile.exists()) { logFile.delete(); } diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Parameter/Iperf3Parameter.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Parameter/Iperf3Parameter.java index badca39e..28f74131 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Parameter/Iperf3Parameter.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Parameter/Iperf3Parameter.java @@ -8,9 +8,7 @@ package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Parameter; -import android.os.Environment; import android.os.Parcel; -import android.os.Parcelable; import android.util.Log; import androidx.annotation.NonNull; @@ -24,8 +22,7 @@ import java.util.ArrayList; public class Iperf3Parameter extends Parameter { - public static final String rawDirPath = rootPath+"/omnt/iperf3/raw/"; - public static final String lineProtocolDirPath = rootPath+"/omnt/iperf3/lineprotocol/"; + public static final String HOST = "host"; public static final String PORT = "port"; public static final String BITRATE = "bitrate"; @@ -66,7 +63,6 @@ public class Iperf3Parameter extends Parameter { public static final String RSAPRIVATEKEYPATH = "rsaPrivateKeyPath"; public static final String IDLETIMEOUT = "idleTimeout"; public static final String SERVERBITRATELIMIT = "serverBitrateLimit"; - public static final String SERVER = "server"; public static final String CLIENT = "client"; public static final String DAEMON = "daemon"; @@ -94,332 +90,35 @@ public class Iperf3Parameter extends Parameter { private static final String TAG = "Iperf3Parameter"; - - protected Iperf3Parameter(Parcel in) { - super(in); - host = in.readString(); - iPerf3UUID = in.readString(); - port = in.readInt(); - interval = in.readDouble(); - bitrate = in.readString(); - length = in.readInt(); - pidfile = in.readString(); - file = in.readString(); - affinity = in.readString(); - bind = in.readString(); - bindDev = in.readString(); - byte tmpVerbose = in.readByte(); - verbose = tmpVerbose == 0 ? null : tmpVerbose == 1; - byte tmpJson = in.readByte(); - json = tmpJson == 0 ? null : tmpJson == 1; - byte tmpJsonStream = in.readByte(); - jsonStream = tmpJsonStream == 0 ? null : tmpJsonStream == 1; - byte tmpForceflush = in.readByte(); - forceflush = tmpForceflush == 0 ? null : tmpForceflush == 1; - timestamps = in.readString(); - if (in.readByte() == 0) { - rcvTimeout = null; - } else { - rcvTimeout = in.readInt(); - } - if (in.readByte() == 0) { - sndTimeout = null; - } else { - sndTimeout = in.readInt(); - } - if (in.readByte() == 0) { - debug = null; - } else { - debug = in.readInt(); - } - byte tmpVersion = in.readByte(); - version = tmpVersion == 0 ? null : tmpVersion == 1; - byte tmpHelp = in.readByte(); - help = tmpHelp == 0 ? null : tmpHelp == 1; - byte tmpDaemon = in.readByte(); - daemon = tmpDaemon == 0 ? null : tmpDaemon == 1; - byte tmpOneOff = in.readByte(); - oneOff = tmpOneOff == 0 ? null : tmpOneOff == 1; - serverBitrateLimit = in.readString(); - if (in.readByte() == 0) { - idleTimeout = null; - } else { - idleTimeout = in.readInt(); - } - rsaPrivateKeyPath = in.readString(); - authorizedUsersPath = in.readString(); - if (in.readByte() == 0) { - timeSkewThreshold = null; - } else { - timeSkewThreshold = in.readInt(); - } - byte tmpUsePkcs1Padding = in.readByte(); - usePkcs1Padding = tmpUsePkcs1Padding == 0 ? null : tmpUsePkcs1Padding == 1; - byte tmpSctp = in.readByte(); - sctp = tmpSctp == 0 ? null : tmpSctp == 1; - xbind = in.readString(); - if (in.readByte() == 0) { - nstreams = null; - } else { - nstreams = in.readInt(); - } - if (in.readByte() == 0) { - connectTimeout = null; - } else { - connectTimeout = in.readInt(); - } - pacingTimer = in.readString(); - fqRate = in.readString(); - if (in.readByte() == 0) { - time = null; - } else { - time = in.readInt(); - } - bytes = in.readString(); - blockcount = in.readString(); - if (in.readByte() == 0) { - cport = null; - } else { - cport = in.readInt(); - } - if (in.readByte() == 0) { - parallel = null; - } else { - parallel = in.readInt(); - } - byte tmpReverse = in.readByte(); - reverse = tmpReverse == 0 ? null : tmpReverse == 1; - byte tmpBidir = in.readByte(); - bidir = tmpBidir == 0 ? null : tmpBidir == 1; - window = in.readString(); - congestion = in.readString(); - if (in.readByte() == 0) { - setMss = null; - } else { - setMss = in.readInt(); - } - byte tmpNoDelay = in.readByte(); - noDelay = tmpNoDelay == 0 ? null : tmpNoDelay == 1; - byte tmpVersion4 = in.readByte(); - version4 = tmpVersion4 == 0 ? null : tmpVersion4 == 1; - byte tmpVersion6 = in.readByte(); - version6 = tmpVersion6 == 0 ? null : tmpVersion6 == 1; - if (in.readByte() == 0) { - tos = null; - } else { - tos = in.readInt(); - } - dscp = in.readString(); - if (in.readByte() == 0) { - flowlabel = null; - } else { - flowlabel = in.readInt(); - } - byte tmpZerocopy = in.readByte(); - zerocopy = tmpZerocopy == 0 ? null : tmpZerocopy == 1; - if (in.readByte() == 0) { - omit = null; - } else { - omit = in.readInt(); - } - title = in.readString(); - extraData = in.readString(); - byte tmpGetServerOutput = in.readByte(); - getServerOutput = tmpGetServerOutput == 0 ? null : tmpGetServerOutput == 1; - byte tmpUdpCounters64bit = in.readByte(); - udpCounters64bit = tmpUdpCounters64bit == 0 ? null : tmpUdpCounters64bit == 1; - byte tmpRepeatingPayload = in.readByte(); - repeatingPayload = tmpRepeatingPayload == 0 ? null : tmpRepeatingPayload == 1; - byte tmpDontFragment = in.readByte(); - dontFragment = tmpDontFragment == 0 ? null : tmpDontFragment == 1; - username = in.readString(); - rsaPublicKeyPath = in.readString(); - } - - public static final Creator CREATOR = new Creator() { - @Override - public Iperf3Parameter createFromParcel(Parcel in) { - return new Iperf3Parameter(in); - } - - @Override - public Iperf3Parameter[] newArray(int size) { - return new Iperf3Parameter[size]; - } - }; - - public Iperf3Parameter(String ip, - int port, - String bitrate, - int duration, - double interval, - String bytes, - int streams, - int cport, - String testUUID, - Iperf3Mode mode, - Iperf3Protocol protocol, - Iperf3Direction direction - ) { - - super(rawDirPath+testUUID+".txt", lineProtocolDirPath+testUUID+".txt"); - this.testUUID = testUUID; - this.host = ip; - this.port = port; - this.bitrate = bitrate; - this.time = duration; - this.interval = interval; - this.bytes = bytes; - this.nstreams = streams; - this.cport = cport; - this.mode = mode; - this.direction = direction; - this.protocol = protocol; - - } - - public Iperf3Parameter(String iPerf3UUID){ - super(rawDirPath+iPerf3UUID+".txt", lineProtocolDirPath+iPerf3UUID+".txt"); - } - public Iperf3Parameter(String ip, - String iPerf3UUID, - Iperf3Protocol protocol, - int port, - double interval, - String bitrate, - int length, - Iperf3Mode mode, - Iperf3Direction direction, - String pidfile, - String file, - String affinity, - String bind, - String bindDev, - Boolean verbose, - Boolean json, - Boolean jsonStream, - String logfile, - Boolean forceflush, - String timestamps, - Integer rcvTimeout, - Integer sndTimeout, - Integer debug, - Boolean version, - Boolean help, - Boolean daemon, - Boolean oneOff, - String serverBitrateLimit, - Integer idleTimeout, - String rsaPrivateKeyPath, - String authorizedUsersPath, - Integer timeSkewThreshold, - Boolean usePkcs1Padding, - Boolean sctp, - String xbind, - Integer nstreams, - Integer connectTimeout, - String pacingTimer, - String fqRate, - Integer time, - String bytes, - String blockcount, - Integer cport, - Integer parallel, - Boolean reverse, - Boolean bidir, - String window, - String congestion, - Integer setMss, - Boolean noDelay, - Boolean version4, - Boolean version6, - Integer tos, - String dscp, - Integer flowlabel, - Boolean zerocopy, - Integer omit, - String title, - String extraData, - Boolean getServerOutput, - Boolean udpCounters64bit, - Boolean repeatingPayload, - Boolean dontFragment, - String username, - String rsaPublicKeyPath) { - super(rawDirPath+iPerf3UUID+".txt", lineProtocolDirPath+iPerf3UUID+".txt"); - this.host = ip; - this.iPerf3UUID = iPerf3UUID; - this.protocol = protocol; - this.port = port; - this.interval = interval; - this.bitrate = bitrate; - this.length = length; - this.mode = mode; - this.direction = direction; - this.pidfile = pidfile; - this.file = file; - this.affinity = affinity; - this.bind = bind; - this.bindDev = bindDev; - this.verbose = verbose; - this.json = json; - this.jsonStream = jsonStream; - this.forceflush = forceflush; - this.timestamps = timestamps; - this.rcvTimeout = rcvTimeout; - this.sndTimeout = sndTimeout; - this.debug = debug; - this.version = version; - this.help = help; - this.daemon = daemon; - this.oneOff = oneOff; - this.serverBitrateLimit = serverBitrateLimit; - this.idleTimeout = idleTimeout; - this.rsaPrivateKeyPath = rsaPrivateKeyPath; - this.authorizedUsersPath = authorizedUsersPath; - this.timeSkewThreshold = timeSkewThreshold; - this.usePkcs1Padding = usePkcs1Padding; - this.sctp = sctp; - this.xbind = xbind; - this.nstreams = nstreams; - this.connectTimeout = connectTimeout; - this.pacingTimer = pacingTimer; - this.fqRate = fqRate; - this.time = time; - this.bytes = bytes; - this.blockcount = blockcount; - this.cport = cport; - this.parallel = parallel; - this.reverse = reverse; - this.bidir = bidir; - this.window = window; - this.congestion = congestion; - this.setMss = setMss; - this.noDelay = noDelay; - this.version4 = version4; - this.version6 = version6; - this.tos = tos; - this.dscp = dscp; - this.flowlabel = flowlabel; - this.zerocopy = zerocopy; - this.omit = omit; - this.title = title; - this.extraData = extraData; - this.getServerOutput = getServerOutput; - this.udpCounters64bit = udpCounters64bit; - this.repeatingPayload = repeatingPayload; - this.dontFragment = dontFragment; - this.username = username; - this.rsaPublicKeyPath = rsaPublicKeyPath; + public void updatePaths(){ + super.setRawLogFilePath(super.getRawDirPath()+"/"+testUUID+".json"); + super.setLineProtocolFilePath(super.getLineProtocolDirPath()+"/"+testUUID+".lp"); + } + public Iperf3Parameter(String testUUID){ + this(new JSONObject(), testUUID); } - public void updatePaths(){ - super.setLogfile(rawDirPath+testUUID+".txt"); - super.setLineProtocolFile(lineProtocolDirPath+testUUID+".txt"); + public void setDirectionFlags() { + switch (this.direction) { + case UP: + this.reverse = false; + this.bidir = false; + break; + case DOWN: + this.reverse = true; + this.bidir = false; + break; + case BIDIR: + this.bidir = true; + this.reverse = false; + break; + } } + public Iperf3Parameter(JSONObject jsonObject, String testUUID) { - super(rawDirPath+testUUID+".txt", lineProtocolDirPath+testUUID+".txt"); + super(ParameterType.IPERF3, + testUUID); this.testUUID = testUUID; this.jsonStream = true; @@ -469,6 +168,8 @@ public Iperf3Parameter(JSONObject jsonObject, String testUUID) { String direction = jsonObject.getString(DIRECTION); Log.d(TAG, "Iperf3Parameter: direction: "+direction); this.direction = Iperf3Direction.valueOf(direction.toUpperCase().trim()); + setDirectionFlags(); + } catch (JSONException e) { this.direction = Iperf3Direction.UP; Log.d(TAG, "direction not set."); @@ -755,85 +456,13 @@ public Iperf3Parameter(JSONObject jsonObject, String testUUID) { Log.d(TAG, "title not set."); } try { - Files.createDirectories(Paths.get(rawDirPath)); - Files.createDirectories(Paths.get(lineProtocolDirPath)); + Files.createDirectories(Paths.get(super.getRawDirPath())); + Files.createDirectories(Paths.get(super.getLineProtocolDirPath())); } catch (IOException e) { Log.d(TAG, "Could not create directories."); } } - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(@NonNull Parcel dest, int flags) { - dest.writeString(host); - dest.writeString(iPerf3UUID); - dest.writeInt(port); - dest.writeDouble(interval); - dest.writeString(bitrate); - dest.writeInt(length); - dest.writeString(mode.name()); - dest.writeString(direction.name()); - dest.writeString(pidfile); - dest.writeString(file); - dest.writeString(affinity); - dest.writeString(bind); - dest.writeString(bindDev); - dest.writeBoolean(verbose); - dest.writeBoolean(json); - dest.writeBoolean(jsonStream); - dest.writeBoolean(forceflush); - dest.writeString(timestamps); - dest.writeInt(rcvTimeout); - dest.writeInt(sndTimeout); - dest.writeInt(debug); - dest.writeBoolean(version); - dest.writeBoolean(help); - dest.writeBoolean(daemon); - dest.writeBoolean(oneOff); - dest.writeString(serverBitrateLimit); - dest.writeInt(idleTimeout); - dest.writeString(rsaPrivateKeyPath); - dest.writeString(authorizedUsersPath); - dest.writeInt(timeSkewThreshold); - dest.writeBoolean(usePkcs1Padding); - dest.writeBoolean(sctp); - dest.writeString(xbind); - dest.writeInt(nstreams); - dest.writeInt(connectTimeout); - dest.writeString(pacingTimer); - dest.writeString(fqRate); - dest.writeInt(time); - dest.writeString(bytes); - dest.writeString(blockcount); - dest.writeInt(cport); - dest.writeInt(parallel); - dest.writeBoolean(reverse); - dest.writeBoolean(bidir); - dest.writeString(window); - dest.writeString(congestion); - dest.writeInt(setMss); - dest.writeBoolean(noDelay); - dest.writeBoolean(version4); - dest.writeBoolean(version6); - dest.writeInt(tos); - dest.writeString(dscp); - dest.writeInt(flowlabel); - dest.writeBoolean(zerocopy); - dest.writeInt(omit); - dest.writeString(title); - dest.writeString(extraData); - dest.writeBoolean(getServerOutput); - dest.writeBoolean(udpCounters64bit); - dest.writeBoolean(repeatingPayload); - dest.writeBoolean(dontFragment); - dest.writeString(username); - dest.writeString(rsaPublicKeyPath); - } - public String getHost() { return host; } @@ -1810,7 +1439,7 @@ public String[] getInputAsCommand() { command.add("--json-stream"); command.add("--forceflush"); command.add("--logfile"); - command.add(super.getLogfile()); + command.add(super.getRawLogFilePath()); diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Parameter/Parameter.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Parameter/Parameter.java index ccf116eb..a259bbfe 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Parameter/Parameter.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Parameter/Parameter.java @@ -12,53 +12,64 @@ import android.os.Parcel; import android.os.Parcelable; -public class Parameter implements Parcelable { - public static final String rootPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath(); - private String lineProtocolFile; - private String logfile; +public class Parameter { + private ParameterType parameterType; + public static final String rootPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath()+"/omnt"; + private String rawDirPath; + private String lineProtocolDirPath; + private String lineProtocolFilePath; + private String rawLogFilePath; protected Parameter(Parcel in) { - lineProtocolFile = in.readString(); - logfile = in.readString(); + lineProtocolFilePath = in.readString(); + rawLogFilePath = in.readString(); } - public Parameter(String logfile, String lineProtocolFile) { - this.logfile = logfile; - this.lineProtocolFile = lineProtocolFile; + public Parameter(ParameterType type, + String testUUID) { + this.parameterType = type; + this.rawDirPath = rootPath + "/" + this.parameterType.toString().toLowerCase() + "/raw"; + this.lineProtocolDirPath = rootPath + "/" + this.parameterType.toString().toLowerCase() + "/lineprotocol"; + this.rawLogFilePath = this.rawDirPath + "/" + testUUID + ".log"; + this.lineProtocolFilePath = this.lineProtocolDirPath + "/" + testUUID + ".lp"; } - public static final Creator CREATOR = new Creator() { - @Override - public Parameter createFromParcel(Parcel in) { - return new Parameter(in); - } + public ParameterType getParameterType() { + return parameterType; + } + + public String getRootPath() { + return rootPath; + } - @Override - public Parameter[] newArray(int size) { - return new Parameter[size]; - } - }; + public String getRawDirPath() { + return rawDirPath; + } - public String getLineProtocolFile() { - return lineProtocolFile; + public void setRawDirPath(String rawDirPath) { + this.rawDirPath = rawDirPath; } - public String getLogfile() { - return logfile; + public String getLineProtocolDirPath() { + return lineProtocolDirPath; } - public int describeContents() { - return 0; + public void setLineProtocolDirPath(String lineProtocolDirPath) { + this.lineProtocolDirPath = lineProtocolDirPath; } - public void writeToParcel(android.os.Parcel dest, int flags) { - dest.writeString(lineProtocolFile); - dest.writeString(logfile); + public String getLineProtocolFilePath() { + return lineProtocolFilePath; } - public void setLineProtocolFile(String lineProtocolFile) { - this.lineProtocolFile = lineProtocolFile; + + public void setLineProtocolFilePath(String lineProtocolFilePath) { + this.lineProtocolFilePath = lineProtocolFilePath; + } + + public String getRawLogFilePath() { + return rawLogFilePath; } - public void setLogfile(String logfile) { - this.logfile = logfile; + public void setRawLogFilePath(String rawLogFilePath) { + this.rawLogFilePath = rawLogFilePath; } } diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Parameter/ParameterType.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Parameter/ParameterType.java new file mode 100644 index 00000000..99146213 --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Parameter/ParameterType.java @@ -0,0 +1,14 @@ +/* + * SPDX-FileCopyrightText: 2025 Peter Hasse + * SPDX-FileCopyrightText: 2025 Johann Hackler + * SPDX-FileCopyrightText: 2025 Fraunhofer FOKUS + * + * SPDX-License-Identifier: BSD-3-Clause-Clear + */ + +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Parameter; + +public enum ParameterType { + PING, + IPERF3 +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Parameter/PingParameter.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Parameter/PingParameter.java index 586be41e..0d25d67a 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Parameter/PingParameter.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Parameter/PingParameter.java @@ -23,11 +23,8 @@ import java.util.ArrayList; public class PingParameter extends Parameter { - public static final String rawDirPath = rootPath+"/omnt/ping/raw/"; - public static final String lineProtocolDirPath = rootPath+"/omnt/ping/lineprotocol/"; private static final String TAG = "PingParameter"; - public static final String PING = "ping"; public static final String DESTINATION = "destination"; public static final String COUNT = "count"; @@ -101,15 +98,16 @@ public String[] getInputAsCommand() { private void setupDirs(){ try { - Files.createDirectories(Paths.get(rawDirPath)); - Files.createDirectories(Paths.get(lineProtocolDirPath)); + Files.createDirectories(Paths.get(super.getRawDirPath())); + Files.createDirectories(Paths.get(super.getLineProtocolFilePath())); } catch (IOException e) { Log.d(TAG, "Could not create directories."); } } public PingParameter(String stringParameter, String testUUID) { - super(rawDirPath + testUUID + ".txt", lineProtocolDirPath + testUUID + ".txt"); + super(ParameterType.PING, + testUUID); this.testUUID = testUUID; String[] parts = stringParameter.split(" "); for (int i = 0; i < parts.length; i++) { @@ -136,7 +134,8 @@ public PingParameter(String stringParameter, String testUUID) { } public PingParameter(JSONObject parameter, String testUUID) { - super(rawDirPath + testUUID + ".txt", lineProtocolDirPath + testUUID + ".txt"); + super(ParameterType.PING, + testUUID); this.testUUID = testUUID; try { destination = parameter.getString(DESTINATION); @@ -188,32 +187,5 @@ protected PingParameter(Parcel in) { network = in.readParcelable(Network.class.getClassLoader()); } - public static final Creator CREATOR = new Creator() { - @Override - public PingParameter createFromParcel(Parcel in) { - return new PingParameter(in); - } - - @Override - public PingParameter[] newArray(int size) { - return new PingParameter[size]; - } - }; - - @Override - public int describeContents() { - return super.describeContents(); - } - - @Override - public void writeToParcel(@NonNull Parcel dest, int flags) { - super.writeToParcel(dest, flags); - dest.writeString(destination); - dest.writeInt(count); - dest.writeDouble(timeoutMillis); - dest.writeInt(packetSize); - dest.writeDouble(intervalMillis); - dest.writeParcelable(network, flags); - } } diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Ping/Worker/PingToLineProtocolWorker.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Ping/Worker/PingToLineProtocolWorker.java index 33e5597d..ec1ab588 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Ping/Worker/PingToLineProtocolWorker.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Ping/Worker/PingToLineProtocolWorker.java @@ -54,10 +54,10 @@ public PingToLineProtocolWorker(@NonNull Context context, @NonNull WorkerParamet pingInput = gson.fromJson(iperf3InputString, PingInput.class); spg = SharedPreferencesGrouper.getInstance(getApplicationContext()); - File lineProtocolDirPath = new File(PingParameter.lineProtocolDirPath); + File lineProtocolDirPath = new File(pingInput.getParameter().getLineProtocolDirPath()); if(!lineProtocolDirPath.exists()){ if(!lineProtocolDirPath.mkdirs()){ - Log.e(TAG, "Error creating lineProtocolDirPath directory: " + PingParameter.lineProtocolDirPath); + Log.e(TAG, "Error creating lineProtocolDirPath directory: " + pingInput.getParameter().getLineProtocolDirPath()); } } } @@ -81,7 +81,7 @@ private LINEType getLineType(String line){ @Override public Result doWork() { Data.Builder output = new Data.Builder().putBoolean("pingUpload", false); - File myObj = new File(pingInput.getPingParameter().getLogfile()); + File myObj = new File(pingInput.getPingParameter().getLineProtocolFilePath()); Scanner scanner = null; try { scanner = new Scanner(myObj); @@ -112,7 +112,7 @@ public Result doWork() { pingInformations.add(pi); } scanner.close(); - File lineprotocolfile = new File(pingInput.getPingParameter().getLineProtocolFile()); + File lineprotocolfile = new File(pingInput.getPingParameter().getLineProtocolFilePath()); if(lineprotocolfile.exists()){ lineprotocolfile.delete(); try { @@ -124,7 +124,7 @@ public Result doWork() { } FileOutputStream pingStream = null; try { - pingStream = new FileOutputStream(pingInput.getPingParameter().getLineProtocolFile(), true); + pingStream = new FileOutputStream(pingInput.getPingParameter().getLineProtocolFilePath(), true); } catch (FileNotFoundException e) { Log.d(TAG, "doWork: " + e.toString()); Log.e(TAG, "doWork: Could not create FileOutputStream"); diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Ping/Worker/PingWorker.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Ping/Worker/PingWorker.java index e167f977..cbb286d1 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Ping/Worker/PingWorker.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Ping/Worker/PingWorker.java @@ -85,10 +85,10 @@ public PingWorker(@NonNull Context context, @NonNull WorkerParameters workerPara notificationManager = (NotificationManager) ct.getSystemService(Context.NOTIFICATION_SERVICE); notificationBuilder = new NotificationCompat.Builder(ct, channelId); - File rawPath = new File(PingParameter.rawDirPath); + File rawPath = new File(pingInput.getParameter().getRawDirPath()); if(!rawPath.exists()){ if(!rawPath.mkdirs()){ - Log.e(TAG, "Error creating rawDirPath directory: " + PingParameter.rawDirPath); + Log.e(TAG, "Error creating rawDirPath directory: " + pingInput.getParameter().getRawDirPath()); } } @@ -154,7 +154,7 @@ public Result doWork() { ProcessBuilder processBuilder = new ProcessBuilder(command); Process process = processBuilder.start(); BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); - FileOutputStream pingStream = new FileOutputStream(pingInput.getPingParameter().getLogfile(), true); + FileOutputStream pingStream = new FileOutputStream(pingInput.getPingParameter().getRawLogFilePath(), true); PingParser pingParser = new PingParser(); String line; diff --git a/app/src/main/res/raw/config.json b/app/src/main/res/raw/config.json index a3118585..17639304 100644 --- a/app/src/main/res/raw/config.json +++ b/app/src/main/res/raw/config.json @@ -513,7 +513,7 @@ "metadata": { "version": "0.7", "code": 7, - "gitHash": "52f0533" + "gitHash": "377044e" } } ] \ No newline at end of file diff --git a/docs/config.json b/docs/config.json index a3118585..17639304 100644 --- a/docs/config.json +++ b/docs/config.json @@ -513,7 +513,7 @@ "metadata": { "version": "0.7", "code": 7, - "gitHash": "52f0533" + "gitHash": "377044e" } } ] \ No newline at end of file