diff --git a/frameworks/base/services/core/java/com/android/server/rkdisplay/HdmiReceiver.java b/frameworks/base/services/core/java/com/android/server/rkdisplay/HdmiReceiver.java
old mode 100644
new mode 100755
index 56caf26bd1…af1ff9496e
— a/frameworks/base/services/core/java/com/android/server/rkdisplay/HdmiReceiver.java
+++ b/frameworks/base/services/core/java/com/android/server/rkdisplay/HdmiReceiver.java
@@ -31,7 +31,16 @@ import android.view.WindowManager;
import java.util.Timer;
import java.util.TimerTask;
import java.util.Vector;
+import android.os.RkDisplayOutputManager;
+import java.util.Map;
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.ArrayList;
- import java.util.List;
+//import com.android.settings.utils.ReflectUtils;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
public class HdmiReceiver extends BroadcastReceiver{
private static final String TAG = “HdmiReceiver”;
private final String HDMI_ACTION = “android.intent.action.HDMI_PLUGGED”;
@@ -64,10 +73,177 @@ public class HdmiReceiver extends BroadcastReceiver{
Log.d(TAG,"onReceive mTaskVector.size() = "+mTaskVector.size());
}
}
- private HashMap<Integer, DisplayInfo> mDisplayInfoList = new HashMap<Integer, DisplayInfo>();
public void updateDisplayInfos(){
mDisplayModes.updateDisplayInfos(); -
Log.v(TAG,"mDisplayModes.updateDisplayInfos="); -
new Thread(){ -
@Override -
public void run() { -
super.run(); -
Log.v(TAG,"initDisplayInfo="); -
initDisplayInfo(); -
} -
}.start(); - }
- DisplayInfo mSelectDisplayInfo;
- public void initDisplayInfo(){
-
RkDisplayOutputManager manager = new RkDisplayOutputManager(); -
int displayNumber = manager.getDisplayNumber(); -
Log.v(TAG, "displayNumber:"+displayNumber); -
for (int i = 0; i < displayNumber; i++) { -
int display = i; -
DisplayInfo displayInfo = new DisplayInfo(); -
displayInfo.setDisplayNo(display); -
mDisplayInfoList.put(display, displayInfo); -
} -
for (Map.Entry<Integer, DisplayInfo> entry : mDisplayInfoList.entrySet()) { -
int display = entry.getKey(); -
Log.v(TAG,"display="+display); -
String key ="Resolution1"; -
// int display = Integer.parseInt(key.replace(KEY_PRE_RESOLUTION, "")); -
// if (display == entry.getKey()) { -
mSelectDisplayInfo = entry.getValue(); -
// } -
Log.v(TAG,"mSelectDisplayInfo="+mSelectDisplayInfo); -
} -
initSetMode(); - }
- public static final int DPY_STATUS_CONNECTED = 1;
- public void initSetMode(){
-
updateSettingsDisplayInfos(); -
updateDisplayModesInfo(mSelectDisplayInfo); -
RkDisplayOutputManager manager = new RkDisplayOutputManager(); -
int display = mSelectDisplayInfo.getDisplayNo(); -
int status = manager.getCurrentDpyConnState(display); -
mSelectDisplayInfo.setStatus(status); -
String[] modes = mSelectDisplayInfo.getOrginModes(); -
int index = 0; -
Log.v(TAG, "display " + display + ", status=" + status + ", modes=" + modes ); -
Log.v(TAG, "index " + index ); -
if (DPY_STATUS_CONNECTED == status && null != modes && modes.length > 0) { -
setDisplayModeTemp(mSelectDisplayInfo, index);
+// String mode = Arrays.asList(modes).get(index);
+// DrmDisplaySetting.setMode(display, mode);
+
-
} - }
-
public static void setMode(int display, String mode) { -
RkDisplayOutputManager manager = new RkDisplayOutputManager(); -
int result = manager.updateDisplayInfos(); -
int type = manager.getCurrentInterface(display); -
Log.v(TAG,"setMode display=" + display + ", type=" + type + ", mode=" + mode); -
manager.setMode(display, type, mode); - }
-
private static String tmpSetMode = null; -
public static void setDisplayModeTemp(DisplayInfo di, int index) { -
String[] modes = di.getOrginModes(); -
String mode ="1920x1080p60"; -
for (int i = 0 ;i < modes.length; i++) { -
String value = modes[i]; -
if (value.contains("1920x1080p60")){ -
mode = Arrays.asList(di.getOrginModes()).get(i); -
} -
} -
// String mode = Arrays.asList(di.getOrginModes()).get(index); -
setMode(di.getDisplayNo(), mode); -
tmpSetMode = mode; - }
- public static void updateDisplayModesInfo(DisplayInfo displayInfo) {
-
int display = displayInfo.getDisplayNo(); -
RkDisplayOutputManager manager = new RkDisplayOutputManager();
+// int[] ifaces = manager.getIfaceList(display);
+// if (null == ifaces || ifaces.length < 1) {
+// Log.w(TAG, "display " + display + “, ifaces=” + ifaces);
+// displayInfo.setOrginModes(null);
+// displayInfo.setModes(null);
+// displayInfo.setCurrentResolution(null);
+// } else {
-
int type = manager.getCurrentInterface(display); -
String[] orginModes = manager.getModeList(display, type); -
orginModes = filterOrginModes(orginModes); -
displayInfo.setOrginModes(orginModes); -
displayInfo.setModes(getFilterModeList(orginModes)); -
String currentMode = manager.getCurrentMode(display, type); -
displayInfo.setCurrentResolution(currentMode);
+// }
}
+
-
private static String[] filterOrginModes(String[] modes) { -
if (modes == null) -
return null; -
List<String> filterModeList = new ArrayList<String>(); -
List<String> resModeList = new ArrayList<String>(); -
for (int i = 0; i < modes.length; ++i) { -
Log.v(TAG,"filterOrginModes->mode:" + modes[i]); -
String itemMode = modes[i]; -
int endIndex = itemMode.indexOf("-"); -
if (endIndex > 0) -
itemMode = itemMode.substring(0, endIndex); -
if (!resModeList.contains(itemMode)) { -
resModeList.add(itemMode); -
if (!filterModeList.contains(modes[i])) -
filterModeList.add(modes[i]); -
} -
} -
return filterModeList.toArray(new String[0]); - }
- public static void updateSettingsDisplayInfos() {
-
Object rkDisplayOutputManager = null; -
try { -
rkDisplayOutputManager = Class.forName("android.os.RkDisplayOutputManager").newInstance(); -
} catch (Exception e) { -
// no handle -
} -
if (rkDisplayOutputManager != null) { -
Log.v(TAG,"updateDisplayInfos"); -
int result = (Integer) invokeMethodNoParameter(rkDisplayOutputManager, "updateDisplayInfos"); -
} - }
-
public static Object invokeMethodNoParameter(Object object, String methodName) { -
try { -
Method method = object.getClass().getDeclaredMethod(methodName); -
method.setAccessible(true); -
return method.invoke(object); -
//return method.invoke(object, paramTypes); -
} catch (Exception e) { -
Log.e(TAG, "invokeMethod->methodName:" + methodName); -
Log.e(TAG, "invokeMethod->exception:" + e); -
} -
return null; - }
-
private static String[] getFilterModeList(String[] modes) { -
if (modes == null) -
return null; -
String[] filterModes = new String[modes.length]; -
for (int i = 0; i < modes.length; ++i) { -
String itemMode = modes[i]; -
int endIndex = itemMode.indexOf("-"); -
if (endIndex > 0) -
itemMode = itemMode.substring(0, endIndex); -
filterModes[i] = itemMode; -
} -
return filterModes; - }
private class MyTask extends TimerTask{
public void run(){
@@ -82,5 +258,100 @@ public class HdmiReceiver extends BroadcastReceiver{
}
}
}
+
+
- public class DisplayInfo implements Serializable {
- private int displayId;
- private int displayNo;
- private int status;
- private int type;
- private String description;
- private String[] modes;
- private String[] orginModes;
- private String currentResolution;
- private String lastResolution = “Auto”;
- public int getDisplayId() {
-
return displayId; - }
- public void setDisplayId(int displayId) {
-
this.displayId = displayId; - }
- public int getDisplayNo() {
-
return displayNo; - }
- public void setDisplayNo(int display) {
-
this.displayNo = display; - }
- public int getStatus() {
-
return status; - }
- public void setStatus(int status) {
-
this.status = status; - }
- public int getType() {
-
return type; - }
- public void setType(int type) {
-
this.type = type; - }
- public String getDescription() {
-
return description; - }
- public void setDescription(String description) {
-
this.description = description; - }
- public String[] getModes() {
-
return modes; - }
- public void setModes(String[] modes) {
-
this.modes = modes; - }
- public String[] getOrginModes() {
-
return orginModes; - }
- public void setOrginModes(String[] orginModes) {
-
this.orginModes = orginModes; - }
- public String getCurrentResolution() {
-
return currentResolution; - }
- public void setCurrentResolution(String currentResolution) {
-
this.currentResolution = currentResolution; - }
- public String getLastResolution() {
-
return lastResolution; - }
- public void setLastResolution(String lastResolution) {
-
this.lastResolution = lastResolution; - }
- @Override
- public String toString() {
-
StringBuilder builder = new StringBuilder(); -
builder.append("displayId:").append(displayId).append(" ") -
.append("type:").append(type).append(" ") -
.append("description:").append(description).append(" ") -
.append("modes:").append(Arrays.toString(modes)); -
return builder.toString(); - }
+}
}
这篇博客讨论了Android 11中HdmiReceiver.java文件的更新,涉及到HDMI连接状态的监听和显示信息的管理。代码变更包括新增了对RkDisplayOutputManager的引用,用于处理显示信息的更新,并且引入了反射机制来操作DisplayInfo对象,特别是关于HDMI输出的分辨率设置。



1420

被折叠的 条评论
为什么被折叠?



