Bug 1415778 - Part 1: Stop using AppConstants.Versions. r=darchons
Versions is no more efficient than checking android.os.Build, and it
actually interferes with the Android lint that checks API
compatibility.
MozReview-Commit-ID: Cl1227uHWKZ
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/GeckoSurface.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/GeckoSurface.java
@@ -2,25 +2,25 @@
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.gfx;
import android.graphics.SurfaceTexture;
+import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.view.Surface;
import android.util.Log;
import java.util.HashMap;
import org.mozilla.gecko.annotation.WrapForJNI;
-import org.mozilla.gecko.AppConstants.Versions;
public final class GeckoSurface extends Surface {
private static final String LOGTAG = "GeckoSurface";
private static HashMap<Integer, GeckoSurfaceTexture> sSurfaceTextures = new HashMap<Integer, GeckoSurfaceTexture>();
private int mHandle;
private boolean mIsSingleBuffer;
@@ -85,9 +85,9 @@ public final class GeckoSurface extends
public boolean getAvailable() {
return mIsAvailable;
}
@WrapForJNI
public void setAvailable(boolean available) {
mIsAvailable = available;
}
-}
\ No newline at end of file
+}
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/GeckoSurfaceTexture.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/GeckoSurfaceTexture.java
@@ -1,23 +1,23 @@
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.gfx;
import android.graphics.SurfaceTexture;
+import android.os.Build;
import android.util.Log;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.HashMap;
import org.mozilla.gecko.annotation.WrapForJNI;
-import org.mozilla.gecko.AppConstants.Versions;
public final class GeckoSurfaceTexture extends SurfaceTexture {
private static final String LOGTAG = "GeckoSurfaceTexture";
private static volatile int sNextHandle = 1;
private static HashMap<Integer, GeckoSurfaceTexture> sSurfaceTextures = new HashMap<Integer, GeckoSurfaceTexture>();
private int mHandle;
private boolean mIsSingleBuffer;
@@ -118,17 +118,17 @@ public final class GeckoSurfaceTexture e
}
public synchronized void setListener(GeckoSurfaceTexture.Callbacks listener) {
mListener = listener;
}
@WrapForJNI
public static boolean isSingleBufferSupported() {
- return Versions.feature19Plus;
+ return Build.VERSION.SDK_INT >= 19;
}
@WrapForJNI
public void incrementUse() {
mUseCount.incrementAndGet();
}
@WrapForJNI
@@ -137,17 +137,17 @@ public final class GeckoSurfaceTexture e
if (useCount == 0) {
synchronized (sSurfaceTextures) {
sSurfaceTextures.remove(mHandle);
}
setListener(null);
- if (Versions.feature16Plus) {
+ if (Build.VERSION.SDK_INT >= 16) {
try {
detachFromGLContext();
} catch (Exception e) {
// This can throw if the EGL context is not current
// but we can't do anything about that now.
}
}
@@ -188,9 +188,9 @@ public final class GeckoSurfaceTexture e
return sSurfaceTextures.get(handle);
}
}
public interface Callbacks {
void onUpdateTexImage();
void onReleaseTexImage();
}
-}
\ No newline at end of file
+}
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHlsAudioRenderer.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHlsAudioRenderer.java
@@ -2,37 +2,36 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.media;
import android.media.MediaCodec;
import android.media.MediaCodec.BufferInfo;
import android.media.MediaCodec.CryptoInfo;
+import android.os.Build;
import android.util.Log;
import org.mozilla.gecko.AppConstants;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.RendererCapabilities;
import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
import com.google.android.exoplayer2.mediacodec.MediaCodecInfo;
import com.google.android.exoplayer2.mediacodec.MediaCodecSelector;
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil;
import com.google.android.exoplayer2.util.MimeTypes;
import java.nio.ByteBuffer;
-import org.mozilla.gecko.AppConstants.Versions;
-
public class GeckoHlsAudioRenderer extends GeckoHlsRendererBase {
public GeckoHlsAudioRenderer(GeckoHlsPlayer.ComponentEventDispatcher eventDispatcher) {
super(C.TRACK_TYPE_AUDIO, eventDispatcher);
- assertTrue(Versions.feature16Plus);
+ assertTrue(Build.VERSION.SDK_INT >= 16);
LOGTAG = getClass().getSimpleName();
DEBUG = AppConstants.NIGHTLY_BUILD || AppConstants.DEBUG_BUILD;;
}
@Override
public final int supportsFormat(Format format) {
/*
* FORMAT_EXCEEDS_CAPABILITIES : The Renderer is capable of rendering
@@ -68,17 +67,17 @@ public class GeckoHlsAudioRenderer exten
return RendererCapabilities.FORMAT_UNSUPPORTED_SUBTYPE;
}
/*
* Note : If the code can make it to this place, ExoPlayer assumes
* support for unknown sampleRate and channelCount when
* SDK version is less than 21, otherwise, further check is needed
* if there's no sampleRate/channelCount in format.
*/
- boolean decoderCapable = Versions.preLollipop ||
+ boolean decoderCapable = (Build.VERSION.SDK_INT < 21) ||
((format.sampleRate == Format.NO_VALUE ||
decoderInfo.isAudioSampleRateSupportedV21(format.sampleRate)) &&
(format.channelCount == Format.NO_VALUE ||
decoderInfo.isAudioChannelCountSupportedV21(format.channelCount)));
int formatSupport = decoderCapable ?
RendererCapabilities.FORMAT_HANDLED :
RendererCapabilities.FORMAT_EXCEEDS_CAPABILITIES;
return RendererCapabilities.ADAPTIVE_NOT_SEAMLESS | formatSupport;
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHlsVideoRenderer.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHlsVideoRenderer.java
@@ -2,34 +2,33 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.media;
import android.media.MediaCodec;
import android.media.MediaCodec.BufferInfo;
import android.media.MediaCodec.CryptoInfo;
+import android.os.Build;
import android.util.Log;
import org.mozilla.gecko.AppConstants;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
import com.google.android.exoplayer2.mediacodec.MediaCodecInfo;
import com.google.android.exoplayer2.mediacodec.MediaCodecSelector;
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil;
import com.google.android.exoplayer2.RendererCapabilities;
import com.google.android.exoplayer2.util.MimeTypes;
import java.nio.ByteBuffer;
import java.util.concurrent.ConcurrentLinkedQueue;
-import org.mozilla.gecko.AppConstants.Versions;
-
public class GeckoHlsVideoRenderer extends GeckoHlsRendererBase {
/*
* By configuring these states, initialization data is provided for
* ExoPlayer's HlsMediaSource to parse HLS bitstream and then provide samples
* starting with an Access Unit Delimiter including SPS/PPS for TS,
* and provide samples starting with an AUD without SPS/PPS for FMP4.
*/
private enum RECONFIGURATION_STATE {
@@ -50,17 +49,17 @@ public class GeckoHlsVideoRenderer exten
// Contain CSD-0(SPS)/CSD-1(PPS) information (in AnnexB format) for
// prepending each keyframe. When video format changes, this information
// changes accordingly.
private byte[] mCSDInfo = null;
public GeckoHlsVideoRenderer(GeckoHlsPlayer.ComponentEventDispatcher eventDispatcher) {
super(C.TRACK_TYPE_VIDEO, eventDispatcher);
- assertTrue(Versions.feature16Plus);
+ assertTrue(Build.VERSION.SDK_INT >= 16);
LOGTAG = getClass().getSimpleName();
DEBUG = AppConstants.NIGHTLY_BUILD || AppConstants.DEBUG_BUILD;;
}
@Override
public final int supportsMixedMimeTypeAdaptation() {
return ADAPTIVE_NOT_SEAMLESS;
}
@@ -100,17 +99,17 @@ public class GeckoHlsVideoRenderer exten
Log.e(LOGTAG, e.getMessage());
}
if (decoderInfo == null) {
return RendererCapabilities.FORMAT_UNSUPPORTED_SUBTYPE;
}
boolean decoderCapable = decoderInfo.isCodecSupported(format.codecs);
if (decoderCapable && format.width > 0 && format.height > 0) {
- if (Versions.preLollipop) {
+ if (Build.VERSION.SDK_INT < 21) {
try {
decoderCapable = format.width * format.height <= MediaCodecUtil.maxH264DecodableFrameSize();
} catch (MediaCodecUtil.DecoderQueryException e) {
Log.e(LOGTAG, e.getMessage());
}
if (!decoderCapable) {
if (DEBUG) {
Log.d(LOGTAG, "Check [legacyFrameSize, " +
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/MediaDrmProxy.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/MediaDrmProxy.java
@@ -11,18 +11,18 @@ import java.util.UUID;
import org.mozilla.gecko.mozglue.JNIObject;
import org.mozilla.gecko.annotation.WrapForJNI;
import org.mozilla.gecko.AppConstants;
import android.media.MediaCodecInfo;
import android.media.MediaCodecList;
import android.media.MediaCrypto;
import android.media.MediaDrm;
+import android.os.Build;
import android.util.Log;
-import android.os.Build;
public final class MediaDrmProxy {
private static final String LOGTAG = "GeckoMediaDrmProxy";
private static final boolean DEBUG = false;
private static final UUID WIDEVINE_SCHEME_UUID =
new UUID(0xedef8ba979d64aceL, 0xa3c827dcd51d21edL);
private static final String WIDEVINE_KEY_SYSTEM = "com.widevine.alpha";
@@ -43,17 +43,17 @@ public final class MediaDrmProxy {
// A flag to avoid using the native object that has been destroyed.
private boolean mDestroyed;
private GeckoMediaDrm mImpl;
private String mDrmStubId;
private static boolean isSystemSupported() {
// Support versions >= Marshmallow
- if (AppConstants.Versions.preMarshmallow) {
+ if (Build.VERSION.SDK_INT < 23) {
if (DEBUG) Log.d(LOGTAG, "System Not supported !!, current SDK version is " + Build.VERSION.SDK_INT);
return false;
}
return true;
}
@WrapForJNI
public static boolean isSchemeSupported(String keySystem) {
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/RemoteMediaDrmBridgeStub.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/RemoteMediaDrmBridgeStub.java
@@ -3,16 +3,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.media;
import org.mozilla.gecko.AppConstants;
import java.util.ArrayList;
import android.media.MediaCrypto;
+import android.os.Build;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
final class RemoteMediaDrmBridgeStub extends IMediaDrmBridge.Stub implements IBinder.DeathRecipient {
private static final String LOGTAG = "GeckoRemoteMediaDrmBridgeStub";
private static final boolean DEBUG = false;
private volatile IMediaDrmBridgeCallbacks mCallbacks = null;
@@ -141,22 +142,22 @@ final class RemoteMediaDrmBridgeStub ext
/* package-private */ void assertTrue(boolean condition) {
if (DEBUG && !condition) {
throw new AssertionError("Expected condition to be true");
}
}
RemoteMediaDrmBridgeStub(String keySystem, String stubId) throws RemoteException {
- if (AppConstants.Versions.preLollipop) {
+ if (Build.VERSION.SDK_INT < 21) {
Log.e(LOGTAG, "Pre-Lollipop should never enter here!!");
throw new RemoteException("Error, unsupported version!");
}
try {
- if (AppConstants.Versions.preMarshmallow) {
+ if (Build.VERSION.SDK_INT < 23) {
mBridge = new GeckoMediaDrmBridgeV21(keySystem);
} else {
mBridge = new GeckoMediaDrmBridgeV23(keySystem);
}
mStubId = stubId;
mBridgeStubs.add(this);
} catch (Exception e) {
throw new RemoteException("RemoteMediaDrmBridgeStub cannot create bridge implementation.");
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/ActivityUtils.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/ActivityUtils.java
@@ -37,17 +37,17 @@ public class ActivityUtils {
newVis |= View.SYSTEM_UI_FLAG_LOW_PROFILE;
}
} else {
// no need to prevent status bar to appear when exiting full screen
preventDisplayStatusbar(activity, false);
newVis = View.SYSTEM_UI_FLAG_VISIBLE;
}
- if (AppConstants.Versions.feature23Plus) {
+ if (Build.VERSION.SDK_INT >= 23) {
// We also have to set SYSTEM_UI_FLAG_LIGHT_STATUS_BAR with to current system ui status
// to support both light and dark status bar.
final int oldVis = window.getDecorView().getSystemUiVisibility();
newVis |= (oldVis & View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
window.getDecorView().setSystemUiVisibility(newVis);
}
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/GeckoBundle.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/GeckoBundle.java
@@ -8,16 +8,17 @@ package org.mozilla.gecko.util;
import org.mozilla.gecko.annotation.RobocopTarget;
import org.mozilla.gecko.annotation.WrapForJNI;
import org.mozilla.gecko.AppConstants;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
+import android.os.Build;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.v4.util.SimpleArrayMap;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Collection;
@@ -740,17 +741,17 @@ public final class GeckoBundle implement
jsonValue = ((GeckoBundle) value).toJSONObject();
} else if (value instanceof GeckoBundle[]) {
final GeckoBundle[] array = (GeckoBundle[]) value;
final JSONArray jsonArray = new JSONArray();
for (int j = 0; j < array.length; j++) {
jsonArray.put(array[j] == null ? JSONObject.NULL : array[j].toJSONObject());
}
jsonValue = jsonArray;
- } else if (AppConstants.Versions.feature19Plus) {
+ } else if (Build.VERSION.SDK_INT >= 19) {
final Object wrapped = JSONObject.wrap(value);
jsonValue = wrapped != null ? wrapped : value.toString();
} else if (value == null) {
jsonValue = JSONObject.NULL;
} else if (value.getClass().isArray()) {
final JSONArray jsonArray = new JSONArray();
for (int j = 0; j < Array.getLength(value); j++) {
jsonArray.put(Array.get(value, j));