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:
parent
4a4608a898
commit
2154fe661e
|
@ -14,11 +14,7 @@ public class BootReceiver extends BroadcastReceiver {
|
||||||
Log.w(TAG, "BOOT_COMPLETE NULL intent");
|
Log.w(TAG, "BOOT_COMPLETE NULL intent");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (QcRilAmService.isServiceRunning()) {
|
|
||||||
Log.d(TAG, "Service is already running");
|
context.startService(new Intent(context, QcRilAmService.class));
|
||||||
} else {
|
|
||||||
intent.setClass(context, QcRilAmService.class);
|
|
||||||
context.startService(new Intent(context, QcRilAmService.class));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,11 +12,6 @@ import vendor.qti.hardware.radio.am.V1_0.IQcRilAudioCallback;
|
||||||
|
|
||||||
public class QcRilAmService extends Service {
|
public class QcRilAmService extends Service {
|
||||||
private static final String TAG = "QcRilAm-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) {
|
private void addCallbackForSimSlot(final int simSlotNo, final AudioManager audioManager) {
|
||||||
try {
|
try {
|
||||||
|
@ -50,7 +45,6 @@ public class QcRilAmService extends Service {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
isRunning = true;
|
|
||||||
int simCount = SubscriptionManager.from(this).getActiveSubscriptionInfoCountMax();
|
int simCount = SubscriptionManager.from(this).getActiveSubscriptionInfoCountMax();
|
||||||
Log.i(TAG, "Device has " + simCount + " sim slots");
|
Log.i(TAG, "Device has " + simCount + " sim slots");
|
||||||
final AudioManager audioManager = getSystemService(AudioManager.class);
|
final AudioManager audioManager = getSystemService(AudioManager.class);
|
||||||
|
|
Loading…
Reference in a new issue