Chinaunix首页 | 论坛 | 博客
  • 博客访问: 438219
  • 博文数量: 205
  • 博客积分: 5630
  • 博客等级: 大校
  • 技术积分: 1945
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-06 20:28
文章分类

全部博文(205)

文章存档

2016年(1)

2015年(6)

2014年(9)

2013年(10)

2012年(53)

2011年(25)

2010年(87)

2009年(14)

分类:

2012-08-02 14:15:33

1.如何添加hdmi选项图标

a).将显示在目录上的图标资源添加至/Gingerbread/packages/app/Settings/res/drawable-hdpi//Gingerbread/packages/app/Settings/res/drawable-mdpi/中。

 

b).Gingerbread/packages/app/Settings/AndroidManifest.xml 中添加以下内容

  

                android:label="@string/hdmi_settings"

                android:clearTaskOnLaunch="true"

                >

           

                

               

               

               

               

               

           

    

 

c).添加相对应的字串和数组,在Gingerbread/packages/app/Settings/res/values/strings.xml中添加内容

          

    HDMI

   

    Hdmi Display Mode

    Please select the display mode you want to use

    HDMI Setting

           Gingerbread/packages/app/Settings/res/values/arrays.xml中添加内容

 

          

   

        1920x1080

        1280x720

        720x576

        720x480

   

 

 

 

 

   

        0

        1

        2

        3

   

   

        The current mode is 1920x1080 mode

        The current mode is 1280x720 mode

        The current mode is 720x576 mode

        The current mode is 720x480 mode

   

 

d).如果对hdmi模块在布局方面有一些特别的要求,可以在res/layout/目录下添加对应的xml文件。

 

2.HDMI setting 格式设计

  /packages/apps/Settings/src/com/android/settings/目录下创建Hdmi_setting.java

  采用一个checkbox来设定HDMI的开关,采取一个列表来选择HDMI的参数模式。

  public void onCreate(Bundle icicle) {

        super.onCreate(icicle);

             

}

中添加以下内容,设定HDMI界面的模式风格

       ContentResolver resolver = getContentResolver();

  WindowManager=IWindowManager.Stub.asInterface(ServiceManager.getService("window"));

         addPreferencesFromResource(R.xml.hdmi_setting);

       mHdmiAccelerometer = (CheckBoxPreference) findPreference(KEY_HDMI_SWITCH);

       mHdmiAccelerometer.setOnPreferenceChangeListener(this);

     mHdmiModes = (ListPreference) findPreference(KEY_HDMI_ACCELEROMETER);

      mHdmiModes.setOnPreferenceChangeListener(this);

 

3.如何调用HdmiSettings

 

Gingerbread/packages/app/Settings/res/xml/setting.xml中添加以下内容

        

            settings:icon="@drawable/ic_settings_hdmi"

            android:title="@string/hdmi_settings">

           

                android:action="android.intent.action.MAIN"

                android:targetPackage="com.android.settings"

                android:targetClass="com.android.settings.HdmiSettings" />

       

 

 

4.如何保存当前的控件的值。

a). franeworks/base/core/java/android/provider/Setting.java中添加两个值的变量的定义

       public static final String HDMI_SETTINGS_STATUS = "hdmi_settings_status";

public static final String HDMI_SETTINGS_MODE = "hdmi_settings_mode";

并在SETTINGS_TO_BACKUP数组中添加这两个成员。

 

b).Gingerbread/frameworks/base/packages/SettingProvider/src/com/android/providers/settings

/DatabaseHelper.java 中添加以下语句

Loadsetting(stmt,settings.system.HDMI_SETTINGS_STATUS,0);

Loadsetting(stmt,settings.system.HDMI_SETTINGS_MODE,0);

 

5.如何调用hdmi脚本

 

a).build the hdmi lib

       pp1938hdmi代码移植,并添加android.mk文件,将该代码编译成一个动态的库,这样就可以在android中采取jni的模式来调用.

 

b).Gingerbread/frameworks/base/core/jni中创建一个android_setting_HdmiJNI.cpp并添加以下代码

static int JNICALL android_setting_HdmiJNI_RunHDMI(JNIEnv * env, jobject obj, jint opt)

{

             return run_hdmi(opt);

    }

static int JNICALL android_setting_HdmiJNI_ChangeHdmiMode(JNIEnv * env, jobject obj, jint opt)

        {

             LOGE("run hdmi function test \n");

             return change_hdmi_mode(opt);

        }

 

        static int JNICALL android_setting_HdmiJNI_StopHDMI(JNIEnv * env, jobject obj)

        {

             LOGE("stop hdmi function test\n");

             return stop_hdmi();

        }

 

        static int JNICALL android_setting_HdmiJNI_Hot_plug_detect(JNIEnv * env, jobject obj)

        {

             LOGE("hot plug detect function test\n");

             return hot_plug_detect();

        }

 

        static JNINativeMethod gMethods[] = {

                {"RunHDMI", "(I)I", (void *) android_setting_HdmiJNI_RunHDMI},

                {"ChangeHdmiMode", "(I)I", (void *) android_setting_HdmiJNI_ChangeHdmiMode},

                {"StopHDMI", "()I", (void *) android_setting_HdmiJNI_StopHDMI},

                {"Hot_plug_detect", "()I", (void *) android_setting_HdmiJNI_Hot_plug_detect},

        };

 

        int register_android_setting_HdmiJNI(JNIEnv * env)

        {

                return jniRegisterNativeMethods(env, "android/setting/HdmiJNI",gMethods, NELEM(gMethods));

        }

 

c)AndroidRuntime.cpp中添加extern int register_android_setting_HdmiJNI(JNIEnv* env);声明,并在数组gRegJNI中添加REG_JNI(register_android_setting_HdmiJNI),

 

d)修改android.mk文件,并添加相对应的路径包含,

 

e) Gingerbread/frameworks/base/core/java/android/setting路径下添加HdmiJNI.java文件

       并添加以下代码

 

package android.setting;

 

/** {@hide} */

public class HdmiJNI

{

        public HdmiJNI()

        {

        }

        public native int RunHDMI(int opt);

        public native int ChangeHdmiMode(int opt);

        public native int StopHDMI();

        public native int Hot_plug_detect();

 

}

 

 

f)Gingerbread/packages/apps/Settings/src/com/android/settings/HdmiSettings.java中添加

import android.setting.HdmiJNI;

import static android.provider.Settings.System.HDMI_SETTINGS_STATUS;

import static android.provider.Settings.System.HDMI_SETTINGS_MODE;

 

 

 

等并使用对用的函数来执行对应的操作,

 

 

注意:若出现无法识别以上的类和变量,请make update-api.

阅读(1876) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~