I have a broadcast receiver(Manifest declared) that listens to an intent and starts the jobIntentService. Since jobIntentService is using Worker Threads and Broadcast Receiver does not have any heavy operations (It just receives the intent and calls the jobIntentService). There shouldn't be any reasons for ANRs in the broadcast receiver. Also, I'm getting ANRs only on Huawei devices.
Here's my code for broadcast receiver:
public class SessionReceiver extends BroadcastReceiver {
private static final String TAG = "SessionReceiver";
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction() == null) return;
Log.d(TAG, "onReceive: called");
SessionChangeService.enqueueWork(context, intent);
}
}
As you can see, I'm only enqueuing the work in the broadcast receiver but I'm still getting ANRs on Huawei devices.
Manifest declaration:
<receiver
android:name=".receivers.SessionReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.media.action.OPEN_AUDIO_EFFECT_CONTROL_SESSION" />
<action android:name="android.media.action.CLOSE_AUDIO_EFFECT_CONTROL_SESSION" />
</intent-filter>
</receiver>
JobIntentService:
public class SessionChangeService extends JobIntentService {
private static final String TAG = "SessionChangeService";
public static void enqueueWork(Context context, Intent intent) {
Log.d(TAG, "enqueueWork: enqueued");
enqueueWork(context, SessionChangeService.class, Constants.SESSION_CHANGE_JOB_ID, intent);
}
@Override
protected void onHandleWork(@NonNull Intent intent) {
//...work...
}
}
ANR log is:
Broadcast of Intent { act=android.media.action.CLOSE_AUDIO_EFFECT_CONTROL_SESSION flg=0x2030 pkg=/.receivers.SessionReceiver (has extras) }
Any help will be appreciated.