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

Unified Diff: device/generic_sensor/platform_sensor_android.cc

Issue 2865263002: Move //device/generic_sensor to be part of the internal implementation of the Device Service. (Closed)
Patch Set: code rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/generic_sensor/platform_sensor_android.h ('k') | device/generic_sensor/platform_sensor_linux.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/generic_sensor/platform_sensor_android.cc
diff --git a/device/generic_sensor/platform_sensor_android.cc b/device/generic_sensor/platform_sensor_android.cc
deleted file mode 100644
index 10e3f6c1383bd6a868e0b9e021fd97cfb7be8953..0000000000000000000000000000000000000000
--- a/device/generic_sensor/platform_sensor_android.cc
+++ /dev/null
@@ -1,100 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "device/generic_sensor/platform_sensor_android.h"
-
-#include "base/bind.h"
-#include "jni/PlatformSensor_jni.h"
-
-using base::android::AttachCurrentThread;
-using base::android::JavaRef;
-
-namespace device {
-
-// static
-bool PlatformSensorAndroid::RegisterJNI(JNIEnv* env) {
- return RegisterNativesImpl(env);
-}
-
-PlatformSensorAndroid::PlatformSensorAndroid(
- mojom::SensorType type,
- mojo::ScopedSharedBufferMapping mapping,
- PlatformSensorProvider* provider,
- const JavaRef<jobject>& java_sensor)
- : PlatformSensor(type, std::move(mapping), provider) {
- JNIEnv* env = AttachCurrentThread();
- j_object_.Reset(java_sensor);
-
- Java_PlatformSensor_initPlatformSensorAndroid(env, j_object_.obj(),
- reinterpret_cast<jlong>(this));
-}
-
-PlatformSensorAndroid::~PlatformSensorAndroid() {
- StopSensor();
-}
-
-mojom::ReportingMode PlatformSensorAndroid::GetReportingMode() {
- JNIEnv* env = AttachCurrentThread();
- return static_cast<mojom::ReportingMode>(
- Java_PlatformSensor_getReportingMode(env, j_object_.obj()));
-}
-
-PlatformSensorConfiguration PlatformSensorAndroid::GetDefaultConfiguration() {
- JNIEnv* env = AttachCurrentThread();
- jdouble frequency =
- Java_PlatformSensor_getDefaultConfiguration(env, j_object_.obj());
- return PlatformSensorConfiguration(frequency);
-}
-
-double PlatformSensorAndroid::GetMaximumSupportedFrequency() {
- JNIEnv* env = AttachCurrentThread();
- return Java_PlatformSensor_getMaximumSupportedFrequency(env, j_object_.obj());
-}
-
-bool PlatformSensorAndroid::StartSensor(
- const PlatformSensorConfiguration& configuration) {
- JNIEnv* env = AttachCurrentThread();
- return Java_PlatformSensor_startSensor(env, j_object_.obj(),
- configuration.frequency());
-}
-
-void PlatformSensorAndroid::StopSensor() {
- JNIEnv* env = AttachCurrentThread();
- Java_PlatformSensor_stopSensor(env, j_object_.obj());
-}
-
-bool PlatformSensorAndroid::CheckSensorConfiguration(
- const PlatformSensorConfiguration& configuration) {
- JNIEnv* env = AttachCurrentThread();
- return Java_PlatformSensor_checkSensorConfiguration(
- env, j_object_.obj(), configuration.frequency());
-}
-
-void PlatformSensorAndroid::NotifyPlatformSensorError(
- JNIEnv*,
- const JavaRef<jobject>& caller) {
- task_runner_->PostTask(
- FROM_HERE, base::Bind(&PlatformSensorAndroid::NotifySensorError, this));
-}
-
-void PlatformSensorAndroid::UpdatePlatformSensorReading(
- JNIEnv*,
- const base::android::JavaRef<jobject>& caller,
- jdouble timestamp,
- jdouble value1,
- jdouble value2,
- jdouble value3,
- jdouble value4) {
- SensorReading reading;
- reading.timestamp = timestamp;
- reading.values[0] = value1;
- reading.values[1] = value2;
- reading.values[2] = value3;
- reading.values[3] = value4;
-
- bool needNotify = (GetReportingMode() == mojom::ReportingMode::ON_CHANGE);
- UpdateSensorReading(reading, needNotify);
-}
-
-} // namespace device
« no previous file with comments | « device/generic_sensor/platform_sensor_android.h ('k') | device/generic_sensor/platform_sensor_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698