Skip to content

Commit d123071

Browse files
Revert "(fix):attempt to fix potential problem with job service items piling up (#243)" (#250)
This reverts commit 1140aca.
1 parent 9b5277b commit d123071

File tree

4 files changed

+6
-14
lines changed

4 files changed

+6
-14
lines changed

datafile-handler/src/main/java/com/optimizely/ab/android/datafile_handler/DatafileRescheduler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void dispatch(Intent intent) {
9797
// so, we don't need to do anything.
9898
// if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
9999
intent.putExtra(DatafileService.EXTRA_DATAFILE_CONFIG, datafileConfig.toJSONString());
100-
ServiceScheduler.startService(context, DatafileService.JOB_ID, intent, false);
100+
ServiceScheduler.startService(context, DatafileService.JOB_ID, intent);
101101
logger.info("Rescheduled data file watching for project {}", datafileConfig);
102102
//}
103103
}

event-handler/src/main/java/com/optimizely/ab/android/event_handler/DefaultEventHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public void dispatchEvent(@NonNull LogEvent logEvent) {
9797
intent.putExtra(EventIntentService.EXTRA_REQUEST_BODY, logEvent.getBody());
9898
intent.putExtra(EventIntentService.EXTRA_INTERVAL, dispatchInterval);
9999

100-
ServiceScheduler.startService(context, EventIntentService.JOB_ID, intent, true);
100+
ServiceScheduler.startService(context, EventIntentService.JOB_ID, intent);
101101

102102
logger.info("Sent url {} to the event handler service", logEvent.getEndpointUrl());
103103
}

event-handler/src/main/java/com/optimizely/ab/android/event_handler/EventRescheduler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void onReceive(Context context, Intent intent) {
9090
void reschedule(@NonNull Context context, @NonNull Intent broadcastIntent, @NonNull Intent eventServiceIntent, @NonNull ServiceScheduler serviceScheduler) {
9191
if (broadcastIntent.getAction().equals(Intent.ACTION_BOOT_COMPLETED) ||
9292
broadcastIntent.getAction().equals(Intent.ACTION_MY_PACKAGE_REPLACED)) {
93-
ServiceScheduler.startService(context, EventIntentService.JOB_ID, eventServiceIntent, false);
93+
ServiceScheduler.startService(context, EventIntentService.JOB_ID, eventServiceIntent);
9494
logger.info("Rescheduling event flushing if necessary");
9595
} else if (broadcastIntent.getAction().equals(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION)
9696
&& broadcastIntent.getBooleanExtra(WifiManager.EXTRA_SUPPLICANT_CONNECTED, false)) {
@@ -101,7 +101,7 @@ void reschedule(@NonNull Context context, @NonNull Intent broadcastIntent, @NonN
101101
// with wifi the service will be rescheduled on the interval.
102102
// Wifi connection state changes all the time and starting services is expensive
103103
// so it's important to only do this if we have stored events.
104-
ServiceScheduler.startService(context, EventIntentService.JOB_ID, eventServiceIntent, false);
104+
ServiceScheduler.startService(context, EventIntentService.JOB_ID, eventServiceIntent);
105105
logger.info("Preemptively flushing events since wifi became available");
106106
}
107107
} else {

shared/src/main/java/com/optimizely/ab/android/shared/ServiceScheduler.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,10 @@ private PendingIntent getPendingIntent(Intent intent, int flag) {
259259
* For example, the BroadcastReceivers use this to handle all versions of the API.
260260
*
261261
* @param context - Application context
262-
* @param jobId - job id for the job to start if it is a job. Jobs are used in Android O and later.
262+
* @param jobId - job id for the job to start if it is a job
263263
* @param intent - Intent you want to run.
264-
* @param allowPendingJobs - If true in versions greater than O, the jobs will be scheduled even if there are pending
265-
* jobs with the same job id. If false, then, the intent will not be started if there are already
266-
* pending jobs with the same id.
267264
*/
268-
public static void startService(Context context, Integer jobId, Intent intent, Boolean allowPendingJobs) {
265+
public static void startService(Context context, Integer jobId, Intent intent) {
269266
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
270267

271268
JobInfo jobInfo = new JobInfo.Builder(jobId,
@@ -276,11 +273,6 @@ public static void startService(Context context, Integer jobId, Intent intent, B
276273
.build();
277274
JobScheduler jobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
278275

279-
if (!allowPendingJobs && jobScheduler.getPendingJob(jobId) != null) {
280-
LoggerFactory.getLogger("ServiceScheduler").debug("Jobs already pending.");
281-
return;
282-
}
283-
284276
JobWorkItem jobWorkItem = new JobWorkItem(intent);
285277
try {
286278
jobScheduler.enqueue(jobInfo, jobWorkItem);

0 commit comments

Comments
 (0)