From c0fdbde903408b636874ef59c306ffe918762821 Mon Sep 17 00:00:00 2001 From: olly Date: Mon, 30 Apr 2018 03:23:31 -0700 Subject: [PATCH] Fix permissions lint errors. - Add ACCESS_NETWORK_STATE to core library. It seems fairly fundamental. We should also be using it elsewhere (e.g. to fail fast if there's no network). - Add annotation to force apps using PlatformScheduler to declare RECEIVE_BOOT_PERMISSION ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=194763051 --- demos/main/src/main/AndroidManifest.xml | 1 - library/core/src/main/AndroidManifest.xml | 5 ++++- .../android/exoplayer2/scheduler/PlatformScheduler.java | 4 ++++ .../google/android/exoplayer2/scheduler/Requirements.java | 2 -- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/demos/main/src/main/AndroidManifest.xml b/demos/main/src/main/AndroidManifest.xml index f0bc0ce50a..25b87f5185 100644 --- a/demos/main/src/main/AndroidManifest.xml +++ b/demos/main/src/main/AndroidManifest.xml @@ -19,7 +19,6 @@ - diff --git a/library/core/src/main/AndroidManifest.xml b/library/core/src/main/AndroidManifest.xml index 430930a3ca..1a6971fdcc 100644 --- a/library/core/src/main/AndroidManifest.xml +++ b/library/core/src/main/AndroidManifest.xml @@ -14,4 +14,7 @@ limitations under the License. --> - + + + diff --git a/library/core/src/main/java/com/google/android/exoplayer2/scheduler/PlatformScheduler.java b/library/core/src/main/java/com/google/android/exoplayer2/scheduler/PlatformScheduler.java index d60bfb2e82..f59e43f35a 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/scheduler/PlatformScheduler.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/scheduler/PlatformScheduler.java @@ -26,6 +26,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.os.PersistableBundle; +import android.support.annotation.RequiresPermission; import android.util.Log; import com.google.android.exoplayer2.util.Util; @@ -78,6 +79,7 @@ public final class PlatformScheduler implements Scheduler { * @param serviceAction The action which the service will be started with. * @param servicePackage The package of the service which contains the logic of the job. */ + @RequiresPermission(android.Manifest.permission.RECEIVE_BOOT_COMPLETED) public PlatformScheduler( Context context, Requirements requirements, @@ -103,6 +105,8 @@ public final class PlatformScheduler implements Scheduler { return true; } + // @RequiresPermission constructor annotation should ensure the permission is present. + @SuppressWarnings("MissingPermission") private static JobInfo buildJobInfo( Context context, Requirements requirements, diff --git a/library/core/src/main/java/com/google/android/exoplayer2/scheduler/Requirements.java b/library/core/src/main/java/com/google/android/exoplayer2/scheduler/Requirements.java index 8c8cf6a3b5..30b07da3eb 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/scheduler/Requirements.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/scheduler/Requirements.java @@ -32,8 +32,6 @@ import java.lang.annotation.RetentionPolicy; /** * Defines a set of device state requirements. - * - *

To use network type requirement, application needs to have ACCESS_NETWORK_STATE permission. */ public final class Requirements {