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

Side by Side Diff: device/generic_sensor/android/java/src/org/chromium/device/sensors/PlatformSensorProvider.java

Issue 2847523002: Android: Remove GetApplicationContext part 4 (Closed)
Patch Set: Rebase and fix build Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.device.sensors; 5 package org.chromium.device.sensors;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.hardware.Sensor; 8 import android.hardware.Sensor;
9 import android.hardware.SensorManager; 9 import android.hardware.SensorManager;
10 import android.os.Build; 10 import android.os.Build;
11 import android.os.Handler; 11 import android.os.Handler;
12 import android.os.HandlerThread; 12 import android.os.HandlerThread;
13 13
14 import org.chromium.base.ContextUtils;
14 import org.chromium.base.annotations.CalledByNative; 15 import org.chromium.base.annotations.CalledByNative;
15 import org.chromium.base.annotations.JNINamespace; 16 import org.chromium.base.annotations.JNINamespace;
16 import org.chromium.device.mojom.SensorType; 17 import org.chromium.device.mojom.SensorType;
17 18
18 import java.util.HashSet; 19 import java.util.HashSet;
19 import java.util.Set; 20 import java.util.Set;
20 21
21 /** 22 /**
22 * Lifetime is controlled by device::PlatformSensorProviderAndroid. 23 * Lifetime is controlled by device::PlatformSensorProviderAndroid.
23 */ 24 */
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } else { 104 } else {
104 mSensorsThread.quit(); 105 mSensorsThread.quit();
105 } 106 }
106 mSensorsThread = null; 107 mSensorsThread = null;
107 mHandler = null; 108 mHandler = null;
108 } 109 }
109 } 110 }
110 111
111 /** 112 /**
112 * Constructor. 113 * Constructor.
113 *
114 * @param context application context.
115 */ 114 */
116 protected PlatformSensorProvider(Context context) { 115 protected PlatformSensorProvider(Context context) {
117 mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR _SERVICE); 116 mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR _SERVICE);
118 } 117 }
119 118
120 /** 119 /**
121 * Creates PlatformSensorProvider instance. 120 * Creates PlatformSensorProvider instance.
122 * 121 *
123 * @param context application context. 122 * @return PlatformSensorProvider new PlatformSensorProvider instance.
123 */
124 protected static PlatformSensorProvider createForTest(Context context) {
125 return new PlatformSensorProvider(context);
126 }
127
128 /**
129 * Creates PlatformSensorProvider instance.
130 *
124 * @return PlatformSensorProvider new PlatformSensorProvider instance. 131 * @return PlatformSensorProvider new PlatformSensorProvider instance.
125 */ 132 */
126 @CalledByNative 133 @CalledByNative
127 protected static PlatformSensorProvider create(Context context) { 134 protected static PlatformSensorProvider create() {
128 return new PlatformSensorProvider(context); 135 return new PlatformSensorProvider(ContextUtils.getApplicationContext());
129 } 136 }
130 137
131 /** 138 /**
132 * Creates PlatformSensor instance. 139 * Creates PlatformSensor instance.
133 * 140 *
134 * @param type type of a sensor. 141 * @param type type of a sensor.
135 * @return PlatformSensor new PlatformSensor instance or null if sensor cann ot be created. 142 * @return PlatformSensor new PlatformSensor instance or null if sensor cann ot be created.
136 */ 143 */
137 @CalledByNative 144 @CalledByNative
138 protected PlatformSensor createSensor(int type) { 145 protected PlatformSensor createSensor(int type) {
(...skipping 12 matching lines...) Expand all
151 return PlatformSensor.create(Sensor.TYPE_MAGNETIC_FIELD, 3, this ); 158 return PlatformSensor.create(Sensor.TYPE_MAGNETIC_FIELD, 3, this );
152 case SensorType.ABSOLUTE_ORIENTATION: 159 case SensorType.ABSOLUTE_ORIENTATION:
153 return PlatformSensor.create(Sensor.TYPE_ROTATION_VECTOR, 4, thi s); 160 return PlatformSensor.create(Sensor.TYPE_ROTATION_VECTOR, 4, thi s);
154 case SensorType.RELATIVE_ORIENTATION: 161 case SensorType.RELATIVE_ORIENTATION:
155 return PlatformSensor.create(Sensor.TYPE_GAME_ROTATION_VECTOR, 4 , this); 162 return PlatformSensor.create(Sensor.TYPE_GAME_ROTATION_VECTOR, 4 , this);
156 default: 163 default:
157 return null; 164 return null;
158 } 165 }
159 } 166 }
160 } 167 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698