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

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

Issue 2051083002: WIP : Generic Sensor API implementation Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 4 years, 6 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
(Empty)
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
3 // found in the LICENSE file.
4
5 package org.chromium.device.sensors;
6
7 import android.hardware.Sensor;
8 import android.hardware.SensorEvent;
9 import android.hardware.SensorManager;
10 import android.os.Handler;
11
12 import org.chromium.mojo.system.SharedBufferHandle;
13 import org.chromium.mojom.device.sensors.SensorType;
14
15 import java.nio.ByteBuffer;
16
17 /**
18 * ProximitySensor implementation.
19 */
20 public class ProximitySensorImpl extends SensorBase {
21 ProximitySensorImpl(SensorManager manager, Handler handler, SharedBufferHand le handle,
22 long offset, long size, SensorStateObserver observer)
23 throws SensorException {
24 super(Sensor.TYPE_PROXIMITY, manager, handler, handle, offset, size, obs erver);
25 }
26
27 @Override
28 public int getType() {
29 return SensorType.PROXIMITY;
30 }
31
32 @Override
33 protected void fillSensorReadingData(SensorEvent event, ByteBuffer buffer)
34 throws SensorException {
35 if(event.values.length < 1) throw new SensorException();
36 // Distance
37 buffer.putDouble(event.values[0]);
38 }
39 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698