android4.0.4 Add HDMI settings

Source: Internet
Author: User

Recently to 4412 the most basic has been tuned and then feel nothing to do so add an HDMI setting can not idle

The following is the use of Canton Road icool210 Development Board source code modified as follows

In the beginning, I first put these settings in the setup and then I went to implement the function here and said that before the android2.3 has HDMI settings, so here is the reference to the increase first modify setting

View LIBHDMI Library First look at the next HDMI can set the format of the source code path

Device/samsung/common/s5p/libhdmi/sechdmi.cpp

You will find the following code

    Mhdmiresolutionvaluelist[0]  = 1080960;    MHDMIRESOLUTIONVALUELIST[1]  = 1080950;    MHDMIRESOLUTIONVALUELIST[2]  = 1080930;    MHDMIRESOLUTIONVALUELIST[3]  = 1080160;    MHDMIRESOLUTIONVALUELIST[4]  = 1080150;    MHDMIRESOLUTIONVALUELIST[5]  = 720960;    MHDMIRESOLUTIONVALUELIST[6]  = 720950;    MHDMIRESOLUTIONVALUELIST[7]  = 5769501;    MHDMIRESOLUTIONVALUELIST[8]  = 5769502;    MHDMIRESOLUTIONVALUELIST[9]  = 4809601;    MHDMIRESOLUTIONVALUELIST[10] = 4809602;
Resolutionvalue According to this we roughly know supported the format below to modify setting

Source Path Packages/apps/settings/res/values/arrays.xml

Add the following code


   <!--TV out settings. --<string-array name= "Tv_resolution_entries" ><item>1080p_60</item><item>1080p_50 </item><item>1080p_30</item><item>1080i_60</item><item>1080i_50</item ><item>720P_60</item><item>720P_50</item><item>576P_50_16_9</item>< Item>576p_50_4_3</item><item>480p_60_16_9</item><item>480p_60_4_3</item> </ String-array> <!--do not translate. --<string-array name= "Tv_resolution_values" translatable= "false" ><!--do not translate. --><item>1080960</item><!--do not translate. --><item>1080950</item><!--do not translate. --><item>1080930</item><!--do not translate. --><item>1080160</item><!--do not translate. --><item>1080150</item><!--do not translate. --><item>720960</item><!--do not translAte. --><item>720950</item><!--do not translate. --><item>5769501</item><!--do not translate. --><item>5769502</item><!--do not translate. --><item>4809601</item><!--do not translate. --><item>4809602</item> </string-array> <!--TV out settings. --<string-array name= "Tv_hdcp_entries" ><item>disable</item><item>enable</item > </string-array> <!--do translate. --><string-array name= "Tv_hdcp_values" translatable= "false" ><!--do not translate. --><item>0</item><!--do not translate. --><item>1</item> </string-array> <!--TV out settings. --<string-array name= "Tv_mode_entries" ><item>hdmi (YCbCr) </item><item>hdmi (RGB) </ Item><item>dvi</item> </string-array> <!--do not translate. -<string-array Name="Tv_mode_values" translatable= "false" ><!--do not translate. --><item>0</item><!--do not translate. --><item>1</item><!--do not translate. --><item>2</item> </string-array>
Source Path Packages/apps/settings/res/values/strings.xml

Add the following content


    <!--sound & display settings screens, setting option name to change TV Mode--<string name= "Tv_mode"     >tv mode</string> <!--sound & display settings screens, setting option summary to change TV Mode--  <string name= "Tv_mode_summary" >choose TV out mode</string> <!--sound & display Settings screens,    Setting option name to change TV Resolution-<string name= "Tv_resolution" >tv resolution</string> <!--sound & display settings screens, setting option summary to change TV Resolution--<string name= "tv_ Resolution_summary ">choose TV resolution</string> <!--sound & display settings screen, setting option Name to change TV HDCP-<string name= "TV_HDCP" >tv hdcp</string> <!--sound & display Settin GS-screen, setting option summary-to-change TV HDCP--<string name= "tv_hdcp_summary" >enable HDMI hdcp</st Ring>
Source Path Packages/apps/settings/res/xml/display_settings.xml

Add the following content

<listpreferenceandroid:key= "Tv_mode" android:title= "@string/tv_mode" android:summary= "@string/tv_mode_summary "Android:persistent=" false "android:entries=" @array/tv_mode_entries "android:entryvalues=" @array/tv_mode_values " /><listpreferenceandroid:key= "Tv_resolution" android:title= "@string/tv_resolution" android:summary= "@ String/tv_resolution_summary "android:persistent=" false "android:entries=" @array/tv_resolution_entries "Android: entryvalues= "@array/tv_resolution_values"/><listpreferenceandroid:key= "TV_HDCP" android:title= "@string/tv _HDCP "android:summary=" @string/tv_hdcp_summary "android:persistent=" false "android:entries=" @array/tv_hdcp_ Entries "android:entryvalues=" @array/tv_hdcp_values "/>
Then modifyFramework

Source Path: Frameworks/base/core/java/android/provider/settings.java

Add the following content:


        /**         * The TV out mode.         */public        static final String Tv_mode = "Tv_mode";        /**         * The TV out resolution.         */public        static final String tv_resolution = "Tv_resolution";        /**         * The TV out mode.         */public        static final String TV_HDCP = "TV_HDCP";
And then search the screen_off_timeout in this file.

Will find one in the public static final string[] Settings_to_backup this array and add the following below it

            Tv_mode,            tv_resolution,            TV_HDCP,
According to my understanding, this should be used to save the data to the database, and then the system starts again after the settings can be saved

Then add the interface that calls the HDMI correlation function. Here, I'm just copying the 2.3, and then making the changes.

Create the appropriate directory add the following file Frameworks/base/slsi/java/com/slsi/sec/android/hdmiservice.java

The contents are as follows


Package Com.slsi.sec.android;public class hdmiservice{    static {        system.loadlibrary ("Hdmiservice_jni");    } Public    native void sethdmicablestatus (int status);    public native void Sethdmimode (int mode);    public native void sethdmiresolution (int resolution);    public native void SETHDMIHDCP (int enhdcp);    public native void Inithdmiservice ();}
Add the following file Frameworks/base/slsi/jni/android.mk

The contents are as follows


Local_path:= $ (call My-dir) include $ (clear_vars) local_src_files:=     com_slsi_sec_android_hdmiservice.cpp     Onload.cpplocal_c_includes + = $ (jni_h_include) Local_shared_libraries: =     libcutils     libandroid_runtime     Libnativehelperifeq ($ (S5P_BOARD_USES_HDMI), true) Local_c_includes + =     Device/samsung/common/s5p/libhdmilocal_ Shared_libraries + = libhdmiclientlocal_cflags     + =-dboard_uses_hdmiendiflocal_prelink_module: = Falseifeq ($ ( Target_simulator), True) ifeq ($ (target_os), Linux) ifeq ($ (target_arch), x86) Local_ldlibs + =-LPTHREAD-LDL- Lrtendifendifendififeq ($ (With_malloc_leak_check), true) Local_cflags + =-dmalloc_leak_checkendiflocal_module_tags: = Optional englocal_module:= libhdmiservice_jniinclude $ (build_shared_library)
Add the following file Frameworks/base/slsi/jni/com_slsi_sec_android_hdmiservice.cpp

The contents are as follows

#define LOG_TAG "Hdmistatusservice" #include "jni.h" #include "JNIHelp.h" #include <cutils/log.h> #if defined ( BOARD_USES_HDMI) #include "SecHdmiClient.h" #endifnamespace Android {/* * Class:com_slsi_sec_android_hdmiservice * Meth Od:sethdmicablestatus * Signature: (I) V */static void Com_slsi_sec_android_hdmiservice_sethdmicablestatus (JNIENV *en    V, jobject obj, jint i) {int result = 0; #if defined (BOARD_USES_HDMI)//logd ("%s HDMI Status:%d", __func__, I); (Sechdmiclient::getinstance ())->sethdmicablestatus (i); #else return; #endif//return result;} /* * Class:com_slsi_sec_android_sethdmimode * Method:sethdmimode * Signature: (I) V */static void Com_slsi_sec_and Roid_hdmiservice_sethdmimode (jnienv *env, jobject obj, jint i) {int result = 0; #if defined (BOARD_USES_HDMI) (sechd  Miclient::getinstance ())->sethdmimode (i); #else return; #endif}/* * class:com_slsi_sec_android_sethdmiresolution * Method:sethdmiresolution * Signature: (I) V */static void Com_slsi_sec_android_hdmiservice_sethdmiresolution (jnienv *env, jobject obj, jint i) {int result = 0; #if defined ( BOARD_USES_HDMI) (Sechdmiclient::getinstance ())->sethdmiresolution (i); #else return; #endif}/* * Class:com_sls I_SEC_ANDROID_SETHDMIHDCP * METHOD:SETHDMIHDCP * Signature: (I) V */static void COM_SLSI_SEC_ANDROID_HDMISERVICE_SETHDM IHDCP (jnienv *env, jobject obj, jint i) {int result = 0; #if defined (BOARD_USES_HDMI) (Sechdmiclient::getinstance ())- &GT;SETHDMIHDCP (i); #else return; #endif}/* * Class:com_slsi_sec_android_hdmiservice * method:inithdmiservice * Signature: () V */static void Com_slsi_sec_android_hdmiservice_inithdmiservice (jnienv *env, Jobject obj) {#if defined (    BOARD_USES_HDMI) Logi ("%s", __func__); (Sechdmiclient::getinstance ())->init (); #else return; #endif//return result;} Static Jninativemethod gmethods[] = {{"Sethdmicablestatus", "(I) V", (void*) Com_slsi_sec_android_hdmiservice_ Sethdmicablestatus}, {"sEthdmimode "," (i) v ", (void*) Com_slsi_sec_android_hdmiservice_sethdmimode}, {" Sethdmiresolution "," (i) v ", (void*) com _slsi_sec_android_hdmiservice_sethdmiresolution}, {"SETHDMIHDCP", "(I) V", (void*) Com_slsi_sec_android_hdmiservice _SETHDMIHDCP}, {"Inithdmiservice", "() V", (void*) Com_slsi_sec_android_hdmiservice_inithdmiservice},};int Register_ Com_samsung_sec_android_hdmiservice (jnienv* env) {Jclass clazz = Env->findclass ("Com/slsi/sec/android/     Hdmiservice ");         if (clazz = = NULL) {LOGE ("Can ' t find Com/slsi/sec/android/hdmiservice");     return-1; } return Jniregisternativemethods (env, "Com/slsi/sec/android/hdmiservice", Gmethod S, Nelem (Gmethods));}} /* Namespace Android */
Add the following file: Frameworks/base/slsi/jni/onload.cpp

The contents are as follows

#include "JNIHelp.h" #include "jni.h" #include "utils/log.h" #include "utils/misc.h" namespace Android {int register_com_ Samsung_sec_android_hdmiservice (jnienv* env);}; Using namespace Android;extern "C" Jint jni_onload (javavm* vm, void* reserved) {    jnienv* env = NULL;    Jint result =-1;    if (vm->getenv (void**) &env, jni_version_1_4)! = JNI_OK) {        LOGE ("GetEnv failed!");        return result;    }    Log_assert (env, "Could not retrieve the env!");    if (Register_com_samsung_sec_android_hdmiservice (env) = =-1)        LOGE ("%s register_com_samsung_sec_android_ Hdmistatus is failed ", __func__);    return jni_version_1_4;}
Then modify the Build/core/pathmap.mk

Add Slsi in Frameworks_base_subdirs

We're going to get him to set the parameters automatically when he starts, so.

Then modify the Frameworks/base/services/java/com/android/server/systemserver.java

Add the following content

Import Com.slsi.sec.android.hdmiservice;import static Android.provider.settings.system.tv_mode;import static Android.provider.settings.system.tv_resolution;import static Android.provider.Settings.System.TV_HDCP;
Private Hdmiservice Mhdmiservice;
And then in

Mcontentresolver = Context.getcontentresolver ();
Then add the following code

SLOG.I (TAG, "HDMI Setting"); mhdmiservice = new Hdmiservice (); Mhdmiservice.sethdmimode (Settings.System.getInt ( Mcontentresolver, Tv_mode, 0); Mhdmiservice.sethdmiresolution (Settings.System.getInt (Mcontentresolver, tv_ RESOLUTION, 4809601)); MHDMISERVICE.SETHDMIHDCP (Settings.System.getInt (mcontentresolver, TV_HDCP, 0));
And then finally modify the displaysetting in setting.

Source Path Packages/apps/settings/src/com/android/settings/displaysettings.java

Add the following content

Import Com.slsi.sec.android.hdmiservice;import static Android.provider.settings.system.tv_mode;import static Android.provider.settings.system.tv_resolution;import static Android.provider.Settings.System.TV_HDCP;
private static final String Key_tv_mode = "Tv_mode";    private static final String key_tv_resolution = "Tv_resolution";    private static final String KEY_TV_HDCP = "TV_HDCP";    private static final int fallback_tv_mode_value = 0;    private static final int fallback_tv_resolution_value = 4809601;    private static final int fallback_tv_hdcp_value = 0; Private Hdmiservice Mhdmiservice;
Then add the following code to the OnCreate

        Listpreference tvmodepreference = (listpreference) findpreference (Key_tv_mode); Tvmodepreference.setvalue (string.valueof (Settings.System.getInt (resolver, Tv_mode, Fallback_tv_mod        (E_value)));        Tvmodepreference.setonpreferencechangelistener (this);        Listpreference tvresolutionpreference = (listpreference) findpreference (key_tv_resolution); Tvresolutionpreference.setvalue (string.valueof (Settings.System.getInt (resolver, tv_resolution, FAL        (Lback_tv_resolution_value)));        Tvresolutionpreference.setonpreferencechangelistener (this);        Listpreference tvhdcppreference = (listpreference) findpreference (KEY_TV_HDCP); Tvhdcppreference.setvalue (string.valueof (Settings.System.getInt (resolver, TV_HDCP, FALLBACK_TV_HDC        (P_value))); Tvhdcppreference.setonpreferencechangelistener (this); mhdmiservice = new Hdmiservice ();
Then add the following in the Onpreferencechange function

        if (Key_tv_mode.equals (KEY)) {int value = Integer.parseint (String) objvalue);            try {Settings.System.putInt (Getcontentresolver (), tv_mode, value);            } catch (NumberFormatException e) {log.e (TAG, "could not persist TV mode setting", e);        } mhdmiservice.sethdmimode (value);            } if (Key_tv_resolution.equals (KEY)) {int value = Integer.parseint (String) objvalue);            try {Settings.System.putInt (Getcontentresolver (), tv_resolution, value);            } catch (NumberFormatException e) {log.e (TAG, "could not persist TV resolution setting", e);        } mhdmiservice.sethdmiresolution (value);            }if (Key_tv_hdcp.equals (KEY)) {int value = Integer.parseint (String) objvalue);                   try {Settings.System.putInt (), Getcontentresolver (),     TV_HDCP, value);            } catch (NumberFormatException e) {log.e (TAG, "could not persist TV resolution setting", e);        } MHDMISERVICE.SETHDMIHDCP (value); }
Basically, it was done.

Related patches I've uploaded my resources, and I don't know why they didn't show up. You can download

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.