better LocalRepoService singleton enforcement
We only ever want a single LocalRepoService. Use the values returned by the standard methods for start/stop and bind/unbind as the test for whether the Service is indeed running.
This commit is contained in:
parent
2c594cae5d
commit
c4b059502c
@ -282,17 +282,21 @@ public class FDroidApp extends Application {
|
|||||||
public static void startLocalRepoService(Context context) {
|
public static void startLocalRepoService(Context context) {
|
||||||
if (!localRepoServiceIsBound) {
|
if (!localRepoServiceIsBound) {
|
||||||
Context app = context.getApplicationContext();
|
Context app = context.getApplicationContext();
|
||||||
app.bindService(new Intent(app, LocalRepoService.class),
|
Intent service = new Intent(app, LocalRepoService.class);
|
||||||
serviceConnection, Context.BIND_AUTO_CREATE);
|
localRepoServiceIsBound = app.bindService(service, serviceConnection,
|
||||||
localRepoServiceIsBound = true;
|
Context.BIND_AUTO_CREATE);
|
||||||
|
if (localRepoServiceIsBound)
|
||||||
|
app.startService(service);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void stopLocalRepoService(Context context) {
|
public static void stopLocalRepoService(Context context) {
|
||||||
|
Context app = context.getApplicationContext();
|
||||||
if (localRepoServiceIsBound) {
|
if (localRepoServiceIsBound) {
|
||||||
context.getApplicationContext().unbindService(serviceConnection);
|
app.unbindService(serviceConnection);
|
||||||
localRepoServiceIsBound = false;
|
localRepoServiceIsBound = false;
|
||||||
}
|
}
|
||||||
|
app.stopService(new Intent(app, LocalRepoService.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void restartLocalRepoService() {
|
public static void restartLocalRepoService() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user