|
发表于 2019-6-27 09:15:10
只看该作者
5#
补丁:
进入到packages/apps/Settings/目录:
diff --git a/Android.mk b/Android.mk
index 537004e..58b0865 100644
--- a/Android.mk
+++ b/Android.mk
@@ -42,6 +42,9 @@ LOCAL_PROGUARD_FLAG_FILES := proguard.flags
LOCAL_AAPT_FLAGS := --auto-add-overlay \
--extra-packages android.support.v7.preference:android.support.v14.preference:android.support.v17.preference:android.support.v7.appcompat:android.support.v7.recyclerview
+#add libsettings-jni by louhn
+LOCAL_JNI_SHARED_LIBRARIES := libsettings-jni
+
ifneq ($(INCREMENTAL_BUILDS),)
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_JACK_ENABLED := incremental
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 3578d24..ee4e0aa 100755
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -3159,6 +3159,11 @@
android:enabled="@bool/config_has_help" />
<activity
android:name="com.android.settings.display.ScreenScaleActivity"/>
- <!-- This is the longest AndroidManifest.xml ever. -->
+<!--add by louhn-->
+<activity
+ android:name="com.android.settings.display.AdvancedDisplaySettingsActivity"/>
+<activity
+ android:name="com.android.settings.display.AdvancedDisplaySettingsMainActivity"/>
+ <!-- This is the longest AndroidManifest.xml ever. -->
</application>
</manifest>
diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml
index 8486a38..dd795c7 100755
--- a/res/values-zh-rCN/strings.xml
+++ b/res/values-zh-rCN/strings.xml
@@ -21,6 +21,26 @@
<string name="root_access_warning_title">允许 Root 授权请求?</string>
<string name="root_access_warning_message">允许应用得到 Root 权限是有风险的,可能会影响您的系统安全!</string>
+ <!--add by louhn:display advanced_settings-->
+ <string name="ok">确定</string>
+ <string name="cancel">取消</string>
+ <string name="advanced_settings">副屏高级设置</string>
+ <string name="advanced_settings_main">主屏高级设置</string>
+ <string name="bcsh">BCSH</string>
+ <string name="bcsh_reset">重置</string>
+ <string name="bcsh_cold">冷</string>
+ <string name="bcsh_warm">暖</string>
+ <string name="bcsh_sharp">锐利</string>
+ <string name="hdr">HDR</string>
+ <string name="brightness">亮度</string>
+ <string name="current">当前数值:</string>
+ <string name="contrast">对比度</string>
+ <string name="saturation">饱和度</string>
+ <string name="tone">色调</string>
+ <string name="max_brightness">最大亮度</string>
+ <string name="min_brightness">最小亮度</string>
+
+
<string name="daemon_switch_title">开启4G守护</string>
<string name="systembar_hide_title">永久隐藏导航栏</string>
<string name="systembar_hide_statustitle">永久隐藏状态栏</string>
@@ -1452,7 +1472,7 @@
<string name="install_unknown_applications" msgid="176855644862942064">"允许安装来自未知来源的应用"</string>
<string name="install_all_warning" product="tablet" msgid="3263360446508268880">"您的平板电脑和个人数据更容易受到从未知来源获取的应用的攻击。对于因使用这些应用而造成的平板电脑损坏或数据丢失,您同意自行承担全部责任。"</string>
<string name="install_all_warning" product="default" msgid="8113734576826384682">"您的手机和个人数据更容易受到从未知来源获取的应用的攻击。对于因使用这些应用而造成的手机损坏或数据丢失,您同意自行承担全部责任。"</string>
- <string name="advanced_settings" msgid="1777249286757067969">"高级设置"</string>
+ <!--string name="advanced_settings" msgid="1777249286757067969">"高级设置"</string-->
<string name="advanced_settings_summary" msgid="4016682978071086747">"启用更多设置选项"</string>
<string name="application_info_label" msgid="5736524913065714880">"应用信息"</string>
<string name="storage_label" msgid="8700867073480107253">"存储空间"</string>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 2155245..aa5356e 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -18,6 +18,7 @@
<color name="black">#000</color>
<color name="red">#F00</color>
<color name="blue">#00F</color>
+ <color name="green">#FF00FF00</color>
<color name="material_empty_color_light">#FFCED7DB</color>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index c68557f..43ef48c 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -19,6 +19,28 @@
<string name="root_access_warning_title">Allow root access?</string>
<string name="root_access_warning_message">Allowing apps to request root access is very dangerous and could compromise the security of your system!</string>
+ <!--add by louhn display advanced_settings -->
+ <string name="color">Color</string>
+ <string name="ok">OK</string>
+ <string name="cancel">Cancel</string>
+ <string name="advanced_settings">Secondary Screen Advanced settings</string>
+ <string name="advanced_settings_main">Main Screen Advanced settings</string>
+ <string name="bcsh">BCSH</string>
+ <string name="bcsh_reset">reset</string>
+ <string name="bcsh_cold">cold</string>
+ <string name="bcsh_warm">warm</string>
+ <string name="bcsh_sharp">sharp</string>
+ <string name="hdr">SDR->HDR</string>
+ <string name="sdr">HDR->SDR</string>
+ <string name="brightness">Brightness</string>
+ <string name="current">Current value:</string>
+ <string name="contrast">Contrast</string>
+ <string name="saturation">Saturation</string>
+ <string name="tone">Tone</string>
+ <string name="max_brightness">Max brightness</string>
+ <string name="min_brightness">Min brightness</string>
+
+
<!-- Strings for Dialog yes button -->
<string name="yes">"Yes"</string>
<!-- Strings for Dialog no button -->
@@ -3410,7 +3432,7 @@
damage to your phone or loss of data that may result from using
these apps.</string>
<!-- Applications settings screen, setting check box title. If checked, applications show more settings options. -->
- <string name="advanced_settings">Advanced settings</string>
+ <!--string name="advanced_settings">Advanced settings</string-->
<!-- Applications settings screen, setting check box summary. This is the summary for "Advanced settings" checkbox -->
<string name="advanced_settings_summary">Enable more settings options</string>
<!-- Manage applications, individual application info screen title. For example, if they click on "Browser" in "Manage applications", the title of the next screen will be this -->
diff --git a/res/xml/hdmi_settings_timeout.xml b/res/xml/hdmi_settings_timeout.xml
index b86c58a..829121c 100644
--- a/res/xml/hdmi_settings_timeout.xml
+++ b/res/xml/hdmi_settings_timeout.xml
@@ -31,6 +31,15 @@
<Preference
android:key="hdmi_screen_zoom"
android:title="@string/hdmi_screen_zoom" />
+
+ <!--add by louhn-->
+ <Preference
+ android:key="advanced_settings_main"
+ android:title="@string/advanced_settings_main" />
+ <Preference
+ android:key="advanced_settings"
+ android:title="@string/advanced_settings" />
+
<ListPreference
android:key="hdmi_rotation"
diff --git a/src/com/android/settings/ApplicationSettings.java b/src/com/android/settings/ApplicationSettings.java
index 759ccea..52b3679 100644
--- a/src/com/android/settings/ApplicationSettings.java
+++ b/src/com/android/settings/ApplicationSettings.java
@@ -30,7 +30,7 @@ public class ApplicationSettings extends SettingsPreferenceFragment {
private static final String KEY_TOGGLE_ADVANCED_SETTINGS = "toggle_advanced_settings";
private static final String KEY_APP_INSTALL_LOCATION = "app_install_location";
-
+
// App installation location. Default is ask the user.
private static final int APP_INSTALL_AUTO = 0;
private static final int APP_INSTALL_DEVICE = 1;
@@ -115,7 +115,7 @@ public class ApplicationSettings extends SettingsPreferenceFragment {
Settings.System.ADVANCED_SETTINGS,
Settings.System.ADVANCED_SETTINGS_DEFAULT) > 0;
}
-
+
private void setAdvancedSettingsEnabled(boolean enabled) {
int value = enabled ? 1 : 0;
// Change the system setting
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java
index 0e66032..a6923d4 100755
--- a/src/com/android/settings/DisplaySettings.java
+++ b/src/com/android/settings/DisplaySettings.java
@@ -58,6 +58,21 @@ import com.android.settingslib.RestrictedPreference;
import java.util.ArrayList;
import java.util.List;
+//add by louhn advancedSetting
+import android.webkit.WebView.FindListener;
+import com.android.settings.display.DrmDisplaySetting;
+import android.support.v7.preference.PreferenceScreen;
+import android.os.DisplayOutputManager;
+import android.hardware.display.DisplayManager;
+import android.support.v7.preference.PreferenceCategory;
+import android.hardware.display.DisplayManager;
+import android.content.IntentFilter;
+import com.android.settings.display.DisplayInfo;
+import com.android.settings.data.ConstData;
+import android.view.Display;
+import java.lang.reflect.Method;
+
+
import static android.provider.Settings.Secure.CAMERA_GESTURE_DISABLED;
import static android.provider.Settings.Secure.DOUBLE_TAP_TO_WAKE;
import static android.provider.Settings.Secure.DOZE_ENABLED;
@@ -103,6 +118,37 @@ Preference.OnPreferenceChangeListener, Indexable {
private CheckBoxPreference mSystemStatusBarHide;
//end
+ //add by louhn advancedSetting
+ public static final String HDMI_PLUG_ACTION = "android.intent.action.HDMI_PLUGGED";
+ private PreferenceScreen mPreferenceScreen;
+ private static String mStrPlatform;
+ private static boolean mIsUseDisplayd;
+ /**
+ * rk_fb输出相关
+ */
+ private DisplayOutputManager mDisplayOutputManager;
+ /**
+ * 原生标准显示管理接口,用于DRM显示相关
+ */
+ private DisplayManager mDisplayManager;
+ /**
+ * 插拔显示设备监听
+ */
+ private DisplayListener mDisplayListener;
+ /**
+ * 主显示
+ */
+ private Preference mMainDisplayPreference;
+ /**
+ * 次显示
+ */
+ private Preference mSecondDisPreference;
+ /**
+ * HDMI热插拔接收器
+ */
+ private HDMIReceiver mHdmiReceiver;
+//////////////end by louhn///////////////////////////
+
/*add by louhn*/
private ListPreference mScreenOrientationPreference;
@@ -280,7 +326,212 @@ Preference.OnPreferenceChangeListener, Indexable {
mNightModePreference.setValue(String.valueOf(currentNightMode));
mNightModePreference.setOnPreferenceChangeListener(this);
}
+ //add by louhn advancedSetting
+ initData();
+ rebuildView();
+ }
+
+ //add by louhn advancedSetting
+ private void initData(){
+ //mMainDisplayPreference = findPreference(KEY_MAIN_DISPLAY);
+ //mSecondDisPreference = findPreference(KEY_SECOND_DISPLAY);
+ //del by louhn
+ //mDisplayDeviceCategory = (PreferenceCategory)findPreference(KEY_DISPLAY_DEVICE_CATEGORY);
+ mDisplayManager = (DisplayManager)getActivity().getSystemService(Context.DISPLAY_SERVICE);
+ mDisplayListener = new DisplayListener();
+ mHdmiReceiver = new HDMIReceiver();
+ }
+ /**
+ * 注册显示监听
+ */
+ private void registerDisplayListener(){
+ mDisplayManager.registerDisplayListener(mDisplayListener, null);
+ }
+
+ /**
+ * 取消显示监听
+ */
+ private void unRegiserDisplayListener(){
+ mDisplayManager.unregisterDisplayListener(mDisplayListener);
+ }
+
+ /**
+ * 注册HDMI接收器
+ */
+ private void registerHDMIReceiver(){
+ IntentFilter filter = new IntentFilter(HDMI_PLUG_ACTION);
+ getActivity().registerReceiver(mHdmiReceiver, filter);
+ }
+
+
+ /**
+ * 取消注册HDMI接收器
+ */
+ private void unRegisterHDMIReceiver(){
+ getActivity().unregisterReceiver(mHdmiReceiver);
+ }
+
+ /**
+ * 重新构造页面
+ */
+ private void rebuildView(){
+ //del by louhn
+ //mDisplayDeviceCategory.removeAll();
+ List<DisplayInfo> displayInfos = getDisplayInfos();
+ Log.i(TAG, "rebuildView->displayInfos:" + displayInfos);
+ if(displayInfos.size() > 0){
+ for(DisplayInfo displayInfo : displayInfos){
+ Intent intent = new Intent();
+ intent.putExtra(ConstData.IntentKey.DISPLAY_INFO, displayInfo);
+ getActivity().setIntent(intent);
+ if(displayInfo.getDisplayId() == 0){
+ Log.d("LOUHN_DEBUG","displayInfo.getDisplayId() == 0 in DisplaySettings.java");
+ //mMainDisplayPreference.setTitle(displayInfo.getDescription());
+ //del by louhn
+ //mDisplayDeviceCategory.addPreference(mMainDisplayPreference);
+ }else{
+ Log.d("LOUHN_DEBUG","displayInfo.getDisplayId() == 1 in DisplaySettings.java");
+ //mSecondDisPreference.setTitle(displayInfo.getDescription());
+ //del by louhn
+ //mDisplayDeviceCategory.addPreference(mSecondDisPreference);
+ }
+ }
+ }
+ }
+
+ /**
+ * 获取所有外接显示设备信息,此方法已兼容rk_fb与DRM
+ * @param <mDisplayOutputManager>
+ * @return
+ */
+ private List<DisplayInfo> getDisplayInfos(){
+ List<DisplayInfo> displayInfos = new ArrayList<DisplayInfo>();
+ mDisplayOutputManager = null;
+ try{
+ mDisplayOutputManager = new DisplayOutputManager();
+ }catch (Exception e){
+ Log.i(TAG, "new DisplayOutputManger exception:" + e);
+ }
+ mIsUseDisplayd = SystemProperties.getBoolean("ro.rk.displayd.enable", true);
+ Log.d("LOUHN_DEBUG","mIsUseDisplayd2="+mIsUseDisplayd +" in DisplaySettings.java");
+ Display[] displays = mDisplayManager.getDisplays();
+ if(!mIsUseDisplayd){
+ displayInfos.addAll(DrmDisplaySetting.getDisplayInfoList());
+ }else{
+ //使用rk_fb方式获取显示列表
+ int[] mainTypes = mDisplayOutputManager.getIfaceList(mDisplayOutputManager.MAIN_DISPLAY);
+ int[] externalTypes = mDisplayOutputManager.getIfaceList(mDisplayOutputManager.AUX_DISPLAY);
+ //RK系列芯片,目前最多只能支持2个屏幕
+ if(mainTypes != null && mainTypes.length > 0){
+ int currMainType = mDisplayOutputManager.getCurrentInterface(mDisplayOutputManager.MAIN_DISPLAY);
+ //主屏只能有一个
+ DisplayInfo displayInfo = new DisplayInfo();
+ displayInfo.setDisplayId(0);
+ displayInfo.setDescription((String)invokeMethod(mDisplayOutputManager, "typetoface", new Class[]{int.class}, new Integer[]{currMainType}));
+ displayInfo.setType(currMainType);
+ displayInfo.setModes(mDisplayOutputManager.getModeList(0,currMainType));
+ displayInfos.add(displayInfo);
+ }
+ if(externalTypes != null && externalTypes.length > 0){
+ int currExternalType = mDisplayOutputManager.getCurrentInterface(mDisplayOutputManager.AUX_DISPLAY);
+ //副屏只能有一个
+ DisplayInfo displayInfo = new DisplayInfo();
+ displayInfo.setType(currExternalType);
+ displayInfo.setModes(mDisplayOutputManager.getModeList(1,currExternalType));
+ displayInfo.setDescription((String)invokeMethod(mDisplayOutputManager, "typetoface", new Class[]{int.class}, new Integer[]{currExternalType}));
+ //副屏的id需要搜索标准接口
+ for(Display display : displays){
+ if(display.getDisplayId() != 0){
+ displayInfo.setDisplayId(display.getDisplayId());
+ break;
+ }
+ }
+ displayInfos.add(displayInfo);
+ }
+ }
+ return displayInfos;
+ }
+
+ /**
+ * 反射调用相关方法
+ * @param object
+ * @param methodName
+ * @param parameterTypes
+ * @param args
+ * @return
+ */
+ private Object invokeMethod(Object object, String methodName, Class<?>[] parameterTypes, Object[] args){
+ Object result = null;
+ try{
+ Method method = object.getClass().getDeclaredMethod(methodName, parameterTypes);
+ method.setAccessible(true);
+ result = method.invoke(object, args);
+ }catch (Exception e){
+ Log.i(TAG, "invokeMethod->exception:" + e);
+ }
+ return result;
+ }
+
+
+ /**
+ * 转换显示接口
+ */
+ private void changeDisplayInterface(boolean isHDMIConnect){
+ mDisplayOutputManager = null;
+ try{
+ mDisplayOutputManager = new DisplayOutputManager();
+ }catch (Exception e){
+ Log.i(TAG, "new DisplayOutputManger exception:" + e);
+ }
+ if(!isHDMIConnect){
+ mDisplayOutputManager.setInterface(mDisplayOutputManager.MAIN_DISPLAY,1, true);
+ }
+ }
+
+ /**
+ * 显示设备插拔监听器
+ * @author GaoFei
+ *
+ */
+ class DisplayListener implements DisplayManager.DisplayListener{
+
+ @Override
+ public void onDisplayAdded(int displayId) {
+ Log.i(TAG, "DisplayListener->onDisplayAdded");
+ rebuildView();
+ }
+
+ @Override
+ public void onDisplayRemoved(int displayId) {
+ Log.i(TAG, "DisplayListener->onDisplayRemoved");
+ rebuildView();
+ }
+
+ @Override
+ public void onDisplayChanged(int displayId) {
+ Log.i(TAG, "DisplayListener->onDisplayChanged");
+
+ }
+
+ }
+
+ /**
+ * HDMI 热插拔事件
+ * @author GaoFei
+ *
+ */
+ class HDMIReceiver extends BroadcastReceiver{
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ boolean state = intent.getBooleanExtra("state", true);
+ changeDisplayInterface(state);
+ //Log.i(TAG, "HDMIReceiver->onReceive");
+ rebuildView();
+ }
+
}
+ //end by louhn advancedSetting
private static boolean allowAllRotations(Context context) {
return Resources.getSystem().getBoolean(
diff --git a/src/com/android/settings/HdmiSettings.java b/src/com/android/settings/HdmiSettings.java
index 9fe6a92..c64fe75 100755
--- a/src/com/android/settings/HdmiSettings.java
+++ b/src/com/android/settings/HdmiSettings.java
@@ -56,7 +56,7 @@ import com.android.settings.display.*;
import android.app.DialogFragment;
import com.android.settings.data.ConstData;
-
+import com.android.settings.data.ConstDataTwo;
import android.hardware.display.DisplayManager;
import android.view.Display;
@@ -72,6 +72,12 @@ public class HdmiSettings extends SettingsPreferenceFragment
private static final String TAG = "HdmiSettings";
private static final String KEY_HDMI_RESOLUTION = "hdmi_resolution";
private static final String KEY_HDMI_SCALE = "hdmi_screen_zoom";
+ /*add by louhn:advanced setting*/
+ private static final String KEY_ADVANCED_SETTINGS = "advanced_settings";
+ private static final String KEY_ADVANCED_SETTINGS_MAIN = "advanced_settings_main";
+ private Preference mHdmiAdvancedSetting;
+ private Preference mHdmiAdvancedMainSetting;
+
private static final String KEY_HDMI_ROTATION="hdmi_rotation";
private static final String KEY_HDMI_DUAL_SCREEN = "dual_screen_setting";
private static final String KEY_HDMI_DUAL_SCREEN_VH = "dual_screen_vh";
@@ -154,7 +160,14 @@ public class HdmiSettings extends SettingsPreferenceFragment
mHdmiDualScreen = (CheckBoxPreference)findPreference(KEY_HDMI_DUAL_SCREEN);
mHdmiDualScreen.setChecked(enable);
mHdmiDualScreen.setOnPreferenceChangeListener(this);
-
+
+ /*add by louhn:advanced setting*/
+ mHdmiAdvancedSetting = findPreference(KEY_ADVANCED_SETTINGS);
+ mHdmiAdvancedSetting.setOnPreferenceClickListener(this);
+ mHdmiAdvancedMainSetting = findPreference(KEY_ADVANCED_SETTINGS_MAIN);
+ mHdmiAdvancedMainSetting.setOnPreferenceClickListener(this);
+
+
mHdmiDualScreenVH = (CheckBoxPreference)findPreference(KEY_HDMI_DUAL_SCREEN_VH);
mHdmiDualScreenVH.setChecked(SystemProperties.getBoolean("persist.sys.rotation.efull", false));
mHdmiDualScreenVH.setOnPreferenceChangeListener(this);
@@ -258,16 +271,24 @@ public class HdmiSettings extends SettingsPreferenceFragment
/**
* 还原分辨率值
*/
- public void updateResolutionValue() {
- String resolutionValue = null;
- mDisplayInfo = getDisplayInfo();
- if (mDisplayInfo != null)
- resolutionValue = DrmDisplaySetting.getCurDisplayMode(mDisplayInfo);
- Log.i(TAG, "resolutionValue:" + resolutionValue);
- mOldResolution = resolutionValue;
- if (resolutionValue != null)
- mHdmiResolution.setValue(resolutionValue);
- }
+ public void updateResolutionValue(){
+ String resolutionValue = null;
+ if(!mIsUseDisplayd){
+ resolutionValue = DrmDisplaySetting.getCurDisplayMode(mDisplayInfo);
+ Log.i(TAG, "3399 resolutionValue:" + resolutionValue);
+ }else{
+ DisplayOutputManager displayOutputManager = null;
+ try{
+ displayOutputManager = new DisplayOutputManager();
+ resolutionValue = displayOutputManager.getCurrentMode(mDisplayInfo.getDisplayId() == 0 ? 0 : 1, mDisplayInfo.getType());
+ }catch (Exception e){
+ Log.i(TAG, "updateResolutionValue->exception:" + e);
+ }
+ if(mOldResolution == null)
+ mOldResolution = resolutionValue;
+ }
+ }
+
private void updateHDMIState() {
Display[] allDisplays = mDisplayManager.getDisplays();
@@ -338,7 +359,20 @@ public class HdmiSettings extends SettingsPreferenceFragment
String value = SystemProperties.get("persist.sys.rotation.einit","0");
mHdmiDualScreenList.setValue(value);
}
- return true;
+ /*add by louhn:advanced setting*/
+ else if (preference == mHdmiAdvancedSetting) {
+ Intent advancedSettingIntent = new Intent(getActivity(), AdvancedDisplaySettingsActivity.class);
+ advancedSettingIntent.putExtra(ConstData.IntentKey.DISPLAY_ID, 1);
+ getActivity().startActivity(advancedSettingIntent);
+ }
+
+ else if (preference == mHdmiAdvancedMainSetting) {
+ Intent advancedSettingIntentMain = new Intent(getActivity(), AdvancedDisplaySettingsMainActivity.class);
+ Log.d("LOUHN_DEBUG","in onPreferenceClick second");
+ advancedSettingIntentMain.putExtra(ConstDataTwo.IntentKey.DISPLAY_ID, 0);
+ getActivity().startActivity(advancedSettingIntentMain);
+ }
+ return true;
}
@Override
|
|