[kk]投影息屏的功能开发

需求分析

投影息屏的功能说明

机器人在投影播放视频时,面部平板页面与投影页面保持一致,且处于常亮状态。若在比较暗的环境下观看,极大影响了观看投影的质量,同时也会分散观看人的注意力。解决方案是在开启投影后,可机器人面部平板可自定义息屏时间,在相应时间内屏幕无任何操作自动息屏,息屏后可通过点击屏幕拍头重新点亮屏幕。
在这里插入图片描述

系统提供的接口

讨论后决定系统端提供三个接口给app:

  1. 开启投影模式
  2. 关闭投影模式
  3. 当前是否是投影息屏模式

接口定义如下:

/*
*开启投影模式
*int:息屏延时
*/
public void startProjectShutdownMode(int time)


/*
*关闭投影模式
*
*/
public void stopProjectShutdownMode()


/*
*
*当前是否是投影息屏模式
*return:true false
*
*/
public boolean currentProjectShutdownMode()

系统端代码提交

frameworks

framework的修改分为两部分
1.投影息屏功能的支持
其实功能实现就是如果处于投影息屏模式的话,每一次input事件后启动一个延时关闭屏幕的息屏任务。如果期间无input事件,则息屏;如果出现了新的input事件,则刷新息屏任务的延时时间。
具体判断input事件的触发放到了userActivityFromNative方法中,在persist.sys.evolver.projecttime中保存的是息屏的时间,app会通过startProjectShutdownMode方法来设置该值。

2.增加面罩中间状态按键的支持。(原因见后面“遇到的问题”小结)

From ff765fc7046afa615c2ad54f647c2912c639f9be Mon Sep 17 00:00:00 2001
From: liuxiuquan <liuxiuquan@ren001.com>
Date: Wed, 21 Mar 2018 13:41:40 +0800
Subject: [PATCH] [liuxq]add for project shutdown screen

Change-Id: I9b7d71779fdbe0f3470dca20fdd18bb46dd4972f
---
 base/core/java/android/os/IPowerManager.aidl  |   5 +
 base/core/java/android/os/PowerManager.java   |  25 +++++
 base/core/java/android/view/KeyEvent.java     |   7 +-
 base/core/res/res/values/attrs.xml            |   5 +-
 .../policy/impl/PhoneWindowManager.java       |  48 +++++++--
 .../server/power/PowerManagerService.java     | 102 ++++++++++++++++++
 native/include/android/keycodes.h             |   1 +
 native/include/input/KeycodeLabels.h          |   1 +
 native/libs/input/Input.cpp                   |   1 +
 9 files changed, 183 insertions(+), 12 deletions(-)

diff --git a/base/core/java/android/os/IPowerManager.aidl b/base/core/java/android/os/IPowerManager.aidl
index 30d6b1c43..d2dde2d6e 100755
--- a/base/core/java/android/os/IPowerManager.aidl
+++ b/base/core/java/android/os/IPowerManager.aidl
@@ -59,4 +59,9 @@ interface IPowerManager
    	void bootFastWake(long time);
     boolean isBootFastStatus();
     boolean isBootFastWakeFromStandby();
+
+    //20180321 liuxq add for project shutdown screen
+    void startProjectShutdownMode(int time);
+    void stopProjectShutdownMode();
+    boolean currentProjectShutdownMode();
 }
diff --git a/base/core/java/android/os/PowerManager.java b/base/core/java/android/os/PowerManager.java
index 6ec68f3f3..d21998a35 100755
--- a/base/core/java/android/os/PowerManager.java
+++ b/base/core/java/android/os/PowerManager.java
@@ -514,6 +514,31 @@ public final class PowerManager {
         }
     }
 
+    //20180321 liuxq add for project shutdown screen begin
+    public void startProjectShutdownMode(int time) {
+        try {
+            mService.startProjectShutdownMode(time);
+        } catch (RemoteException e) {
+        }
+    }
+
+    public void stopProjectShutdownMode() {
+        try {
+            mService.stopProjectShutdownMode();
+        } catch (RemoteException e) {
+        }
+    }
+
+    public boolean currentProjectShutdownMode() {
+        boolean retValue = false;
+        try {
+            retValue=mService.currentProjectShutdownMode();
+        } catch (RemoteException e) {
+        }
+         return retValue;
+    }
+    //20180321 liuxq add for project shutdown screen end
+
     /**
      * Forces the device to start napping.
      * <p>
diff --git a/base/core/java/android/view/KeyEvent.java b/base/core/java/android/view/KeyEvent.java
index 8e2aa535d..b3f9ffd70 100644
--- a/base/core/java/android/view/KeyEvent.java
+++ b/base/core/java/android/view/KeyEvent.java
@@ -649,7 +649,7 @@ public class KeyEvent extends InputEvent implements Parcelable {
 
     public static final int KEYCODE_GESTURE_RIGHT = 230;
 
-    private static final int LAST_KEYCODE           = KEYCODE_GESTURE_RIGHT;
+    //private static final int LAST_KEYCODE           = KEYCODE_GESTURE_RIGHT;
 
     // NOTE: If you add a new keycode here you must also add it to:
     //  isSystem()
@@ -669,6 +669,11 @@ public class KeyEvent extends InputEvent implements Parcelable {
     public static final int KEYCODE_MASK_OPEN = 231;
     public static final int KEYCODE_MASK_CLOSE = 232;
     public static final int KEYCODE_HEADTOUCH = 233;
+    //20180321 liuxq add for project shutdown screen begin
+    public static final int KEYCODE_MASK_ONPROGRESS = 234;
+    private static final int LAST_KEYCODE = KEYCODE_GESTURE_RIGHT;
+    //20180321 liuxq add for project shutdown screen end
+
     // Symbolic names of all key codes.
     private static final SparseArray<String> KEYCODE_SYMBOLIC_NAMES = new SparseArray<String>();
     private static void populateKeycodeSymbolicNames() {
diff --git a/base/core/res/res/values/attrs.xml b/base/core/res/res/values/attrs.xml
index 19cf63384..478df4422 100644
--- a/base/core/res/res/values/attrs.xml
+++ b/base/core/res/res/values/attrs.xml
@@ -1342,7 +1342,9 @@
     <eat-comment />
 
     <!-- This enum provides the same keycode values as can be found in
-        {@link android.view.KeyEvent}. -->
+        {@link android.view.KeyEvent}.
+        20180321 liuxq add KEYCODE_MASK_ONPROGRESS for project shutdown screen
+     -->
     <attr name="keycode">
         <enum name="KEYCODE_UNKNOWN" value="0" />
         <enum name="KEYCODE_SOFT_LEFT" value="1" />
@@ -1578,6 +1580,7 @@
         <enum name="KEYCODE_MASK_OPEN" value="231" />
         <enum name="KEYCODE_MASK_CLOSE" value="232" />
         <enum name="KEYCODE_HEADTOUCH" value="233" />
+        <enum name="KEYCODE_MASK_ONPROGRESS" value="234" />
     </attr>
 
     <!-- ***************************************************************** -->
diff --git a/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 015fee8c5..1129f526f 100755
--- a/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -4560,17 +4560,16 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                 Log.d(TAG, "--KEYCODE_MASK_OPEN--  action="
                         + (event.getAction() == KeyEvent.ACTION_UP ? "ACTION_UP" : "ACTION_DOWN"));
 
-                if( (MASK_INIT_STATUS == 0||MASK_INIT_STATUS == 1) &&
+                /* if( (MASK_INIT_STATUS == 0||MASK_INIT_STATUS == 1) &&
                         event.getAction()==KeyEvent.ACTION_DOWN && MASK_INIT){
                     Log.d(TAG,"KEYCODE_MASK init status is open/close. skip ACTION_DOWN this time "+
                             " MASK_INIT_STATUS= "+MASK_INIT_STATUS+" MASK_INIT="+MASK_INIT);
                     MASK_INIT = false;
                     break;
-                }
+                }*/
 
-                if(event.getAction() == KeyEvent.ACTION_UP) {
-                    sendKeyBroadcast(2);
-                } else {
+                //20180321 liuxq add for project shutdown screen
+                if(event.getAction() == KeyEvent.ACTION_DOWN) {
                     sendKeyBroadcast(0);
                 }
                 break;
@@ -4579,21 +4578,30 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                 Log.d(TAG, "--KEYCODE_MASK_CLOSE-- action="
                         + (event.getAction() == KeyEvent.ACTION_UP ? "ACTION_UP" : "ACTION_DOWN"));
 
-                if( (MASK_INIT_STATUS == 0||MASK_INIT_STATUS == 1) &&
+               /*  if( (MASK_INIT_STATUS == 0||MASK_INIT_STATUS == 1) &&
                         event.getAction()==KeyEvent.ACTION_DOWN && MASK_INIT){
                     Log.d(TAG,"KEYCODE_MASK init status is OnProgress. skip ACTION_DOWN this time "+
                             " MASK_INIT_STATUS= "+MASK_INIT_STATUS+" MASK_INIT="+MASK_INIT);
                     MASK_INIT = false;
                     break;
-                }
+                }*/
 
-                if(event.getAction() == KeyEvent.ACTION_UP) {
-                    sendKeyBroadcast(2);
-                } else {
+                //20180321 liuxq add for project shutdown screen
+                if(event.getAction() == KeyEvent.ACTION_DOWN) {
                     sendKeyBroadcast(1);
                 }
                 break;
             }
+            //liuxq
+            case KeyEvent.KEYCODE_MASK_ONPROGRESS:{
+                Log.d(TAG, "KEYCODE_MASK_ONPROGRESS "+(down ? "down":"up")
+                            +". send KEYCODE_MASK_ONPROGRESS broadcast.");
+                if(event.getAction() == KeyEvent.ACTION_DOWN) {
+                    sendKeyBroadcast(2);
+                }
+
+                break;
+            }
             case KeyEvent.KEYCODE_HEADTOUCH:{
                 Log.d(TAG, "KEYCODE_HEADTOUCH "+(down ? "down":"up")
                             +". send HEADTOUCH broadcast.");
@@ -4610,6 +4618,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
     }
 
     private void sendKeyBroadcast(int key) {
+        //20180321 liuxq add for project shutdown screen begin
+        int lcd_delay_timeout = SystemProperties.getInt("persist.sys.evolver.projecttime", -1);
+        int projectOn=SystemProperties.getInt("persist.sys.evolver.project", 0);
+        //20180321 liuxq add for project shutdown screen end
+
         switch (key) {
             case 0:
                 Intent intentO = new Intent(Intent.ACTION_EVOLVER_MASK_STATUS_CHANGE);
@@ -4617,6 +4630,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                 mContext.sendBroadcast(intentO);
                 MASK_CLOSE = false;
                 Log.d(TAG, "send KEYCODE_MASK_OPEN broadcast. MASK_CLOSE="+MASK_CLOSE);
+                //20180321 liuxq add for project shutdown screen begin
+                if(projectOn==1&&lcd_delay_timeout!=-1&&!mPowerManager.currentProjectShutdownMode()){
+                    mPowerManager.startProjectShutdownMode(lcd_delay_timeout);
+                }
+                //20180321 liuxq add for project shutdown screen end
                 break;
             case 1:
                 Intent intentC = new Intent(Intent.ACTION_EVOLVER_MASK_STATUS_CHANGE);
@@ -4625,6 +4643,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                 mContext.sendBroadcast(intentC);
                 MASK_CLOSE = true;
                 Log.d(TAG, "send KEYCODE_MASK_CLOSE broadcast. MASK_CLOSE="+MASK_CLOSE);
+                //20180321 liuxq add for project shutdown screen begin
+                if(mPowerManager.currentProjectShutdownMode()){
+                    mPowerManager.stopProjectShutdownMode();
+                }
+                //20180321 liuxq add for project shutdown screen end
                 break;
             case 2:
                 Intent intentP = new Intent(Intent.ACTION_EVOLVER_MASK_STATUS_CHANGE);
@@ -4632,6 +4655,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                 mContext.sendBroadcast(intentP);
                 MASK_CLOSE = false;
                 Log.d(TAG, "send KEYCODE_MASK_ONPROGRESS broadcast. MASK_CLOSE="+MASK_CLOSE);
+                //20180321 liuxq add for project shutdown screen begin
+                if(projectOn==1&&lcd_delay_timeout!=-1&&!mPowerManager.currentProjectShutdownMode()){
+                    mPowerManager.startProjectShutdownMode(lcd_delay_timeout);
+                }
+                //20180321 liuxq add for project shutdown screen end
                 break;
             default:
                 Log.e(TAG, "KEY error");
diff --git a/base/services/java/com/android/server/power/PowerManagerService.java b/base/services/java/com/android/server/power/PowerManagerService.java
index 614810a7e..75e161316 100755
--- a/base/services/java/com/android/server/power/PowerManagerService.java
+++ b/base/services/java/com/android/server/power/PowerManagerService.java
@@ -392,6 +392,9 @@ public final class PowerManagerService extends IPowerManager.Stub
     // Time when we last logged a warning about calling userActivity() without permission.
     private long mLastWarningAboutUserActivityPermission = Long.MIN_VALUE;
 
+    //20180321 liuxq add for project shutdown screen
+    private boolean mHdmiConnect;
+
     private native void nativeInit();
 
     private static native void nativeSetPowerState(boolean screenOn, boolean screenBright);
@@ -898,6 +901,89 @@ public final class PowerManagerService extends IPowerManager.Stub
         }
     }
 
+
+    //20180321 liuxq add for project shutdown screen begin
+    private void turnonScreen(){
+        boolean LOGABLE = Log.isLoggable(TAG, Log.VERBOSE);
+        if(LOGABLE){
+            Slog.d(TAG,"liuxq L917 enter turnonScreen");
+        }
+        mHandler1.removeCallbacks(mScreenTimeout);
+        if(mTimeout){
+            try {
+                if(LOGABLE){
+                    Slog.d(TAG,"liuxq L925 enter turnOffLcdLight(false,mScreenBrightnessSetting)");//open the light
+                }
+                turnOffLcdLight(false,mScreenBrightnessSetting);
+            } catch (Exception e) {
+                Slog.e(TAG, "Exception"+e);
+            }
+        }
+        mTimeout=false;
+        lockScreenOff();
+    }
+
+    private void lockScreenOff() {
+       if(lcd_delay_timeout!=-1){
+         mHandler1.postAtTime(mScreenTimeout, SystemClock.uptimeMillis() + 1000 * lcd_delay_timeout);
+       }
+    }
+
+    @Override // Binder call
+    public void startProjectShutdownMode(int time) {
+        boolean LOGABLE = Log.isLoggable(TAG, Log.VERBOSE);
+        if(LOGABLE){
+            Slog.d(TAG,"liuxq L940 enter startProjectShutdownMode. time="+time);
+        }
+        lcd_delay_timeout=time;
+        mHdmiConnect=true;
+        turnonScreen();
+    }
+    @Override // Binder call
+    public void stopProjectShutdownMode() {
+        boolean LOGABLE = Log.isLoggable(TAG, Log.VERBOSE);
+        if(LOGABLE){
+            Slog.d(TAG,"liuxq L944 enter stopProjectShutdownMode.");
+        }
+        mHdmiConnect=false;
+        turnOffLcdLight(false, mScreenBrightnessSetting);
+        mHandler1.removeCallbacks(mScreenTimeout);
+    }
+
+    @Override // Binder call
+    public boolean currentProjectShutdownMode() {
+        boolean LOGABLE = Log.isLoggable(TAG, Log.VERBOSE);
+        if(LOGABLE){
+            Slog.d(TAG,"liuxq L949 enter currentProjectShutdownMode.mHdmiConnect="+mHdmiConnect);
+        }
+        return mHdmiConnect;
+    }
+
+    private int lcd_delay_timeout = -1;
+    private Handler mHandler1 = new Handler();
+    private boolean mTimeout=false;
+
+    Runnable mScreenTimeout = new Runnable() {
+        public void run() {
+            synchronized (this) {
+                if(mHdmiConnect==true){
+                    try {
+                        boolean LOGABLE = Log.isLoggable(TAG, Log.VERBOSE);
+                        if(LOGABLE){
+                            Slog.d(TAG,"liuxq L954 turnOffLcdLight(true, 0)");//shutdown light
+                        }
+                        turnOffLcdLight(true, 0);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }finally{
+                        mTimeout=true;
+                    }
+                }
+            }
+        }
+    };
+    //20180321 liuxq add for project shutdown screen end
+
     @Override // Binder call
     public void userActivity(long eventTime, int event, int flags) {
 
@@ -935,6 +1021,22 @@ public final class PowerManagerService extends IPowerManager.Stub
 
     // Called from native code.
     private void userActivityFromNative(long eventTime, int event, int flags) {
+    //20180321 liuxq add for project shutdown screen begin
+    boolean LOGABLE = Log.isLoggable(TAG, Log.VERBOSE);
+    if(LOGABLE){
+        Slog.d(TAG,"liuxq L938 userActivityFromNative,eventTime"+eventTime+",event="+event+",flags="+flags);
+    }
+
+    synchronized (mLock) {
+        if(mHdmiConnect==true){
+            if(LOGABLE){
+                Slog.d(TAG,"liuxq L1005 userActivityFromNative turnonScreen");
+            }
+            turnonScreen();//liuxq turn on the screen,and post a screen off delay
+        }
+    }
+    //20180321 liuxq add for project shutdown screen end
+
     	if(!mBootFastStats){
         	userActivityInternal(eventTime, event, flags, Process.SYSTEM_UID);
     	}else{
diff --git a/native/include/android/keycodes.h b/native/include/android/keycodes.h
index 1f9a370a6..141f15d7d 100644
--- a/native/include/android/keycodes.h
+++ b/native/include/android/keycodes.h
@@ -280,6 +280,7 @@ enum {
     AKEYCODE_MASK_OPEN       = 231,
     AKEYCODE_MASK_CLOSE      = 232,
     AKEYCODE_HEADTOUCH      = 233,
+    AKEYCODE_MASK_ONPROGRESS      = 234,//20180321 liuxq add for project shutdown screen
 };
 
 #ifdef __cplusplus
diff --git a/native/include/input/KeycodeLabels.h b/native/include/input/KeycodeLabels.h
index 5c3811513..d7af3f8e9 100644
--- a/native/include/input/KeycodeLabels.h
+++ b/native/include/input/KeycodeLabels.h
@@ -261,6 +261,7 @@ static const KeycodeLabel KEYCODES[] = {
     { "MASK_OPEN", 231 },
     { "MASK_CLOSE", 232 },
     { "HEADTOUCH", 233 },
+    { "MASK_ONPROGRESS", 234 },//20180321 liuxq add for project shutdown screen
     { NULL, 0 }
 };
 
diff --git a/native/libs/input/Input.cpp b/native/libs/input/Input.cpp
index b0274528b..f4574fa32 100644
--- a/native/libs/input/Input.cpp
+++ b/native/libs/input/Input.cpp
@@ -122,6 +122,7 @@ bool KeyEvent::isSystemKey(int32_t keyCode) {
         case AKEYCODE_MASK_OPEN:
         case AKEYCODE_MASK_CLOSE:
         case AKEYCODE_HEADTOUCH:
+        case AKEYCODE_MASK_ONPROGRESS://20180321 liuxq add for project shutdown screen
             return true;
     }
     
-- 
2.19.1

device

device的修改很简单:
1.增加property支持
2.在kl文件中增加面罩中间状态按键的支持。

From 0252364efa738104aa81872eb6e45ea6d86914de Mon Sep 17 00:00:00 2001
From: liuxiuquan <liuxiuquan@ren001.com>
Date: Wed, 21 Mar 2018 13:47:10 +0800
Subject: [PATCH] [liuxq]add for project shutdown screen

Change-Id: Iec229dda8e18179bb1f2aedd257fab5c7a70a590
---
 softwinner/fabo/fabo.mk                       | 4 ++++
 softwinner/kylin-p2/configs/sunxi-keyboard.kl | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/softwinner/fabo/fabo.mk b/softwinner/fabo/fabo.mk
index c9b34388..d899832a 100644
--- a/softwinner/fabo/fabo.mk
+++ b/softwinner/fabo/fabo.mk
@@ -208,6 +208,10 @@ PRODUCT_PROPERTY_OVERRIDES += \
 PRODUCT_PROPERTY_OVERRIDES += \
 	ro.update.mobile_app=0
 
+#20180321 liuxq add for project shutdown screen
+PRODUCT_PROPERTY_OVERRIDES += \
+    persist.sys.evolver.projecttime=-1
+
 $(call inherit-product-if-exists, device/softwinner/fabo/modules/modules.mk)
 
 PRODUCT_AAPT_CONFIG := xlarge hdpi xhdpi
diff --git a/softwinner/kylin-p2/configs/sunxi-keyboard.kl b/softwinner/kylin-p2/configs/sunxi-keyboard.kl
index 46ea1d32..e17af17f 100644
--- a/softwinner/kylin-p2/configs/sunxi-keyboard.kl
+++ b/softwinner/kylin-p2/configs/sunxi-keyboard.kl
@@ -3,3 +3,5 @@ key 115	  VOLUME_DOWN
 key 249   MASK_OPEN
 key 250   MASK_CLOSE
 key 251   HEADTOUCH
+# 20180321 liuxq add for project shutdown screen
+key 252   MASK_ONPROGRESS
-- 
2.19.1

kernel

增加面罩中间状态按键的支持,具体原因见下面“遇到的问题”

From 8619feff2a77b4ea6049003ee259ccf519c30529 Mon Sep 17 00:00:00 2001
From: liuxiuquan <liuxiuquan@ren001.com>
Date: Wed, 21 Mar 2018 13:49:02 +0800
Subject: [PATCH] [liuxq]add for project shutdown screen

Change-Id: I57aa2dc6b83dda58f50ea9691a7064bf9d6cd712
---
 .../drivers/input/keyboard/sun8i-keyboard.h   |  4 +-
 linux-3.4/drivers/input/keyboard/sunxi-vol.c  | 68 ++++++++++++-------
 linux-3.4/include/linux/input.h               |  3 +
 3 files changed, 50 insertions(+), 25 deletions(-)

diff --git a/linux-3.4/drivers/input/keyboard/sun8i-keyboard.h b/linux-3.4/drivers/input/keyboard/sun8i-keyboard.h
index f24952b17..e417b4cc6 100755
--- a/linux-3.4/drivers/input/keyboard/sun8i-keyboard.h
+++ b/linux-3.4/drivers/input/keyboard/sun8i-keyboard.h
@@ -9,7 +9,8 @@
 
 #define INPUT_DEV_NAME          ("sunxi-keyboard")
 
-#define KEY_MAX_CNT             (14)
+//20180321 liuxq add for project shutdown screen
+#define KEY_MAX_CNT             (15)
  
 #ifdef CONFIG_ARCH_SUN9IW1P1
 #define KEY_BASSADDRESS         (0xf6001800)
@@ -134,6 +135,7 @@ static unsigned int sunxi_scankeycodes[KEY_MAX_CNT] = {
 	[11] = KEY_MASKHIGH,
 	[12] = KEY_MASKLOW,
 	[13] = KEY_HEADTOUCH,
+	[14] = KEY_MASKPROGRESS,//20180321 liuxq add for project shutdown screen
 };
 #endif
 
diff --git a/linux-3.4/drivers/input/keyboard/sunxi-vol.c b/linux-3.4/drivers/input/keyboard/sunxi-vol.c
index 11929c7ea..e63c488e4 100644
--- a/linux-3.4/drivers/input/keyboard/sunxi-vol.c
+++ b/linux-3.4/drivers/input/keyboard/sunxi-vol.c
@@ -188,22 +188,32 @@ static void vol_check_func(struct work *work){
                 		mask_init = 0;
                 		printk("skip the first down. init status is open\n");
                 	}else{
-                		input_report_key(sunxikbd_dev,sunxi_scankeycodes[11], 1);
-                		input_sync(sunxikbd_dev);
+                        input_report_key(sunxikbd_dev,sunxi_scankeycodes[11], 1);
+                        input_sync(sunxikbd_dev);
+                        //20180321 liuxq add for project shutdown screen begin
+                        input_report_key(sunxikbd_dev,sunxi_scankeycodes[11], 0);
+                        input_sync(sunxikbd_dev);
+                        //20180321 liuxq add for project shutdown screen end
                 	}
                 }else{//highkey open
                         if (val1_init==2){
-								printk("evolve facemask init. val1= %d  val1_init =%d !\n",val1,val1_init);
-								//sc. action down event for init mask status
-								input_report_key(sunxikbd_dev,sunxi_scankeycodes[11], 1);
-								input_sync(sunxikbd_dev);
-								input_report_key(sunxikbd_dev,sunxi_scankeycodes[11], 0);
-								input_sync(sunxikbd_dev);
-								val2_init=val1_init=0;
+                            printk("evolve facemask init. val1= %d  val1_init =%d !\n",val1,val1_init);
+                            //sc. action down event for init mask status
+                            //20180321 liuxq add for project shutdown screen begin
+                            input_report_key(sunxikbd_dev,sunxi_scankeycodes[14], 1);
+                            input_sync(sunxikbd_dev);
+                            input_report_key(sunxikbd_dev,sunxi_scankeycodes[14], 0);
+                            //20180321 liuxq add for project shutdown screen end
+                            input_sync(sunxikbd_dev);
+                            val2_init=val1_init=0;
                         }else{
-                        		input_report_key(sunxikbd_dev,sunxi_scankeycodes[11], 0);
-                        		input_sync(sunxikbd_dev);
-                        	}
+                            //20180321 liuxq add for project shutdown screen begin
+                            input_report_key(sunxikbd_dev,sunxi_scankeycodes[14], 1);
+                            input_sync(sunxikbd_dev);
+                            input_report_key(sunxikbd_dev,sunxi_scankeycodes[14], 0);
+                            //20180321 liuxq add for project shutdown screen end
+                            input_sync(sunxikbd_dev);
+                        }
                 }
         }
 
@@ -215,21 +225,31 @@ static void vol_check_func(struct work *work){
                 		mask_init = 0;
                 		printk("skip the first down. init status is closed\n");
                 	}else{
-                		input_report_key(sunxikbd_dev,sunxi_scankeycodes[12], 1);
-                		input_sync(sunxikbd_dev);
+                        //20180321 liuxq add for project shutdown screen begin
+                        input_report_key(sunxikbd_dev,sunxi_scankeycodes[12], 1);
+                        input_sync(sunxikbd_dev);
+                        input_report_key(sunxikbd_dev,sunxi_scankeycodes[12], 0);
+                        input_sync(sunxikbd_dev);
+                        //20180321 liuxq add for project shutdown screen end
                 	}
                 }else{//lowkey open
                         if(val2_init==2){
-								printk("evolve facemask init. val2= %d  val2_init =%d !\n",val2,val2_init);
-								//sc. action down event for init mask status
-								input_report_key(sunxikbd_dev,sunxi_scankeycodes[12], 1);
-								input_sync(sunxikbd_dev);
-								input_report_key(sunxikbd_dev,sunxi_scankeycodes[12], 0);
-								input_sync(sunxikbd_dev);
-								val2_init=val1_init=0;
-                         }else{
-                        		input_report_key(sunxikbd_dev,sunxi_scankeycodes[12], 0);
-                        		input_sync(sunxikbd_dev);
+                            printk("evolve facemask init. val2= %d  val2_init =%d !\n",val2,val2_init);
+                            //sc. action down event for init mask status
+                            //20180321 liuxq add for project shutdown screen begin
+                            input_report_key(sunxikbd_dev,sunxi_scankeycodes[14], 1);
+                            input_sync(sunxikbd_dev);
+                            input_report_key(sunxikbd_dev,sunxi_scankeycodes[14], 0);
+                            //20180321 liuxq add for project shutdown screen end
+                            input_sync(sunxikbd_dev);
+                            val2_init=val1_init=0;
+                        }else{
+                            //20180321 liuxq add for project shutdown screen begin
+                            input_report_key(sunxikbd_dev,sunxi_scankeycodes[14], 1);
+                            input_sync(sunxikbd_dev);
+                            input_report_key(sunxikbd_dev,sunxi_scankeycodes[14], 0);
+                            //20180321 liuxq add for project shutdown screen end
+                            input_sync(sunxikbd_dev);
                     	}
                 }
         }
diff --git a/linux-3.4/include/linux/input.h b/linux-3.4/include/linux/input.h
index 60df515f6..d455d5514 100644
--- a/linux-3.4/include/linux/input.h
+++ b/linux-3.4/include/linux/input.h
@@ -479,6 +479,9 @@ struct input_keymap_entry {
 #define KEY_HEADTOUCH          251
 /* end */
 
+//20180321 liuxq add for project shutdown screen
+#define KEY_MASKPROGRESS        252
+
 
 /* Code 255 is reserved for special needs of AT keyboard driver */
 
-- 
2.19.1

app端调用

因为不想再提供新的android.jar给app了,所以给他们使用反射调用的方法,尽管效率可能慢点,不过确实方便了很多。

调用方法:
IPowerManager iWindowManager= IPowerManager.Stub.asInterface(
                ServiceManager.getService(Context.POWER_SERVICE));

//Class<?> cls=Class.forName("android.os.IPowerManager");
//开启
try {
    Class<?> cls=Class.forName("android.os.IPowerManager");
    int time=30;
    Method startProjectShutdownMode=cls.getDeclaredMethod("startProjectShutdownMode",int.class);
    startProjectShutdownMode.invoke(iWindowManager,time);
} catch (Exception e) {
    e.printStackTrace();
}
//关闭
try {
    Class<?> cls=Class.forName("android.os.IPowerManager");
    Method stopProjectShutdownMode=cls.getDeclaredMethod("stopProjectShutdownMode");
    stopProjectShutdownMode.invoke(iWindowManager);
} catch (Exception e) {
    e.printStackTrace();
}
//当前是否投影息屏模式
try {
    Class<?> cls=Class.forName("android.os.IPowerManager");
    Method currentProjectShutdownMode=cls.getDeclaredMethod("currentProjectShutdownMode");
    boolean res= (Boolean) currentProjectShutdownMode.invoke(iWindowManager);
    Log.d(TAG, "liuxq L158 currentProjectShutdownMode res="+res);
} catch (Exception e) {
    e.printStackTrace();
}

遇到的问题

开发的过程中发现当面罩连接的限位开关按下的情况下会一直上报按下的事件给userActivityFromNative

最后跟了下代码发现之前动的同学写面罩驱动时,kernel中按键按下只上报了一次按下事件,因为一直没有再报按键弹起的事件,系统会判断当前一直处于长按导致按下事件不停的上报。讨论后决定将这块的逻辑改成限位开关按下分别上报按键按下和弹起的事件,相应的限位开关弹起也报一对按键按下和弹起的事件。因此当限位开关弹起的时候,需要额外加入一个新的type的按键。

具体来说明一下
目前面罩用了两组限位开关:
记为key1,key2吧
在这里插入图片描述

之前的按键事件:

key1key2
按下keycode[11], 1keycode[12], 1
弹起keycode[11], 0keycode[11], 0

修改之后的按键事件:

key1key2
按下(keycode[11], 1) and (keycode[11], 0)(keycode[12], 1) and (keycode[12], 0)
弹起(keycode[14], 1) and (keycode[14], 0)(keycode[14], 1) and (keycode[14], 0)

一些补充

  1. app组开启投影会把状态存在SystemPropertypersist.sys.evolver.project1开启 0关闭
  2. 设置更新息屏延时的时候会把时间存在SystemPropertypersist.sys.evolver.projecttime(15,30,60,-1),其中-1是禁止息屏
  3. 设置中更新的息屏时间,如果是-1调用stopProjectShutdownMode方法,如果是其他值(15,30,60)调用startProjectShutdownMode(int time)方法
  4. 如果要屏蔽某个按键,可以在PhoneWindowManager中的interceptKeyBeforeQueueing方法&= ~ACTION_PASS_TO_USER来进行屏蔽操作
  5. 代码中有对面罩状态MASK的判断,这个根据实际情况来。我们定义的是当面罩关闭的时候退出投影息屏模式,如果需要重新进入由面罩关闭状态启动的app来控制。

代码基于kk

全志R16平台的Android6系统下调通rtl8189es 2017/8/28 9:41 版本:V1.1 1、干掉BT选项: Q:\r16m\rtl8189es_r16m\Android\device\softwinner\astar-evb30\overlay\frameworks\base\core\res\res\values\config.xml <!-- List of regexpressions describing the interface (if any) that represent tetherable bluetooth interfaces. If the device doesn't want to support tethering over bluetooth this should be empty. --> <!-- default: disable Bluetooth PAN feature --> <string-array translatable="false" name="config_tether_bluetooth_regexs"> <item>"bt-pan"</item> </string-array> 2、 Q:\r16m\rtl8189es_r16m\android\device\softwinner\astar-evb30\astar_evb30.mk $(call inherit-product, build/target/product/full_base.mk) $(call inherit-product, device/softwinner/astar-common/astar-common.mk) $(call inherit-product-if-exists, device/softwinner/astar-evb30/modules/modules.mk) DEVICE_PACKAGE_OVERLAYS := device/softwinner/astar-evb30/overlay \ $(DEVICE_PACKAGE_OVERLAYS) PRODUCT_PACKAGES += Launcher3 PRODUCT_PACKAGES += \ ESFileExplorer \ VideoPlayer #Bluetooth # PartnerChromeCustomizationsProvider PRODUCT_COPY_FILES += \ device/softwinner/astar-evb30/kernel:kernel \ device/softwinner/astar-evb30/fstab.sun8i:root/fstab.sun8i \ device/softwinner/astar-evb30/init.sun8i.rc:root/init.sun8i.rc \ device/softwinner/astar-evb30/init.recovery.sun8i.rc:root/init.recovery.sun8i.rc \ device/softwinner/astar-evb30/ueventd.sun8i.rc:root/ueventd.sun8i.rc \ device/softwinner/astar-evb30/recovery.fstab:recovery.fstab \ device/softwinner/astar-evb30/modules/modules/nand.ko:root/nand.ko \ device/softwinner/astar-evb30/modules/modules/disp.ko:root/disp.ko \ device/softwinner/astar-evb30/modules/modules/lcd.ko:root/lcd.ko \ device/softwinner/astar-evb30/modules/modules/gslX680new.ko:root/gslX680new.ko \ device/softwinner/astar-evb30/modules/modules/sunxi-keyboard.ko:root/sunxi-keyboard.ko \ device/softwinner/astar-evb30/modules/modules/sw-device.ko:root/sw-device.ko \ device/softwinner/astar-evb30/modules/modules/sunxi-keyboard.ko:obj/sunxi-keyboard.ko \ device/softwinner/astar-evb30/modules/modules/sw-device.ko:obj/sw-device.ko \ device/softwinner/astar-evb30/modules/modules/gslX680new.ko:obj/gslX680new.ko PRODUCT_COPY_FILES += \ frameworks/native/data/etc/android.hardware.camera.xml:system/etc/permissions/android.hardware.camera.xml \ frameworks/native/data/etc/android.hardware.camera.front.xml:system/etc/permissions/android.hardware.camera.front.xml \ frameworks/native/data/etc/android.hardware.ethernet.xml:system/etc/permissions/android.hardware.ethernet.xml #frameworks/native/data/etc/android.hardware.bluetooth.xml:system/etc/permissions/android.hardware.bluetooth.xml # Low mem(memory <= 512M) device should not copy android.software.managed_users.xml #PRODUCT_COPY_FILES += \ # frameworks/native/data/etc/android.software.managed_users.xml:system/etc/permissions/android.software.managed_users.xml PRODUCT_COPY_FILES += \ device/softwinner/astar-evb30/configs/camera.cfg:system/etc/camera.cfg \ device/softwinner/astar-evb30/configs/gsensor.cfg:system/usr/gsensor.cfg \ device/softwinner/astar-evb30/configs/media_profiles.xml:system/etc/media_profiles.xml \ device/softwinner/astar-evb30/configs/sunxi-keyboard.kl:system/usr/keylayout/sunxi-keyboard.kl \ device/softwinner/astar-evb30/configs/tp.idc:system/usr/idc/tp.idc #PRODUCT_COPY_FILES += \ # device/softwinner/astar-evb30/bluetooth/bt_vendor.conf:system/etc/bluetooth/bt_vendor.conf # bootanimation PRODUCT_COPY_FILES += \ device/softwinner/astar-evb30/media/bootanimation.zip:system/media/bootanimation.zip # camera config for camera detector #PRODUCT_COPY_FILES += \ # device/softwinner/astar-evb30/hawkview/sensor_list_cfg.ini:system/etc/hawkview/sensor_list_cfg.ini # Radio Packages and Configuration Flie $(call inherit-product, device/softwinner/common/rild/radio_common.mk) #$(call inherit-product, device/softwinner/common/ril_modem/huawei/mu509/huawei_mu509.mk) #$(call inherit-product, device/softwinner/common/ril_modem/Oviphone/em55/oviphone_em55.mk) #PRODUCT_PROPERTY_OVERRIDES += \ # limit dex2oat threads to improve thermals PRODUCT_PROPERTY_OVERRIDES += \ dalvik.vm.boot-dex2oat-threads=4 \ dalvik.vm.dex2oat-threads=3 \ dalvik.vm.image-dex2oat-threads=4 # Realtek wifi efuse map #PRODUCT_COPY_FILES += \ # device/softwinner/astar-d7/wifi_efuse_8723bs-vq0.map:system/etc/wifi/wifi_efuse_8723bs-vq0.map PRODUCT_PROPERTY_OVERRIDES += \ dalvik.vm.dex2oat-flags=--no-watch-dog \ dalvik.vm.jit.codecachesize=0 \ ro.am.reschedule_service=true PRODUCT_PROPERTY_OVERRIDES += \ ro.frp.pst=/dev/block/by-name/frp PRODUCT_PROPERTY_OVERRIDES += \ persist.sys.usb.config=mass_storage,adb \ ro.adb.secure=0 \ ro.sys.mutedrm=true \ rw.logger=0 # A33 Media PRODUCT_PROPERTY_OVERRIDES += \ ro.config.media=1 PRODUCT_PROPERTY_OVERRIDES += \ dalvik.vm.heapsize=384m \ dalvik.vm.heapstartsize=8m \ dalvik.vm.heapgrowthlimit=80m \ dalvik.vm.heaptargetutilization=0.75 \ dalvik.vm.heapminfree=512k \ dalvik.vm.heapmaxfree=8m \ ro.zygote.disable_gl_preload=false #PRODUCT_PROPERTY_OVERRIDES += \ # ro.config.low_ram=true PRODUCT_PROPERTY_OVERRIDES += \ ro.sf.lcd_density=213 PRODUCT_PROPERTY_OVERRIDES += \ persist.sys.timezone=Asia/Shanghai \ persist.sys.country=CN \ persist.sys.language=zh # stoarge PRODUCT_PROPERTY_OVERRIDES += \ persist.fw.force_adoptable=true PRODUCT_CHARACTERISTICS := tablet PRODUCT_AAPT_CONFIG := mdpi PRODUCT_AAPT_PREF_CONFIG := mdpi #$(call inherit-product-if-exists, vendor/google/products/gms_base.mk) #for 8723bs-vq0,should setmacaddr #PRODUCT_PACKAGES += setmacaddr PRODUCT_BRAND := Allwinner PRODUCT_NAME := astar_evb30 PRODUCT_DEVICE := astar-evb30 PRODUCT_MODEL := QUAD-CORE R16 evb30 PRODUCT_MANUFACTURER := Allwinner 3、在这里配置你所使用的WIFI+BT: Q:\r16m\rtl8189es_r16m\android\device\softwinner\astar-evb30\BoardConfig.mk # wifi and bt configuration # 1. Wifi Configuration # 1.1 realtek wifi support # 1.1 realtek wifi configuration # BOARD_USR_WIFI: rtl8188eu/rtl8723bs/rtl8723bs_vq0/rtl8723cs BOARD_WIFI_VENDOR := realtek ifeq ($(BOARD_WIFI_VENDOR), realtek) WPA_SUPPLICANT_VERSION := VER_0_8_X BOARD_WPA_SUPPLICANT_DRIVER := NL80211 BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_rtl BOARD_HOSTAPD_DRIVER := NL80211 BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_rtl #BOARD_USR_WIFI := rtl8723bs_vq0 #BOARD_USR_WIFI := rtl8188eu BOARD_USR_WIFI := rtl8189es include hardware/realtek/wlan/config/config.mk endif # 1.2 broadcom wifi support #BOARD_WIFI_VENDOR := broadcom ifeq ($(BOARD_WIFI_VENDOR), broadcom) BOARD_WPA_SUPPLICANT_DRIVER := NL80211 WPA_SUPPLICANT_VERSION := VER_0_8_X BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_bcmdhd BOARD_HOSTAPD_DRIVER := NL80211 BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_bcmdhd BOARD_WLAN_DEVICE := bcmdhd WIFI_DRIVER_FW_PATH_PARAM := "/sys/module/bcmdhd/parameters/firmware_path" BOARD_USR_WIFI := ap6212 include hardware/broadcom/wlan/bcmdhd/firmware/$(BOARD_USR_WIFI)/device-bcm.mk endif ## 2. Bluetooth Configuration ## make sure BOARD_HAVE_BLUETOOTH is true for every bt vendor #BOARD_HAVE_BLUETOOTH := true #BOARD_HAVE_BLUETOOTH_BCM := true #BOARD_HAVE_BLUETOOTH_NAME := ap6212 #BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := device/softwinner/astar-evb30/bluetooth TARGET_USE_BOOSTUP_OPZ := true 4、 Q:\r16m\rtl8189es_r16m\android\device\softwinner\astar-evb30\init.sun8i.rc ## bluetooth # # UART device # chmod 0660 /dev/ttyS1 # chown bluetooth net_bt_stack /dev/ttyS1 # # # power up/down interface # chmod 0660 /sys/class/rfkill/rfkill0/state # chmod 0660 /sys/class/rfkill/rfkill0/type # chown bluetooth net_bt_stack /sys/class/rfkill/rfkill0/state # chown bluetooth net_bt_stack /sys/class/rfkill/rfkill0/type # # # bluetooth MAC address programming # chown bluetooth net_bt_stack ro.bt.bdaddr_path # chown bluetooth net_bt_stack /system/etc/bluetooth # chown bluetooth net_bt_stack /data/misc/bluetooth # setprop ro.bt.bdaddr_path "/data/misc/bluetooth/bdaddr" # # # bluetooth LPM # chmod 0220 /proc/bluetooth/sleep/lpm # chmod 0220 /proc/bluetooth/sleep/btwrite # chown bluetooth net_bt_stack /proc/bluetooth/sleep/lpm # chown bluetooth net_bt_stack /proc/bluetooth/sleep/btwrite ## broadcom wifi service ## 1 broadcom wifi sta service #service wpa_supplicant /system/bin/wpa_supplicant \ # -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \ # -I/system/etc/wifi/wpa_supplicant_overlay.conf \ # -O/data/misc/wifi/sockets \ # -e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0 # # we will start as root and wpa_supplicant will switch to user wifi # # after setting up the capabilities required for WEXT # # user wifi # # group wifi inet keystore # class main # socket wpa_wlan0 dgram 660 wifi wifi # disabled # oneshot # ## 2 broadcom wifi sta p2p concurrent service #service p2p_supplicant /system/bin/wpa_supplicant \ # -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \ # -I/system/etc/wifi/wpa_supplicant_overlay.conf \ # -O/data/misc/wifi/sockets -N \ # -ip2p0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf \ # -I/system/etc/wifi/p2p_supplicant_overlay.conf \ # -puse_p2p_group_interface=1 -e/data/misc/wifi/entropy.bin \ # -g@android:wpa_wlan0 # # we will start as root and wpa_supplicant will switch to user wifi # # after setting up the capabilities required for WEXT # # user wifi # # group wifi inet keystore # class main # socket wpa_wlan0 dgram 660 wifi wifi # disabled # oneshot # realtek wifi service service wpa_supplicant /system/bin/logwrapper /system/bin/wpa_supplicant \ -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \ -O/data/misc/wifi/sockets \ -e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0 class main socket wpa_wlan0 dgram 660 wifi wifi disabled oneshot # 1.2 realtek wifi sta p2p concurrent service service p2p_supplicant /system/bin/logwrapper /system/bin/wpa_supplicant \ -ip2p0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf \ -e/data/misc/wifi/entropy.bin -N \ -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \ -O/data/misc/wifi/sockets \ -g@android:wpa_wlan0 class main socket wpa_wlan0 dgram 660 wifi wifi disabled oneshot 5、可选:为了调试方便 Q:\r16m\rtl8189es_r16m\android\frameworks\base\packages\SettingsProvider\res\values\defaults.xml <integer name="def_screen_off_timeout">60000</integer> <bool name="def_lockscreen_disabled">false</bool> 修改为: <integer name="def_screen_off_timeout">1800000</integer> <bool name="def_lockscreen_disabled">true</bool> 6、解决编译不过的问题。rtl8189es没有BT: Q:\r16m\rtl8189es_r16m\android\hardware\realtek\bluetooth\firmware\rtlbtfw_cfg.mk PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/rtl8723a_fw:system/etc/firmware/rtl8723as_fw \ $(LOCAL_PATH)/rtl8723a_config:system/etc/firmware/rtl8723as_config \ $(LOCAL_PATH)/rtl8723b_fw:system/etc/firmware/rtl8723bs_fw \ $(LOCAL_PATH)/rtl8723b_config:system/etc/firmware/rtl8723bs_config \ $(LOCAL_PATH)/rtl8723b_VQ0_fw:system/etc/firmware/rtl8723bs_VQ0_fw \ $(LOCAL_PATH)/rtl8723b_VQ0_config:system/etc/firmware/rtl8723bs_VQ0_config \ $(LOCAL_PATH)/rtl8723cs_xx_fw:system/etc/firmware/rtl8723cs_xx_fw \ $(LOCAL_PATH)/rtl8723cs_xx_config:system/etc/firmware/rtl8723cs_xx_config \ $(LOCAL_PATH)/rtl8723cs_cg_fw:system/etc/firmware/rtl8723cs_cg_fw \ $(LOCAL_PATH)/rtl8723cs_cg_config:system/etc/firmware/rtl8723cs_cg_config \ $(LOCAL_PATH)/rtl8723cs_vf_fw:system/etc/firmware/rtl8723cs_vf_fw \ $(LOCAL_PATH)/rtl8723cs_vf_config:system/etc/firmware/rtl8723cs_vf_config \ $(LOCAL_PATH)/rtl8703b_fw:system/etc/firmware/rtl8703bs_fw \ $(LOCAL_PATH)/rtl8703b_config:system/etc/firmware/rtl8703bs_config #$(TOP_DIR)device/softwinner/$(basename $(TARGET_DEVICE))/bluetooth/rtkbt.conf:system/etc/bluetooth/rtkbt.conf \ 7、默认的BSP没有加载rtl8189es Q:\r16m\rtl8189es_r16m\android\hardware\libhardware_legacy\wifi\Android.mk # realtek sdio wifi module ifeq ($(BOARD_USR_WIFI), rtl8189fs) LOCAL_CFLAGS += -DRTL_8189FS_WIFI_USED LOCAL_CFLAGS += -DRTL_WIFI_VENDOR endif # realtek sdio wifi module ifeq ($(BOARD_USR_WIFI), rtl8189es) LOCAL_CFLAGS += -DRTL_8189ES_WIFI_USED LOCAL_CFLAGS += -DRTL_WIFI_VENDOR endif Q:\r16m\rtl8189es_r16m\android\hardware\libhardware_legacy\wifi\wifi.c #elif defined RTL_8189FS_WIFI_USED /* rtl8189FS sdio wifi */ #ifndef WIFI_DRIVER_MODULE_PATH #define WIFI_DRIVER_MODULE_PATH "/system/vendor/modules/8189fs.ko" #endif #ifndef WIFI_DRIVER_MODULE_NAME #define WIFI_DRIVER_MODULE_NAME "8189fs" #endif #ifndef WIFI_DRIVER_MODULE_ARG #define WIFI_DRIVER_MODULE_ARG "ifname=wlan0 if2name=p2p0" #endif #elif defined RTL_8189ES_WIFI_USED /* rtl8189ES sdio wifi */ #ifndef WIFI_DRIVER_MODULE_PATH #define WIFI_DRIVER_MODULE_PATH "/system/vendor/modules/8189es.ko" #endif #ifndef WIFI_DRIVER_MODULE_NAME #define WIFI_DRIVER_MODULE_NAME "8189es" #endif #ifndef WIFI_DRIVER_MODULE_ARG #define WIFI_DRIVER_MODULE_ARG "ifname=wlan0 if2name=p2p0" #endif #elif defined ESPRESSIF_ESP8089_WIFI_USED /* esp8089 sdio wifi */ #ifndef WIFI_DRIVER_MODULE_PATH #define WIFI_DRIVER_MODULE_PATH "/system/vendor/modules/esp8089.ko" #endif #ifndef WIFI_DRIVER_MODULE_NAME #define WIFI_DRIVER_MODULE_NAME "esp8089" #endif #ifndef WIFI_DRIVER_MODULE_ARG #define WIFI_DRIVER_MODULE_ARG "" #endif #endif 8、WIFI+BT的驱动识别: Q:\r16m\rtl8189es_r16m\lichee\Linux-3.4\drivers\misc\rf_pm\bt_pm.c static int rfkill_set_power(void *data, bool blocked) { unsigned int mod_sel = get_rf_mod_type(); RF_MSG("rfkill set power %d\n", !blocked); switch (mod_sel){ case 2: /* ap6210 */ case 5: /* rtl8723bs */ case 7: /* ap6476 */ case 8: /* ap6330 */ case 9: /* gb9663 */ case 10: /* ap6212 */ if (!blocked) { if(bt_rst_n != -1) gpio_set_value(bt_rst_n, 1); } else { if(bt_rst_n != -1) gpio_set_value(bt_rst_n, 0); } break; default: RF_MSG("no bt module matched !!\n"); } bt_state = !blocked; msleep(10); return 0; } Q:\r16m\rtl8189es_r16m\lichee\linux-3.4\drivers\misc\rf_pm\rf_pm.c char *module_list[] = { " ", "ap6181", "ap6210", "rtl8188eu", "rtl8723au", "rtl8723bs", "esp8089", "ap6476", "ap6330", "gb9663", "ap6212", "rtl8189es" }; static int rf_pm_probe(struct platform_device *pdev) { get_module_res(); if (mod_info.num <= 0) return -1; //moduls power init switch(mod_info.num){ case 1: /* ap6181 */ case 2: /* ap6210 */ case 5: /* rtl8723bs */ case 6: /* esp8089 */ case 7: /* ap6476 */ case 8: /* ap6330 */ case 9: /* gb9663 */ case 10: /* ap6212 */ case 11: /* rtl8189es */ rf_module_power(1); break; case 3: /* rtl8188eu */ case 4: /* rtl8723au */ rf_module_power(0); break; default: rf_pm_msg("wrong module select %d !\n", mod_info.num); } //opt ap 32k if(mod_info.lpo_use_apclk && strcmp(mod_info.lpo_use_apclk, "")){ ap_32k = clk_get(NULL, mod_info.lpo_use_apclk); if (!ap_32k || IS_ERR(ap_32k)){ rf_pm_msg("get clk %s failed!\n", mod_info.lpo_use_apclk); return -1; } rf_pm_msg("set %s 32k out\n", mod_info.lpo_use_apclk); enable_ap_32k(1); } scene_lock_init(&gpio_hold_standby, SCENE_GPIO_HOLD_STANDBY, "rf_pm"); return 0; } Q:\r16m\rtl8189es_r16m\lichee\linux-3.4\drivers\misc\rf_pm\wifi_pm.c void wifi_pm_power(int on) { int mod_num = get_rf_mod_type(); int on_off = 0; if (on > 0){ on_off = 1; } else { on_off = 0; } wifi_pm_msg("wifi power %s\n", on?"on":"off"); switch(mod_num){ case 1: /* ap6181 */ case 2: /* ap6210 */ case 5: /* rtl8723bs */ case 6: /* esp8089 */ case 7: /* ap6476 */ case 8: /* ap6330 */ case 9: /* gb9663*/ case 10: /* ap6212 */ case 11: /* rtl8189es */ if (wl_info.wl_reg_on != -1) gpio_set_value(wl_info.wl_reg_on, on_off); break; case 3: /* rtl8188eu */ rf_module_power(on_off); break; case 4: /* rtl8723au */ break; default: wifi_pm_msg("wrong module select %d !\n", mod_num); } wl_info.wl_power_state = on_off; wifi_state = on_off; } EXPORT_SYMBOL(wifi_pm_power); 9、直接使用全志R16平台的parrot v1.1系统下的rtl8189es驱动代替。Android6.0.1自带的驱动貌似有问题! Q:\r16m\rtl8189es_r16m\lichee\linux-3.4\drivers\net\wireless\rtl8189es\ rootroot@rootroot-E400:~/wyb/rtl8189es_r16m$ 7za x rtl8189es_r16m验证通过20170818_1659没有外层目录.7z -r -o./ rootroot@rootroot-E400:~/wyb/rtl8189es_r16m$ cd lichee/linux-3.4/drivers/net/wireless/ rootroot@rootroot-E400:~/wyb/rtl8189es_r16m/lichee/linux-3.4/drivers/net/wireless$ rootroot@rootroot-E400:~/wyb/rtl8189es_r16m/lichee/linux-3.4/drivers/net/wireless$ rm rtl8189es -rf rootroot@rootroot-E400:~/wyb/rtl8189es_r16m/lichee/linux-3.4/drivers/net/wireless$ tar zxvf rtl8189es4.tar.gz 10、可选操作:为了调试方便 Q:\r16m\rtl8189es_r16m\lichee\tools\pack\chips\sun8iw5p1\configs\default\env.cfg #kernel command arguments console=ttyS0,115200 nand_root=/dev/nandd mmc_root=/dev/mmcblk0p7 init=/init loglevel=8 #set kernel cmdline if boot.img or recovery.img has no cmdline we will use this setargs_nand=setenv bootargs console=${console} root=${nand_root} init=${init} ion_cma_list="120m,256m" loglevel=${loglevel} partitions=${partitions} setargs_mmc=setenv bootargs console=${console} root=${mmc_root} init=${init} ion_cma_list="120m,256m" loglevel=${loglevel} partitions=${partitions} #nand command syntax: sunxi_flash read address partition_name read_bytes #0x40007800 = 0x40008000(kernel entry) - 0x800(boot.img header 2k) boot_normal=sunxi_flash read 40007800 boot;boota 40007800 boot_recovery=sunxi_flash read 40007800 recovery;boota 40007800 boot_fastboot=fastboot #recovery key recovery_key_value_max=0x13 recovery_key_value_min=0x10 #fastboot key fastboot_key_value_max=0x8 fastboot_key_value_min=0x2 #uboot system env config bootdelay=3 #default bootcmd, will change at runtime according to key press bootcmd=run setargs_nand boot_normal#default nand boot 11、 Q:\r16m\rtl8189es_r16m\lichee\tools\pack\chips\sun8iw5p1\configs\evb-30\sys_config.fex ;--------------------------------------------------------------------------------------------------------- ; wakeup_src_para: ; sometimes, u would like to add more wakeup src in standby mode, these para will be ; help; ; u need to make sure the standby mode support the wakeup src. Also, some hw ; condition must be guaranteed. ; including: ; cpu_en: power on or off. ; 1: mean power on ; 0: mean power off ; cpu_freq: indicating lowest freq. unit is Mhz; ; dram selfresh_en: selfresh or not. ; 1: enable enter selfresh ; 0: disable enter selfresh ; dram_pll: if not enter selfresh, indicating lowest freq. unit is Mhz; ; wakeup_src: to make the scenario work, the wakeup src is needed. ;--------------------------------------------------------------------------------------------------------- [wakeup_src_para] cpu_en = 0 cpu_freq = 48 ; (cpu:apb:ahb) pll_ratio = 0x111 dram_selfresh_en= 1 dram_freq = 36 wakeup_src_wl = port:PL07<4><default><default><0> ;wakeup_src_bt = port:PL09<4><default><default><0> bb_wake_ap = port:PL02<4><default><default><0> ;-------------------------------------------------------------------------------- ;wifi/bt/fm/gps/nfc modules configuration ;module_num: ; 0- none ; 1- ap6181(wifi) ; 2- ap6210/ap6212(wifi+bt) ; 3- rtl8188eu(wifi) ; 4- rtl8723au(wifi+bt) ; 5- rtl8723bs/rtl8723bs-vq0(wifi+bt) ; 6- esp8089(wifi) ; 7- ap6476(wifi+bt+fm+gps) ; 8- ap6330(wifi+bt+fm) ; 9- gb9663(wifi+bt+fm) ; 10- ap6212(wifi+bt) ; 11- rtl8189es(wifi) ;module_power1: ""- bat, "axp_dldo1"- axp dldo1 ;module_power1_vol: power1 voltage, mv; not used for module_power1 is "" ;module_power2: ""- bat, "axp_dldo2"- axp dldo2 ;module_power2_vol: power2 voltage, mv; not used for module_power2 is "" ;module_power3: ""- bat, "axp_dldo2"- axp dldo2 ;module_power3_vol: power3 voltage, mv; not used for module_power3 is "" ;power_switch: module power switch io when bat supply ;chip_en: enable chip io ;lpo_use_apclk: ""- not use, "losc_out"- a23/33, "ac10032k1"?"ac10032k2"?"ac10032k3"- a80/a83 ;-------------------------------------------------------------------------------- [rf_para] module_num = 11 module_power1 = "axp22_dldo1" module_power1_vol = 3300000 module_power2 = "axp22_dldo2" module_power2_vol = 3300000 module_power3 = "axp22_aldo1" module_power3_vol = 3300000 power_switch = chip_en = lpo_use_apclk = "losc_out" ;-------------------------------------------------------------------------------- ;wifi configuration ;wifi_used: 0-not use, 1- use ;wifi_sdc_id: 0- SDC0, 1- SDC1, 2- SDC2, 3- SDC3 ;wifi_usbc_id: 0- USB0, 1- USB1, 2- USB2 ;wifi_usbc_type: 1- EHCI(speed 2.0), 2- OHCI(speed 1.0) ;wl_reg_on: wifi function enable io ;wl_host_wake: wifi device wake-up host ;wl_host_wake_invert: whether wl_host_wake use inverter between ap and module ; 0: not used, 1: used ;-------------------------------------------------------------------------------- [wifi_para] wifi_used = 1 wifi_sdc_id = 1 wifi_usbc_id = 1 wifi_usbc_type = 1 wl_reg_on = port:PL06<1><default><default><0> wl_host_wake = port:PL07<4><default><default><0> rtl8189es_host_wake = port:PL07<4><default><default><0> wl_host_wake_invert = 0 ;-------------------------------------------------------------------------------- ;bluetooth configuration ;bt_used: 0- no used, 1- used ;bt_uard_id: 0- uart0, 1- uart1, 2- uart2 ;bt_rst_n: bt function enable io ;bt_wake: host wake-up bluetooth device ;bt_wak_host: bt device wake-up host ;bt_host_wake_invert: whether bt_host_wake use inverter between ap and module ; 0: not used, 1: used ;-------------------------------------------------------------------------------- [bt_para] bt_used = 0 ;bt_uart_id = 1 ;bt_rst_n = port:PL08<1><default><default><0> ;bt_wake = port:PL10<1><default><default><0> ;bt_host_wake = port:PL09<4><default><default><0> ;bt_host_wake_invert = 0 power_start = 3 pmu_temp_enable = 0
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值