Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1402)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/DeviceMotionAndOrientation.java

Issue 22978010: [Android] Remove all usage of com.google.common.collect (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nyquist fixes Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/browser/DeviceMotionAndOrientation.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/DeviceMotionAndOrientation.java b/content/public/android/java/src/org/chromium/content/browser/DeviceMotionAndOrientation.java
index 54a0c56738d1651775d0877abc045557364138c1..eb9cf0ec596f90bf1b888bc7ea6ba3be984ec85b 100644
--- a/content/public/android/java/src/org/chromium/content/browser/DeviceMotionAndOrientation.java
+++ b/content/public/android/java/src/org/chromium/content/browser/DeviceMotionAndOrientation.java
@@ -11,17 +11,16 @@ import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Handler;
import android.os.HandlerThread;
-import android.os.Looper;
import android.util.Log;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Sets;
import org.chromium.base.CalledByNative;
+import org.chromium.base.CollectionUtil;
import org.chromium.base.JNINamespace;
import org.chromium.base.WeakContext;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -38,14 +37,14 @@ class DeviceMotionAndOrientation implements SensorEventListener {
private Handler mHandler;
// The lock to access the mHandler.
- private Object mHandlerLock = new Object();
+ private final Object mHandlerLock = new Object();
// Non-zero if and only if we're listening for events.
// To avoid race conditions on the C++ side, access must be synchronized.
private int mNativePtr;
// The lock to access the mNativePtr.
- private Object mNativePtrLock = new Object();
+ private final Object mNativePtrLock = new Object();
// The acceleration vector including gravity expressed in the body frame.
private float[] mAccelerationIncludingGravityVector;
@@ -67,17 +66,17 @@ class DeviceMotionAndOrientation implements SensorEventListener {
static final int DEVICE_ORIENTATION = 0;
static final int DEVICE_MOTION = 1;
- static final ImmutableSet<Integer> DEVICE_ORIENTATION_SENSORS = ImmutableSet.of(
+ static final Set<Integer> DEVICE_ORIENTATION_SENSORS = CollectionUtil.newHashSet(
Sensor.TYPE_ACCELEROMETER,
Sensor.TYPE_MAGNETIC_FIELD);
- static final ImmutableSet<Integer> DEVICE_MOTION_SENSORS = ImmutableSet.of(
+ static final Set<Integer> DEVICE_MOTION_SENSORS = CollectionUtil.newHashSet(
Sensor.TYPE_ACCELEROMETER,
Sensor.TYPE_LINEAR_ACCELERATION,
Sensor.TYPE_GYROSCOPE);
@VisibleForTesting
- final Set<Integer> mActiveSensors = Sets.newHashSet();
+ final Set<Integer> mActiveSensors = new HashSet<Integer>();
boolean mDeviceMotionIsActive = false;
boolean mDeviceOrientationIsActive = false;
@@ -122,7 +121,7 @@ class DeviceMotionAndOrientation implements SensorEventListener {
@CalledByNative
public int getNumberActiveDeviceMotionSensors() {
- Set<Integer> deviceMotionSensors = Sets.newHashSet(DEVICE_MOTION_SENSORS);
+ Set<Integer> deviceMotionSensors = new HashSet<Integer>(DEVICE_MOTION_SENSORS);
deviceMotionSensors.removeAll(mActiveSensors);
return DEVICE_MOTION_SENSORS.size() - deviceMotionSensors.size();
}
@@ -138,7 +137,7 @@ class DeviceMotionAndOrientation implements SensorEventListener {
*/
@CalledByNative
public void stop(int eventType) {
- Set<Integer> sensorsToRemainActive = Sets.newHashSet();
+ Set<Integer> sensorsToRemainActive = new HashSet<Integer>();
synchronized (mNativePtrLock) {
switch (eventType) {
case DEVICE_ORIENTATION:
@@ -156,7 +155,7 @@ class DeviceMotionAndOrientation implements SensorEventListener {
return;
}
- Set<Integer> sensorsToDeactivate = Sets.newHashSet(mActiveSensors);
+ Set<Integer> sensorsToDeactivate = new HashSet<Integer>(mActiveSensors);
sensorsToDeactivate.removeAll(sensorsToRemainActive);
unregisterSensors(sensorsToDeactivate);
setEventTypeActive(eventType, false);
@@ -298,9 +297,9 @@ class DeviceMotionAndOrientation implements SensorEventListener {
* activated. When false the method return true if at least one
* sensor in sensorTypes could be activated.
*/
- private boolean registerSensors(Iterable<Integer> sensorTypes, int rateInMilliseconds,
+ private boolean registerSensors(Set<Integer> sensorTypes, int rateInMilliseconds,
boolean failOnMissingSensor) {
- Set<Integer> sensorsToActivate = Sets.newHashSet(sensorTypes);
+ Set<Integer> sensorsToActivate = new HashSet<Integer>(sensorTypes);
sensorsToActivate.removeAll(mActiveSensors);
boolean success = false;
@@ -442,6 +441,7 @@ class DeviceMotionAndOrientation implements SensorEventListener {
mSensorManager = sensorManager;
}
+ @Override
public boolean registerListener(SensorEventListener listener, int sensorType, int rate,
Handler handler) {
List<Sensor> sensors = mSensorManager.getSensorList(sensorType);
@@ -451,6 +451,7 @@ class DeviceMotionAndOrientation implements SensorEventListener {
return mSensorManager.registerListener(listener, sensors.get(0), rate, handler);
}
+ @Override
public void unregisterListener(SensorEventListener listener, int sensorType) {
List<Sensor> sensors = mSensorManager.getSensorList(sensorType);
if (!sensors.isEmpty()) {

Powered by Google App Engine
This is Rietveld 408576698