From 4109439fcd4be0c86b91f718f28adf95165e144b Mon Sep 17 00:00:00 2001 From: Martin Kankaanranta <55850510+norkator@users.noreply.github.com> Date: Sun, 14 Nov 2021 12:15:50 +0200 Subject: [PATCH 1/2] get ups ssh status and events command from ups object --- .../com/nitramite/apcupsdmonitor/ConnectorTask.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/nitramite/apcupsdmonitor/ConnectorTask.java b/app/src/main/java/com/nitramite/apcupsdmonitor/ConnectorTask.java index fc8af0a..7bfafad 100644 --- a/app/src/main/java/com/nitramite/apcupsdmonitor/ConnectorTask.java +++ b/app/src/main/java/com/nitramite/apcupsdmonitor/ConnectorTask.java @@ -332,7 +332,7 @@ private void getUPSStatusSSH( StringBuilder stringBuilder = new StringBuilder(); Channel channel = session.openChannel("exec"); - ((ChannelExec) channel).setCommand(Constants.STATUS_COMMAND_APCUPSD); + ((ChannelExec) channel).setCommand(ups.UPS_SERVER_STATUS_COMMAND); channel.setInputStream(null); ((ChannelExec) channel).setErrStream(System.err); InputStream input = channel.getInputStream(); @@ -362,7 +362,7 @@ private void getUPSStatusSSH( databaseHelper.insertUpdateUps(writablePool, ups.UPS_ID, contentValues); if (this.taskMode == TaskMode.MODE_ACTIVITY) { - getUPSEvents(writablePool, session, ups.UPS_ID, loadEvents); + getUPSEvents(writablePool, session, ups, loadEvents); } } catch (JSchException | IOException e) { e.printStackTrace(); @@ -409,7 +409,7 @@ private void getUPSStatusAPCUPSD( // Get ups events private void getUPSEvents( - SQLiteDatabase writablePool, Session session, final String upsId, final boolean loadEvents + SQLiteDatabase writablePool, Session session, final UPS ups, final boolean loadEvents ) { ArrayList events = new ArrayList<>(); if (loadEvents) { @@ -418,7 +418,7 @@ private void getUPSEvents( ChannelSftp channelSftp = (ChannelSftp) session.openChannel("sftp"); channelSftp.connect(); final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - channelSftp.get(Constants.EVENTS_LOCATION, byteArrayOutputStream); + channelSftp.get(ups.UPS_SERVER_EVENTS_LOCATION, byteArrayOutputStream); BufferedReader bufferedReader = new BufferedReader(new StringReader(byteArrayOutputStream.toString())); String line = null; while ((line = bufferedReader.readLine()) != null) { @@ -427,7 +427,7 @@ private void getUPSEvents( bufferedReader.close(); channelSftp.disconnect(); sessionDisconnect(session); - databaseHelper.insertEvents(writablePool, upsId, events); + databaseHelper.insertEvents(writablePool, ups.UPS_ID, events); } catch (JSchException | IOException | SftpException e) { e.printStackTrace(); apcupsdInterface.onCommandError(e.toString()); From 2c072dda03e5fb8bf54b2a0ce3fc4266282ad3a4 Mon Sep 17 00:00:00 2001 From: Martin Kankaanranta <55850510+norkator@users.noreply.github.com> Date: Sun, 14 Nov 2021 12:16:12 +0200 Subject: [PATCH 2/2] bump app version --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d22d390..35d8998 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { minSdkVersion 22 targetSdkVersion 30 - versionCode 49 - versionName "1.18.0" // Use Semver + versionCode 50 + versionName "1.18.1" // Use Semver testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes {