Skip to content
This repository was archived by the owner on Dec 18, 2022. It is now read-only.

Commit e3e52fe

Browse files
authored
Merge pull request #50 from 05nelsonm/mn/feature/remove-background-policy-keep-alive
Disable ability to select BackgroundManager Policy keep alive
2 parents 0b8353a + c75259f commit e3e52fe

File tree

2 files changed

+18
-21
lines changed
  • sampleapp/src/main/java/io/matthewnelson/sampleapp
  • topl-service/src/main/java/io/matthewnelson/topl_service/lifecycle

2 files changed

+18
-21
lines changed

sampleapp/src/main/java/io/matthewnelson/sampleapp/App.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,6 @@ class App: Application() {
122122
private fun generateBackgroundManagerPolicy(): BackgroundManager.Builder.Policy {
123123
// private fun generateBackgroundManagerPolicy(): BackgroundManager.Builder.Policy {
124124
return BackgroundManager.Builder()
125-
126-
// Can only choose 1 option, but this is the other unselected one.
127-
// .keepAliveWhileInBackground(secondsFrom20To40 = 30)
128125
.respectResourcesWhileInBackground(secondsFrom5To45 = 20)
129126

130127
// }

topl-service/src/main/java/io/matthewnelson/topl_service/lifecycle/BackgroundManager.kt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -151,24 +151,24 @@ class BackgroundManager internal constructor(
151151
// performing it's normal lifecycle after user swipes it away such that it's not going
152152
// through Application.onCreate, but is holding onto references. (same problem when
153153
// starting the service using Context.startForegroundService), which is bullshit.
154-
/**
155-
* While your application is in the background (the Recent App's tray or lock screen),
156-
* this [Policy] periodically switches [TorService] to the foreground then immediately
157-
* back the background. Doing do prevents your application from going idle and being
158-
* killed by the OS. It is much more resource intensive than choosing
159-
* [respectResourcesWhileInBackground].
160-
*
161-
* @param [secondsFrom20To40]? Seconds between the events of cycling from background to
162-
* foreground to background. Sending null will use the default (30s)
163-
* @return [BackgroundManager.Builder.Policy] To use when initializing
164-
* [io.matthewnelson.topl_service.TorServiceController.Builder]
165-
* */
166-
fun keepAliveWhileInBackground(secondsFrom20To40: Int? = null): Policy {
167-
chosenPolicy = BackgroundPolicy.KEEP_ALIVE
168-
if (secondsFrom20To40 != null && secondsFrom20To40 in 20..40)
169-
executionDelay = (secondsFrom20To40 * 1000).toLong()
170-
return Policy(this)
171-
}
154+
// /**
155+
// * While your application is in the background (the Recent App's tray or lock screen),
156+
// * this [Policy] periodically switches [TorService] to the foreground then immediately
157+
// * back the background. Doing do prevents your application from going idle and being
158+
// * killed by the OS. It is much more resource intensive than choosing
159+
// * [respectResourcesWhileInBackground].
160+
// *
161+
// * @param [secondsFrom20To40]? Seconds between the events of cycling from background to
162+
// * foreground to background. Sending null will use the default (30s)
163+
// * @return [BackgroundManager.Builder.Policy] To use when initializing
164+
// * [io.matthewnelson.topl_service.TorServiceController.Builder]
165+
// * */
166+
// fun keepAliveWhileInBackground(secondsFrom20To40: Int? = null): Policy {
167+
// chosenPolicy = BackgroundPolicy.KEEP_ALIVE
168+
// if (secondsFrom20To40 != null && secondsFrom20To40 in 20..40)
169+
// executionDelay = (secondsFrom20To40 * 1000).toLong()
170+
// return Policy(this)
171+
// }
172172

173173
/**
174174
* Stops [TorService] after being in the background for the declared [secondsFrom5To45].

0 commit comments

Comments
 (0)