Merge "Mkae SysUIPlugins its own gradle target." into sc-dev
This commit is contained in:
@@ -50,13 +50,6 @@ java_library {
|
|||||||
srcs: ["src/com/android/systemui/EventLogTags.logtags"],
|
srcs: ["src/com/android/systemui/EventLogTags.logtags"],
|
||||||
}
|
}
|
||||||
|
|
||||||
java_library {
|
|
||||||
name: "SystemUI-sensors",
|
|
||||||
srcs: [
|
|
||||||
"src/com/android/systemui/util/sensors/ThresholdSensor.java",
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
||||||
android_library {
|
android_library {
|
||||||
name: "SystemUI-core",
|
name: "SystemUI-core",
|
||||||
srcs: [
|
srcs: [
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ android_library {
|
|||||||
|
|
||||||
static_libs: [
|
static_libs: [
|
||||||
"PluginCoreLib",
|
"PluginCoreLib",
|
||||||
"SystemUI-sensors",
|
|
||||||
],
|
],
|
||||||
|
|
||||||
manifest: "AndroidManifest.xml",
|
manifest: "AndroidManifest.xml",
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ java_library {
|
|||||||
static_libs: [
|
static_libs: [
|
||||||
"androidx.annotation_annotation",
|
"androidx.annotation_annotation",
|
||||||
"PluginCoreLib",
|
"PluginCoreLib",
|
||||||
"SystemUI-sensors",
|
|
||||||
"SystemUIAnimationLib",
|
"SystemUIAnimationLib",
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import android.net.Uri;
|
|||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
|
||||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||||
import com.android.systemui.util.sensors.ThresholdSensor;
|
|
||||||
|
|
||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
@@ -118,7 +117,7 @@ public interface FalsingManager {
|
|||||||
void cleanup();
|
void cleanup();
|
||||||
|
|
||||||
/** Call to report a ProximityEvent to the FalsingManager. */
|
/** Call to report a ProximityEvent to the FalsingManager. */
|
||||||
void onProximityEvent(ThresholdSensor.ThresholdSensorEvent proximityEvent);
|
void onProximityEvent(ProximityEvent proximityEvent);
|
||||||
|
|
||||||
/** Adds a {@link FalsingBeliefListener}. */
|
/** Adds a {@link FalsingBeliefListener}. */
|
||||||
void addFalsingBeliefListener(FalsingBeliefListener listener);
|
void addFalsingBeliefListener(FalsingBeliefListener listener);
|
||||||
@@ -141,4 +140,13 @@ public interface FalsingManager {
|
|||||||
interface FalsingTapListener {
|
interface FalsingTapListener {
|
||||||
void onDoubleTapRequired();
|
void onDoubleTapRequired();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Passed to {@link FalsingManager#onProximityEvent}. */
|
||||||
|
interface ProximityEvent {
|
||||||
|
/** Returns true when the proximity sensor was covered. */
|
||||||
|
boolean getCovered();
|
||||||
|
|
||||||
|
/** Returns when the proximity sensor was covered in nanoseconds. */
|
||||||
|
long getTimestampNs();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ import com.android.systemui.dagger.qualifiers.TestHarness;
|
|||||||
import com.android.systemui.dock.DockManager;
|
import com.android.systemui.dock.DockManager;
|
||||||
import com.android.systemui.plugins.FalsingManager;
|
import com.android.systemui.plugins.FalsingManager;
|
||||||
import com.android.systemui.statusbar.policy.KeyguardStateController;
|
import com.android.systemui.statusbar.policy.KeyguardStateController;
|
||||||
import com.android.systemui.util.sensors.ThresholdSensor;
|
|
||||||
|
|
||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
@@ -317,7 +316,7 @@ public class BrightLineFalsingManager implements FalsingManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProximityEvent(ThresholdSensor.ThresholdSensorEvent proximityEvent) {
|
public void onProximityEvent(ProximityEvent proximityEvent) {
|
||||||
// TODO: some of these classifiers might allow us to abort early, meaning we don't have to
|
// TODO: some of these classifiers might allow us to abort early, meaning we don't have to
|
||||||
// make these calls.
|
// make these calls.
|
||||||
mClassifiers.forEach((classifier) -> classifier.onProximityEvent(proximityEvent));
|
mClassifiers.forEach((classifier) -> classifier.onProximityEvent(proximityEvent));
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ package com.android.systemui.classifier;
|
|||||||
|
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
|
||||||
import com.android.systemui.util.sensors.ProximitySensor;
|
import com.android.systemui.plugins.FalsingManager;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ public abstract class FalsingClassifier {
|
|||||||
/**
|
/**
|
||||||
* Called when a ProximityEvent occurs (change in near/far).
|
* Called when a ProximityEvent occurs (change in near/far).
|
||||||
*/
|
*/
|
||||||
void onProximityEvent(ProximitySensor.ThresholdSensorEvent proximityEvent) {}
|
void onProximityEvent(FalsingManager.ProximityEvent proximityEvent) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The phone screen has turned on and we need to begin falsing detection.
|
* The phone screen has turned on and we need to begin falsing detection.
|
||||||
|
|||||||
@@ -361,7 +361,7 @@ class FalsingCollectorImpl implements FalsingCollector {
|
|||||||
private void onProximityEvent(ThresholdSensor.ThresholdSensorEvent proximityEvent) {
|
private void onProximityEvent(ThresholdSensor.ThresholdSensorEvent proximityEvent) {
|
||||||
// TODO: some of these classifiers might allow us to abort early, meaning we don't have to
|
// TODO: some of these classifiers might allow us to abort early, meaning we don't have to
|
||||||
// make these calls.
|
// make these calls.
|
||||||
mFalsingManager.onProximityEvent(proximityEvent);
|
mFalsingManager.onProximityEvent(new ProximityEventImpl(proximityEvent));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -374,4 +374,21 @@ class FalsingCollectorImpl implements FalsingCollector {
|
|||||||
Log.d(TAG, msg, throwable);
|
Log.d(TAG, msg, throwable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class ProximityEventImpl implements FalsingManager.ProximityEvent {
|
||||||
|
private ThresholdSensor.ThresholdSensorEvent mThresholdSensorEvent;
|
||||||
|
|
||||||
|
ProximityEventImpl(ThresholdSensor.ThresholdSensorEvent thresholdSensorEvent) {
|
||||||
|
mThresholdSensorEvent = thresholdSensorEvent;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean getCovered() {
|
||||||
|
return mThresholdSensorEvent.getBelow();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getTimestampNs() {
|
||||||
|
return mThresholdSensorEvent.getTimestampNs();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import android.net.Uri;
|
|||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.systemui.plugins.FalsingManager;
|
import com.android.systemui.plugins.FalsingManager;
|
||||||
import com.android.systemui.util.sensors.ThresholdSensor;
|
|
||||||
|
|
||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
@@ -133,7 +132,7 @@ public class FalsingManagerFake implements FalsingManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProximityEvent(ThresholdSensor.ThresholdSensorEvent proximityEvent) {
|
public void onProximityEvent(ProximityEvent proximityEvent) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import com.android.systemui.plugins.FalsingPlugin;
|
|||||||
import com.android.systemui.plugins.PluginListener;
|
import com.android.systemui.plugins.PluginListener;
|
||||||
import com.android.systemui.shared.plugins.PluginManager;
|
import com.android.systemui.shared.plugins.PluginManager;
|
||||||
import com.android.systemui.util.DeviceConfigProxy;
|
import com.android.systemui.util.DeviceConfigProxy;
|
||||||
import com.android.systemui.util.sensors.ThresholdSensor;
|
|
||||||
|
|
||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
@@ -186,7 +185,7 @@ public class FalsingManagerProxy implements FalsingManager, Dumpable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProximityEvent(ThresholdSensor.ThresholdSensorEvent proximityEvent) {
|
public void onProximityEvent(ProximityEvent proximityEvent) {
|
||||||
mInternalFalsingManager.onProximityEvent(proximityEvent);
|
mInternalFalsingManager.onProximityEvent(proximityEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ import static com.android.systemui.classifier.Classifier.QUICK_SETTINGS;
|
|||||||
import android.provider.DeviceConfig;
|
import android.provider.DeviceConfig;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
|
||||||
|
import com.android.systemui.plugins.FalsingManager;
|
||||||
import com.android.systemui.util.DeviceConfigProxy;
|
import com.android.systemui.util.DeviceConfigProxy;
|
||||||
import com.android.systemui.util.sensors.ProximitySensor;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@@ -107,11 +107,11 @@ class ProximityClassifier extends FalsingClassifier {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProximityEvent(
|
public void onProximityEvent(
|
||||||
ProximitySensor.ThresholdSensorEvent proximityEvent) {
|
FalsingManager.ProximityEvent proximityEvent) {
|
||||||
boolean near = proximityEvent.getBelow();
|
boolean covered = proximityEvent.getCovered();
|
||||||
long timestampNs = proximityEvent.getTimestampNs();
|
long timestampNs = proximityEvent.getTimestampNs();
|
||||||
logDebug("Sensor is: " + near + " at time " + timestampNs);
|
logDebug("Sensor is: " + covered + " at time " + timestampNs);
|
||||||
update(near, timestampNs);
|
update(covered, timestampNs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ import android.view.MotionEvent;
|
|||||||
|
|
||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
|
|
||||||
|
import com.android.systemui.plugins.FalsingManager;
|
||||||
import com.android.systemui.util.DeviceConfigProxyFake;
|
import com.android.systemui.util.DeviceConfigProxyFake;
|
||||||
import com.android.systemui.util.sensors.ProximitySensor;
|
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -149,8 +149,17 @@ public class ProximityClassifierTest extends ClassifierTest {
|
|||||||
motionEvent.recycle();
|
motionEvent.recycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ProximitySensor.ThresholdSensorEvent createSensorEvent(
|
private FalsingManager.ProximityEvent createSensorEvent(boolean covered, long timestampMs) {
|
||||||
boolean covered, long timestampMs) {
|
return new FalsingManager.ProximityEvent() {
|
||||||
return new ProximitySensor.ThresholdSensorEvent(covered, timestampMs * NS_PER_MS);
|
@Override
|
||||||
|
public boolean getCovered() {
|
||||||
|
return covered;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getTimestampNs() {
|
||||||
|
return timestampMs * NS_PER_MS;
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user