From ae7703fad0ed2f439a84a95f83a5edd6b27224b4 Mon Sep 17 00:00:00 2001 From: Greg Alexander Date: Sat, 1 Oct 2016 17:35:41 -0400 Subject: [PATCH] implemented startForeground(), with some reservation --- NOTES | 71 ++++++++++++++++-- res/drawable/notification_icon.png | Bin 0 -> 3033 bytes .../galexander/sshd/SimpleSSHDService.java | 22 ++++-- 3 files changed, 82 insertions(+), 11 deletions(-) create mode 100644 res/drawable/notification_icon.png diff --git a/NOTES b/NOTES index 89b2c4f..82a203e 100644 --- a/NOTES +++ b/NOTES @@ -245,8 +245,69 @@ all of the off_t to off64_t and hope for the best. sftp and rsync work! Not gonna bother testing scp on big files... -XXX - Jared Stafford says startForeground() improves responsiveness -substantially on Nkey Lime Pie - -XXX - if you remove it from the recent apps list, does it stop the service?? -XXX - support password-based logins? +October 1, 2016. + +Jared Stafford told me startForeground() improves responsiveness on +Nougat. There had been a comment suggesting startForeground(), but I +never got around to trying it because it has worked "well enough". With +Nougat, though, there is a definite tendency for SimpleSSHD to be +non-responsive. I'm not sure exactly what its cause is, but the symptom +I notice most frequently is that the first ssh connection after a while +will be delayed "a long time" - on the order of 10-30 seconds, or maybe +indefinitely sometimes. Oddly, a second connection can sometimes get +through undelayed, even before the first connection does. It is as if +the fork() of process for the new connection is where the delay is, not +in the listen() call. + +That's not overall too surprising, Nougat is a lot harsher about +background processes as part of a Google push to reduce power consumption +on idle devices. + +Another concern is related to a change back in July - sometimes the +system will kill the sshd process for no good reason (maybe because they +removed it from the recent apps list). The remedy I settled on was to +monitor for the sshd process dying from within the regular +Android-managed process, and restart it. I guess I didn't write down +where in the documentation I found it, but Android seems expressly +antagonistic to non-system-managed processes. If they ever get more +hard-assed about that, this whole idea goes out the window. + +Anyways, I implemented startForeground(), and I am unhappy that it +requires a Notification. At API 7 (Android 2.1) those are really +primitive. For example, the PRIORITY_MIN behavior which will sometimes +hide the notification is added in API 16 (Android 4.1). So, I've got it +with this stupid old-style notification, and it really doesn't look good, +and it is always present. That is not awesome. + +On the other hand, it's easy to block the notifications, and a few people +have expressed an interest in a notification. + +It doesn't seem worth it to me to upgrade to a newer API just for the +better notifications... On the other hand, Google Play shows that I have +862 users: + Android 7+ : 3.13% + Android 6+ : 37.47% + Android 5+ : 67.86% + Android 4.1+: 96.62% + Android 4.0+: 98.01% + +The oldest reported version is Android 2.3. + +So, there are a few people on very old versions, but actually SimpleSSHD +is used on newer devices than the average app, which is the reverse of my +typical trend. So a few people would be negatively impacted, but not a +very large number. I could switch to multi-APK mode so that legacy users +are just stuck with an unsupported back-version, which is probably what +they truly want anyways.. + +Anyways, I'm gonna use it with startForeground() and the notifications +disabled for a while, and if I find it to be an improvement then I'll +just make it so clicking on the notification goes to the app, update the +doc, and then publish it. + + + +XXX - make clicking on the notification go to the app? + + +XXX - support password-based logins for boot-strapping? diff --git a/res/drawable/notification_icon.png b/res/drawable/notification_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..aaec993647111e64606db1bafe8beacb7a7c1ae0 GIT binary patch literal 3033 zcmZ`*X*ARi7yixI%9bo+t%xL9#=eCiJHsS~Y>|Cm$G&C@|Bx&rMkIu&8HOZeR|Z96 z&pLyDG4_3Xy&vBX?>*7(MaFNSnM`fzQ! zIeHMg0?o+Gi%kHaKhW3GFmsz(%lAaExpMXn2@43&Ue<>#u<+BPW6huf=J7}kM3W_L z^`3{k}x%%C%$T^VfS#6yG7Wp|HUs8njtiMMZ^*Xoh4539OVv1N0GsrWy7ZVhcyq znOA69r41({;?83r0X~(=l6m5!Bb~FfxHFH_b9Pb?(F_q8jxkojI8;1^Gdk6$Au*J~^p#)z!5vY=@-(JpU~5!mX3`rhn+c zOv{WNSU^rre1NR`YW%tPU4Hukp4ht<%F5JWu)tkUC!srcWPjn6gi%bJp*}uD;$7t1 zw*c_=?drGytG3Qe+j--oz7e+KI<`)bJyi2P-il|F82%F{-MDtj{z(e7rtAh;b^GY-40J(nCvk zn#DknXv}EM%WtWv2_0eEXrr7eEcTP7a2=KG&v7o^IQ{~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