Fixed start at boot time crash on Android O
This commit is contained in:
parent
b685baeca6
commit
a2dce957fa
4 changed files with 22 additions and 1 deletions
|
@ -6,6 +6,7 @@ import android.annotation.TargetApi;
|
|||
import android.app.Notification;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||
|
@ -137,4 +138,8 @@ public class ApiSixteenPlus {
|
|||
|
||||
return notif;
|
||||
}
|
||||
|
||||
public static void startService(Context context, Intent intent) {
|
||||
context.startService(intent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import android.app.NotificationChannel;
|
|||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.media.AudioAttributes;
|
||||
import android.view.ViewTreeObserver;
|
||||
|
@ -176,4 +177,8 @@ public class ApiTwentySixPlus {
|
|||
|
||||
return notif;
|
||||
}
|
||||
|
||||
public static void startService(Context context, Intent intent) {
|
||||
context.startForegroundService(intent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import android.app.AlarmManager;
|
|||
import android.app.Notification;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Build;
|
||||
import android.os.PowerManager;
|
||||
|
@ -154,4 +155,12 @@ public class Compatibility {
|
|||
ApiElevenPlus.scheduleAlarm(alarmManager, type, triggerAtMillis, operation);
|
||||
}
|
||||
}
|
||||
|
||||
public static void startService(Context context, Intent intent) {
|
||||
if (Version.sdkAboveOrEqual(Version.API26_O_80)) {
|
||||
ApiTwentySixPlus.startService(context, intent);
|
||||
} else {
|
||||
ApiSixteenPlus.startService(context, intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphonePreferences;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.compatibility.Compatibility;
|
||||
import org.linphone.core.Factory;
|
||||
import org.linphone.core.Config;
|
||||
import org.linphone.mediastream.Log;
|
||||
|
@ -34,6 +35,7 @@ public class BootReceiver extends BroadcastReceiver {
|
|||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
LinphonePreferences.instance().setContext(context);
|
||||
if (intent.getAction().equalsIgnoreCase(Intent.ACTION_SHUTDOWN)) {
|
||||
android.util.Log.d("LinphoneBootReceiver", "Device is shutting down, destroying Core to unregister");
|
||||
LinphoneManager.destroy();
|
||||
|
@ -43,7 +45,7 @@ public class BootReceiver extends BroadcastReceiver {
|
|||
if (autostart) {
|
||||
Intent lLinphoneServiceIntent = new Intent(Intent.ACTION_MAIN);
|
||||
lLinphoneServiceIntent.setClass(context, LinphoneService.class);
|
||||
context.startService(lLinphoneServiceIntent);
|
||||
Compatibility.startService(context, lLinphoneServiceIntent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue