virtual<二>

改动文件如下

 

froyo/frameworks/base/api/current.xml

line 167996 修改如下

 

 <method name="getHeight"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getHeightWithPanel"
 return="int"
 abstract="false"
 native="true"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>

 

line 168075 修改如下

 

<method name="getWidth"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getWidthWithPanel"
 return="int"
 abstract="false"
 native="true"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>

 

froyo\frameworks\base\core\java\android\view\Display.java

 

line 69  

把native public int getWidth(); 改成 如下方法

    public int getWidth() {
        if(getWidthWithPanel() > getHeightWithPanel()){
            return getWidthWithPanel() - 40;
        }else{
            return getWidthWithPanel();
        }       
    }

并且加入此方法:

    native public int getWidthWithPanel();

 

 

line 87

把native public int getHeight();改成如下方法

 public int getHeight() {
        if(getWidthWithPanel() > getHeightWithPanel()){
            return getHeightWithPanel();
        }else{
            return getHeightWithPanel() - 40;
        }

    }

并加入

    native public int getHeightWithPanel();

 

froyo\frameworks\base\core\java\android\view\IWindowManager.aidl

 

line 55 加入

boolean injectKeyEvent2(in KeyEvent ev, boolean sync);

 

froyo\frameworks\base\core\jni\android_view_Display.cpp

 

line 108:

把 {   "getWidth", "()I", 改成 {   "getWidthWithPanel", "()I",

line 110:
 把{   "getHeight", "()I", 改成 {   "getHeightWithPanel", "()I",

 

froyo\frameworks\base\services\java\com\android\server\InputDevice.java

 

line 838:

final int dispW = display.getWidth()-1;
final int dispH = display.getHeight()-1;

改成

 final int dispW = display.getWidthWithPanel()-1;
 final int dispH = display.getHeightWithPanel()-1;

 

 

froyo\frameworks\base\services\java\com\android\server\KeyInputQueue.java

 

line 51 加入 :import android.util.Log;

 

line 1382 加入 方法:

 

    public void addLocked2(KeyEvent ev) {
        Log.i(TAG, "addLocked2");
        synchronized (mFirst) {
            final int N = mDevices.size();
            for (int i=0; i<N; i++) {
                InputDevice d = mDevices.valueAt(i);
                if( (d != null) && ((d.classes&RawInputEvent.CLASS_KEYBOARD) != 0) ) {
                    addLocked(d, System.nanoTime(), 0, RawInputEvent.CLASS_KEYBOARD, ev);
                    Log.i(TAG, "addLocked2  .........");
                    break;
                }
            }
        }
    }

 

froyo\frameworks\base\services\java\com\android\server\WindowManagerService.java

 

line 5528 :加入

    public boolean injectKeyEvent2(KeyEvent ev, boolean sync) {
        mQueue.addLocked2(ev);
        return true;
    }

 

 

froyo\frameworks\base\services\java\com\android\server\status\StatusBarService.java

 

line 70:加入

import android.graphics.Color;
import android.widget.ImageView;

 

import android.os.ServiceManager;
import android.util.Log;
import android.view.IWindowManager;
import android.view.KeyCharacterMap;
import android.view.View.OnTouchListener;

 

line 98 :修改

把public class StatusBarService extends IStatusBar.Stub改成

public class StatusBarService extends IStatusBar.Stub implements OnTouchListener

 

line 244 加入:ImageView iv1, iv2, iv3, iv4;

 

line 364 加入:

        LinearLayout mSystemMenuBarView = (LinearLayout)View.inflate(mContext,
                com.android.internal.R.layout.control_panel, null);
        mSystemMenuBarView.setBackgroundColor(Color.BLACK);
        mSystemMenuBarView.setOrientation(LinearLayout.VERTICAL);
        iv1 = (ImageView) mSystemMenuBarView.findViewById(R.id.panel1);
        iv2 = (ImageView) mSystemMenuBarView.findViewById(R.id.panel2);
        iv3 = (ImageView) mSystemMenuBarView.findViewById(R.id.panel3);
        iv4 = (ImageView) mSystemMenuBarView.findViewById(R.id.panel4);
        iv1.setOnTouchListener(this);
        iv2.setOnTouchListener(this);
        iv3.setOnTouchListener(this);
        iv4.setOnTouchListener(this);

        WindowManager.LayoutParams lp1 = new WindowManager.LayoutParams(           
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW + 20,
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|//note by unic: this line of code make the activity content being in the front.
                WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING,
                PixelFormat.TRANSLUCENT);
//            lp1.gravity = Gravity.RIGHT | Gravity.FILL_VERTICAL;
        lp1.setTitle("systemMenuBar");

        WindowManagerImpl.getDefault().addView(mSystemMenuBarView, lp1);

 

 

line 1880加入:

 

  public boolean onTouch(View v, MotionEvent event) {
  if (event.getAction() == MotionEvent.ACTION_DOWN) {
            if (mDisplay.getWidth() > mDisplay.getHeight()) {
       switch (v.getId()) {
        case R.id.panel1:                   
                        iv1.setImageResource(R.drawable.panel_back_pressed);                   
         new Thread(new RunKey(KeyEvent.KEYCODE_BACK, KeyEvent.ACTION_DOWN)).start();
         break;    
        case R.id.panel2:
                        iv2.setImageResource(R.drawable.panel_search_pressed);
         new Thread(new RunKey(KeyEvent.KEYCODE_SEARCH, KeyEvent.ACTION_DOWN)).start();
         break;
        case R.id.panel3:
                        iv3.setImageResource(R.drawable.panel_menu_pressed);
         new Thread(new RunKey(KeyEvent.KEYCODE_MENU, KeyEvent.ACTION_DOWN)).start();
         break;     
        case R.id.panel4:
                        iv4.setImageResource(R.drawable.panel_home_pressed);                   
         new Thread(new RunKey(KeyEvent.KEYCODE_HOME, KeyEvent.ACTION_DOWN)).start();
         break;
       }
            }else{
                switch (v.getId()) {
        case R.id.panel1:                   
                        iv1.setImageResource(R.drawable.panel_home_pressed);                   
         new Thread(new RunKey(KeyEvent.KEYCODE_HOME, KeyEvent.ACTION_DOWN)).start();
         break;
        case R.id.panel2:
                        iv2.setImageResource(R.drawable.panel_menu_pressed);
         new Thread(new RunKey(KeyEvent.KEYCODE_MENU, KeyEvent.ACTION_DOWN)).start();
         break;
        case R.id.panel3:
                        iv3.setImageResource(R.drawable.panel_search_pressed);
         new Thread(new RunKey(KeyEvent.KEYCODE_SEARCH, KeyEvent.ACTION_DOWN)).start();              
         break;     
        case R.id.panel4:
                       iv4.setImageResource(R.drawable.panel_back_pressed);                   
         new Thread(new RunKey(KeyEvent.KEYCODE_BACK, KeyEvent.ACTION_DOWN)).start();
                        break;        
                }
            }       
  }
       
  if (event.getAction() == MotionEvent.ACTION_UP) {
            if (mDisplay.getWidth() > mDisplay.getHeight()) {
       switch (v.getId()) {
        case R.id.panel1:
                        iv1.setImageResource(R.drawable.panel_back);                   
         new Thread(new RunKey(KeyEvent.KEYCODE_BACK, KeyEvent.ACTION_UP)).start();
         break;    
        case R.id.panel2:
                        iv2.setImageResource(R.drawable.panel_search);                   
         new Thread(new RunKey(KeyEvent.KEYCODE_SEARCH, KeyEvent.ACTION_UP)).start();
         break;
        case R.id.panel3:
                        iv3.setImageResource(R.drawable.panel_menu);
         new Thread(new RunKey(KeyEvent.KEYCODE_MENU, KeyEvent.ACTION_UP)).start();
         break;     
        case R.id.panel4:
                        iv4.setImageResource(R.drawable.panel_home);
         new Thread(new RunKey(KeyEvent.KEYCODE_HOME, KeyEvent.ACTION_UP)).start();
         break;
       }
            }else {
       switch (v.getId()) {
        case R.id.panel1:
                        iv1.setImageResource(R.drawable.panel_home);
         new Thread(new RunKey(KeyEvent.KEYCODE_HOME, KeyEvent.ACTION_UP)).start();
         break;    
        case R.id.panel2:
                        iv2.setImageResource(R.drawable.panel_menu);
                        new Thread(new RunKey(KeyEvent.KEYCODE_MENU, KeyEvent.ACTION_UP)).start();

         break;
        case R.id.panel3:
                        iv3.setImageResource(R.drawable.panel_search);                   
         new Thread(new RunKey(KeyEvent.KEYCODE_SEARCH, KeyEvent.ACTION_UP)).start();
         break;     
        case R.id.panel4:
                        iv4.setImageResource(R.drawable.panel_back);                   
         new Thread(new RunKey(KeyEvent.KEYCODE_BACK, KeyEvent.ACTION_UP)).start();
         break;
                 }           
            }
  }
  return true;
 }
   
    private class RunKey implements Runnable{
  int code;
        int type;
  
  public void run() {      
   long now = SystemClock.uptimeMillis();      
   try {
             KeyEvent down = new KeyEvent(now, now, type, code, 0);            
             (IWindowManager.Stub
                 .asInterface(ServiceManager.getService("window")))
                 .injectKeyEvent2(down, true);               
         } catch (RemoteException e) {
             Log.i("Input", "DeadOjbectException");
         }
     }
  

        public RunKey (int keycode, int actionType){
         this.code = keycode;
            this.type = actionType;
        }
    }  

 

froyo\frameworks\policies\base\phone\com\android\internal\policy\impl\PhoneWindowManager.java

 

 

line 194 : 加入    WindowState mSystemMenuBar = null;   

 

 

line 766 :在 方法 public int windowTypeToLayerLw(int type) 中加入

 

case TYPE_STATUS_BAR + 20:
            return STATUS_BAR_LAYER + 20;

 

line 960 :在方法 public int prepareAddWindowLw(WindowState win, WindowManager.LayoutParams attrs)

中加入

 

 

case TYPE_STATUS_BAR + 20:
                if (mSystemMenuBar != null) {
                    return WindowManagerImpl.ADD_MULTIPLE_SINGLETON;
                }
                mSystemMenuBar = win;
                break;

 

 

 

line 992 : 在方法 public void removeWindowLw(WindowState win)中 加入

 

else if (mSystemMenuBar == win) {
            mSystemMenuBar = null;
        }

 

 

 

line 1251 在方法 public void beginLayoutLw(int displayWidth, int displayHeight 中加入

 

final Rect pf = mTmpParentFrame;
        final Rect df = mTmpDisplayFrame;
        final Rect vf = mTmpVisibleFrame;
        pf.left = df.left = vf.left = 0;
        pf.top = df.top = vf.top = 0;
        pf.right = df.right = vf.right = displayWidth;       
        pf.bottom = df.bottom = vf.bottom = displayHeight;       
           

 

 

并且 把

 

if (mStatusBar != null) {
            final Rect pf = mTmpParentFrame;
            final Rect df = mTmpDisplayFrame;
            final Rect vf = mTmpVisibleFrame;
            pf.left = df.left = vf.left = 0;
            pf.top = df.top = vf.top = 0;
            pf.right = df.right = vf.right = displayWidth;
            pf.bottom = df.bottom = vf.bottom = displayHeight;
           
            mStatusBar.computeFrameLw(pf, df, vf, vf);

改成

 if (mStatusBar != null) {
            mStatusBar.computeFrameLw(pf, df, vf, vf);

 

 

并在 line 1270  加入(加到方法beginLayoutLw中)

 

       if (displayWidth > displayHeight) {
            pf.left = df.left = vf.left = displayWidth;
            pf.right = df.right = vf.right = displayWidth + 40;
        } else {
            pf.top = df.top = vf.top = displayHeight;
            pf.bottom = df.bottom = vf.bottom = displayHeight + 40;
        }   

        if (mSystemMenuBar != null) {   
            mSystemMenuBar.computeFrameLw(pf, df, vf, vf);
        }   

 

 

 

line 1348  在方法 public void layoutWindowLw(WindowState win, WindowManager.LayoutParams attrs,
            WindowState attached) 中 加入 (line 1355)

 

if (win == mSystemMenuBar) {
            return;
        }

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值