Fix some lint warnings

PiperOrigin-RevId: 424383900
This commit is contained in:
olly 2022-01-26 18:26:53 +00:00 committed by Andrew Lewis
parent 497f55a4bb
commit d2cc14a98b
15 changed files with 36 additions and 47 deletions

View File

@ -21,10 +21,9 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<application <application
android:allowBackup="true" android:allowBackup="false"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.Media3Demo"> android:theme="@style/Theme.Media3Demo">
<activity <activity
@ -38,13 +37,11 @@
<activity <activity
android:name=".PlayerActivity" android:name=".PlayerActivity"
android:exported="true"> android:exported="true"/>
</activity>
<activity <activity
android:name=".PlayableFolderActivity" android:name=".PlayableFolderActivity"
android:exported="true"> android:exported="true"/>
</activity>
<service <service
android:name=".PlaybackService" android:name=".PlaybackService"

View File

@ -27,7 +27,9 @@
android:label="@string/application_name" android:label="@string/application_name"
android:exported="true"> android:exported="true">
<activity android:name=".MainActivity"> <activity
android:name=".MainActivity"
android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>

View File

@ -14,7 +14,7 @@
apply from: "$gradle.ext.androidxMediaSettingsDir/common_library_config.gradle" apply from: "$gradle.ext.androidxMediaSettingsDir/common_library_config.gradle"
dependencies { dependencies {
api 'com.google.android.gms:play-services-cast-framework:20.1.0' api 'com.google.android.gms:play-services-cast-framework:21.0.1'
implementation 'androidx.annotation:annotation:' + androidxAnnotationVersion implementation 'androidx.annotation:annotation:' + androidxAnnotationVersion
implementation project(modulePrefix + 'lib-common') implementation project(modulePrefix + 'lib-common')
compileOnly 'org.checkerframework:checker-qual:' + checkerframeworkVersion compileOnly 'org.checkerframework:checker-qual:' + checkerframeworkVersion

View File

@ -102,7 +102,7 @@ public final class HeartRating extends Rating {
private static HeartRating fromBundle(Bundle bundle) { private static HeartRating fromBundle(Bundle bundle) {
checkArgument( checkArgument(
bundle.getInt(keyForField(FIELD_RATING_TYPE), /* defaultValue= */ RATING_TYPE_DEFAULT) bundle.getInt(keyForField(FIELD_RATING_TYPE), /* defaultValue= */ RATING_TYPE_UNSET)
== TYPE); == TYPE);
boolean isRated = bundle.getBoolean(keyForField(FIELD_RATED), /* defaultValue= */ false); boolean isRated = bundle.getBoolean(keyForField(FIELD_RATED), /* defaultValue= */ false);
return isRated return isRated

View File

@ -98,7 +98,7 @@ public final class PercentageRating extends Rating {
private static PercentageRating fromBundle(Bundle bundle) { private static PercentageRating fromBundle(Bundle bundle) {
checkArgument( checkArgument(
bundle.getInt(keyForField(FIELD_RATING_TYPE), /* defaultValue= */ RATING_TYPE_DEFAULT) bundle.getInt(keyForField(FIELD_RATING_TYPE), /* defaultValue= */ RATING_TYPE_UNSET)
== TYPE); == TYPE);
float percent = bundle.getFloat(keyForField(FIELD_PERCENT), /* defaultValue= */ RATING_UNSET); float percent = bundle.getFloat(keyForField(FIELD_PERCENT), /* defaultValue= */ RATING_UNSET);
return percent == RATING_UNSET ? new PercentageRating() : new PercentageRating(percent); return percent == RATING_UNSET ? new PercentageRating() : new PercentageRating(percent);

View File

@ -42,7 +42,7 @@ public abstract class Rating implements Bundleable {
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@IntDef({ @IntDef({
RATING_TYPE_DEFAULT, RATING_TYPE_UNSET,
RATING_TYPE_HEART, RATING_TYPE_HEART,
RATING_TYPE_PERCENTAGE, RATING_TYPE_PERCENTAGE,
RATING_TYPE_STAR, RATING_TYPE_STAR,
@ -50,7 +50,7 @@ public abstract class Rating implements Bundleable {
}) })
/* package */ @interface RatingType {} /* package */ @interface RatingType {}
/* package */ static final int RATING_TYPE_DEFAULT = -1; /* package */ static final int RATING_TYPE_UNSET = -1;
/* package */ static final int RATING_TYPE_HEART = 0; /* package */ static final int RATING_TYPE_HEART = 0;
/* package */ static final int RATING_TYPE_PERCENTAGE = 1; /* package */ static final int RATING_TYPE_PERCENTAGE = 1;
/* package */ static final int RATING_TYPE_STAR = 2; /* package */ static final int RATING_TYPE_STAR = 2;
@ -69,7 +69,7 @@ public abstract class Rating implements Bundleable {
private static Rating fromBundle(Bundle bundle) { private static Rating fromBundle(Bundle bundle) {
@RatingType @RatingType
int ratingType = int ratingType =
bundle.getInt(keyForField(FIELD_RATING_TYPE), /* defaultValue= */ RATING_TYPE_DEFAULT); bundle.getInt(keyForField(FIELD_RATING_TYPE), /* defaultValue= */ RATING_TYPE_UNSET);
switch (ratingType) { switch (ratingType) {
case RATING_TYPE_HEART: case RATING_TYPE_HEART:
return HeartRating.CREATOR.fromBundle(bundle); return HeartRating.CREATOR.fromBundle(bundle);
@ -79,8 +79,9 @@ public abstract class Rating implements Bundleable {
return StarRating.CREATOR.fromBundle(bundle); return StarRating.CREATOR.fromBundle(bundle);
case RATING_TYPE_THUMB: case RATING_TYPE_THUMB:
return ThumbRating.CREATOR.fromBundle(bundle); return ThumbRating.CREATOR.fromBundle(bundle);
case RATING_TYPE_UNSET:
default: default:
throw new IllegalArgumentException("Encountered unknown rating type: " + ratingType); throw new IllegalArgumentException("Unknown RatingType: " + ratingType);
} }
} }

View File

@ -127,7 +127,7 @@ public final class StarRating extends Rating {
private static StarRating fromBundle(Bundle bundle) { private static StarRating fromBundle(Bundle bundle) {
checkArgument( checkArgument(
bundle.getInt(keyForField(FIELD_RATING_TYPE), /* defaultValue= */ RATING_TYPE_DEFAULT) bundle.getInt(keyForField(FIELD_RATING_TYPE), /* defaultValue= */ RATING_TYPE_UNSET)
== TYPE); == TYPE);
int maxStars = int maxStars =
bundle.getInt(keyForField(FIELD_MAX_STARS), /* defaultValue= */ MAX_STARS_DEFAULT); bundle.getInt(keyForField(FIELD_MAX_STARS), /* defaultValue= */ MAX_STARS_DEFAULT);

View File

@ -99,7 +99,7 @@ public final class ThumbRating extends Rating {
private static ThumbRating fromBundle(Bundle bundle) { private static ThumbRating fromBundle(Bundle bundle) {
checkArgument( checkArgument(
bundle.getInt(keyForField(FIELD_RATING_TYPE), /* defaultValue= */ RATING_TYPE_DEFAULT) bundle.getInt(keyForField(FIELD_RATING_TYPE), /* defaultValue= */ RATING_TYPE_UNSET)
== TYPE); == TYPE);
boolean rated = bundle.getBoolean(keyForField(FIELD_RATED), /* defaultValue= */ false); boolean rated = bundle.getBoolean(keyForField(FIELD_RATED), /* defaultValue= */ false);
return rated return rated

View File

@ -2407,6 +2407,8 @@ public final class Util {
return "camera motion"; return "camera motion";
case C.TRACK_TYPE_NONE: case C.TRACK_TYPE_NONE:
return "none"; return "none";
case C.TRACK_TYPE_UNKNOWN:
return "unknown";
default: default:
return trackType >= C.TRACK_TYPE_CUSTOM_BASE ? "custom (" + trackType + ")" : "?"; return trackType >= C.TRACK_TYPE_CUSTOM_BASE ? "custom (" + trackType + ")" : "?";
} }

View File

@ -20,7 +20,7 @@ android {
} }
dependencies { dependencies {
api "com.google.android.gms:play-services-cronet:17.0.1" api "com.google.android.gms:play-services-cronet:18.0.1"
implementation project(modulePrefix + 'lib-common') implementation project(modulePrefix + 'lib-common')
implementation project(modulePrefix + 'lib-datasource') implementation project(modulePrefix + 'lib-datasource')
implementation 'androidx.annotation:annotation:' + androidxAnnotationVersion implementation 'androidx.annotation:annotation:' + androidxAnnotationVersion

View File

@ -109,8 +109,7 @@ public class DownloadManagerDashTest {
testThread.release(); testThread.release();
} }
// Disabled due to flakiness. @Ignore("Disabled due to flakiness")
@Ignore
@Test @Test
public void saveAndLoadActionFile() throws Throwable { public void saveAndLoadActionFile() throws Throwable {
// Configure fakeDataSet to block until interrupted when TEST_MPD is read. // Configure fakeDataSet to block until interrupted when TEST_MPD is read.

View File

@ -157,7 +157,7 @@ public class DownloadServiceDashTest {
testThread.release(); testThread.release();
} }
@Ignore // b/78877092 @Ignore("Internal ref: b/78877092")
@Test @Test
public void multipleDownloadRequest() throws Throwable { public void multipleDownloadRequest() throws Throwable {
downloadKeys(fakeStreamKey1); downloadKeys(fakeStreamKey1);
@ -168,7 +168,7 @@ public class DownloadServiceDashTest {
assertCachedData(cache, fakeDataSet); assertCachedData(cache, fakeDataSet);
} }
@Ignore // b/78877092 @Ignore("Internal ref: b/78877092")
@Test @Test
public void removeAction() throws Throwable { public void removeAction() throws Throwable {
downloadKeys(fakeStreamKey1, fakeStreamKey2); downloadKeys(fakeStreamKey1, fakeStreamKey2);
@ -182,7 +182,7 @@ public class DownloadServiceDashTest {
assertCacheEmpty(cache); assertCacheEmpty(cache);
} }
@Ignore // b/78877092 @Ignore("Internal ref: b/78877092")
@Test @Test
public void removeBeforeDownloadComplete() throws Throwable { public void removeBeforeDownloadComplete() throws Throwable {
pauseDownloadCondition = new ConditionVariable(); pauseDownloadCondition = new ConditionVariable();

View File

@ -25,7 +25,7 @@ android {
} }
dependencies { dependencies {
api 'com.google.ads.interactivemedia.v3:interactivemedia:3.25.1' api 'com.google.ads.interactivemedia.v3:interactivemedia:3.26.0'
implementation project(modulePrefix + 'lib-exoplayer') implementation project(modulePrefix + 'lib-exoplayer')
implementation 'androidx.annotation:annotation:' + androidxAnnotationVersion implementation 'androidx.annotation:annotation:' + androidxAnnotationVersion
compileOnly 'org.checkerframework:checker-qual:' + checkerframeworkVersion compileOnly 'org.checkerframework:checker-qual:' + checkerframeworkVersion

View File

@ -251,9 +251,7 @@ public class MediaStyleNotificationHelper {
if (!tombstone) { if (!tombstone) {
button.setOnClickPendingIntent(androidx.media.R.id.action0, action.getActionIntent()); button.setOnClickPendingIntent(androidx.media.R.id.action0, action.getActionIntent());
} }
if (Build.VERSION.SDK_INT >= 15) { button.setContentDescription(androidx.media.R.id.action0, action.getTitle());
Api15Impl.setContentDescription(button, androidx.media.R.id.action0, action.getTitle());
}
return button; return button;
} }
@ -474,17 +472,6 @@ public class MediaStyleNotificationHelper {
} }
} }
@RequiresApi(15)
private static class Api15Impl {
private Api15Impl() {}
@DoNotInline
public static void setContentDescription(
RemoteViews remoteViews, int viewId, @Nullable CharSequence contentDescription) {
remoteViews.setContentDescription(viewId, contentDescription);
}
}
@RequiresApi(21) @RequiresApi(21)
private static class Api21Impl { private static class Api21Impl {
private Api21Impl() {} private Api21Impl() {}

View File

@ -1480,6 +1480,7 @@ public class PlayerNotificationManager {
return actions; return actions;
} }
@SuppressWarnings("UnspecifiedImmutableFlag") // Warning is spurious.
private static PendingIntent createBroadcastIntent( private static PendingIntent createBroadcastIntent(
String action, Context context, int instanceId) { String action, Context context, int instanceId) {
Intent intent = new Intent(action).setPackage(context.getPackageName()); Intent intent = new Intent(action).setPackage(context.getPackageName());