Added HDMI settings for android4.0.4

Source: Internet
Author: User

Added HDMI settings for android4.0.4

Recently, the most basic settings of 4412 have been adjusted, and I feel that nothing has been done. Therefore, you cannot add an HDMI configuration.

The following is how to modify the source code of the icool210 Development Board of Guangzhou SDO.

In the beginning, I first added these settings in the settings and then implemented the functions. Here we will talk about the HDMI settings in android2.3. So here we will refer to the Add. First, modify Setting.

View the libhdmi library. First, check the source code path of the hdmi format.

 

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 based on this we generally know that the supported format is below to modify Setting

 

 

Add the following code:

 

   
     
 
  
   1080P_60
  
  
   1080P_50
  
  
   1080P_30
  
  
   1080I_60
  
  
   1080I_50
  
  
   720P_60
  
  
   720P_50
  
  
   576P_50_16_9
  
  
   576P_50_4_3
  
  
   480P_60_16_9
  
  
   480P_60_4_3
      
     
     
 
  
  
   1080960
  
  
  
   1080950
  
  
  
   1080930
  
  
  
   1080160
  
  
  
   1080150
  
  
  
   720960
  
  
  
   720950
  
  
  
   5769501
  
  
  
   5769502
  
  
  
   4809601
  
  
  
   4809602
      
     
     
 
  
   Disable
  
  
   Enable
      
     
 
 
  
  
   0
  
  
  
   1
      
     
     
 
  
   HDMI(YCbCr)
  
  
   HDMI(RGB)
  
  
   DVI
      
     
     
 
  
  
   0
  
  
  
   1
  
  
  
   2
      
 
Source code path packages/apps/Settings/res/values/strings. xml

 

Add the following content:

 

    
     
 
  TV Mode
     
     
 
  Choose TV out mode
     
     
 
  TV Resolution
     
     
 
  Choose TV resolution
     
     
 
  TV HDCP
     
     
 
  Enable HDMI HDCP
 
Source code path: packages/apps/Settings/res/xml/display_settings.xml

 

Add the following content:

 

 
  
   
  
 
Modify the framework

 

Source code 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;
Search the SCREEN_OFF_TIMEOUT file.

 

Find one in the array public static final String [] SETTINGS_TO_BACKUP and add the following

 

            TV_MODE,            TV_RESOLUTION,            TV_HDCP,
According to my understanding, this should be used to save the data to the database. Then, after the system is started again, the settings can be saved.

 

Then we added the interface for calling the hdmi functions. Here I copied the 2.3 directly and then modified it.

Add the following file to the directory: frameworks/base/slsi/java/com/slsi/sec/android/HdmiService. java.

The content is 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 content is 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 content is as follows:

 

#define LOG_TAG HDMIStatusService#include jni.h#include JNIHelp.h#include 
 
  #if defined(BOARD_USES_HDMI)#include SecHdmiClient.h#endifnamespace android {/* * Class:     com_slsi_sec_android_HdmiService * Method:    setHdmiCableStatus * Signature: (I)V */static void com_slsi_sec_android_HdmiService_setHdmiCableStatus  (JNIEnv *env, 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_android_HdmiService_setHdmiMode  (JNIEnv *env, jobject obj, jint i){    int result = 0;#if defined(BOARD_USES_HDMI)    (SecHdmiClient::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_slsi_sec_android_setHdmiHdcp * Method:    setHdmiHdcp * Signature: (I)V */static void com_slsi_sec_android_HdmiService_setHdmiHdcp(JNIEnv *env, jobject obj, jint i){    int result = 0;#if defined(BOARD_USES_HDMI)    (SecHdmiClient::getInstance())->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,                                     gMethods, NELEM(gMethods));}} /* namespace android */
 
Add the following file: frameworks/base/slsi/jni/onload. cpp

 

The content is as follows:

 

#include JNIHelp.h#include jni.h#include utils/Log.h#include utils/misc.hnamespace 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 build/core/pathmap. mk

 

Add slsi in FRAMEWORKS_BASE_SUBDIRS

We want him to be able to automatically set the parameter when starting.

Modify 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;
Then

 

 

 mContentResolver = context.getContentResolver();
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));
Modify DisplaySetting in Setting.

 

Source code 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 in onCreate

 

 

        ListPreference tvModePreference =            (ListPreference) findPreference(KEY_TV_MODE);        tvModePreference.setValue(String.valueOf(Settings.System.getInt(                        resolver, TV_MODE, FALLBACK_TV_MODE_VALUE)));        tvModePreference.setOnPreferenceChangeListener(this);        ListPreference tvResolutionPreference =            (ListPreference) findPreference(KEY_TV_RESOLUTION);        tvResolutionPreference.setValue(String.valueOf(Settings.System.getInt(                        resolver, TV_RESOLUTION, FALLBACK_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_HDCP_VALUE)));        tvHdcpPreference.setOnPreferenceChangeListener(this);mHdmiService = new HdmiService();
Add the following content to 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, the last step is done.

 

I uploaded the related patches to my resources. I don't know why I didn't show them. I can download them if needed.

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.