Skip to content

Service Crashing Due to ForegroundServiceStartNotAllowedException #2

Description

@Cmcburney2308

Ive been using the RedMagic Control Center for a bit now and it's been great, yet I've been experiencing frequent crashes occasionally.

I looked at the logcat for it and noticed it's probably using the DataSync Background Service type which is typically used for mediaplayback, location etc based on this specific exception.

These crashes are most likely occurring because once the services using the datasync tag are on for a certain amount of time the OS will force it to crash and not start up properly due to that ForegroundServiceStartNotAllowedException as in simple terms it's used up its daily limit.

the fix for this is simple tho, you must use the specialUse tag instead of datasync because as it's hardware control it falls outside of them normal categories that aren't typically used all the time.

Ps. Just as a non functionality dependant bug, the notification that displays temps stay in Fahrenheit even when switched to Celsius in the app, just thought I should mention

LOGCAT:
AndroidRuntime: FATAL EXCEPTION: main
AndroidRuntime: Process: com.elitedarkkaiser.redmagic, PID: 20477
AndroidRuntime: java.lang.RuntimeException: Unable to create service com.elitedarkkaiser.redmagic.AutoFanService
AndroidRuntime: at android.app.ActivityThread.handleCreateService(ActivityThread.java:5563)
AndroidRuntime: at android.app.ActivityThread.-$$Nest$mhandleCreateService(Unknown Source:0)
AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2733)
AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:132)
AndroidRuntime: at android.os.Looper.dispatchMessage(Looper.java:333)
AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:263)
AndroidRuntime: at android.os.Looper.loop(Looper.java:367)
AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:9287)
AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:566)
AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:929)
AndroidRuntime: Caused by: android.app.ForegroundServiceStartNotAllowedException: Time limit already exhausted for foreground service type dataSync
AndroidRuntime: at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54)
AndroidRuntime: at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50)
AndroidRuntime: at android.os.Parcel.readParcelableInternal(Parcel.java:5262)
AndroidRuntime: at android.os.Parcel.readParcelable(Parcel.java:5243)
AndroidRuntime: at android.os.Parcel.createExceptionOrNull(Parcel.java:3368)
AndroidRuntime: at android.os.Parcel.createException(Parcel.java:3357)
AndroidRuntime: at android.os.Parcel.readException(Parcel.java:3340)
AndroidRuntime: at android.os.Parcel.readException(Parcel.java:3282)
AndroidRuntime: at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:7509)
AndroidRuntime: at android.app.Service.startForeground(Service.java:775)
AndroidRuntime: at com.elitedarkkaiser.redmagic.AutoFanService.onCreate(AutoFanService.kt:62)
AndroidRuntime: at android.app.ActivityThread.handleCreateService(ActivityThread.java:5552)
AndroidRuntime: ... 10 more

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions