Remove deprecated extension-jobdispatcher module
PiperOrigin-RevId: 356456843
This commit is contained in:
parent
846bb94ec4
commit
c501908dad
@ -13,6 +13,9 @@
|
||||
* Fix a bug where an assertion would fail if the player started to buffer
|
||||
an ad media period before the ad URI was known then an ad state update
|
||||
arrived that didn't set the ad URI.
|
||||
* Remove deprecated symbols:
|
||||
* Remove `extension-jobdispatcher` module. Use the `extension-workmanager`
|
||||
module instead.
|
||||
|
||||
### 2.13.0 (2021-02-04)
|
||||
|
||||
|
@ -47,7 +47,6 @@ include modulePrefix + 'extension-opus'
|
||||
include modulePrefix + 'extension-vp9'
|
||||
include modulePrefix + 'extension-rtmp'
|
||||
include modulePrefix + 'extension-leanback'
|
||||
include modulePrefix + 'extension-jobdispatcher'
|
||||
include modulePrefix + 'extension-workmanager'
|
||||
|
||||
project(modulePrefix + 'library').projectDir = new File(rootDir, 'library/all')
|
||||
@ -76,5 +75,4 @@ project(modulePrefix + 'extension-opus').projectDir = new File(rootDir, 'extensi
|
||||
project(modulePrefix + 'extension-vp9').projectDir = new File(rootDir, 'extensions/vp9')
|
||||
project(modulePrefix + 'extension-rtmp').projectDir = new File(rootDir, 'extensions/rtmp')
|
||||
project(modulePrefix + 'extension-leanback').projectDir = new File(rootDir, 'extensions/leanback')
|
||||
project(modulePrefix + 'extension-jobdispatcher').projectDir = new File(rootDir, 'extensions/jobdispatcher')
|
||||
project(modulePrefix + 'extension-workmanager').projectDir = new File(rootDir, 'extensions/workmanager')
|
||||
|
@ -1,25 +0,0 @@
|
||||
# ExoPlayer Firebase JobDispatcher extension #
|
||||
|
||||
**This extension is deprecated. Use the [WorkManager extension][] instead.**
|
||||
|
||||
This extension provides a Scheduler implementation which uses [Firebase JobDispatcher][].
|
||||
|
||||
[WorkManager extension]: https://github.com/google/ExoPlayer/blob/release-v2/extensions/workmanager/README.md
|
||||
[Firebase JobDispatcher]: https://github.com/firebase/firebase-jobdispatcher-android
|
||||
|
||||
## Getting the extension ##
|
||||
|
||||
The easiest way to use the extension is to add it as a gradle dependency:
|
||||
|
||||
```gradle
|
||||
implementation 'com.google.android.exoplayer:extension-jobdispatcher:2.X.X'
|
||||
```
|
||||
|
||||
where `2.X.X` is the version, which must match the version of the ExoPlayer
|
||||
library being used.
|
||||
|
||||
Alternatively, you can clone the ExoPlayer repository and depend on the module
|
||||
locally. Instructions for doing this can be found in ExoPlayer's
|
||||
[top level README][].
|
||||
|
||||
[top level README]: https://github.com/google/ExoPlayer/blob/release-v2/README.md
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
apply from: "$gradle.ext.exoplayerSettingsDir/common_library_config.gradle"
|
||||
|
||||
dependencies {
|
||||
implementation project(modulePrefix + 'library-core')
|
||||
implementation 'com.firebase:firebase-jobdispatcher:0.8.5'
|
||||
compileOnly 'org.jetbrains.kotlin:kotlin-annotations-jvm:' + kotlinAnnotationsVersion
|
||||
}
|
||||
|
||||
ext {
|
||||
javadocTitle = 'Firebase JobDispatcher extension'
|
||||
}
|
||||
apply from: '../../javadoc_library.gradle'
|
||||
|
||||
ext {
|
||||
releaseArtifact = 'extension-jobdispatcher'
|
||||
releaseDescription = 'Firebase JobDispatcher extension for ExoPlayer.'
|
||||
}
|
||||
apply from: '../../publish.gradle'
|
@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2018 The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<manifest package="com.google.android.exoplayer2.ext.jobdispatcher"/>
|
@ -1,171 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.android.exoplayer2.ext.jobdispatcher;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import com.firebase.jobdispatcher.Constraint;
|
||||
import com.firebase.jobdispatcher.FirebaseJobDispatcher;
|
||||
import com.firebase.jobdispatcher.GooglePlayDriver;
|
||||
import com.firebase.jobdispatcher.Job;
|
||||
import com.firebase.jobdispatcher.JobParameters;
|
||||
import com.firebase.jobdispatcher.JobService;
|
||||
import com.firebase.jobdispatcher.Lifetime;
|
||||
import com.google.android.exoplayer2.scheduler.Requirements;
|
||||
import com.google.android.exoplayer2.scheduler.Scheduler;
|
||||
import com.google.android.exoplayer2.util.Assertions;
|
||||
import com.google.android.exoplayer2.util.Log;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
|
||||
/**
|
||||
* A {@link Scheduler} that uses {@link FirebaseJobDispatcher}. To use this scheduler, you must add
|
||||
* {@link JobDispatcherSchedulerService} to your manifest:
|
||||
*
|
||||
* <pre>{@literal
|
||||
* <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||
* <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
|
||||
*
|
||||
* <service
|
||||
* android:name="com.google.android.exoplayer2.ext.jobdispatcher.JobDispatcherScheduler$JobDispatcherSchedulerService"
|
||||
* android:exported="false">
|
||||
* <intent-filter>
|
||||
* <action android:name="com.firebase.jobdispatcher.ACTION_EXECUTE"/>
|
||||
* </intent-filter>
|
||||
* </service>
|
||||
* }</pre>
|
||||
*
|
||||
* <p>This Scheduler uses Google Play services but does not do any availability checks. Any uses
|
||||
* should be guarded with a call to {@code
|
||||
* GoogleApiAvailability#isGooglePlayServicesAvailable(android.content.Context)}
|
||||
*
|
||||
* @see <a
|
||||
* href="https://developers.google.com/android/reference/com/google/android/gms/common/GoogleApiAvailability#isGooglePlayServicesAvailable(android.content.Context)">GoogleApiAvailability</a>
|
||||
* @deprecated Use com.google.android.exoplayer2.ext.workmanager.WorkManagerScheduler or {@link
|
||||
* com.google.android.exoplayer2.scheduler.PlatformScheduler}.
|
||||
*/
|
||||
@Deprecated
|
||||
public final class JobDispatcherScheduler implements Scheduler {
|
||||
|
||||
private static final String TAG = "JobDispatcherScheduler";
|
||||
private static final String KEY_SERVICE_ACTION = "service_action";
|
||||
private static final String KEY_SERVICE_PACKAGE = "service_package";
|
||||
private static final String KEY_REQUIREMENTS = "requirements";
|
||||
private static final int SUPPORTED_REQUIREMENTS =
|
||||
Requirements.NETWORK
|
||||
| Requirements.NETWORK_UNMETERED
|
||||
| Requirements.DEVICE_IDLE
|
||||
| Requirements.DEVICE_CHARGING;
|
||||
|
||||
private final String jobTag;
|
||||
private final FirebaseJobDispatcher jobDispatcher;
|
||||
|
||||
/**
|
||||
* @param context A context.
|
||||
* @param jobTag A tag for jobs scheduled by this instance. If the same tag was used by a previous
|
||||
* instance, anything scheduled by the previous instance will be canceled by this instance if
|
||||
* {@link #schedule(Requirements, String, String)} or {@link #cancel()} are called.
|
||||
*/
|
||||
public JobDispatcherScheduler(Context context, String jobTag) {
|
||||
context = context.getApplicationContext();
|
||||
this.jobDispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(context));
|
||||
this.jobTag = jobTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean schedule(Requirements requirements, String servicePackage, String serviceAction) {
|
||||
Job job = buildJob(jobDispatcher, requirements, jobTag, servicePackage, serviceAction);
|
||||
int result = jobDispatcher.schedule(job);
|
||||
return result == FirebaseJobDispatcher.SCHEDULE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cancel() {
|
||||
int result = jobDispatcher.cancel(jobTag);
|
||||
return result == FirebaseJobDispatcher.CANCEL_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Requirements getSupportedRequirements(Requirements requirements) {
|
||||
return requirements.filterRequirements(SUPPORTED_REQUIREMENTS);
|
||||
}
|
||||
|
||||
private static Job buildJob(
|
||||
FirebaseJobDispatcher dispatcher,
|
||||
Requirements requirements,
|
||||
String tag,
|
||||
String servicePackage,
|
||||
String serviceAction) {
|
||||
Requirements filteredRequirements = requirements.filterRequirements(SUPPORTED_REQUIREMENTS);
|
||||
if (!filteredRequirements.equals(requirements)) {
|
||||
Log.w(
|
||||
TAG,
|
||||
"Ignoring unsupported requirements: "
|
||||
+ (filteredRequirements.getRequirements() ^ requirements.getRequirements()));
|
||||
}
|
||||
|
||||
Job.Builder builder =
|
||||
dispatcher
|
||||
.newJobBuilder()
|
||||
.setService(JobDispatcherSchedulerService.class) // the JobService that will be called
|
||||
.setTag(tag);
|
||||
if (requirements.isUnmeteredNetworkRequired()) {
|
||||
builder.addConstraint(Constraint.ON_UNMETERED_NETWORK);
|
||||
} else if (requirements.isNetworkRequired()) {
|
||||
builder.addConstraint(Constraint.ON_ANY_NETWORK);
|
||||
}
|
||||
if (requirements.isIdleRequired()) {
|
||||
builder.addConstraint(Constraint.DEVICE_IDLE);
|
||||
}
|
||||
if (requirements.isChargingRequired()) {
|
||||
builder.addConstraint(Constraint.DEVICE_CHARGING);
|
||||
}
|
||||
builder.setLifetime(Lifetime.FOREVER).setReplaceCurrent(true);
|
||||
|
||||
Bundle extras = new Bundle();
|
||||
extras.putString(KEY_SERVICE_ACTION, serviceAction);
|
||||
extras.putString(KEY_SERVICE_PACKAGE, servicePackage);
|
||||
extras.putInt(KEY_REQUIREMENTS, requirements.getRequirements());
|
||||
builder.setExtras(extras);
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
/** A {@link JobService} that starts the target service if the requirements are met. */
|
||||
public static final class JobDispatcherSchedulerService extends JobService {
|
||||
@Override
|
||||
public boolean onStartJob(JobParameters params) {
|
||||
Bundle extras = Assertions.checkNotNull(params.getExtras());
|
||||
Requirements requirements = new Requirements(extras.getInt(KEY_REQUIREMENTS));
|
||||
int notMetRequirements = requirements.getNotMetRequirements(this);
|
||||
if (notMetRequirements == 0) {
|
||||
String serviceAction = Assertions.checkNotNull(extras.getString(KEY_SERVICE_ACTION));
|
||||
String servicePackage = Assertions.checkNotNull(extras.getString(KEY_SERVICE_PACKAGE));
|
||||
Intent intent = new Intent(serviceAction).setPackage(servicePackage);
|
||||
Util.startForegroundService(this, intent);
|
||||
} else {
|
||||
Log.w(TAG, "Requirements not met: " + notMetRequirements);
|
||||
jobFinished(params, /* needsReschedule */ true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onStopJob(JobParameters params) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
@NonNullApi
|
||||
package com.google.android.exoplayer2.ext.jobdispatcher;
|
||||
|
||||
import com.google.android.exoplayer2.util.NonNullApi;
|
Loading…
x
Reference in New Issue
Block a user