зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1512274 - [geckoview] Fix indentation. r=geckoview-reviewers,snorp
Differential Revision: https://phabricator.services.mozilla.com/D23689 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
2dd021c9ae
Коммит
568a8b3da0
|
@ -420,58 +420,58 @@ public class GeckoAppShell {
|
|||
final long time = s.timestamp / 1000;
|
||||
|
||||
switch (sensorType) {
|
||||
case Sensor.TYPE_ACCELEROMETER:
|
||||
case Sensor.TYPE_LINEAR_ACCELERATION:
|
||||
case Sensor.TYPE_ORIENTATION:
|
||||
if (sensorType == Sensor.TYPE_ACCELEROMETER) {
|
||||
halType = GeckoHalDefines.SENSOR_ACCELERATION;
|
||||
} else if (sensorType == Sensor.TYPE_LINEAR_ACCELERATION) {
|
||||
halType = GeckoHalDefines.SENSOR_LINEAR_ACCELERATION;
|
||||
} else {
|
||||
halType = GeckoHalDefines.SENSOR_ORIENTATION;
|
||||
}
|
||||
x = s.values[0];
|
||||
y = s.values[1];
|
||||
z = s.values[2];
|
||||
break;
|
||||
case Sensor.TYPE_ACCELEROMETER:
|
||||
case Sensor.TYPE_LINEAR_ACCELERATION:
|
||||
case Sensor.TYPE_ORIENTATION:
|
||||
if (sensorType == Sensor.TYPE_ACCELEROMETER) {
|
||||
halType = GeckoHalDefines.SENSOR_ACCELERATION;
|
||||
} else if (sensorType == Sensor.TYPE_LINEAR_ACCELERATION) {
|
||||
halType = GeckoHalDefines.SENSOR_LINEAR_ACCELERATION;
|
||||
} else {
|
||||
halType = GeckoHalDefines.SENSOR_ORIENTATION;
|
||||
}
|
||||
x = s.values[0];
|
||||
y = s.values[1];
|
||||
z = s.values[2];
|
||||
break;
|
||||
|
||||
case Sensor.TYPE_GYROSCOPE:
|
||||
halType = GeckoHalDefines.SENSOR_GYROSCOPE;
|
||||
x = (float) Math.toDegrees(s.values[0]);
|
||||
y = (float) Math.toDegrees(s.values[1]);
|
||||
z = (float) Math.toDegrees(s.values[2]);
|
||||
break;
|
||||
case Sensor.TYPE_GYROSCOPE:
|
||||
halType = GeckoHalDefines.SENSOR_GYROSCOPE;
|
||||
x = (float) Math.toDegrees(s.values[0]);
|
||||
y = (float) Math.toDegrees(s.values[1]);
|
||||
z = (float) Math.toDegrees(s.values[2]);
|
||||
break;
|
||||
|
||||
case Sensor.TYPE_PROXIMITY:
|
||||
halType = GeckoHalDefines.SENSOR_PROXIMITY;
|
||||
x = s.values[0];
|
||||
z = s.sensor.getMaximumRange();
|
||||
break;
|
||||
case Sensor.TYPE_PROXIMITY:
|
||||
halType = GeckoHalDefines.SENSOR_PROXIMITY;
|
||||
x = s.values[0];
|
||||
z = s.sensor.getMaximumRange();
|
||||
break;
|
||||
|
||||
case Sensor.TYPE_LIGHT:
|
||||
halType = GeckoHalDefines.SENSOR_LIGHT;
|
||||
x = s.values[0];
|
||||
break;
|
||||
case Sensor.TYPE_LIGHT:
|
||||
halType = GeckoHalDefines.SENSOR_LIGHT;
|
||||
x = s.values[0];
|
||||
break;
|
||||
|
||||
case Sensor.TYPE_ROTATION_VECTOR:
|
||||
case Sensor.TYPE_GAME_ROTATION_VECTOR: // API >= 18
|
||||
halType = (sensorType == Sensor.TYPE_ROTATION_VECTOR ?
|
||||
GeckoHalDefines.SENSOR_ROTATION_VECTOR :
|
||||
GeckoHalDefines.SENSOR_GAME_ROTATION_VECTOR);
|
||||
x = s.values[0];
|
||||
y = s.values[1];
|
||||
z = s.values[2];
|
||||
if (s.values.length >= 4) {
|
||||
w = s.values[3];
|
||||
} else {
|
||||
// s.values[3] was optional in API <= 18, so we need to compute it
|
||||
// The values form a unit quaternion, so we can compute the angle of
|
||||
// rotation purely based on the given 3 values.
|
||||
w = 1.0f - s.values[0] * s.values[0] -
|
||||
s.values[1] * s.values[1] - s.values[2] * s.values[2];
|
||||
w = (w > 0.0f) ? (float) Math.sqrt(w) : 0.0f;
|
||||
}
|
||||
break;
|
||||
case Sensor.TYPE_ROTATION_VECTOR:
|
||||
case Sensor.TYPE_GAME_ROTATION_VECTOR: // API >= 18
|
||||
halType = (sensorType == Sensor.TYPE_ROTATION_VECTOR ?
|
||||
GeckoHalDefines.SENSOR_ROTATION_VECTOR :
|
||||
GeckoHalDefines.SENSOR_GAME_ROTATION_VECTOR);
|
||||
x = s.values[0];
|
||||
y = s.values[1];
|
||||
z = s.values[2];
|
||||
if (s.values.length >= 4) {
|
||||
w = s.values[3];
|
||||
} else {
|
||||
// s.values[3] was optional in API <= 18, so we need to compute it
|
||||
// The values form a unit quaternion, so we can compute the angle of
|
||||
// rotation purely based on the given 3 values.
|
||||
w = 1.0f - s.values[0] * s.values[0] -
|
||||
s.values[1] * s.values[1] - s.values[2] * s.values[2];
|
||||
w = (w > 0.0f) ? (float) Math.sqrt(w) : 0.0f;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
GeckoAppShell.onSensorChanged(halType, x, y, z, w, time);
|
||||
|
@ -572,13 +572,13 @@ public class GeckoAppShell {
|
|||
|
||||
if (WakeLockDelegate.LOCK_CPU.equals(lock) ||
|
||||
WakeLockDelegate.LOCK_AUDIO_PLAYING.equals(lock)) {
|
||||
wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, lock);
|
||||
wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, lock);
|
||||
} else if (WakeLockDelegate.LOCK_SCREEN.equals(lock) ||
|
||||
WakeLockDelegate.LOCK_VIDEO_PLAYING.equals(lock)) {
|
||||
// ON_AFTER_RELEASE is set, the user activity timer will be reset when the
|
||||
// WakeLock is released, causing the illumination to remain on a bit longer.
|
||||
wl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK |
|
||||
PowerManager.ON_AFTER_RELEASE, lock);
|
||||
wl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK |
|
||||
PowerManager.ON_AFTER_RELEASE, lock);
|
||||
} else {
|
||||
Log.w(LOGTAG, "Unsupported wake-lock: " + lock);
|
||||
return;
|
||||
|
@ -677,108 +677,108 @@ public class GeckoAppShell {
|
|||
getApplicationContext().getSystemService(Context.SENSOR_SERVICE);
|
||||
|
||||
switch (aSensortype) {
|
||||
case GeckoHalDefines.SENSOR_GAME_ROTATION_VECTOR:
|
||||
if (gGameRotationVectorSensor == null) {
|
||||
gGameRotationVectorSensor = sm.getDefaultSensor(
|
||||
Sensor.TYPE_GAME_ROTATION_VECTOR);
|
||||
}
|
||||
if (gGameRotationVectorSensor != null) {
|
||||
sm.registerListener(getSensorListener(),
|
||||
gGameRotationVectorSensor,
|
||||
SensorManager.SENSOR_DELAY_FASTEST);
|
||||
}
|
||||
if (gGameRotationVectorSensor != null) {
|
||||
break;
|
||||
}
|
||||
// Fallthrough
|
||||
case GeckoHalDefines.SENSOR_GAME_ROTATION_VECTOR:
|
||||
if (gGameRotationVectorSensor == null) {
|
||||
gGameRotationVectorSensor = sm.getDefaultSensor(
|
||||
Sensor.TYPE_GAME_ROTATION_VECTOR);
|
||||
}
|
||||
if (gGameRotationVectorSensor != null) {
|
||||
sm.registerListener(getSensorListener(),
|
||||
gGameRotationVectorSensor,
|
||||
SensorManager.SENSOR_DELAY_FASTEST);
|
||||
}
|
||||
if (gGameRotationVectorSensor != null) {
|
||||
break;
|
||||
}
|
||||
// Fallthrough
|
||||
|
||||
case GeckoHalDefines.SENSOR_ROTATION_VECTOR:
|
||||
if (gRotationVectorSensor == null) {
|
||||
gRotationVectorSensor = sm.getDefaultSensor(
|
||||
Sensor.TYPE_ROTATION_VECTOR);
|
||||
}
|
||||
if (gRotationVectorSensor != null) {
|
||||
sm.registerListener(getSensorListener(),
|
||||
gRotationVectorSensor,
|
||||
SensorManager.SENSOR_DELAY_FASTEST);
|
||||
}
|
||||
if (gRotationVectorSensor != null) {
|
||||
break;
|
||||
}
|
||||
// Fallthrough
|
||||
case GeckoHalDefines.SENSOR_ROTATION_VECTOR:
|
||||
if (gRotationVectorSensor == null) {
|
||||
gRotationVectorSensor = sm.getDefaultSensor(
|
||||
Sensor.TYPE_ROTATION_VECTOR);
|
||||
}
|
||||
if (gRotationVectorSensor != null) {
|
||||
sm.registerListener(getSensorListener(),
|
||||
gRotationVectorSensor,
|
||||
SensorManager.SENSOR_DELAY_FASTEST);
|
||||
}
|
||||
if (gRotationVectorSensor != null) {
|
||||
break;
|
||||
}
|
||||
// Fallthrough
|
||||
|
||||
case GeckoHalDefines.SENSOR_ORIENTATION:
|
||||
if (gOrientationSensor == null) {
|
||||
gOrientationSensor = sm.getDefaultSensor(
|
||||
Sensor.TYPE_ORIENTATION);
|
||||
}
|
||||
if (gOrientationSensor != null) {
|
||||
sm.registerListener(getSensorListener(),
|
||||
gOrientationSensor,
|
||||
SensorManager.SENSOR_DELAY_FASTEST);
|
||||
}
|
||||
break;
|
||||
case GeckoHalDefines.SENSOR_ORIENTATION:
|
||||
if (gOrientationSensor == null) {
|
||||
gOrientationSensor = sm.getDefaultSensor(
|
||||
Sensor.TYPE_ORIENTATION);
|
||||
}
|
||||
if (gOrientationSensor != null) {
|
||||
sm.registerListener(getSensorListener(),
|
||||
gOrientationSensor,
|
||||
SensorManager.SENSOR_DELAY_FASTEST);
|
||||
}
|
||||
break;
|
||||
|
||||
case GeckoHalDefines.SENSOR_ACCELERATION:
|
||||
if (gAccelerometerSensor == null) {
|
||||
gAccelerometerSensor = sm.getDefaultSensor(
|
||||
Sensor.TYPE_ACCELEROMETER);
|
||||
}
|
||||
if (gAccelerometerSensor != null) {
|
||||
sm.registerListener(getSensorListener(),
|
||||
gAccelerometerSensor,
|
||||
SensorManager.SENSOR_DELAY_FASTEST);
|
||||
}
|
||||
break;
|
||||
case GeckoHalDefines.SENSOR_ACCELERATION:
|
||||
if (gAccelerometerSensor == null) {
|
||||
gAccelerometerSensor = sm.getDefaultSensor(
|
||||
Sensor.TYPE_ACCELEROMETER);
|
||||
}
|
||||
if (gAccelerometerSensor != null) {
|
||||
sm.registerListener(getSensorListener(),
|
||||
gAccelerometerSensor,
|
||||
SensorManager.SENSOR_DELAY_FASTEST);
|
||||
}
|
||||
break;
|
||||
|
||||
case GeckoHalDefines.SENSOR_PROXIMITY:
|
||||
if (gProximitySensor == null) {
|
||||
gProximitySensor = sm.getDefaultSensor(Sensor.TYPE_PROXIMITY);
|
||||
}
|
||||
if (gProximitySensor != null) {
|
||||
sm.registerListener(getSensorListener(),
|
||||
gProximitySensor,
|
||||
SensorManager.SENSOR_DELAY_NORMAL);
|
||||
}
|
||||
break;
|
||||
case GeckoHalDefines.SENSOR_PROXIMITY:
|
||||
if (gProximitySensor == null) {
|
||||
gProximitySensor = sm.getDefaultSensor(Sensor.TYPE_PROXIMITY);
|
||||
}
|
||||
if (gProximitySensor != null) {
|
||||
sm.registerListener(getSensorListener(),
|
||||
gProximitySensor,
|
||||
SensorManager.SENSOR_DELAY_NORMAL);
|
||||
}
|
||||
break;
|
||||
|
||||
case GeckoHalDefines.SENSOR_LIGHT:
|
||||
if (gLightSensor == null) {
|
||||
gLightSensor = sm.getDefaultSensor(Sensor.TYPE_LIGHT);
|
||||
}
|
||||
if (gLightSensor != null) {
|
||||
sm.registerListener(getSensorListener(),
|
||||
gLightSensor,
|
||||
SensorManager.SENSOR_DELAY_NORMAL);
|
||||
}
|
||||
break;
|
||||
case GeckoHalDefines.SENSOR_LIGHT:
|
||||
if (gLightSensor == null) {
|
||||
gLightSensor = sm.getDefaultSensor(Sensor.TYPE_LIGHT);
|
||||
}
|
||||
if (gLightSensor != null) {
|
||||
sm.registerListener(getSensorListener(),
|
||||
gLightSensor,
|
||||
SensorManager.SENSOR_DELAY_NORMAL);
|
||||
}
|
||||
break;
|
||||
|
||||
case GeckoHalDefines.SENSOR_LINEAR_ACCELERATION:
|
||||
if (gLinearAccelerometerSensor == null) {
|
||||
gLinearAccelerometerSensor = sm.getDefaultSensor(
|
||||
Sensor.TYPE_LINEAR_ACCELERATION);
|
||||
}
|
||||
if (gLinearAccelerometerSensor != null) {
|
||||
sm.registerListener(getSensorListener(),
|
||||
gLinearAccelerometerSensor,
|
||||
SensorManager.SENSOR_DELAY_FASTEST);
|
||||
}
|
||||
break;
|
||||
case GeckoHalDefines.SENSOR_LINEAR_ACCELERATION:
|
||||
if (gLinearAccelerometerSensor == null) {
|
||||
gLinearAccelerometerSensor = sm.getDefaultSensor(
|
||||
Sensor.TYPE_LINEAR_ACCELERATION);
|
||||
}
|
||||
if (gLinearAccelerometerSensor != null) {
|
||||
sm.registerListener(getSensorListener(),
|
||||
gLinearAccelerometerSensor,
|
||||
SensorManager.SENSOR_DELAY_FASTEST);
|
||||
}
|
||||
break;
|
||||
|
||||
case GeckoHalDefines.SENSOR_GYROSCOPE:
|
||||
if (gGyroscopeSensor == null) {
|
||||
gGyroscopeSensor = sm.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
|
||||
}
|
||||
if (gGyroscopeSensor != null) {
|
||||
sm.registerListener(getSensorListener(),
|
||||
gGyroscopeSensor,
|
||||
SensorManager.SENSOR_DELAY_FASTEST);
|
||||
}
|
||||
break;
|
||||
case GeckoHalDefines.SENSOR_GYROSCOPE:
|
||||
if (gGyroscopeSensor == null) {
|
||||
gGyroscopeSensor = sm.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
|
||||
}
|
||||
if (gGyroscopeSensor != null) {
|
||||
sm.registerListener(getSensorListener(),
|
||||
gGyroscopeSensor,
|
||||
SensorManager.SENSOR_DELAY_FASTEST);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
Log.w(LOGTAG, "Error! Can't enable unknown SENSOR type " +
|
||||
aSensortype);
|
||||
default:
|
||||
Log.w(LOGTAG, "Error! Can't enable unknown SENSOR type " +
|
||||
aSensortype);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -789,57 +789,57 @@ public class GeckoAppShell {
|
|||
getApplicationContext().getSystemService(Context.SENSOR_SERVICE);
|
||||
|
||||
switch (aSensortype) {
|
||||
case GeckoHalDefines.SENSOR_GAME_ROTATION_VECTOR:
|
||||
if (gGameRotationVectorSensor != null) {
|
||||
sm.unregisterListener(getSensorListener(), gGameRotationVectorSensor);
|
||||
break;
|
||||
}
|
||||
// Fallthrough
|
||||
case GeckoHalDefines.SENSOR_GAME_ROTATION_VECTOR:
|
||||
if (gGameRotationVectorSensor != null) {
|
||||
sm.unregisterListener(getSensorListener(), gGameRotationVectorSensor);
|
||||
break;
|
||||
}
|
||||
// Fallthrough
|
||||
|
||||
case GeckoHalDefines.SENSOR_ROTATION_VECTOR:
|
||||
if (gRotationVectorSensor != null) {
|
||||
sm.unregisterListener(getSensorListener(), gRotationVectorSensor);
|
||||
break;
|
||||
}
|
||||
// Fallthrough
|
||||
case GeckoHalDefines.SENSOR_ROTATION_VECTOR:
|
||||
if (gRotationVectorSensor != null) {
|
||||
sm.unregisterListener(getSensorListener(), gRotationVectorSensor);
|
||||
break;
|
||||
}
|
||||
// Fallthrough
|
||||
|
||||
case GeckoHalDefines.SENSOR_ORIENTATION:
|
||||
if (gOrientationSensor != null) {
|
||||
sm.unregisterListener(getSensorListener(), gOrientationSensor);
|
||||
}
|
||||
break;
|
||||
case GeckoHalDefines.SENSOR_ORIENTATION:
|
||||
if (gOrientationSensor != null) {
|
||||
sm.unregisterListener(getSensorListener(), gOrientationSensor);
|
||||
}
|
||||
break;
|
||||
|
||||
case GeckoHalDefines.SENSOR_ACCELERATION:
|
||||
if (gAccelerometerSensor != null) {
|
||||
sm.unregisterListener(getSensorListener(), gAccelerometerSensor);
|
||||
}
|
||||
break;
|
||||
case GeckoHalDefines.SENSOR_ACCELERATION:
|
||||
if (gAccelerometerSensor != null) {
|
||||
sm.unregisterListener(getSensorListener(), gAccelerometerSensor);
|
||||
}
|
||||
break;
|
||||
|
||||
case GeckoHalDefines.SENSOR_PROXIMITY:
|
||||
if (gProximitySensor != null) {
|
||||
sm.unregisterListener(getSensorListener(), gProximitySensor);
|
||||
}
|
||||
break;
|
||||
case GeckoHalDefines.SENSOR_PROXIMITY:
|
||||
if (gProximitySensor != null) {
|
||||
sm.unregisterListener(getSensorListener(), gProximitySensor);
|
||||
}
|
||||
break;
|
||||
|
||||
case GeckoHalDefines.SENSOR_LIGHT:
|
||||
if (gLightSensor != null) {
|
||||
sm.unregisterListener(getSensorListener(), gLightSensor);
|
||||
}
|
||||
break;
|
||||
case GeckoHalDefines.SENSOR_LIGHT:
|
||||
if (gLightSensor != null) {
|
||||
sm.unregisterListener(getSensorListener(), gLightSensor);
|
||||
}
|
||||
break;
|
||||
|
||||
case GeckoHalDefines.SENSOR_LINEAR_ACCELERATION:
|
||||
if (gLinearAccelerometerSensor != null) {
|
||||
sm.unregisterListener(getSensorListener(), gLinearAccelerometerSensor);
|
||||
}
|
||||
break;
|
||||
case GeckoHalDefines.SENSOR_LINEAR_ACCELERATION:
|
||||
if (gLinearAccelerometerSensor != null) {
|
||||
sm.unregisterListener(getSensorListener(), gLinearAccelerometerSensor);
|
||||
}
|
||||
break;
|
||||
|
||||
case GeckoHalDefines.SENSOR_GYROSCOPE:
|
||||
if (gGyroscopeSensor != null) {
|
||||
sm.unregisterListener(getSensorListener(), gGyroscopeSensor);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Log.w(LOGTAG, "Error! Can't disable unknown SENSOR type " + aSensortype);
|
||||
case GeckoHalDefines.SENSOR_GYROSCOPE:
|
||||
if (gGyroscopeSensor != null) {
|
||||
sm.unregisterListener(getSensorListener(), gGyroscopeSensor);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Log.w(LOGTAG, "Error! Can't disable unknown SENSOR type " + aSensortype);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -875,12 +875,12 @@ public class GeckoAppShell {
|
|||
|
||||
@WrapForJNI(calledFrom = "gecko")
|
||||
private static boolean getHWEncoderCapability() {
|
||||
return HardwareCodecCapabilityUtils.getHWEncoderCapability();
|
||||
return HardwareCodecCapabilityUtils.getHWEncoderCapability();
|
||||
}
|
||||
|
||||
@WrapForJNI(calledFrom = "gecko")
|
||||
private static boolean getHWDecoderCapability() {
|
||||
return HardwareCodecCapabilityUtils.getHWDecoderCapability();
|
||||
return HardwareCodecCapabilityUtils.getHWDecoderCapability();
|
||||
}
|
||||
|
||||
static List<ResolveInfo> queryIntentActivities(final Intent intent) {
|
||||
|
@ -1124,7 +1124,7 @@ public class GeckoAppShell {
|
|||
long vibrationDuration = 0;
|
||||
int iterLen = pattern.length & ~1;
|
||||
for (int i = 0; i < iterLen; i++) {
|
||||
vibrationDuration += pattern[i];
|
||||
vibrationDuration += pattern[i];
|
||||
}
|
||||
|
||||
sVibrationEndTime = System.nanoTime() + vibrationDuration * 1000000;
|
||||
|
@ -1151,7 +1151,7 @@ public class GeckoAppShell {
|
|||
@WrapForJNI(calledFrom = "gecko")
|
||||
private static boolean isNetworkLinkUp() {
|
||||
ConnectivityManager cm = (ConnectivityManager)
|
||||
getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
try {
|
||||
NetworkInfo info = cm.getActiveNetworkInfo();
|
||||
if (info == null || !info.isConnected())
|
||||
|
@ -1783,8 +1783,7 @@ public class GeckoAppShell {
|
|||
|
||||
@Override
|
||||
public synchronized int read(final byte[] buffer, final int byteOffset,
|
||||
final int byteCount)
|
||||
throws IOException {
|
||||
final int byteCount) throws IOException {
|
||||
if (mHaveConnected) {
|
||||
return super.read(buffer, byteOffset, byteCount);
|
||||
}
|
||||
|
|
|
@ -117,9 +117,9 @@ public class GeckoNetworkManager extends BroadcastReceiver implements BundleEven
|
|||
final Context applicationContext = GeckoAppShell.getApplicationContext();
|
||||
final ConnectionType connectionType = mCurrentConnectionType;
|
||||
return new double[] {
|
||||
connectionType.value,
|
||||
connectionType == ConnectionType.WIFI ? 1.0 : 0.0,
|
||||
connectionType == ConnectionType.WIFI ? wifiDhcpGatewayAddress(applicationContext) : 0.0
|
||||
connectionType.value,
|
||||
connectionType == ConnectionType.WIFI ? 1.0 : 0.0,
|
||||
connectionType == ConnectionType.WIFI ? wifiDhcpGatewayAddress(applicationContext) : 0.0
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -138,16 +138,16 @@ public class GeckoProfileDirectories {
|
|||
* if the Mozilla directory did not exist and could not be created.
|
||||
*/
|
||||
static String findDefaultProfileName(final Context context) throws NoMozillaDirectoryException {
|
||||
final INIParser parser = GeckoProfileDirectories.getProfilesINI(getMozillaDirectory(context));
|
||||
if (parser.getSections() != null) {
|
||||
for (Enumeration<INISection> e = parser.getSections().elements(); e.hasMoreElements(); ) {
|
||||
final INISection section = e.nextElement();
|
||||
if (section.getIntProperty("Default") == 1) {
|
||||
return section.getStringProperty("Name");
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
final INIParser parser = GeckoProfileDirectories.getProfilesINI(getMozillaDirectory(context));
|
||||
if (parser.getSections() != null) {
|
||||
for (Enumeration<INISection> e = parser.getSections().elements(); e.hasMoreElements(); ) {
|
||||
final INISection section = e.nextElement();
|
||||
if (section.getIntProperty("Default") == 1) {
|
||||
return section.getStringProperty("Name");
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static Map<String, String> getDefaultProfile(final File mozillaDir) {
|
||||
|
|
|
@ -92,7 +92,7 @@ public class GeckoSystemStateListener
|
|||
*/
|
||||
private static boolean prefersReducedMotion() {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
ContentResolver contentResolver = sApplicationContext.getContentResolver();
|
||||
|
|
|
@ -16,8 +16,7 @@ public class NSSBridge {
|
|||
private static native String nativeDecrypt(String aDb, String aValue);
|
||||
|
||||
@RobocopTarget
|
||||
static public String encrypt(final Context context, final String aValue)
|
||||
throws Exception {
|
||||
static public String encrypt(final Context context, final String aValue) throws Exception {
|
||||
GeckoLoader.loadNSSLibs(context);
|
||||
|
||||
String path = GeckoProfile.get(context).getDir().toString();
|
||||
|
@ -26,16 +25,14 @@ public class NSSBridge {
|
|||
|
||||
@RobocopTarget
|
||||
static public String encrypt(final Context context, final String profilePath,
|
||||
final String aValue)
|
||||
throws Exception {
|
||||
final String aValue) throws Exception {
|
||||
GeckoLoader.loadNSSLibs(context);
|
||||
|
||||
return nativeEncrypt(profilePath, aValue);
|
||||
}
|
||||
|
||||
@RobocopTarget
|
||||
static public String decrypt(final Context context, final String aValue)
|
||||
throws Exception {
|
||||
static public String decrypt(final Context context, final String aValue) throws Exception {
|
||||
GeckoLoader.loadNSSLibs(context);
|
||||
|
||||
String path = GeckoProfile.get(context).getDir().toString();
|
||||
|
@ -44,8 +41,7 @@ public class NSSBridge {
|
|||
|
||||
@RobocopTarget
|
||||
static public String decrypt(final Context context, final String profilePath,
|
||||
final String aValue)
|
||||
throws Exception {
|
||||
final String aValue) throws Exception {
|
||||
GeckoLoader.loadNSSLibs(context);
|
||||
|
||||
return nativeDecrypt(profilePath, aValue);
|
||||
|
|
|
@ -81,7 +81,7 @@ public class TelemetryUtils {
|
|||
}
|
||||
|
||||
public long getElapsed() {
|
||||
return mElapsed;
|
||||
return mElapsed;
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
|
|
|
@ -214,7 +214,7 @@ import org.mozilla.gecko.mozglue.JNIObject;
|
|||
for (GeckoSurfaceTexture tex : list) {
|
||||
try {
|
||||
if (tex.isSingleBuffer()) {
|
||||
tex.releaseTexImage();
|
||||
tex.releaseTexImage();
|
||||
}
|
||||
|
||||
tex.detachFromGLContext();
|
||||
|
|
|
@ -172,11 +172,11 @@ public final class CodecProxy {
|
|||
|
||||
@WrapForJNI
|
||||
public synchronized boolean isAdaptivePlaybackSupported() {
|
||||
if (mRemote == null) {
|
||||
Log.e(LOGTAG, "cannot check isAdaptivePlaybackSupported with an ended codec");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
if (mRemote == null) {
|
||||
Log.e(LOGTAG, "cannot check isAdaptivePlaybackSupported with an ended codec");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
return mRemote.isAdaptivePlaybackSupported();
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -186,11 +186,11 @@ public final class CodecProxy {
|
|||
|
||||
@WrapForJNI
|
||||
public synchronized boolean isHardwareAccelerated() {
|
||||
if (mRemote == null) {
|
||||
Log.e(LOGTAG, "cannot check isHardwareAccelerated with an ended codec");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
if (mRemote == null) {
|
||||
Log.e(LOGTAG, "cannot check isHardwareAccelerated with an ended codec");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
return mRemote.isHardwareAccelerated();
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -200,11 +200,11 @@ public final class CodecProxy {
|
|||
|
||||
@WrapForJNI
|
||||
public synchronized boolean isTunneledPlaybackSupported() {
|
||||
if (mRemote == null) {
|
||||
Log.e(LOGTAG, "cannot check isTunneledPlaybackSupported with an ended codec");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
if (mRemote == null) {
|
||||
Log.e(LOGTAG, "cannot check isTunneledPlaybackSupported with an ended codec");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
return mRemote.isTunneledPlaybackSupported();
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -34,9 +34,7 @@ public final class GeckoHLSDemuxerWrapper {
|
|||
|
||||
private BaseHlsPlayer mPlayer = null;
|
||||
|
||||
public static class Callbacks extends JNIObject
|
||||
implements BaseHlsPlayer.DemuxerCallbacks {
|
||||
|
||||
public static class Callbacks extends JNIObject implements BaseHlsPlayer.DemuxerCallbacks {
|
||||
@WrapForJNI(calledFrom = "gecko")
|
||||
Callbacks() {}
|
||||
|
||||
|
|
|
@ -16,8 +16,7 @@ public class GeckoHLSResourceWrapper {
|
|||
private BaseHlsPlayer mPlayer = null;
|
||||
private boolean mDestroy = false;
|
||||
|
||||
public static class Callbacks extends JNIObject
|
||||
implements BaseHlsPlayer.ResourceCallbacks {
|
||||
public static class Callbacks extends JNIObject implements BaseHlsPlayer.ResourceCallbacks {
|
||||
@WrapForJNI(calledFrom = "gecko")
|
||||
Callbacks() {}
|
||||
|
||||
|
|
|
@ -81,6 +81,6 @@ public final class GeckoHLSSample {
|
|||
append(", duration=").append(duration).
|
||||
append(", flags=").append(Integer.toHexString(info.flags)).append(" }").
|
||||
append(" }");
|
||||
return str.toString();
|
||||
return str.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,9 +173,9 @@ public class GeckoHlsPlayer implements BaseHlsPlayer, ExoPlayer.EventListener {
|
|||
private BaseHlsPlayer.ResourceCallbacks mResourceCallbacks;
|
||||
|
||||
private static void assertTrue(final boolean condition) {
|
||||
if (DEBUG && !condition) {
|
||||
throw new AssertionError("Expected condition to be true");
|
||||
}
|
||||
if (DEBUG && !condition) {
|
||||
throw new AssertionError("Expected condition to be true");
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkInitDone() {
|
||||
|
@ -512,23 +512,23 @@ public class GeckoHlsPlayer implements BaseHlsPlayer, ExoPlayer.EventListener {
|
|||
}
|
||||
Timeline.Period period = new Timeline.Period();
|
||||
for (int i = 0; i < Math.min(periodCount, MAX_TIMELINE_ITEM_LINES); i++) {
|
||||
timeline.getPeriod(i, period);
|
||||
if (mDurationUs < period.getDurationUs()) {
|
||||
mDurationUs = period.getDurationUs();
|
||||
}
|
||||
timeline.getPeriod(i, period);
|
||||
if (mDurationUs < period.getDurationUs()) {
|
||||
mDurationUs = period.getDurationUs();
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < Math.min(windowCount, MAX_TIMELINE_ITEM_LINES); i++) {
|
||||
timeline.getWindow(i, window);
|
||||
if (mDurationUs < window.getDurationUs()) {
|
||||
mDurationUs = window.getDurationUs();
|
||||
}
|
||||
timeline.getWindow(i, window);
|
||||
if (mDurationUs < window.getDurationUs()) {
|
||||
mDurationUs = window.getDurationUs();
|
||||
}
|
||||
}
|
||||
// TODO : Need to check if the duration from play.getDuration is different
|
||||
// with the one calculated from multi-timelines/windows.
|
||||
if (DEBUG) {
|
||||
Log.d(LOGTAG, "Media duration (from Timeline) = " + mDurationUs +
|
||||
"(us)" + " player.getDuration() = " + mPlayer.getDuration() +
|
||||
"(ms)");
|
||||
"(us)" + " player.getDuration() = " + mPlayer.getDuration() +
|
||||
"(ms)");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -549,45 +549,45 @@ public class GeckoHlsPlayer implements BaseHlsPlayer, ExoPlayer.EventListener {
|
|||
|
||||
private static String getFormatSupportString(final int formatSupport) {
|
||||
switch (formatSupport) {
|
||||
case RendererCapabilities.FORMAT_HANDLED:
|
||||
return "YES";
|
||||
case RendererCapabilities.FORMAT_EXCEEDS_CAPABILITIES:
|
||||
return "NO_EXCEEDS_CAPABILITIES";
|
||||
case RendererCapabilities.FORMAT_UNSUPPORTED_SUBTYPE:
|
||||
return "NO_UNSUPPORTED_TYPE";
|
||||
case RendererCapabilities.FORMAT_UNSUPPORTED_TYPE:
|
||||
return "NO";
|
||||
default:
|
||||
return "?";
|
||||
case RendererCapabilities.FORMAT_HANDLED:
|
||||
return "YES";
|
||||
case RendererCapabilities.FORMAT_EXCEEDS_CAPABILITIES:
|
||||
return "NO_EXCEEDS_CAPABILITIES";
|
||||
case RendererCapabilities.FORMAT_UNSUPPORTED_SUBTYPE:
|
||||
return "NO_UNSUPPORTED_TYPE";
|
||||
case RendererCapabilities.FORMAT_UNSUPPORTED_TYPE:
|
||||
return "NO";
|
||||
default:
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String getAdaptiveSupportString(final int trackCount,
|
||||
final int adaptiveSupport) {
|
||||
if (trackCount < 2) {
|
||||
return "N/A";
|
||||
return "N/A";
|
||||
}
|
||||
switch (adaptiveSupport) {
|
||||
case RendererCapabilities.ADAPTIVE_SEAMLESS:
|
||||
return "YES";
|
||||
case RendererCapabilities.ADAPTIVE_NOT_SEAMLESS:
|
||||
return "YES_NOT_SEAMLESS";
|
||||
case RendererCapabilities.ADAPTIVE_NOT_SUPPORTED:
|
||||
return "NO";
|
||||
default:
|
||||
return "?";
|
||||
case RendererCapabilities.ADAPTIVE_SEAMLESS:
|
||||
return "YES";
|
||||
case RendererCapabilities.ADAPTIVE_NOT_SEAMLESS:
|
||||
return "YES_NOT_SEAMLESS";
|
||||
case RendererCapabilities.ADAPTIVE_NOT_SUPPORTED:
|
||||
return "NO";
|
||||
default:
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String getTrackStatusString(final TrackSelection selection,
|
||||
final TrackGroup group, final int trackIndex) {
|
||||
private static String getTrackStatusString(final TrackSelection selection,
|
||||
final TrackGroup group, final int trackIndex) {
|
||||
return getTrackStatusString(selection != null && selection.getTrackGroup() == group
|
||||
&& selection.indexOf(trackIndex) != C.INDEX_UNSET);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getTrackStatusString(final boolean enabled) {
|
||||
private static String getTrackStatusString(final boolean enabled) {
|
||||
return enabled ? "[X]" : "[ ]";
|
||||
}
|
||||
}
|
||||
|
||||
// Called on GeckoHlsPlayerThread
|
||||
private synchronized void createExoPlayer(final String url) {
|
||||
|
@ -828,7 +828,7 @@ public class GeckoHlsPlayer implements BaseHlsPlayer, ExoPlayer.EventListener {
|
|||
@Override
|
||||
public synchronized void resume() {
|
||||
if (!mExoplayerSuspended) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
if (mMediaDecoderPlayState == MediaDecoderPlayState.PLAY_STATE_PLAYING) {
|
||||
if (DEBUG) {
|
||||
|
|
|
@ -290,8 +290,9 @@ public class GeckoHlsVideoRenderer extends GeckoHlsRendererBase {
|
|||
@Override
|
||||
protected boolean canReconfigure(final Format oldFormat, final Format newFormat) {
|
||||
boolean canReconfig = areAdaptationCompatible(oldFormat, newFormat)
|
||||
&& newFormat.width <= mCodecMaxValues.width && newFormat.height <= mCodecMaxValues.height
|
||||
&& newFormat.maxInputSize <= mCodecMaxValues.inputSize;
|
||||
&& newFormat.width <= mCodecMaxValues.width
|
||||
&& newFormat.height <= mCodecMaxValues.height
|
||||
&& newFormat.maxInputSize <= mCodecMaxValues.inputSize;
|
||||
if (DEBUG) {
|
||||
Log.d(LOGTAG, "[canReconfigure] : " + canReconfig);
|
||||
}
|
||||
|
|
|
@ -88,12 +88,12 @@ public class GeckoMediaDrmBridgeV21 implements GeckoMediaDrm {
|
|||
return mCrypto.requiresSecureDecoderComponent(mimeType);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void assertTrue(final boolean condition) {
|
||||
if (DEBUG && !condition) {
|
||||
throw new AssertionError("Expected condition to be true");
|
||||
}
|
||||
if (DEBUG && !condition) {
|
||||
throw new AssertionError("Expected condition to be true");
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("WrongConstant")
|
||||
|
@ -672,11 +672,11 @@ public class GeckoMediaDrmBridgeV21 implements GeckoMediaDrm {
|
|||
}
|
||||
|
||||
private UUID convertKeySystemToSchemeUUID(final String keySystem) {
|
||||
if (WIDEVINE_KEY_SYSTEM.equals(keySystem)) {
|
||||
return WIDEVINE_SCHEME_UUID;
|
||||
}
|
||||
if (DEBUG) Log.d(LOGTAG, "Cannot convert unsupported key system : " + keySystem);
|
||||
return new UUID(0L, 0L);
|
||||
if (WIDEVINE_KEY_SYSTEM.equals(keySystem)) {
|
||||
return WIDEVINE_SCHEME_UUID;
|
||||
}
|
||||
if (DEBUG) Log.d(LOGTAG, "Cannot convert unsupported key system : " + keySystem);
|
||||
return new UUID(0L, 0L);
|
||||
}
|
||||
|
||||
private String getCDMUserAgent() {
|
||||
|
|
|
@ -73,7 +73,7 @@ final class JellyBeanAsyncCodec implements AsyncCodec {
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A handler to invoke AsyncCodec.Callbacks methods.
|
||||
private final class CallbackSender extends CancelableHandler {
|
||||
|
@ -84,8 +84,8 @@ final class JellyBeanAsyncCodec implements AsyncCodec {
|
|||
private Callbacks mCallbacks;
|
||||
|
||||
private CallbackSender(final Looper looper, final Callbacks callbacks) {
|
||||
super(looper);
|
||||
mCallbacks = callbacks;
|
||||
super(looper);
|
||||
mCallbacks = callbacks;
|
||||
}
|
||||
|
||||
public void notifyInputBuffer(final int index) {
|
||||
|
|
|
@ -100,8 +100,8 @@ public final class MediaDrmProxy {
|
|||
int sessionMessageType,
|
||||
byte[] request);
|
||||
|
||||
void onSessionError(byte[] sessionId,
|
||||
String message);
|
||||
void onSessionError(byte[] sessionId,
|
||||
String message);
|
||||
|
||||
// MediaDrm.KeyStatus is available in API level 23(M)
|
||||
// https://developer.android.com/reference/android/media/MediaDrm.KeyStatus.html
|
||||
|
|
|
@ -269,6 +269,6 @@ public final class Sample implements Parcelable {
|
|||
append(", pts=").append(info.presentationTimeUs).
|
||||
append(", flags=").append(Integer.toHexString(info.flags)).append(" }").
|
||||
append(" }");
|
||||
return str.toString();
|
||||
return str.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -276,7 +276,7 @@ public class SQLiteBridge {
|
|||
|
||||
public void close() {
|
||||
if (isOpen()) {
|
||||
closeDatabase(mDbPointer);
|
||||
closeDatabase(mDbPointer);
|
||||
}
|
||||
mDbPointer = 0L;
|
||||
}
|
||||
|
@ -308,11 +308,11 @@ public class SQLiteBridge {
|
|||
return;
|
||||
|
||||
try {
|
||||
if (mTransactionSuccess) {
|
||||
execSQL("COMMIT TRANSACTION");
|
||||
} else {
|
||||
execSQL("ROLLBACK TRANSACTION");
|
||||
}
|
||||
if (mTransactionSuccess) {
|
||||
execSQL("COMMIT TRANSACTION");
|
||||
} else {
|
||||
execSQL("ROLLBACK TRANSACTION");
|
||||
}
|
||||
} catch (SQLiteBridgeException ex) {
|
||||
Log.e(LOGTAG, "Error ending transaction", ex);
|
||||
}
|
||||
|
|
|
@ -168,70 +168,70 @@ public final class BitmapUtils {
|
|||
}
|
||||
|
||||
public static @ColorInt int getDominantColorCustomImplementation(
|
||||
final Bitmap source, final boolean applyThreshold, final @ColorInt int defaultColor) {
|
||||
if (source == null) {
|
||||
return defaultColor;
|
||||
}
|
||||
|
||||
// Keep track of how many times a hue in a given bin appears in the image.
|
||||
// Hue values range [0 .. 360), so dividing by 10, we get 36 bins.
|
||||
int[] colorBins = new int[36];
|
||||
|
||||
// The bin with the most colors. Initialize to -1 to prevent accidentally
|
||||
// thinking the first bin holds the dominant color.
|
||||
int maxBin = -1;
|
||||
|
||||
// Keep track of sum hue/saturation/value per hue bin, which we'll use to
|
||||
// compute an average to for the dominant color.
|
||||
float[] sumHue = new float[36];
|
||||
float[] sumSat = new float[36];
|
||||
float[] sumVal = new float[36];
|
||||
float[] hsv = new float[3];
|
||||
|
||||
int height = source.getHeight();
|
||||
int width = source.getWidth();
|
||||
int[] pixels = new int[width * height];
|
||||
source.getPixels(pixels, 0, width, 0, 0, width, height);
|
||||
for (int row = 0; row < height; row++) {
|
||||
for (int col = 0; col < width; col++) {
|
||||
int c = pixels[col + row * width];
|
||||
// Ignore pixels with a certain transparency.
|
||||
if (Color.alpha(c) < 128)
|
||||
continue;
|
||||
|
||||
Color.colorToHSV(c, hsv);
|
||||
|
||||
// If a threshold is applied, ignore arbitrarily chosen values for "white" and "black".
|
||||
if (applyThreshold && (hsv[1] <= 0.35f || hsv[2] <= 0.35f))
|
||||
continue;
|
||||
|
||||
// We compute the dominant color by putting colors in bins based on their hue.
|
||||
int bin = (int) Math.floor(hsv[0] / 10.0f);
|
||||
|
||||
// Update the sum hue/saturation/value for this bin.
|
||||
sumHue[bin] = sumHue[bin] + hsv[0];
|
||||
sumSat[bin] = sumSat[bin] + hsv[1];
|
||||
sumVal[bin] = sumVal[bin] + hsv[2];
|
||||
|
||||
// Increment the number of colors in this bin.
|
||||
colorBins[bin]++;
|
||||
|
||||
// Keep track of the bin that holds the most colors.
|
||||
if (maxBin < 0 || colorBins[bin] > colorBins[maxBin])
|
||||
maxBin = bin;
|
||||
final Bitmap source, final boolean applyThreshold, final @ColorInt int defaultColor) {
|
||||
if (source == null) {
|
||||
return defaultColor;
|
||||
}
|
||||
}
|
||||
|
||||
// maxBin may never get updated if the image holds only transparent and/or black/white pixels.
|
||||
if (maxBin < 0) {
|
||||
return defaultColor;
|
||||
}
|
||||
// Keep track of how many times a hue in a given bin appears in the image.
|
||||
// Hue values range [0 .. 360), so dividing by 10, we get 36 bins.
|
||||
int[] colorBins = new int[36];
|
||||
|
||||
// Return a color with the average hue/saturation/value of the bin with the most colors.
|
||||
hsv[0] = sumHue[maxBin] / colorBins[maxBin];
|
||||
hsv[1] = sumSat[maxBin] / colorBins[maxBin];
|
||||
hsv[2] = sumVal[maxBin] / colorBins[maxBin];
|
||||
return Color.HSVToColor(hsv);
|
||||
// The bin with the most colors. Initialize to -1 to prevent accidentally
|
||||
// thinking the first bin holds the dominant color.
|
||||
int maxBin = -1;
|
||||
|
||||
// Keep track of sum hue/saturation/value per hue bin, which we'll use to
|
||||
// compute an average to for the dominant color.
|
||||
float[] sumHue = new float[36];
|
||||
float[] sumSat = new float[36];
|
||||
float[] sumVal = new float[36];
|
||||
float[] hsv = new float[3];
|
||||
|
||||
int height = source.getHeight();
|
||||
int width = source.getWidth();
|
||||
int[] pixels = new int[width * height];
|
||||
source.getPixels(pixels, 0, width, 0, 0, width, height);
|
||||
for (int row = 0; row < height; row++) {
|
||||
for (int col = 0; col < width; col++) {
|
||||
int c = pixels[col + row * width];
|
||||
// Ignore pixels with a certain transparency.
|
||||
if (Color.alpha(c) < 128)
|
||||
continue;
|
||||
|
||||
Color.colorToHSV(c, hsv);
|
||||
|
||||
// If a threshold is applied, ignore arbitrarily chosen values for "white" and "black".
|
||||
if (applyThreshold && (hsv[1] <= 0.35f || hsv[2] <= 0.35f))
|
||||
continue;
|
||||
|
||||
// We compute the dominant color by putting colors in bins based on their hue.
|
||||
int bin = (int) Math.floor(hsv[0] / 10.0f);
|
||||
|
||||
// Update the sum hue/saturation/value for this bin.
|
||||
sumHue[bin] = sumHue[bin] + hsv[0];
|
||||
sumSat[bin] = sumSat[bin] + hsv[1];
|
||||
sumVal[bin] = sumVal[bin] + hsv[2];
|
||||
|
||||
// Increment the number of colors in this bin.
|
||||
colorBins[bin]++;
|
||||
|
||||
// Keep track of the bin that holds the most colors.
|
||||
if (maxBin < 0 || colorBins[bin] > colorBins[maxBin])
|
||||
maxBin = bin;
|
||||
}
|
||||
}
|
||||
|
||||
// maxBin may never get updated if the image holds only transparent and/or black/white pixels.
|
||||
if (maxBin < 0) {
|
||||
return defaultColor;
|
||||
}
|
||||
|
||||
// Return a color with the average hue/saturation/value of the bin with the most colors.
|
||||
hsv[0] = sumHue[maxBin] / colorBins[maxBin];
|
||||
hsv[1] = sumSat[maxBin] / colorBins[maxBin];
|
||||
hsv[2] = sumVal[maxBin] / colorBins[maxBin];
|
||||
return Color.HSVToColor(hsv);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -133,9 +133,9 @@ public class ContentUriUtils {
|
|||
}
|
||||
|
||||
if (!TextUtils.isEmpty(fileName) && success) {
|
||||
File copyFile = new File(folder.getPath(), fileName);
|
||||
FileUtils.copy(context, contentUri, copyFile);
|
||||
return copyFile.getAbsolutePath();
|
||||
File copyFile = new File(folder.getPath(), fileName);
|
||||
FileUtils.copy(context, contentUri, copyFile);
|
||||
return copyFile.getAbsolutePath();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ public class ContentUriUtils {
|
|||
final String selection, final String[] selectionArgs) {
|
||||
final String column = "_data";
|
||||
final String[] projection = {
|
||||
column
|
||||
column
|
||||
};
|
||||
|
||||
try (Cursor cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs,
|
||||
|
|
|
@ -79,13 +79,13 @@ public class FileUtils {
|
|||
String[] files = null;
|
||||
|
||||
if (filter != null) {
|
||||
files = dir.list(filter);
|
||||
files = dir.list(filter);
|
||||
} else {
|
||||
files = dir.list();
|
||||
files = dir.list();
|
||||
}
|
||||
|
||||
if (files == null) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
for (String file : files) {
|
||||
|
|
|
@ -392,20 +392,20 @@ public final class GeckoBundle implements Parcelable {
|
|||
}
|
||||
|
||||
private void put(final String key, final Object value) {
|
||||
// We intentionally disallow a generic put() method for type safety and sanity. For
|
||||
// example, we assume elsewhere in the code that a value belongs to a small list of
|
||||
// predefined types, and cannot be any arbitrary object. If you want to put an
|
||||
// Object in the bundle, check the type of the Object first and call the
|
||||
// corresponding put methods. For example,
|
||||
//
|
||||
// if (obj instanceof Integer) {
|
||||
// bundle.putInt(key, (Integer) key);
|
||||
// } else if (obj instanceof String) {
|
||||
// bundle.putString(key, (String) obj);
|
||||
// } else {
|
||||
// throw new IllegalArgumentException("unexpected type");
|
||||
// }
|
||||
throw new UnsupportedOperationException();
|
||||
// We intentionally disallow a generic put() method for type safety and sanity. For
|
||||
// example, we assume elsewhere in the code that a value belongs to a small list of
|
||||
// predefined types, and cannot be any arbitrary object. If you want to put an
|
||||
// Object in the bundle, check the type of the Object first and call the
|
||||
// corresponding put methods. For example,
|
||||
//
|
||||
// if (obj instanceof Integer) {
|
||||
// bundle.putInt(key, (Integer) key);
|
||||
// } else if (obj instanceof String) {
|
||||
// bundle.putString(key, (String) obj);
|
||||
// } else {
|
||||
// throw new IllegalArgumentException("unexpected type");
|
||||
// }
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,221 +18,222 @@ import android.util.Log;
|
|||
import java.util.Locale;
|
||||
|
||||
public final class HardwareCodecCapabilityUtils {
|
||||
private static final String LOGTAG = "GeckoHardwareCodecCapabilityUtils";
|
||||
private static final String LOGTAG = "GeckoHardwareCodecCapabilityUtils";
|
||||
|
||||
// List of supported HW VP8 encoders.
|
||||
private static final String[] supportedVp8HwEncCodecPrefixes =
|
||||
{"OMX.qcom.", "OMX.Intel." };
|
||||
// List of supported HW VP8 decoders.
|
||||
private static final String[] supportedVp8HwDecCodecPrefixes =
|
||||
{"OMX.qcom.", "OMX.Nvidia.", "OMX.Exynos.", "OMX.Intel." };
|
||||
private static final String VP8_MIME_TYPE = "video/x-vnd.on2.vp8";
|
||||
private static final String VP9_MIME_TYPE = "video/x-vnd.on2.vp9";
|
||||
// NV12 color format supported by QCOM codec, but not declared in MediaCodec -
|
||||
// see /hardware/qcom/media/mm-core/inc/OMX_QCOMExtns.h
|
||||
private static final int
|
||||
COLOR_QCOM_FORMATYUV420PackedSemiPlanar32m = 0x7FA30C04;
|
||||
// Allowable color formats supported by codec - in order of preference.
|
||||
private static final int[] supportedColorList = {
|
||||
CodecCapabilities.COLOR_FormatYUV420Planar,
|
||||
CodecCapabilities.COLOR_FormatYUV420SemiPlanar,
|
||||
CodecCapabilities.COLOR_QCOM_FormatYUV420SemiPlanar,
|
||||
COLOR_QCOM_FORMATYUV420PackedSemiPlanar32m
|
||||
};
|
||||
private static final String[] adaptivePlaybackBlacklist =
|
||||
{
|
||||
"GT-I9300", // S3 (I9300 / I9300I)
|
||||
"SCH-I535", // S3
|
||||
"SGH-T999", // S3 (T-Mobile)
|
||||
"SAMSUNG-SGH-T999", // S3 (T-Mobile)
|
||||
"SGH-M919", // S4
|
||||
"GT-I9505", // S4
|
||||
"GT-I9515", // S4
|
||||
"SCH-R970", // S4
|
||||
"SGH-I337", // S4
|
||||
"SPH-L720", // S4 (Sprint)
|
||||
"SAMSUNG-SGH-I337", // S4
|
||||
"GT-I9195", // S4 Mini
|
||||
"300E5EV/300E4EV/270E5EV/270E4EV/2470EV/2470EE",
|
||||
"LG-D605" // LG Optimus L9 II
|
||||
};
|
||||
// List of supported HW VP8 encoders.
|
||||
private static final String[] supportedVp8HwEncCodecPrefixes = {
|
||||
"OMX.qcom.", "OMX.Intel."
|
||||
};
|
||||
// List of supported HW VP8 decoders.
|
||||
private static final String[] supportedVp8HwDecCodecPrefixes = {
|
||||
"OMX.qcom.", "OMX.Nvidia.", "OMX.Exynos.", "OMX.Intel."
|
||||
};
|
||||
private static final String VP8_MIME_TYPE = "video/x-vnd.on2.vp8";
|
||||
private static final String VP9_MIME_TYPE = "video/x-vnd.on2.vp9";
|
||||
// NV12 color format supported by QCOM codec, but not declared in MediaCodec -
|
||||
// see /hardware/qcom/media/mm-core/inc/OMX_QCOMExtns.h
|
||||
private static final int
|
||||
COLOR_QCOM_FORMATYUV420PackedSemiPlanar32m = 0x7FA30C04;
|
||||
// Allowable color formats supported by codec - in order of preference.
|
||||
private static final int[] supportedColorList = {
|
||||
CodecCapabilities.COLOR_FormatYUV420Planar,
|
||||
CodecCapabilities.COLOR_FormatYUV420SemiPlanar,
|
||||
CodecCapabilities.COLOR_QCOM_FormatYUV420SemiPlanar,
|
||||
COLOR_QCOM_FORMATYUV420PackedSemiPlanar32m
|
||||
};
|
||||
private static final String[] adaptivePlaybackBlacklist = {
|
||||
"GT-I9300", // S3 (I9300 / I9300I)
|
||||
"SCH-I535", // S3
|
||||
"SGH-T999", // S3 (T-Mobile)
|
||||
"SAMSUNG-SGH-T999", // S3 (T-Mobile)
|
||||
"SGH-M919", // S4
|
||||
"GT-I9505", // S4
|
||||
"GT-I9515", // S4
|
||||
"SCH-R970", // S4
|
||||
"SGH-I337", // S4
|
||||
"SPH-L720", // S4 (Sprint)
|
||||
"SAMSUNG-SGH-I337", // S4
|
||||
"GT-I9195", // S4 Mini
|
||||
"300E5EV/300E4EV/270E5EV/270E4EV/2470EV/2470EE",
|
||||
"LG-D605" // LG Optimus L9 II
|
||||
};
|
||||
|
||||
@WrapForJNI
|
||||
public static boolean findDecoderCodecInfoForMimeType(final String aMimeType) {
|
||||
int numCodecs = 0;
|
||||
try {
|
||||
numCodecs = MediaCodecList.getCodecCount();
|
||||
} catch (final RuntimeException e) {
|
||||
Log.e(LOGTAG, "Failed to retrieve media codec count", e);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < numCodecs; ++i) {
|
||||
MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i);
|
||||
if (info.isEncoder()) {
|
||||
continue;
|
||||
}
|
||||
for (String mimeType : info.getSupportedTypes()) {
|
||||
if (mimeType.equals(aMimeType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@WrapForJNI
|
||||
public static boolean checkSupportsAdaptivePlayback(final MediaCodec aCodec,
|
||||
final String aMimeType) {
|
||||
// isFeatureSupported supported on API level >= 19.
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT ||
|
||||
isAdaptivePlaybackBlacklisted(aMimeType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
MediaCodecInfo info = aCodec.getCodecInfo();
|
||||
MediaCodecInfo.CodecCapabilities capabilities = info.getCapabilitiesForType(aMimeType);
|
||||
return capabilities != null &&
|
||||
capabilities.isFeatureSupported(
|
||||
MediaCodecInfo.CodecCapabilities.FEATURE_AdaptivePlayback);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.e(LOGTAG, "Retrieve codec information failed", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// See Bug1360626 and
|
||||
// https://codereview.chromium.org/1869103002 for details.
|
||||
private static boolean isAdaptivePlaybackBlacklisted(final String aMimeType) {
|
||||
Log.d(LOGTAG, "The device ModelID is " + Build.MODEL);
|
||||
if (!aMimeType.equals("video/avc") && !aMimeType.equals("video/avc1")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Build.MANUFACTURER.toLowerCase(Locale.getDefault()).equals("samsung")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (String model : adaptivePlaybackBlacklist) {
|
||||
if (Build.MODEL.startsWith(model)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean getHWEncoderCapability() {
|
||||
if (Build.VERSION.SDK_INT >= 20) {
|
||||
for (int i = 0; i < MediaCodecList.getCodecCount(); ++i) {
|
||||
MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i);
|
||||
if (!info.isEncoder()) {
|
||||
continue;
|
||||
}
|
||||
String name = null;
|
||||
for (String mimeType : info.getSupportedTypes()) {
|
||||
if (mimeType.equals(VP8_MIME_TYPE)) {
|
||||
name = info.getName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (name == null) {
|
||||
continue; // No HW support in this codec; try the next one.
|
||||
}
|
||||
Log.e(LOGTAG, "Found candidate encoder " + name);
|
||||
|
||||
// Check if this is supported encoder.
|
||||
boolean supportedCodec = false;
|
||||
for (String codecPrefix : supportedVp8HwEncCodecPrefixes) {
|
||||
if (name.startsWith(codecPrefix)) {
|
||||
supportedCodec = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!supportedCodec) {
|
||||
continue;
|
||||
@WrapForJNI
|
||||
public static boolean findDecoderCodecInfoForMimeType(final String aMimeType) {
|
||||
int numCodecs = 0;
|
||||
try {
|
||||
numCodecs = MediaCodecList.getCodecCount();
|
||||
} catch (final RuntimeException e) {
|
||||
Log.e(LOGTAG, "Failed to retrieve media codec count", e);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if codec supports either yuv420 or nv12.
|
||||
CodecCapabilities capabilities =
|
||||
info.getCapabilitiesForType(VP8_MIME_TYPE);
|
||||
for (int colorFormat : capabilities.colorFormats) {
|
||||
Log.v(LOGTAG, " Color: 0x" + Integer.toHexString(colorFormat));
|
||||
}
|
||||
for (int supportedColorFormat : supportedColorList) {
|
||||
for (int codecColorFormat : capabilities.colorFormats) {
|
||||
if (codecColorFormat == supportedColorFormat) {
|
||||
// Found supported HW Encoder.
|
||||
Log.e(LOGTAG, "Found target encoder " + name +
|
||||
". Color: 0x" + Integer.toHexString(codecColorFormat));
|
||||
return true;
|
||||
for (int i = 0; i < numCodecs; ++i) {
|
||||
MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i);
|
||||
if (info.isEncoder()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// No HW encoder.
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean getHWDecoderCapability() {
|
||||
return getHWDecoderCapability(VP8_MIME_TYPE);
|
||||
}
|
||||
|
||||
@WrapForJNI
|
||||
public static boolean HasHWVP9() {
|
||||
return getHWDecoderCapability(VP9_MIME_TYPE);
|
||||
}
|
||||
|
||||
public static boolean getHWDecoderCapability(final String aMimeType) {
|
||||
if (Build.VERSION.SDK_INT >= 20) {
|
||||
for (int i = 0; i < MediaCodecList.getCodecCount(); ++i) {
|
||||
MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i);
|
||||
if (info.isEncoder()) {
|
||||
continue;
|
||||
}
|
||||
String name = null;
|
||||
for (String mimeType : info.getSupportedTypes()) {
|
||||
if (mimeType.equals(aMimeType)) {
|
||||
name = info.getName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (name == null) {
|
||||
continue; // No HW support in this codec; try the next one.
|
||||
}
|
||||
Log.e(LOGTAG, "Found candidate decoder " + name);
|
||||
|
||||
// Check if this is supported decoder.
|
||||
boolean supportedCodec = false;
|
||||
for (String codecPrefix : supportedVp8HwDecCodecPrefixes) {
|
||||
if (name.startsWith(codecPrefix)) {
|
||||
supportedCodec = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!supportedCodec) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if codec supports either yuv420 or nv12.
|
||||
CodecCapabilities capabilities =
|
||||
info.getCapabilitiesForType(aMimeType);
|
||||
for (int colorFormat : capabilities.colorFormats) {
|
||||
Log.v(LOGTAG, " Color: 0x" + Integer.toHexString(colorFormat));
|
||||
}
|
||||
for (int supportedColorFormat : supportedColorList) {
|
||||
for (int codecColorFormat : capabilities.colorFormats) {
|
||||
if (codecColorFormat == supportedColorFormat) {
|
||||
// Found supported HW decoder.
|
||||
Log.e(LOGTAG, "Found target decoder " + name +
|
||||
". Color: 0x" + Integer.toHexString(codecColorFormat));
|
||||
return true;
|
||||
for (String mimeType : info.getSupportedTypes()) {
|
||||
if (mimeType.equals(aMimeType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@WrapForJNI
|
||||
public static boolean checkSupportsAdaptivePlayback(final MediaCodec aCodec,
|
||||
final String aMimeType) {
|
||||
// isFeatureSupported supported on API level >= 19.
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT ||
|
||||
isAdaptivePlaybackBlacklisted(aMimeType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
MediaCodecInfo info = aCodec.getCodecInfo();
|
||||
MediaCodecInfo.CodecCapabilities capabilities = info.getCapabilitiesForType(aMimeType);
|
||||
return capabilities != null &&
|
||||
capabilities.isFeatureSupported(
|
||||
MediaCodecInfo.CodecCapabilities.FEATURE_AdaptivePlayback);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.e(LOGTAG, "Retrieve codec information failed", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// See Bug1360626 and
|
||||
// https://codereview.chromium.org/1869103002 for details.
|
||||
private static boolean isAdaptivePlaybackBlacklisted(final String aMimeType) {
|
||||
Log.d(LOGTAG, "The device ModelID is " + Build.MODEL);
|
||||
if (!aMimeType.equals("video/avc") && !aMimeType.equals("video/avc1")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Build.MANUFACTURER.toLowerCase(Locale.getDefault()).equals("samsung")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (String model : adaptivePlaybackBlacklist) {
|
||||
if (Build.MODEL.startsWith(model)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean getHWEncoderCapability() {
|
||||
if (Build.VERSION.SDK_INT >= 20) {
|
||||
for (int i = 0; i < MediaCodecList.getCodecCount(); ++i) {
|
||||
MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i);
|
||||
if (!info.isEncoder()) {
|
||||
continue;
|
||||
}
|
||||
String name = null;
|
||||
for (String mimeType : info.getSupportedTypes()) {
|
||||
if (mimeType.equals(VP8_MIME_TYPE)) {
|
||||
name = info.getName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (name == null) {
|
||||
continue; // No HW support in this codec; try the next one.
|
||||
}
|
||||
Log.e(LOGTAG, "Found candidate encoder " + name);
|
||||
|
||||
// Check if this is supported encoder.
|
||||
boolean supportedCodec = false;
|
||||
for (String codecPrefix : supportedVp8HwEncCodecPrefixes) {
|
||||
if (name.startsWith(codecPrefix)) {
|
||||
supportedCodec = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!supportedCodec) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if codec supports either yuv420 or nv12.
|
||||
CodecCapabilities capabilities =
|
||||
info.getCapabilitiesForType(VP8_MIME_TYPE);
|
||||
for (int colorFormat : capabilities.colorFormats) {
|
||||
Log.v(LOGTAG, " Color: 0x" + Integer.toHexString(colorFormat));
|
||||
}
|
||||
for (int supportedColorFormat : supportedColorList) {
|
||||
for (int codecColorFormat : capabilities.colorFormats) {
|
||||
if (codecColorFormat == supportedColorFormat) {
|
||||
// Found supported HW Encoder.
|
||||
Log.e(LOGTAG, "Found target encoder " + name +
|
||||
". Color: 0x" + Integer.toHexString(codecColorFormat));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// No HW encoder.
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean getHWDecoderCapability() {
|
||||
return getHWDecoderCapability(VP8_MIME_TYPE);
|
||||
}
|
||||
|
||||
@WrapForJNI
|
||||
public static boolean HasHWVP9() {
|
||||
return getHWDecoderCapability(VP9_MIME_TYPE);
|
||||
}
|
||||
|
||||
public static boolean getHWDecoderCapability(final String aMimeType) {
|
||||
if (Build.VERSION.SDK_INT >= 20) {
|
||||
for (int i = 0; i < MediaCodecList.getCodecCount(); ++i) {
|
||||
MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i);
|
||||
if (info.isEncoder()) {
|
||||
continue;
|
||||
}
|
||||
String name = null;
|
||||
for (String mimeType : info.getSupportedTypes()) {
|
||||
if (mimeType.equals(aMimeType)) {
|
||||
name = info.getName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (name == null) {
|
||||
continue; // No HW support in this codec; try the next one.
|
||||
}
|
||||
Log.e(LOGTAG, "Found candidate decoder " + name);
|
||||
|
||||
// Check if this is supported decoder.
|
||||
boolean supportedCodec = false;
|
||||
for (String codecPrefix : supportedVp8HwDecCodecPrefixes) {
|
||||
if (name.startsWith(codecPrefix)) {
|
||||
supportedCodec = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!supportedCodec) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if codec supports either yuv420 or nv12.
|
||||
CodecCapabilities capabilities =
|
||||
info.getCapabilitiesForType(aMimeType);
|
||||
for (int colorFormat : capabilities.colorFormats) {
|
||||
Log.v(LOGTAG, " Color: 0x" + Integer.toHexString(colorFormat));
|
||||
}
|
||||
for (int supportedColorFormat : supportedColorList) {
|
||||
for (int codecColorFormat : capabilities.colorFormats) {
|
||||
if (codecColorFormat == supportedColorFormat) {
|
||||
// Found supported HW decoder.
|
||||
Log.e(LOGTAG, "Found target decoder " + name +
|
||||
". Color: 0x" + Integer.toHexString(codecColorFormat));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false; // No HW decoder.
|
||||
}
|
||||
return false; // No HW decoder.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public class INISection {
|
|||
public String getStringProperty(final String key) {
|
||||
Object val = getProperty(key);
|
||||
if (val == null)
|
||||
return null;
|
||||
return null;
|
||||
|
||||
return val.toString();
|
||||
}
|
||||
|
|
|
@ -138,14 +138,14 @@ public class ProxySelector {
|
|||
for (int i = 0; i < nonProxyHosts.length(); i++) {
|
||||
char c = nonProxyHosts.charAt(i);
|
||||
switch (c) {
|
||||
case '.':
|
||||
patternBuilder.append("\\.");
|
||||
break;
|
||||
case '*':
|
||||
patternBuilder.append(".*");
|
||||
break;
|
||||
default:
|
||||
patternBuilder.append(c);
|
||||
case '.':
|
||||
patternBuilder.append("\\.");
|
||||
break;
|
||||
case '*':
|
||||
patternBuilder.append(".*");
|
||||
break;
|
||||
default:
|
||||
patternBuilder.append(c);
|
||||
}
|
||||
}
|
||||
// check whether the host is the nonProxyHosts.
|
||||
|
|
|
@ -185,10 +185,10 @@ public final class ThreadUtils {
|
|||
final IllegalThreadStateException e = new IllegalThreadStateException(message);
|
||||
|
||||
switch (behavior) {
|
||||
case THROW:
|
||||
throw e;
|
||||
default:
|
||||
Log.e(LOGTAG, "Method called on wrong thread!", e);
|
||||
case THROW:
|
||||
throw e;
|
||||
default:
|
||||
Log.e(LOGTAG, "Method called on wrong thread!", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -544,60 +544,60 @@ import android.view.inputmethod.EditorInfo;
|
|||
|
||||
private void icPerformAction(final Action action) throws RemoteException {
|
||||
switch (action.mType) {
|
||||
case Action.TYPE_EVENT:
|
||||
case Action.TYPE_SET_HANDLER:
|
||||
mFocusedChild.onImeSynchronize();
|
||||
break;
|
||||
case Action.TYPE_EVENT:
|
||||
case Action.TYPE_SET_HANDLER:
|
||||
mFocusedChild.onImeSynchronize();
|
||||
break;
|
||||
|
||||
case Action.TYPE_SET_SPAN: {
|
||||
final boolean needUpdate = (action.mSpanFlags & Spanned.SPAN_INTERMEDIATE) == 0 &&
|
||||
((action.mSpanFlags & Spanned.SPAN_COMPOSING) != 0 ||
|
||||
action.mSpanObject == Selection.SELECTION_START ||
|
||||
action.mSpanObject == Selection.SELECTION_END);
|
||||
case Action.TYPE_SET_SPAN: {
|
||||
final boolean needUpdate = (action.mSpanFlags & Spanned.SPAN_INTERMEDIATE) == 0 &&
|
||||
((action.mSpanFlags & Spanned.SPAN_COMPOSING) != 0 ||
|
||||
action.mSpanObject == Selection.SELECTION_START ||
|
||||
action.mSpanObject == Selection.SELECTION_END);
|
||||
|
||||
action.mSequence = TextUtils.substring(
|
||||
mText.getShadowText(), action.mStart, action.mEnd);
|
||||
action.mSequence = TextUtils.substring(
|
||||
mText.getShadowText(), action.mStart, action.mEnd);
|
||||
|
||||
mNeedUpdateComposition |= needUpdate;
|
||||
if (needUpdate) {
|
||||
icMaybeSendComposition(mText.getShadowText(), SEND_COMPOSITION_NOTIFY_GECKO |
|
||||
SEND_COMPOSITION_KEEP_CURRENT);
|
||||
mNeedUpdateComposition |= needUpdate;
|
||||
if (needUpdate) {
|
||||
icMaybeSendComposition(mText.getShadowText(), SEND_COMPOSITION_NOTIFY_GECKO |
|
||||
SEND_COMPOSITION_KEEP_CURRENT);
|
||||
}
|
||||
|
||||
mFocusedChild.onImeSynchronize();
|
||||
break;
|
||||
}
|
||||
case Action.TYPE_REMOVE_SPAN: {
|
||||
final boolean needUpdate = (action.mSpanFlags & Spanned.SPAN_INTERMEDIATE) == 0 &&
|
||||
(action.mSpanFlags & Spanned.SPAN_COMPOSING) != 0;
|
||||
|
||||
mFocusedChild.onImeSynchronize();
|
||||
break;
|
||||
}
|
||||
case Action.TYPE_REMOVE_SPAN: {
|
||||
final boolean needUpdate = (action.mSpanFlags & Spanned.SPAN_INTERMEDIATE) == 0 &&
|
||||
(action.mSpanFlags & Spanned.SPAN_COMPOSING) != 0;
|
||||
mNeedUpdateComposition |= needUpdate;
|
||||
if (needUpdate) {
|
||||
icMaybeSendComposition(mText.getShadowText(), SEND_COMPOSITION_NOTIFY_GECKO |
|
||||
SEND_COMPOSITION_KEEP_CURRENT);
|
||||
}
|
||||
|
||||
mNeedUpdateComposition |= needUpdate;
|
||||
if (needUpdate) {
|
||||
icMaybeSendComposition(mText.getShadowText(), SEND_COMPOSITION_NOTIFY_GECKO |
|
||||
SEND_COMPOSITION_KEEP_CURRENT);
|
||||
mFocusedChild.onImeSynchronize();
|
||||
break;
|
||||
}
|
||||
case Action.TYPE_REPLACE_TEXT:
|
||||
// Always sync text after a replace action, so that if the Gecko
|
||||
// text is not changed, we will revert the shadow text to before.
|
||||
mNeedSync = true;
|
||||
|
||||
mFocusedChild.onImeSynchronize();
|
||||
break;
|
||||
}
|
||||
case Action.TYPE_REPLACE_TEXT:
|
||||
// Always sync text after a replace action, so that if the Gecko
|
||||
// text is not changed, we will revert the shadow text to before.
|
||||
mNeedSync = true;
|
||||
// Because we get composition styling here essentially for free,
|
||||
// we don't need to check if we're in batch mode.
|
||||
if (!icMaybeSendComposition(
|
||||
action.mSequence, SEND_COMPOSITION_USE_ENTIRE_TEXT)) {
|
||||
// Since we don't have a composition, we can try sending key events.
|
||||
sendCharKeyEvents(action);
|
||||
}
|
||||
mFocusedChild.onImeReplaceText(
|
||||
action.mStart, action.mEnd, action.mSequence.toString());
|
||||
break;
|
||||
|
||||
// Because we get composition styling here essentially for free,
|
||||
// we don't need to check if we're in batch mode.
|
||||
if (!icMaybeSendComposition(
|
||||
action.mSequence, SEND_COMPOSITION_USE_ENTIRE_TEXT)) {
|
||||
// Since we don't have a composition, we can try sending key events.
|
||||
sendCharKeyEvents(action);
|
||||
}
|
||||
mFocusedChild.onImeReplaceText(
|
||||
action.mStart, action.mEnd, action.mSequence.toString());
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new IllegalStateException("Action not processed");
|
||||
default:
|
||||
throw new IllegalStateException("Action not processed");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1137,79 +1137,79 @@ import android.view.inputmethod.EditorInfo;
|
|||
getConstantName(Action.class, "TYPE_", action.mType) + ")");
|
||||
}
|
||||
switch (action.mType) {
|
||||
case Action.TYPE_REPLACE_TEXT: {
|
||||
final Spanned currentText = mText.getCurrentText();
|
||||
final int actionNewEnd = action.mStart + action.mSequence.length();
|
||||
if (mLastTextChangeStart > mLastTextChangeNewEnd ||
|
||||
mLastTextChangeNewEnd > currentText.length() ||
|
||||
action.mStart < mLastTextChangeStart || actionNewEnd > mLastTextChangeNewEnd) {
|
||||
// Replace-text action doesn't match our text change.
|
||||
break;
|
||||
}
|
||||
|
||||
int indexInText = TextUtils.indexOf(currentText, action.mSequence,
|
||||
action.mStart, mLastTextChangeNewEnd);
|
||||
if (indexInText < 0 && action.mStart != mLastTextChangeStart) {
|
||||
final String changedText = TextUtils.substring(
|
||||
currentText, mLastTextChangeStart, actionNewEnd);
|
||||
indexInText = changedText.lastIndexOf(action.mSequence.toString());
|
||||
if (indexInText >= 0) {
|
||||
indexInText += mLastTextChangeStart;
|
||||
case Action.TYPE_REPLACE_TEXT: {
|
||||
final Spanned currentText = mText.getCurrentText();
|
||||
final int actionNewEnd = action.mStart + action.mSequence.length();
|
||||
if (mLastTextChangeStart > mLastTextChangeNewEnd ||
|
||||
mLastTextChangeNewEnd > currentText.length() ||
|
||||
action.mStart < mLastTextChangeStart || actionNewEnd > mLastTextChangeNewEnd) {
|
||||
// Replace-text action doesn't match our text change.
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (indexInText < 0) {
|
||||
// Replace-text action doesn't match our current text.
|
||||
break;
|
||||
}
|
||||
|
||||
final int selStart = Selection.getSelectionStart(currentText);
|
||||
final int selEnd = Selection.getSelectionEnd(currentText);
|
||||
|
||||
// Replace-text action matches our current text; copy the new spans to the
|
||||
// current text.
|
||||
mText.currentReplace(indexInText,
|
||||
indexInText + action.mSequence.length(),
|
||||
action.mSequence);
|
||||
// Make sure selection is preserved.
|
||||
mText.currentSetSelection(selStart, selEnd);
|
||||
|
||||
// The text change is caused by the replace-text event. If the text change
|
||||
// replaced the previous selection, we need to rely on Gecko for an updated
|
||||
// selection, so don't ignore selection change. However, if the text change
|
||||
// did not replace the previous selection, we can ignore the Gecko selection
|
||||
// in favor of the Java selection.
|
||||
mIgnoreSelectionChange = !mLastTextChangeReplacedSelection;
|
||||
break;
|
||||
}
|
||||
|
||||
case Action.TYPE_SET_SPAN:
|
||||
final int len = mText.getCurrentText().length();
|
||||
if (action.mStart > len || action.mEnd > len ||
|
||||
!TextUtils.substring(mText.getCurrentText(), action.mStart,
|
||||
action.mEnd).equals(action.mSequence)) {
|
||||
if (DEBUG) {
|
||||
Log.d(LOGTAG, "discarding stale set span call");
|
||||
int indexInText = TextUtils.indexOf(currentText, action.mSequence,
|
||||
action.mStart, mLastTextChangeNewEnd);
|
||||
if (indexInText < 0 && action.mStart != mLastTextChangeStart) {
|
||||
final String changedText = TextUtils.substring(
|
||||
currentText, mLastTextChangeStart, actionNewEnd);
|
||||
indexInText = changedText.lastIndexOf(action.mSequence.toString());
|
||||
if (indexInText >= 0) {
|
||||
indexInText += mLastTextChangeStart;
|
||||
}
|
||||
}
|
||||
if (indexInText < 0) {
|
||||
// Replace-text action doesn't match our current text.
|
||||
break;
|
||||
}
|
||||
|
||||
final int selStart = Selection.getSelectionStart(currentText);
|
||||
final int selEnd = Selection.getSelectionEnd(currentText);
|
||||
|
||||
// Replace-text action matches our current text; copy the new spans to the
|
||||
// current text.
|
||||
mText.currentReplace(indexInText,
|
||||
indexInText + action.mSequence.length(),
|
||||
action.mSequence);
|
||||
// Make sure selection is preserved.
|
||||
mText.currentSetSelection(selStart, selEnd);
|
||||
|
||||
// The text change is caused by the replace-text event. If the text change
|
||||
// replaced the previous selection, we need to rely on Gecko for an updated
|
||||
// selection, so don't ignore selection change. However, if the text change
|
||||
// did not replace the previous selection, we can ignore the Gecko selection
|
||||
// in favor of the Java selection.
|
||||
mIgnoreSelectionChange = !mLastTextChangeReplacedSelection;
|
||||
break;
|
||||
}
|
||||
if ((action.mSpanObject == Selection.SELECTION_START ||
|
||||
action.mSpanObject == Selection.SELECTION_END) &&
|
||||
(action.mStart < mLastTextChangeStart && action.mEnd < mLastTextChangeStart ||
|
||||
action.mStart > mLastTextChangeOldEnd && action.mEnd > mLastTextChangeOldEnd)) {
|
||||
// Use the Java selection if, between text-change notification and replace-text
|
||||
// processing, we specifically set the selection to outside the replaced range.
|
||||
mLastTextChangeReplacedSelection = false;
|
||||
}
|
||||
mText.currentSetSpan(action.mSpanObject, action.mStart, action.mEnd, action.mSpanFlags);
|
||||
break;
|
||||
|
||||
case Action.TYPE_REMOVE_SPAN:
|
||||
mText.currentRemoveSpan(action.mSpanObject);
|
||||
break;
|
||||
case Action.TYPE_SET_SPAN:
|
||||
final int len = mText.getCurrentText().length();
|
||||
if (action.mStart > len || action.mEnd > len ||
|
||||
!TextUtils.substring(mText.getCurrentText(), action.mStart,
|
||||
action.mEnd).equals(action.mSequence)) {
|
||||
if (DEBUG) {
|
||||
Log.d(LOGTAG, "discarding stale set span call");
|
||||
}
|
||||
break;
|
||||
}
|
||||
if ((action.mSpanObject == Selection.SELECTION_START ||
|
||||
action.mSpanObject == Selection.SELECTION_END) &&
|
||||
(action.mStart < mLastTextChangeStart && action.mEnd < mLastTextChangeStart ||
|
||||
action.mStart > mLastTextChangeOldEnd && action.mEnd > mLastTextChangeOldEnd)) {
|
||||
// Use the Java selection if, between text-change notification and replace-text
|
||||
// processing, we specifically set the selection to outside the replaced range.
|
||||
mLastTextChangeReplacedSelection = false;
|
||||
}
|
||||
mText.currentSetSpan(action.mSpanObject, action.mStart, action.mEnd, action.mSpanFlags);
|
||||
break;
|
||||
|
||||
case Action.TYPE_SET_HANDLER:
|
||||
geckoSetIcHandler(action.mHandler);
|
||||
break;
|
||||
case Action.TYPE_REMOVE_SPAN:
|
||||
mText.currentRemoveSpan(action.mSpanObject);
|
||||
break;
|
||||
|
||||
case Action.TYPE_SET_HANDLER:
|
||||
geckoSetIcHandler(action.mHandler);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1830,12 +1830,12 @@ import android.view.inputmethod.EditorInfo;
|
|||
final String str = obj.toString();
|
||||
sb.append('"');
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
final char chr = str.charAt(i);
|
||||
if (chr >= 0x20 && chr <= 0x7e) {
|
||||
sb.append(chr);
|
||||
} else {
|
||||
sb.append(getPrintableChar(chr));
|
||||
}
|
||||
final char chr = str.charAt(i);
|
||||
if (chr >= 0x20 && chr <= 0x7e) {
|
||||
sb.append(chr);
|
||||
} else {
|
||||
sb.append(getPrintableChar(chr));
|
||||
}
|
||||
}
|
||||
sb.append('"');
|
||||
} else if (obj.getClass().isArray()) {
|
||||
|
|
|
@ -133,9 +133,9 @@ import java.lang.reflect.Proxy;
|
|||
return (SessionTextInput.InputConnectionClient) Proxy.newProxyInstance(
|
||||
GeckoInputConnection.class.getClassLoader(),
|
||||
new Class<?>[] {
|
||||
InputConnection.class,
|
||||
SessionTextInput.InputConnectionClient.class,
|
||||
SessionTextInput.EditableListener.class
|
||||
InputConnection.class,
|
||||
SessionTextInput.InputConnectionClient.class,
|
||||
SessionTextInput.EditableListener.class
|
||||
}, handler);
|
||||
}
|
||||
|
||||
|
|
|
@ -294,13 +294,12 @@ public final class GeckoRuntime implements Parcelable {
|
|||
@UiThread
|
||||
public @NonNull GeckoResult<Void> registerWebExtension(
|
||||
final @NonNull WebExtension webExtension) {
|
||||
final GeckoSession.CallbackResult<Void> result =
|
||||
new GeckoSession.CallbackResult<Void>() {
|
||||
@Override
|
||||
public void sendSuccess(final Object response) {
|
||||
complete(null);
|
||||
}
|
||||
};
|
||||
final GeckoSession.CallbackResult<Void> result = new GeckoSession.CallbackResult<Void>() {
|
||||
@Override
|
||||
public void sendSuccess(final Object response) {
|
||||
complete(null);
|
||||
}
|
||||
};
|
||||
|
||||
final GeckoBundle bundle = new GeckoBundle(1);
|
||||
bundle.putString("locationUri", webExtension.location.toString());
|
||||
|
@ -465,8 +464,8 @@ public final class GeckoRuntime implements Parcelable {
|
|||
mSettings = source.readParcelable(getClass().getClassLoader());
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<GeckoRuntime> CREATOR
|
||||
= new Parcelable.Creator<GeckoRuntime>() {
|
||||
public static final Parcelable.Creator<GeckoRuntime> CREATOR =
|
||||
new Parcelable.Creator<GeckoRuntime>() {
|
||||
@Override
|
||||
@AnyThread
|
||||
public GeckoRuntime createFromParcel(final Parcel in) {
|
||||
|
|
|
@ -806,17 +806,17 @@ public final class GeckoRuntimeSettings extends RuntimeSettings {
|
|||
}
|
||||
|
||||
public static final Parcelable.Creator<GeckoRuntimeSettings> CREATOR
|
||||
= new Parcelable.Creator<GeckoRuntimeSettings>() {
|
||||
@Override
|
||||
public GeckoRuntimeSettings createFromParcel(final Parcel in) {
|
||||
final GeckoRuntimeSettings settings = new GeckoRuntimeSettings();
|
||||
settings.readFromParcel(in);
|
||||
return settings;
|
||||
}
|
||||
= new Parcelable.Creator<GeckoRuntimeSettings>() {
|
||||
@Override
|
||||
public GeckoRuntimeSettings createFromParcel(final Parcel in) {
|
||||
final GeckoRuntimeSettings settings = new GeckoRuntimeSettings();
|
||||
settings.readFromParcel(in);
|
||||
return settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeckoRuntimeSettings[] newArray(final int size) {
|
||||
return new GeckoRuntimeSettings[size];
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public GeckoRuntimeSettings[] newArray(final int size) {
|
||||
return new GeckoRuntimeSettings[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -747,71 +747,71 @@ public class GeckoSession implements Parcelable {
|
|||
new GeckoSessionHandler<MediaDelegate>(
|
||||
"GeckoViewMedia", this,
|
||||
new String[]{
|
||||
"GeckoView:MediaAdd",
|
||||
"GeckoView:MediaRemove",
|
||||
"GeckoView:MediaRemoveAll",
|
||||
"GeckoView:MediaReadyStateChanged",
|
||||
"GeckoView:MediaTimeChanged",
|
||||
"GeckoView:MediaPlaybackStateChanged",
|
||||
"GeckoView:MediaMetadataChanged",
|
||||
"GeckoView:MediaProgress",
|
||||
"GeckoView:MediaVolumeChanged",
|
||||
"GeckoView:MediaRateChanged",
|
||||
"GeckoView:MediaFullscreenChanged",
|
||||
"GeckoView:MediaError",
|
||||
"GeckoView:MediaAdd",
|
||||
"GeckoView:MediaRemove",
|
||||
"GeckoView:MediaRemoveAll",
|
||||
"GeckoView:MediaReadyStateChanged",
|
||||
"GeckoView:MediaTimeChanged",
|
||||
"GeckoView:MediaPlaybackStateChanged",
|
||||
"GeckoView:MediaMetadataChanged",
|
||||
"GeckoView:MediaProgress",
|
||||
"GeckoView:MediaVolumeChanged",
|
||||
"GeckoView:MediaRateChanged",
|
||||
"GeckoView:MediaFullscreenChanged",
|
||||
"GeckoView:MediaError",
|
||||
}
|
||||
) {
|
||||
@Override
|
||||
public void handleMessage(final MediaDelegate delegate,
|
||||
final String event,
|
||||
final GeckoBundle message,
|
||||
final EventCallback callback) {
|
||||
if ("GeckoView:MediaAdd".equals(event)) {
|
||||
final MediaElement element = new MediaElement(message.getLong("id"), GeckoSession.this);
|
||||
delegate.onMediaAdd(GeckoSession.this, element);
|
||||
return;
|
||||
} else if ("GeckoView:MediaRemoveAll".equals(event)) {
|
||||
for (int i = 0; i < mMediaElements.size(); i++) {
|
||||
final long key = mMediaElements.keyAt(i);
|
||||
delegate.onMediaRemove(GeckoSession.this, mMediaElements.get(key));
|
||||
}
|
||||
mMediaElements.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
final long id = message.getLong("id", 0);
|
||||
final MediaElement element = mMediaElements.get(id);
|
||||
if (element == null) {
|
||||
Log.w(LOGTAG, "MediaElement not found for '" + id + "'");
|
||||
return;
|
||||
}
|
||||
|
||||
if ("GeckoView:MediaTimeChanged".equals(event)) {
|
||||
element.notifyTimeChange(message.getDouble("time"));
|
||||
} else if ("GeckoView:MediaProgress".equals(event)) {
|
||||
element.notifyLoadProgress(message);
|
||||
} else if ("GeckoView:MediaMetadataChanged".equals(event)) {
|
||||
element.notifyMetadataChange(message);
|
||||
} else if ("GeckoView:MediaReadyStateChanged".equals(event)) {
|
||||
element.notifyReadyStateChange(message.getInt("readyState"));
|
||||
} else if ("GeckoView:MediaPlaybackStateChanged".equals(event)) {
|
||||
element.notifyPlaybackStateChange(message.getString("playbackState"));
|
||||
} else if ("GeckoView:MediaVolumeChanged".equals(event)) {
|
||||
element.notifyVolumeChange(message.getDouble("volume"), message.getBoolean("muted"));
|
||||
} else if ("GeckoView:MediaRateChanged".equals(event)) {
|
||||
element.notifyPlaybackRateChange(message.getDouble("rate"));
|
||||
} else if ("GeckoView:MediaFullscreenChanged".equals(event)) {
|
||||
element.notifyFullscreenChange(message.getBoolean("fullscreen"));
|
||||
} else if ("GeckoView:MediaRemove".equals(event)) {
|
||||
delegate.onMediaRemove(GeckoSession.this, element);
|
||||
mMediaElements.remove(element.getVideoId());
|
||||
} else if ("GeckoView:MediaError".equals(event)) {
|
||||
element.notifyError(message.getInt("code"));
|
||||
} else {
|
||||
throw new UnsupportedOperationException(event + " media message not implemented");
|
||||
}
|
||||
@Override
|
||||
public void handleMessage(final MediaDelegate delegate,
|
||||
final String event,
|
||||
final GeckoBundle message,
|
||||
final EventCallback callback) {
|
||||
if ("GeckoView:MediaAdd".equals(event)) {
|
||||
final MediaElement element = new MediaElement(message.getLong("id"), GeckoSession.this);
|
||||
delegate.onMediaAdd(GeckoSession.this, element);
|
||||
return;
|
||||
} else if ("GeckoView:MediaRemoveAll".equals(event)) {
|
||||
for (int i = 0; i < mMediaElements.size(); i++) {
|
||||
final long key = mMediaElements.keyAt(i);
|
||||
delegate.onMediaRemove(GeckoSession.this, mMediaElements.get(key));
|
||||
}
|
||||
};
|
||||
mMediaElements.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
final long id = message.getLong("id", 0);
|
||||
final MediaElement element = mMediaElements.get(id);
|
||||
if (element == null) {
|
||||
Log.w(LOGTAG, "MediaElement not found for '" + id + "'");
|
||||
return;
|
||||
}
|
||||
|
||||
if ("GeckoView:MediaTimeChanged".equals(event)) {
|
||||
element.notifyTimeChange(message.getDouble("time"));
|
||||
} else if ("GeckoView:MediaProgress".equals(event)) {
|
||||
element.notifyLoadProgress(message);
|
||||
} else if ("GeckoView:MediaMetadataChanged".equals(event)) {
|
||||
element.notifyMetadataChange(message);
|
||||
} else if ("GeckoView:MediaReadyStateChanged".equals(event)) {
|
||||
element.notifyReadyStateChange(message.getInt("readyState"));
|
||||
} else if ("GeckoView:MediaPlaybackStateChanged".equals(event)) {
|
||||
element.notifyPlaybackStateChange(message.getString("playbackState"));
|
||||
} else if ("GeckoView:MediaVolumeChanged".equals(event)) {
|
||||
element.notifyVolumeChange(message.getDouble("volume"), message.getBoolean("muted"));
|
||||
} else if ("GeckoView:MediaRateChanged".equals(event)) {
|
||||
element.notifyPlaybackRateChange(message.getDouble("rate"));
|
||||
} else if ("GeckoView:MediaFullscreenChanged".equals(event)) {
|
||||
element.notifyFullscreenChange(message.getBoolean("fullscreen"));
|
||||
} else if ("GeckoView:MediaRemove".equals(event)) {
|
||||
delegate.onMediaRemove(GeckoSession.this, element);
|
||||
mMediaElements.remove(element.getVideoId());
|
||||
} else if ("GeckoView:MediaError".equals(event)) {
|
||||
element.notifyError(message.getInt("code"));
|
||||
} else {
|
||||
throw new UnsupportedOperationException(event + " media message not implemented");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* package */ int handlersCount;
|
||||
|
|
|
@ -692,16 +692,16 @@ public final class GeckoSessionSettings implements Parcelable {
|
|||
|
||||
public static final Parcelable.Creator<GeckoSessionSettings> CREATOR
|
||||
= new Parcelable.Creator<GeckoSessionSettings>() {
|
||||
@Override
|
||||
public GeckoSessionSettings createFromParcel(final Parcel in) {
|
||||
final GeckoSessionSettings settings = new GeckoSessionSettings();
|
||||
settings.readFromParcel(in);
|
||||
return settings;
|
||||
}
|
||||
@Override
|
||||
public GeckoSessionSettings createFromParcel(final Parcel in) {
|
||||
final GeckoSessionSettings settings = new GeckoSessionSettings();
|
||||
settings.readFromParcel(in);
|
||||
return settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeckoSessionSettings[] newArray(final int size) {
|
||||
return new GeckoSessionSettings[size];
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public GeckoSessionSettings[] newArray(final int size) {
|
||||
return new GeckoSessionSettings[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public class GeckoVRManager {
|
|||
|
||||
@WrapForJNI
|
||||
private static synchronized long getExternalContext() {
|
||||
return mExternalContext;
|
||||
return mExternalContext;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,5 +37,4 @@ public class GeckoVRManager {
|
|||
public static synchronized void setExternalContext(final long externalContext) {
|
||||
mExternalContext = externalContext;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -85,22 +85,22 @@ public class SessionAccessibility {
|
|||
@WrapForJNI static final int CLASSNAME_WEBVIEW = 15;
|
||||
|
||||
private static final String[] CLASSNAMES = {
|
||||
"android.view.View",
|
||||
"android.widget.Button",
|
||||
"android.widget.CheckBox",
|
||||
"android.app.Dialog",
|
||||
"android.widget.EditText",
|
||||
"android.widget.GridView",
|
||||
"android.widget.Image",
|
||||
"android.widget.ListView",
|
||||
"android.view.MenuItem",
|
||||
"android.widget.ProgressBar",
|
||||
"android.widget.RadioButton",
|
||||
"android.widget.SeekBar",
|
||||
"android.widget.Spinner",
|
||||
"android.widget.TabWidget",
|
||||
"android.widget.ToggleButton",
|
||||
"android.webkit.WebView"
|
||||
"android.view.View",
|
||||
"android.widget.Button",
|
||||
"android.widget.CheckBox",
|
||||
"android.app.Dialog",
|
||||
"android.widget.EditText",
|
||||
"android.widget.GridView",
|
||||
"android.widget.Image",
|
||||
"android.widget.ListView",
|
||||
"android.view.MenuItem",
|
||||
"android.widget.ProgressBar",
|
||||
"android.widget.RadioButton",
|
||||
"android.widget.SeekBar",
|
||||
"android.widget.Spinner",
|
||||
"android.widget.TabWidget",
|
||||
"android.widget.ToggleButton",
|
||||
"android.webkit.WebView"
|
||||
};
|
||||
|
||||
static private String getClassName(final int index) {
|
||||
|
@ -141,10 +141,10 @@ public class SessionAccessibility {
|
|||
final GeckoBundle data;
|
||||
|
||||
switch (action) {
|
||||
case AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS:
|
||||
sendEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED, virtualViewId, CLASSNAME_UNKNOWN, null);
|
||||
return true;
|
||||
case AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS:
|
||||
case AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS:
|
||||
sendEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED, virtualViewId, CLASSNAME_UNKNOWN, null);
|
||||
return true;
|
||||
case AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS:
|
||||
if (virtualViewId == View.NO_ID) {
|
||||
sendEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED, View.NO_ID, CLASSNAME_WEBVIEW, null);
|
||||
} else {
|
||||
|
@ -154,89 +154,89 @@ public class SessionAccessibility {
|
|||
sendEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED, virtualViewId, CLASSNAME_UNKNOWN, null);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case AccessibilityNodeInfo.ACTION_CLICK:
|
||||
nativeProvider.click(virtualViewId);
|
||||
GeckoBundle nodeInfo = getMostRecentBundle(virtualViewId);
|
||||
if (nodeInfo != null) {
|
||||
if ((nodeInfo.getInt("flags") & (FLAG_SELECTABLE | FLAG_CHECKABLE)) == 0) {
|
||||
sendEvent(AccessibilityEvent.TYPE_VIEW_CLICKED, virtualViewId, nodeInfo.getInt("className"), null);
|
||||
return true;
|
||||
case AccessibilityNodeInfo.ACTION_CLICK:
|
||||
nativeProvider.click(virtualViewId);
|
||||
GeckoBundle nodeInfo = getMostRecentBundle(virtualViewId);
|
||||
if (nodeInfo != null) {
|
||||
if ((nodeInfo.getInt("flags") & (FLAG_SELECTABLE | FLAG_CHECKABLE)) == 0) {
|
||||
sendEvent(AccessibilityEvent.TYPE_VIEW_CLICKED, virtualViewId, nodeInfo.getInt("className"), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case AccessibilityNodeInfo.ACTION_LONG_CLICK:
|
||||
mSession.getEventDispatcher().dispatch("GeckoView:AccessibilityLongPress", null);
|
||||
return true;
|
||||
case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD:
|
||||
mSession.getEventDispatcher().dispatch("GeckoView:AccessibilityScrollForward", null);
|
||||
return true;
|
||||
case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD:
|
||||
mSession.getEventDispatcher().dispatch("GeckoView:AccessibilityScrollBackward", null);
|
||||
return true;
|
||||
case AccessibilityNodeInfo.ACTION_SELECT:
|
||||
nativeProvider.click(virtualViewId);
|
||||
return true;
|
||||
case AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT:
|
||||
case AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT:
|
||||
if (arguments != null) {
|
||||
return true;
|
||||
case AccessibilityNodeInfo.ACTION_LONG_CLICK:
|
||||
mSession.getEventDispatcher().dispatch("GeckoView:AccessibilityLongPress", null);
|
||||
return true;
|
||||
case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD:
|
||||
mSession.getEventDispatcher().dispatch("GeckoView:AccessibilityScrollForward", null);
|
||||
return true;
|
||||
case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD:
|
||||
mSession.getEventDispatcher().dispatch("GeckoView:AccessibilityScrollBackward", null);
|
||||
return true;
|
||||
case AccessibilityNodeInfo.ACTION_SELECT:
|
||||
nativeProvider.click(virtualViewId);
|
||||
return true;
|
||||
case AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT:
|
||||
case AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT:
|
||||
if (arguments != null) {
|
||||
data = new GeckoBundle(1);
|
||||
data.putString("rule", arguments.getString(AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING));
|
||||
} else {
|
||||
data = null;
|
||||
}
|
||||
mSession.getEventDispatcher().dispatch(action == AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT ?
|
||||
"GeckoView:AccessibilityNext" : "GeckoView:AccessibilityPrevious", data);
|
||||
return true;
|
||||
case AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY:
|
||||
case AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY:
|
||||
// XXX: Self brailling gives this action with a bogus argument instead of an actual click action;
|
||||
// the argument value is the BRAILLE_CLICK_BASE_INDEX - the index of the routing key that was hit.
|
||||
// Other negative values are used by ChromeVox, but we don't support them.
|
||||
// FAKE_GRANULARITY_READ_CURRENT = -1
|
||||
// FAKE_GRANULARITY_READ_TITLE = -2
|
||||
// FAKE_GRANULARITY_STOP_SPEECH = -3
|
||||
// FAKE_GRANULARITY_CHANGE_SHIFTER = -4
|
||||
int granularity = arguments.getInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT);
|
||||
if (granularity <= BRAILLE_CLICK_BASE_INDEX) {
|
||||
int keyIndex = BRAILLE_CLICK_BASE_INDEX - granularity;
|
||||
data = new GeckoBundle(1);
|
||||
data.putInt("keyIndex", keyIndex);
|
||||
mSession.getEventDispatcher().dispatch("GeckoView:AccessibilityActivate", data);
|
||||
} else if (granularity > 0) {
|
||||
boolean extendSelection = arguments.getBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN);
|
||||
data = new GeckoBundle(3);
|
||||
data.putString("direction", action == AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY ? "Next" : "Previous");
|
||||
data.putInt("granularity", granularity);
|
||||
data.putBoolean("select", extendSelection);
|
||||
mSession.getEventDispatcher().dispatch("GeckoView:AccessibilityByGranularity", data);
|
||||
}
|
||||
return true;
|
||||
case AccessibilityNodeInfo.ACTION_SET_SELECTION:
|
||||
if (arguments == null) {
|
||||
return false;
|
||||
}
|
||||
int selectionStart = arguments.getInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT);
|
||||
int selectionEnd = arguments.getInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT);
|
||||
data = new GeckoBundle(2);
|
||||
data.putInt("start", selectionStart);
|
||||
data.putInt("end", selectionEnd);
|
||||
mSession.getEventDispatcher().dispatch("GeckoView:AccessibilitySetSelection", data);
|
||||
return true;
|
||||
case AccessibilityNodeInfo.ACTION_CUT:
|
||||
case AccessibilityNodeInfo.ACTION_COPY:
|
||||
case AccessibilityNodeInfo.ACTION_PASTE:
|
||||
data = new GeckoBundle(1);
|
||||
data.putString("rule", arguments.getString(AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING));
|
||||
} else {
|
||||
data = null;
|
||||
}
|
||||
mSession.getEventDispatcher().dispatch(action == AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT ?
|
||||
"GeckoView:AccessibilityNext" : "GeckoView:AccessibilityPrevious", data);
|
||||
return true;
|
||||
case AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY:
|
||||
case AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY:
|
||||
// XXX: Self brailling gives this action with a bogus argument instead of an actual click action;
|
||||
// the argument value is the BRAILLE_CLICK_BASE_INDEX - the index of the routing key that was hit.
|
||||
// Other negative values are used by ChromeVox, but we don't support them.
|
||||
// FAKE_GRANULARITY_READ_CURRENT = -1
|
||||
// FAKE_GRANULARITY_READ_TITLE = -2
|
||||
// FAKE_GRANULARITY_STOP_SPEECH = -3
|
||||
// FAKE_GRANULARITY_CHANGE_SHIFTER = -4
|
||||
int granularity = arguments.getInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT);
|
||||
if (granularity <= BRAILLE_CLICK_BASE_INDEX) {
|
||||
int keyIndex = BRAILLE_CLICK_BASE_INDEX - granularity;
|
||||
data = new GeckoBundle(1);
|
||||
data.putInt("keyIndex", keyIndex);
|
||||
mSession.getEventDispatcher().dispatch("GeckoView:AccessibilityActivate", data);
|
||||
} else if (granularity > 0) {
|
||||
boolean extendSelection = arguments.getBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN);
|
||||
data = new GeckoBundle(3);
|
||||
data.putString("direction", action == AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY ? "Next" : "Previous");
|
||||
data.putInt("granularity", granularity);
|
||||
data.putBoolean("select", extendSelection);
|
||||
mSession.getEventDispatcher().dispatch("GeckoView:AccessibilityByGranularity", data);
|
||||
}
|
||||
return true;
|
||||
case AccessibilityNodeInfo.ACTION_SET_SELECTION:
|
||||
if (arguments == null) {
|
||||
return false;
|
||||
}
|
||||
int selectionStart = arguments.getInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT);
|
||||
int selectionEnd = arguments.getInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT);
|
||||
data = new GeckoBundle(2);
|
||||
data.putInt("start", selectionStart);
|
||||
data.putInt("end", selectionEnd);
|
||||
mSession.getEventDispatcher().dispatch("GeckoView:AccessibilitySetSelection", data);
|
||||
return true;
|
||||
case AccessibilityNodeInfo.ACTION_CUT:
|
||||
case AccessibilityNodeInfo.ACTION_COPY:
|
||||
case AccessibilityNodeInfo.ACTION_PASTE:
|
||||
data = new GeckoBundle(1);
|
||||
data.putInt("action", action);
|
||||
mSession.getEventDispatcher().dispatch("GeckoView:AccessibilityClipboard", data);
|
||||
return true;
|
||||
case AccessibilityNodeInfo.ACTION_SET_TEXT:
|
||||
final String value = arguments.getString(Build.VERSION.SDK_INT >= 21
|
||||
? AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE
|
||||
: ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE);
|
||||
if (mAttached) {
|
||||
nativeProvider.setText(virtualViewId, value);
|
||||
}
|
||||
return true;
|
||||
data.putInt("action", action);
|
||||
mSession.getEventDispatcher().dispatch("GeckoView:AccessibilityClipboard", data);
|
||||
return true;
|
||||
case AccessibilityNodeInfo.ACTION_SET_TEXT:
|
||||
final String value = arguments.getString(Build.VERSION.SDK_INT >= 21
|
||||
? AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE
|
||||
: ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE);
|
||||
if (mAttached) {
|
||||
nativeProvider.setText(virtualViewId, value);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return mView.performAccessibilityAction(action, arguments);
|
||||
|
@ -257,7 +257,7 @@ public class SessionAccessibility {
|
|||
break;
|
||||
}
|
||||
|
||||
return super.findFocus(focus);
|
||||
return super.findFocus(focus);
|
||||
}
|
||||
|
||||
private AccessibilityNodeInfo getNodeFromGecko(final int virtualViewId) {
|
||||
|
@ -555,24 +555,12 @@ public class SessionAccessibility {
|
|||
AccessibilityManager accessibilityManager =
|
||||
(AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
|
||||
|
||||
accessibilityManager.addAccessibilityStateChangeListener(
|
||||
new AccessibilityManager.AccessibilityStateChangeListener() {
|
||||
@Override
|
||||
public void onAccessibilityStateChanged(final boolean enabled) {
|
||||
updateAccessibilitySettings();
|
||||
}
|
||||
}
|
||||
);
|
||||
accessibilityManager.addAccessibilityStateChangeListener(enabled ->
|
||||
updateAccessibilitySettings());
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 19) {
|
||||
accessibilityManager.addTouchExplorationStateChangeListener(
|
||||
new AccessibilityManager.TouchExplorationStateChangeListener() {
|
||||
@Override
|
||||
public void onTouchExplorationStateChanged(final boolean enabled) {
|
||||
updateAccessibilitySettings();
|
||||
}
|
||||
}
|
||||
);
|
||||
accessibilityManager.addTouchExplorationStateChangeListener(enabled ->
|
||||
updateAccessibilitySettings());
|
||||
}
|
||||
|
||||
PrefsHelper.PrefHandler prefHandler = new PrefsHelper.PrefHandlerBase() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче