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
This commit is contained in:
olly 2018-04-30 03:23:31 -07:00 committed by Oliver Woodman
parent 9c15c63d4e
commit c0fdbde903
4 changed files with 8 additions and 4 deletions

View File

@ -19,7 +19,6 @@
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-feature android:name="android.software.leanback" android:required="false"/>

View File

@ -14,4 +14,7 @@
limitations under the License.
-->
<manifest package="com.google.android.exoplayer2.core"/>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.android.exoplayer2.core">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
</manifest>

View File

@ -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,

View File

@ -32,8 +32,6 @@ import java.lang.annotation.RetentionPolicy;
/**
* Defines a set of device state requirements.
*
* <p>To use network type requirement, application needs to have ACCESS_NETWORK_STATE permission.
*/
public final class Requirements {