OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2014 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 package org.appspot.apprtc; | 11 package org.appspot.apprtc; |
12 | 12 |
13 import org.appspot.apprtc.util.AppRTCUtils; | |
14 | |
15 import android.content.Context; | 13 import android.content.Context; |
16 import android.hardware.Sensor; | 14 import android.hardware.Sensor; |
17 import android.hardware.SensorEvent; | 15 import android.hardware.SensorEvent; |
18 import android.hardware.SensorEventListener; | 16 import android.hardware.SensorEventListener; |
19 import android.hardware.SensorManager; | 17 import android.hardware.SensorManager; |
20 import android.os.Build; | 18 import android.os.Build; |
21 import android.util.Log; | 19 import android.util.Log; |
22 | 20 import org.appspot.apprtc.util.AppRTCUtils; |
23 import org.webrtc.ThreadUtils; | 21 import org.webrtc.ThreadUtils; |
24 | 22 |
25 /** | 23 /** |
26 * AppRTCProximitySensor manages functions related to the proximity sensor in | 24 * AppRTCProximitySensor manages functions related to the proximity sensor in |
27 * the AppRTC demo. | 25 * the AppRTC demo. |
28 * On most device, the proximity sensor is implemented as a boolean-sensor. | 26 * On most device, the proximity sensor is implemented as a boolean-sensor. |
29 * It returns just two values "NEAR" or "FAR". Thresholding is done on the LUX | 27 * It returns just two values "NEAR" or "FAR". Thresholding is done on the LUX |
30 * value i.e. the LUX value of the light sensor is compared with a threshold. | 28 * value i.e. the LUX value of the light sensor is compared with a threshold. |
31 * A LUX-value more than the threshold means the proximity sensor returns "FAR". | 29 * A LUX-value more than the threshold means the proximity sensor returns "FAR". |
32 * Anything less than the threshold value and the sensor returns "NEAR". | 30 * Anything less than the threshold value and the sensor returns "NEAR". |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 private void logProximitySensorInfo() { | 140 private void logProximitySensorInfo() { |
143 if (proximitySensor == null) { | 141 if (proximitySensor == null) { |
144 return; | 142 return; |
145 } | 143 } |
146 StringBuilder info = new StringBuilder("Proximity sensor: "); | 144 StringBuilder info = new StringBuilder("Proximity sensor: "); |
147 info.append("name=").append(proximitySensor.getName()); | 145 info.append("name=").append(proximitySensor.getName()); |
148 info.append(", vendor: ").append(proximitySensor.getVendor()); | 146 info.append(", vendor: ").append(proximitySensor.getVendor()); |
149 info.append(", power: ").append(proximitySensor.getPower()); | 147 info.append(", power: ").append(proximitySensor.getPower()); |
150 info.append(", resolution: ").append(proximitySensor.getResolution()); | 148 info.append(", resolution: ").append(proximitySensor.getResolution()); |
151 info.append(", max range: ").append(proximitySensor.getMaximumRange()); | 149 info.append(", max range: ").append(proximitySensor.getMaximumRange()); |
152 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { | 150 info.append(", min delay: ").append(proximitySensor.getMinDelay()); |
153 // Added in API level 9. | |
154 info.append(", min delay: ").append(proximitySensor.getMinDelay()); | |
155 } | |
156 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { | 151 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { |
157 // Added in API level 20. | 152 // Added in API level 20. |
158 info.append(", type: ").append(proximitySensor.getStringType()); | 153 info.append(", type: ").append(proximitySensor.getStringType()); |
159 } | 154 } |
160 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | 155 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
161 // Added in API level 21. | 156 // Added in API level 21. |
162 info.append(", max delay: ").append(proximitySensor.getMaxDelay()); | 157 info.append(", max delay: ").append(proximitySensor.getMaxDelay()); |
163 info.append(", reporting mode: ").append(proximitySensor.getReportingMode(
)); | 158 info.append(", reporting mode: ").append(proximitySensor.getReportingMode(
)); |
164 info.append(", isWakeUpSensor: ").append(proximitySensor.isWakeUpSensor())
; | 159 info.append(", isWakeUpSensor: ").append(proximitySensor.isWakeUpSensor())
; |
165 } | 160 } |
166 Log.d(TAG, info.toString()); | 161 Log.d(TAG, info.toString()); |
167 } | 162 } |
168 } | 163 } |
OLD | NEW |