OSDN Git Service

add Eee PC hot keys support for mute, sleep and wifi
authorYi Sun <beyounn@gmail.com>
Sun, 23 Jan 2011 17:09:00 +0000 (01:09 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Fri, 5 Aug 2011 08:29:46 +0000 (16:29 +0800)
Change-Id: Iad1c9ec16ec1e153e07b60bc2db48d27ea7bd219

api/current.xml
core/java/android/content/Intent.java
services/java/com/android/server/WifiService.java

index 20f4cbb..32faba8 100644 (file)
  visibility="public"
 >
 </field>
+<field name="ACTION_WIFI_BUTTON"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.intent.action.WIFI_BUTTON&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="CATEGORY_ALTERNATIVE"
  type="java.lang.String"
  transient="false"
index de8e3f4..31926f4 100644 (file)
@@ -1727,6 +1727,8 @@ public class Intent implements Parcelable, Cloneable {
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
     public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
 
+    public static final String ACTION_WIFI_BUTTON = "android.intent.action.WIFI_BUTTON";
+
     // *** NOTE: @todo(*) The following really should go into a more domain-specific
     // location; they are not general-purpose actions.
 
index 647f115..3fa1e53 100644 (file)
@@ -303,6 +303,15 @@ public class WifiService extends IWifiManager.Stub {
 
         //Initiate a read of Wifi Ap configuration
         Message.obtain(mWifiHandler, MESSAGE_READ_WIFI_AP_CONFIG).sendToTarget();
+
+        mContext.registerReceiver(
+                new BroadcastReceiver() {
+                    @Override
+                    public void onReceive(Context context, Intent intent) {
+                        processWifiButton();
+                    }
+                },
+                new IntentFilter(Intent.ACTION_WIFI_BUTTON));
     }
 
     /**
@@ -379,6 +388,12 @@ public class WifiService extends IWifiManager.Stub {
         return (wifiSavedState == 1);
     }
 
+    private void processWifiButton( ) {
+        if (isAirplaneModeOn() != true) {
+            setWifiEnabled(getWifiEnabledState() == WIFI_STATE_DISABLED);
+        }
+    }
+
     private boolean getPersistedWifiEnabled() {
         final ContentResolver cr = mContext.getContentResolver();
         try {