Add minDistance parameter to GnssBatching (framework/base)
Test: atest CtsLocationFineTestCases Bug: b/206670536 Change-Id: I716641a64710c2a5a1cad7cb81d971a478b89660
This commit is contained in:
@@ -1147,7 +1147,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "startBatching " + mFixInterval + " " + batchLengthMs);
|
||||
}
|
||||
if (mGnssNative.startBatch(MILLISECONDS.toNanos(mFixInterval), true)) {
|
||||
if (mGnssNative.startBatch(MILLISECONDS.toNanos(mFixInterval), 0, true)) {
|
||||
mBatchingStarted = true;
|
||||
|
||||
if (batchSize < getBatchSize()) {
|
||||
|
||||
@@ -817,9 +817,10 @@ public class GnssNative {
|
||||
/**
|
||||
* Start batching.
|
||||
*/
|
||||
public boolean startBatch(long periodNanos, boolean wakeOnFifoFull) {
|
||||
public boolean startBatch(long periodNanos, float minUpdateDistanceMeters,
|
||||
boolean wakeOnFifoFull) {
|
||||
Preconditions.checkState(mRegistered);
|
||||
return mGnssHal.startBatch(periodNanos, wakeOnFifoFull);
|
||||
return mGnssHal.startBatch(periodNanos, minUpdateDistanceMeters, wakeOnFifoFull);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1380,8 +1381,9 @@ public class GnssNative {
|
||||
native_cleanup_batching();
|
||||
}
|
||||
|
||||
protected boolean startBatch(long periodNanos, boolean wakeOnFifoFull) {
|
||||
return native_start_batch(periodNanos, wakeOnFifoFull);
|
||||
protected boolean startBatch(long periodNanos, float minUpdateDistanceMeters,
|
||||
boolean wakeOnFifoFull) {
|
||||
return native_start_batch(periodNanos, minUpdateDistanceMeters, wakeOnFifoFull);
|
||||
}
|
||||
|
||||
protected void flushBatch() {
|
||||
@@ -1539,7 +1541,8 @@ public class GnssNative {
|
||||
|
||||
private static native void native_cleanup_batching();
|
||||
|
||||
private static native boolean native_start_batch(long periodNanos, boolean wakeOnFifoFull);
|
||||
private static native boolean native_start_batch(long periodNanos,
|
||||
float minUpdateDistanceMeters, boolean wakeOnFifoFull);
|
||||
|
||||
private static native void native_flush_batch();
|
||||
|
||||
|
||||
@@ -2273,11 +2273,12 @@ static void android_location_gnss_hal_GnssNative_cleanup_batching(JNIEnv*, jclas
|
||||
}
|
||||
|
||||
static jboolean android_location_gnss_hal_GnssNative_start_batch(JNIEnv*, jclass, jlong periodNanos,
|
||||
jfloat minUpdateDistanceMeters,
|
||||
jboolean wakeOnFifoFull) {
|
||||
if (gnssBatchingIface == nullptr) {
|
||||
return JNI_FALSE; // batching not supported
|
||||
}
|
||||
return gnssBatchingIface->start(periodNanos, wakeOnFifoFull);
|
||||
return gnssBatchingIface->start(periodNanos, minUpdateDistanceMeters, wakeOnFifoFull);
|
||||
}
|
||||
|
||||
static void android_location_gnss_hal_GnssNative_flush_batch(JNIEnv*, jclass) {
|
||||
@@ -2367,7 +2368,7 @@ static const JNINativeMethod sBatchingMethods[] = {
|
||||
/* name, signature, funcPtr */
|
||||
{"native_get_batch_size", "()I",
|
||||
reinterpret_cast<void*>(android_location_gnss_hal_GnssNative_get_batch_size)},
|
||||
{"native_start_batch", "(JZ)Z",
|
||||
{"native_start_batch", "(JFZ)Z",
|
||||
reinterpret_cast<void*>(android_location_gnss_hal_GnssNative_start_batch)},
|
||||
{"native_flush_batch", "()V",
|
||||
reinterpret_cast<void*>(android_location_gnss_hal_GnssNative_flush_batch)},
|
||||
|
||||
@@ -47,9 +47,12 @@ jint GnssBatching::getBatchSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
jboolean GnssBatching::start(long periodNanos, bool wakeOnFifoFull) {
|
||||
int flags = (wakeOnFifoFull) ? IGnssBatching::WAKEUP_ON_FIFO_FULL : 0;
|
||||
auto status = mIGnssBatching->start(periodNanos, flags);
|
||||
jboolean GnssBatching::start(long periodNanos, float minUpdateDistanceMeters, bool wakeOnFifoFull) {
|
||||
IGnssBatching::Options options;
|
||||
options.flags = (wakeOnFifoFull) ? IGnssBatching::WAKEUP_ON_FIFO_FULL : 0;
|
||||
options.periodNanos = periodNanos;
|
||||
options.minDistanceMeters = minUpdateDistanceMeters;
|
||||
auto status = mIGnssBatching->start(options);
|
||||
return checkAidlStatus(status, "IGnssBatchingAidl start() failed.");
|
||||
}
|
||||
|
||||
@@ -88,9 +91,13 @@ jint GnssBatching_V1_0::getBatchSize() {
|
||||
return static_cast<jint>(result);
|
||||
}
|
||||
|
||||
jboolean GnssBatching_V1_0::start(long periodNanos, bool wakeOnFifoFull) {
|
||||
jboolean GnssBatching_V1_0::start(long periodNanos, float minUpdateDistanceMeters,
|
||||
bool wakeOnFifoFull) {
|
||||
IGnssBatching_V1_0::Options options;
|
||||
options.periodNanos = periodNanos;
|
||||
if (minUpdateDistanceMeters > 0) {
|
||||
ALOGW("minUpdateDistanceMeters is not supported in 1.0 GNSS HAL.");
|
||||
}
|
||||
if (wakeOnFifoFull) {
|
||||
options.flags = static_cast<uint8_t>(IGnssBatching_V1_0::Flag::WAKEUP_ON_FIFO_FULL);
|
||||
} else {
|
||||
|
||||
@@ -38,7 +38,8 @@ public:
|
||||
virtual ~GnssBatchingInterface() {}
|
||||
virtual jboolean init(const std::unique_ptr<GnssBatchingCallback>& callback) = 0;
|
||||
virtual jint getBatchSize() = 0;
|
||||
virtual jboolean start(long periodNanos, bool wakeupOnFifoFull) = 0;
|
||||
virtual jboolean start(long periodNanos, float minUpdateDistanceMeters,
|
||||
bool wakeupOnFifoFull) = 0;
|
||||
virtual jboolean stop() = 0;
|
||||
virtual jboolean flush() = 0;
|
||||
virtual jboolean cleanup() = 0;
|
||||
@@ -49,7 +50,7 @@ public:
|
||||
GnssBatching(const sp<android::hardware::gnss::IGnssBatching>& iGnssBatching);
|
||||
jboolean init(const std::unique_ptr<GnssBatchingCallback>& callback) override;
|
||||
jint getBatchSize() override;
|
||||
jboolean start(long periodNanos, bool wakeupOnFifoFull) override;
|
||||
jboolean start(long periodNanos, float minUpdateDistanceMeters, bool wakeupOnFifoFull) override;
|
||||
jboolean stop() override;
|
||||
jboolean flush() override;
|
||||
jboolean cleanup() override;
|
||||
@@ -63,7 +64,7 @@ public:
|
||||
GnssBatching_V1_0(const sp<android::hardware::gnss::V1_0::IGnssBatching>& iGnssBatching);
|
||||
jboolean init(const std::unique_ptr<GnssBatchingCallback>& callback) override;
|
||||
jint getBatchSize() override;
|
||||
jboolean start(long periodNanos, bool wakeupOnFifoFull) override;
|
||||
jboolean start(long periodNanos, float minUpdateDistanceMeters, bool wakeupOnFifoFull) override;
|
||||
jboolean stop() override;
|
||||
jboolean flush() override;
|
||||
jboolean cleanup() override;
|
||||
|
||||
@@ -109,15 +109,19 @@ public final class FakeGnssHal extends GnssNative.GnssHal {
|
||||
public static class GnssHalBatchingMode {
|
||||
|
||||
public final long PeriodNanos;
|
||||
public final float MinUpdateDistanceMeters;
|
||||
public final boolean WakeOnFifoFull;
|
||||
|
||||
GnssHalBatchingMode() {
|
||||
PeriodNanos = 0;
|
||||
MinUpdateDistanceMeters = 0.0f;
|
||||
WakeOnFifoFull = false;
|
||||
}
|
||||
|
||||
public GnssHalBatchingMode(long periodNanos, boolean wakeOnFifoFull) {
|
||||
public GnssHalBatchingMode(long periodNanos, float minUpdateDistanceMeters,
|
||||
boolean wakeOnFifoFull) {
|
||||
PeriodNanos = periodNanos;
|
||||
MinUpdateDistanceMeters = minUpdateDistanceMeters;
|
||||
WakeOnFifoFull = wakeOnFifoFull;
|
||||
}
|
||||
|
||||
@@ -132,12 +136,13 @@ public final class FakeGnssHal extends GnssNative.GnssHal {
|
||||
|
||||
GnssHalBatchingMode that = (GnssHalBatchingMode) o;
|
||||
return PeriodNanos == that.PeriodNanos
|
||||
&& MinUpdateDistanceMeters == that.MinUpdateDistanceMeters
|
||||
&& WakeOnFifoFull == that.WakeOnFifoFull;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(PeriodNanos, WakeOnFifoFull);
|
||||
return Objects.hash(PeriodNanos, MinUpdateDistanceMeters, WakeOnFifoFull);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -570,9 +575,11 @@ public final class FakeGnssHal extends GnssNative.GnssHal {
|
||||
protected void cleanupBatching() {}
|
||||
|
||||
@Override
|
||||
protected boolean startBatch(long periodNanos, boolean wakeOnFifoFull) {
|
||||
protected boolean startBatch(long periodNanos, float minUpdateDistanceMeters,
|
||||
boolean wakeOnFifoFull) {
|
||||
mState.mBatchingStarted = true;
|
||||
mState.mBatchingMode = new GnssHalBatchingMode(periodNanos, wakeOnFifoFull);
|
||||
mState.mBatchingMode = new GnssHalBatchingMode(periodNanos, minUpdateDistanceMeters,
|
||||
wakeOnFifoFull);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user