Drop useless isRunning boolean; startService only starts it once.

A service can only be started once. After that, intents will be
delivered to the onStartCommand function (if overridden).

In the very unlikely event that the service dies and the bootreceiver
receives an intent it is properly restarted again, instead of falsely
being classified as running.

Signed-off-by: MarijnS95 <marijns95@gmail.com>
This commit is contained in:
MarijnS95 2019-12-04 18:14:51 +01:00
parent 4a4608a898
commit 2154fe661e
2 changed files with 2 additions and 12 deletions

View file

@ -14,11 +14,7 @@ public class BootReceiver extends BroadcastReceiver {
Log.w(TAG, "BOOT_COMPLETE NULL intent");
return;
}
if (QcRilAmService.isServiceRunning()) {
Log.d(TAG, "Service is already running");
} else {
intent.setClass(context, QcRilAmService.class);
context.startService(new Intent(context, QcRilAmService.class));
}
context.startService(new Intent(context, QcRilAmService.class));
}
}

View file

@ -12,11 +12,6 @@ import vendor.qti.hardware.radio.am.V1_0.IQcRilAudioCallback;
public class QcRilAmService extends Service {
private static final String TAG = "QcRilAm-Service";
private static boolean isRunning = false;
public static boolean isServiceRunning() {
return isRunning;
}
private void addCallbackForSimSlot(final int simSlotNo, final AudioManager audioManager) {
try {
@ -50,7 +45,6 @@ public class QcRilAmService extends Service {
@Override
public void onCreate() {
isRunning = true;
int simCount = SubscriptionManager.from(this).getActiveSubscriptionInfoCountMax();
Log.i(TAG, "Device has " + simCount + " sim slots");
final AudioManager audioManager = getSystemService(AudioManager.class);