OSDN Git Service

Add Consumer IR feature
authorAlex Ray <aray@google.com>
Thu, 3 Oct 2013 19:17:54 +0000 (12:17 -0700)
committerAlex Ray <aray@google.com>
Fri, 4 Oct 2013 01:19:38 +0000 (18:19 -0700)
Bug: 10676690
Change-Id: Id2c118225dc6ef259f5ed97da4071e9b6de3a83a

api/current.txt
core/java/android/content/pm/PackageManager.java
services/java/com/android/server/ConsumerIrService.java

index e8f4204..106dbbf 100644 (file)
@@ -7277,6 +7277,7 @@ package android.content.pm {
     field public static final java.lang.String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus";
     field public static final java.lang.String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash";
     field public static final java.lang.String FEATURE_CAMERA_FRONT = "android.hardware.camera.front";
+    field public static final java.lang.String FEATURE_CONSUMER_IR = "android.hardware.consumerir";
     field public static final java.lang.String FEATURE_DEVICE_ADMIN = "android.software.device_admin";
     field public static final java.lang.String FEATURE_FAKETOUCH = "android.hardware.faketouch";
     field public static final java.lang.String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct";
index 9203af9..b63db8a 100644 (file)
@@ -915,6 +915,14 @@ public abstract class PackageManager {
 
     /**
      * Feature for {@link #getSystemAvailableFeatures} and
+     * {@link #hasSystemFeature}: The device is capable of communicating with
+     * consumer IR devices.
+     */
+    @SdkConstant(SdkConstantType.FEATURE)
+    public static final String FEATURE_CONSUMER_IR = "android.hardware.consumerir";
+
+    /**
+     * Feature for {@link #getSystemAvailableFeatures} and
      * {@link #hasSystemFeature}: The device supports one or more methods of
      * reporting current location.
      */
index 07f2a41..783dff1 100644 (file)
@@ -39,6 +39,7 @@ import android.provider.Settings.SettingNotFoundException;
 import android.util.Slog;
 import android.view.InputDevice;
 
+import java.lang.RuntimeException;
 import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.ListIterator;
@@ -65,8 +66,12 @@ public class ConsumerIrService extends IConsumerIrService.Stub {
         mWakeLock.setReferenceCounted(true);
 
         mHal = halOpen();
-        if (mHal == 0) {
-            Slog.w(TAG, "No IR HAL loaded");
+        if (mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CONSUMER_IR)) {
+            if (mHal == 0) {
+                throw new RuntimeException("FEATURE_CONSUMER_IR present, but no IR HAL loaded!");
+            }
+        } else if (mHal != 0) {
+            throw new RuntimeException("IR HAL present, but FEATURE_CONSUMER_IR is not set!");
         }
     }