Android 4.0 虚拟按键、手机模式、平板模式

关键词:android 4.0 手机模式(phone)  平板模式(table)  虚拟按键  lcd_density

平台信息:
内核:linux2.6/linux3.0
系统:android/android4.0 
平台:S5PV310(samsungexynos4210/4412)

    三星新拿回来来的BSP,编译后没有“返回、最近打开应用、home”三个虚拟键。我们硬件在设计的时候也没有设定相应的物理按键,平时调试程序的时候比较麻烦。怎么把这三个按键显示出来??下面我们来说明。

    同时在开始分析问前我引入另外两个问题:

    table 模式、phone模式选择;

    lcd_density参数设定,来决定图标密度大小。

一、引入问题:

1、 手机模式、平板模式

android4.0手机模式、平板模式两种情况 界面的主体布局不太一样,如下图所示。



2、lcd_density

ro.sf.lcd_density=240 和ro.sf.lcd_density=160两种不同的现象,很明显说明这个参数的做用。后面我们遇到一个问题要从这里说明。


  1. To change the density of the screen change /system/build.prop  
  2. ro.sf.lcd_density=240   
  3. high-density, at the right of the picture, comes by default in the mephisto's roms.  
  4. ro.sf.lcd_density=180   
  5. low density, at the left of the picture  
  6. (This means that the number of pixels per inch is 240=800/3.5"   
  7. 3.5" is the screen of the H1 and 800×480 display resolution).  
  8. So you can pick any number between 240 and 180 - personally I use 220.  
  9. You can do this using root explorer apk for instance:  
To change the density of the screen change /system/build.prop
ro.sf.lcd_density=240 
high-density, at the right of the picture, comes by default in the mephisto's roms.
ro.sf.lcd_density=180 
low density, at the left of the picture
(This means that the number of pixels per inch is 240=800/3.5" 
3.5" is the screen of the H1 and 800×480 display resolution).
So you can pick any number between 240 and 180 - personally I use 220.
You can do this using root explorer apk for instance:

二、问题分析

1、参考网友的说法:

将\frameworks\base\core\res\res\values\config.xml中的下面属性的值改为true;

  1. <bool name="config_showNavigationBar">false</bool>  
<bool name="config_showNavigationBar">false</bool>

状态:

  1. 模式:phone  
  2. 参数:config_showNavigationBar=true  
模式:phone
参数:config_showNavigationBar=true

出现以下情况:

1)、虚拟按键边上那个黑框已经出来;
2)、看不到三个按键图标;
3)、点击边缘时会有颜色变化,横屏是返回键,竖屏时点击为最近打开程序感觉那个按键被放大了一样。 由上面分析,这种现象是布局出问题,我们LCD分辨率为1280*800,其实三个按键出来了,只不过图标显示太大,所以我们看不到。同时在这里我们引入前面我们提到的两个问题:(1)、table 模式、phone模式选择;(2)lcd_density参数设定,来决定图标密度大小。

    很明显的我们可以看出现在编译的时phone模式、那个图标为什么看不到, lcd­_density设定的图标太大。

2、问题分析

    打开机器,在串口终端或者是adb shell中:

cd/system

catdefault.prop


我们可以看到:

  1. ro.build.characteristics=phone  
ro.build.characteristics=phone

这就是我们所说的table、phone参数设定,不同的模式在这里决定的。查找这些参数在那里设定,最终找到:

android_ramos_4412_02/android/device/samsung/smdk4x12/device.mk

  1. ifeq ($(BOARD_USES_HIGH_RESOLUTION_LCD),true) //(1)、如果满足条件,就设为table模式;  
  2. PRODUCT_CHARACTERISTICS :tablet  
  3. PRODUCT_COPY_FILES += \ frameworks/base/data/etc/tablet_core_hardware.xml:system/etc/permissions/tablet_core_hardware.xml  
  4. $(call inherit-product, frameworks/base/build/tablet-dalvik-heap.mk)   
  5. else   
  6. PRODUCT_CHARACTERISTICS :phone //(2)、满足条件就设为phone模式;  
  7. PRODUCT_COPY_FILES += \   
  8. frameworks/base/data/etc/handheld_core_hardware.xml:system/etc/permissions/handheld_core_hardware.xml   
  9. $(call inherit-product, frameworks/base/build/phone-hdpi-512-dalvik-heap.mk) PRODUCT_PROPERTY_OVERRIDES += \   
  10. ro.sf.lcd_density=240                //(3)、lcd_density设定。  
  11. PRODUCT_AAPT_CONFIG :normal hdpi   
  12. Endif  
ifeq ($(BOARD_USES_HIGH_RESOLUTION_LCD),true) //(1)、如果满足条件,就设为table模式;
PRODUCT_CHARACTERISTICS := tablet
PRODUCT_COPY_FILES += \ frameworks/base/data/etc/tablet_core_hardware.xml:system/etc/permissions/tablet_core_hardware.xml
$(call inherit-product, frameworks/base/build/tablet-dalvik-heap.mk) 
else 
PRODUCT_CHARACTERISTICS := phone //(2)、满足条件就设为phone模式;
PRODUCT_COPY_FILES += \ 
frameworks/base/data/etc/handheld_core_hardware.xml:system/etc/permissions/handheld_core_hardware.xml 
$(call inherit-product, frameworks/base/build/phone-hdpi-512-dalvik-heap.mk) PRODUCT_PROPERTY_OVERRIDES += \ 
ro.sf.lcd_density=240                //(3)、lcd_density设定。
PRODUCT_AAPT_CONFIG := normal hdpi 
Endif

(1)、如果满足条件,就设为table

BOARD_USES_HIGH_RESOLUTION_LCD = true,就设定为table模式。

(2)、满足条件就设为phone模式;

BOARD_USES_HIGH_RESOLUTION_LCD = flash,就设定为phone模式

(3)、lcd_density设定。

在PRODUCT_CHARACTERISTICS := phone时,lcd_density设置为240。

现在我们要用table模式,所以我们要把BOARD_USES_HIGH_RESOLUTION_LCD这个参数设定为true。

android_ramos_4412_02/android/device/samsung/smdk4x12/BoardConfig.mk

  1. OARD_USES_HIGH_RESOLUTION_LCD :true  
OARD_USES_HIGH_RESOLUTION_LCD := true

把BOARD_USES_HIGH_RESOLUTION_LCD选为ture就可以编译成平板模式。

(4)、把config_showNavigationBar还原成默认值

将\frameworks\base\core\res\res\values\config.xml

  1. <boolnameboolname="config_showNavigationBar">false</bool>  
 <boolname="config_showNavigationBar">false</bool>

状态

  1. 模式:table  
  2. 参数:config_showNavigationBar=false  
模式:table
参数:config_showNavigationBar=false

编译,平板模式三个虚拟按键就可以出来了。我们的问题解决了。设为平板模式;三个虚拟按键出现。

三、phone模式下为什么只有一个黑框?

       问题解决了,但是我们还有一个疑问,那就是按网友那种方法改动后,为什么没有出现我们理想的效果呢?回顾“1、参考网友的说法:”更改后,个别键有做用,但是不能看到三个按键。

分析代码android/frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java

  1. mNavigationBarHeight =mHasNavigationBar ? mContext.getResources().getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_height) : 0; mNavigationBarWidth =mHasNavigationBar ?mContext.getResources().getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_width) : 0;  
  2. Log.v(TAG, "xubin testmNavigationBarHeight = " + mNavigationBarHeight  
  3.   " mNavigationBarWidth =" +mNavigationBarWidth);  
mNavigationBarHeight =mHasNavigationBar ? mContext.getResources().getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_height) : 0; mNavigationBarWidth =mHasNavigationBar ?mContext.getResources().getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_width) : 0;
Log.v(TAG, "xubin testmNavigationBarHeight = " + mNavigationBarHeight
  " mNavigationBarWidth =" +mNavigationBarWidth);
  1. <SPAN style="FONT-FAMILY: Arial, Helvetica, sans-serif; WHITE-SPACE: normal">打印值为:</SPAN>  
打印值为:

  1. V/WindowManager( 1250): xubin testmNavigationBarHeight = 72 mNavigationBarWidth =63  
  2. V/WindowManager(1250): xubin test mNavigationBarHeight = 72 mNavigationBarWidth =63  
V/WindowManager( 1250): xubin testmNavigationBarHeight = 72 mNavigationBarWidth =63
V/WindowManager(1250): xubin test mNavigationBarHeight = 72 mNavigationBarWidth =63

打印出来的信息也没什么问题,相对的而已文件也正确。这就回到我们开始提到那个lcd_density参数问题了,上面可以很明显的看到,当lcd_density值发生小的改变后,图标大小有很大的变化,再个来说我们LCD的分辨率太高,1280X800的,所以把那三人图标放大大,所以我们看到上面那种现象。


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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值