Move ConsumerIrService to HIDL HAL
Test: Service builds successfully and runs on boot.
Change-Id: I0fd90a1ff1d9bde9c1a0872b248f88c5990a1b57
Signed-off-by: Connor O'Brien <connoro@google.com>
diff --git a/services/core/java/com/android/server/ConsumerIrService.java b/services/core/java/com/android/server/ConsumerIrService.java
index ea6812d..2ed6c77 100644
--- a/services/core/java/com/android/server/ConsumerIrService.java
+++ b/services/core/java/com/android/server/ConsumerIrService.java
@@ -29,13 +29,13 @@
private static final int MAX_XMIT_TIME = 2000000; /* in microseconds */
- private static native long halOpen();
- private static native int halTransmit(long halObject, int carrierFrequency, int[] pattern);
- private static native int[] halGetCarrierFrequencies(long halObject);
+ private static native boolean halOpen();
+ private static native int halTransmit(int carrierFrequency, int[] pattern);
+ private static native int[] halGetCarrierFrequencies();
private final Context mContext;
private final PowerManager.WakeLock mWakeLock;
- private final long mNativeHal;
+ private final boolean mHasNativeHal;
private final Object mHalLock = new Object();
ConsumerIrService(Context context) {
@@ -45,23 +45,23 @@
mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
mWakeLock.setReferenceCounted(true);
- mNativeHal = halOpen();
+ mHasNativeHal = halOpen();
if (mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CONSUMER_IR)) {
- if (mNativeHal == 0) {
+ if (!mHasNativeHal) {
throw new RuntimeException("FEATURE_CONSUMER_IR present, but no IR HAL loaded!");
}
- } else if (mNativeHal != 0) {
+ } else if (mHasNativeHal) {
throw new RuntimeException("IR HAL present, but FEATURE_CONSUMER_IR is not set!");
}
}
@Override
public boolean hasIrEmitter() {
- return mNativeHal != 0;
+ return mHasNativeHal;
}
private void throwIfNoIrEmitter() {
- if (mNativeHal == 0) {
+ if (!mHasNativeHal) {
throw new UnsupportedOperationException("IR emitter not available");
}
}
@@ -91,7 +91,7 @@
// Right now there is no mechanism to ensure fair queing of IR requests
synchronized (mHalLock) {
- int err = halTransmit(mNativeHal, carrierFrequency, pattern);
+ int err = halTransmit(carrierFrequency, pattern);
if (err < 0) {
Slog.e(TAG, "Error transmitting: " + err);
@@ -109,7 +109,7 @@
throwIfNoIrEmitter();
synchronized(mHalLock) {
- return halGetCarrierFrequencies(mNativeHal);
+ return halGetCarrierFrequencies();
}
}
}