CEC: Make dumpsys message history size editable
Increase or decrease the dumpsys message history using adb shell
command.
Bug: 197220407
Test: adb shell cmd hdmi_control history_size set 300
adb shell cmd hdmi_control history_size get
Change-Id: I729fcb5ef9f993f1a465d0093ebf605ff0e7cf2d
This commit is contained in:
committed by
Yan Han
parent
006c201920
commit
49b51e6772
@@ -294,6 +294,16 @@ public final class HdmiControlServiceWrapper {
|
||||
HdmiControlServiceWrapper.this.removeHdmiCecVolumeControlFeatureListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMessageHistorySize() {
|
||||
return HdmiControlServiceWrapper.this.getMessageHistorySize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setMessageHistorySize(int newSize) {
|
||||
return HdmiControlServiceWrapper.this.setMessageHistorySize(newSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCecSettingChangeListener(String name,
|
||||
IHdmiCecSettingChangeListener listener) {
|
||||
@@ -522,6 +532,16 @@ public final class HdmiControlServiceWrapper {
|
||||
public void removeHdmiCecVolumeControlFeatureListener(
|
||||
IHdmiCecVolumeControlFeatureListener listener) {}
|
||||
|
||||
/** @hide */
|
||||
public int getMessageHistorySize() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public boolean setMessageHistorySize(int newSize) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public void addCecSettingChangeListener(String name,
|
||||
IHdmiCecSettingChangeListener listener) {}
|
||||
|
||||
@@ -88,6 +88,8 @@ interface IHdmiControlService {
|
||||
void setStandbyMode(boolean isStandbyModeOn);
|
||||
void reportAudioStatus(int deviceType, int volume, int maxVolume, boolean isMute);
|
||||
void setSystemAudioModeOnForAudioOnlySource();
|
||||
boolean setMessageHistorySize(int newSize);
|
||||
int getMessageHistorySize();
|
||||
void addCecSettingChangeListener(String name, IHdmiCecSettingChangeListener listener);
|
||||
void removeCecSettingChangeListener(String name, IHdmiCecSettingChangeListener listener);
|
||||
List<String> getUserCecSettings();
|
||||
|
||||
@@ -375,6 +375,17 @@ public class HdmiAudioSystemClientTest {
|
||||
IHdmiCecVolumeControlFeatureListener listener) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMessageHistorySize() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setMessageHistorySize(int newSize) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> getUserCecSettings() {
|
||||
return new ArrayList<>();
|
||||
|
||||
@@ -90,7 +90,7 @@ final class HdmiCecController {
|
||||
|
||||
private static final int MAX_DEDICATED_ADDRESS = 11;
|
||||
|
||||
private static final int MAX_HDMI_MESSAGE_HISTORY = 250;
|
||||
private static final int INITIAL_HDMI_MESSAGE_HISTORY_SIZE = 250;
|
||||
|
||||
private static final int INVALID_PHYSICAL_ADDRESS = 0xFFFF;
|
||||
|
||||
@@ -138,8 +138,10 @@ final class HdmiCecController {
|
||||
private final HdmiControlService mService;
|
||||
|
||||
// Stores recent CEC messages and HDMI Hotplug event history for debugging purpose.
|
||||
private final ArrayBlockingQueue<Dumpable> mMessageHistory =
|
||||
new ArrayBlockingQueue<>(MAX_HDMI_MESSAGE_HISTORY);
|
||||
private ArrayBlockingQueue<Dumpable> mMessageHistory =
|
||||
new ArrayBlockingQueue<>(INITIAL_HDMI_MESSAGE_HISTORY_SIZE);
|
||||
|
||||
private final Object mMessageHistoryLock = new Object();
|
||||
|
||||
private final NativeWrapper mNativeWrapperImpl;
|
||||
|
||||
@@ -750,12 +752,39 @@ final class HdmiCecController {
|
||||
}
|
||||
|
||||
private void addEventToHistory(Dumpable event) {
|
||||
if (!mMessageHistory.offer(event)) {
|
||||
mMessageHistory.poll();
|
||||
mMessageHistory.offer(event);
|
||||
synchronized (mMessageHistoryLock) {
|
||||
if (!mMessageHistory.offer(event)) {
|
||||
mMessageHistory.poll();
|
||||
mMessageHistory.offer(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int getMessageHistorySize() {
|
||||
synchronized (mMessageHistoryLock) {
|
||||
return mMessageHistory.size() + mMessageHistory.remainingCapacity();
|
||||
}
|
||||
}
|
||||
|
||||
boolean setMessageHistorySize(int newSize) {
|
||||
if (newSize < INITIAL_HDMI_MESSAGE_HISTORY_SIZE) {
|
||||
return false;
|
||||
}
|
||||
ArrayBlockingQueue<Dumpable> newMessageHistory = new ArrayBlockingQueue<>(newSize);
|
||||
|
||||
synchronized (mMessageHistoryLock) {
|
||||
if (newSize < mMessageHistory.size()) {
|
||||
for (int i = 0; i < mMessageHistory.size() - newSize; i++) {
|
||||
mMessageHistory.poll();
|
||||
}
|
||||
}
|
||||
|
||||
newMessageHistory.addAll(mMessageHistory);
|
||||
mMessageHistory = newMessageHistory;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void dump(final IndentingPrintWriter pw) {
|
||||
pw.println("CEC message history:");
|
||||
pw.increaseIndent();
|
||||
|
||||
@@ -2365,6 +2365,25 @@ public class HdmiControlService extends SystemService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setMessageHistorySize(int newSize) {
|
||||
enforceAccessPermission();
|
||||
if (mCecController == null) {
|
||||
return false;
|
||||
}
|
||||
return mCecController.setMessageHistorySize(newSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMessageHistorySize() {
|
||||
enforceAccessPermission();
|
||||
if (mCecController != null) {
|
||||
return mCecController.getMessageHistorySize();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCecSettingChangeListener(String name,
|
||||
final IHdmiCecSettingChangeListener listener) {
|
||||
|
||||
@@ -95,6 +95,11 @@ final class HdmiControlShellCommand extends ShellCommand {
|
||||
pw.println(" deviceselect <device id>");
|
||||
pw.println(" Switch to device with given id");
|
||||
pw.println(" The device's id is represented by its logical address.");
|
||||
pw.println(" history_size get");
|
||||
pw.println(" Gets the number of messages that can be stored in dumpsys history");
|
||||
pw.println(" history_size set <new_size>");
|
||||
pw.println(" Changes the number of messages that can be stored in dumpsys history to"
|
||||
+ " new_size");
|
||||
}
|
||||
|
||||
private int handleShellCommand(String cmd) throws RemoteException {
|
||||
@@ -115,6 +120,8 @@ final class HdmiControlShellCommand extends ShellCommand {
|
||||
return setArcMode(pw);
|
||||
case "deviceselect":
|
||||
return deviceSelect(pw);
|
||||
case "history_size":
|
||||
return historySize(pw);
|
||||
}
|
||||
|
||||
getErrPrintWriter().println("Unhandled command: " + cmd);
|
||||
@@ -275,6 +282,41 @@ final class HdmiControlShellCommand extends ShellCommand {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int historySize(PrintWriter pw) throws RemoteException {
|
||||
if (1 > getRemainingArgsCount()) {
|
||||
throw new IllegalArgumentException("Use 'set' or 'get' for the command action");
|
||||
}
|
||||
|
||||
String operation = getNextArgRequired();
|
||||
switch (operation) {
|
||||
case "get": {
|
||||
int value = mBinderService.getMessageHistorySize();
|
||||
pw.println("CEC dumpsys message history size = " + value);
|
||||
return 0;
|
||||
}
|
||||
case "set": {
|
||||
String arg = getNextArgRequired();
|
||||
int value;
|
||||
try {
|
||||
value = Integer.parseInt(arg);
|
||||
} catch (NumberFormatException nfe) {
|
||||
pw.println("Cannot set CEC dumpsys message history size to " + arg);
|
||||
return 1;
|
||||
}
|
||||
if (mBinderService.setMessageHistorySize(value)) {
|
||||
pw.println("Setting CEC dumpsys message history size to " + value);
|
||||
} else {
|
||||
pw.println(
|
||||
"Message history size not changed, was it lower than the minimum "
|
||||
+ "size?");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown operation: " + operation);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean receiveCallback(String command) {
|
||||
try {
|
||||
if (!mLatch.await(HdmiConfig.TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
|
||||
|
||||
Reference in New Issue
Block a user