From f67113f7abd536cc3eb888344bf925762aa5278e Mon Sep 17 00:00:00 2001 From: Jungshik Jang Date: Fri, 22 Aug 2014 16:27:19 +0900 Subject: Use common language code in hdmi service. Bug: 15844859 Change-Id: I12945f743730ee234b25a40543ea44345abf43fa --- .../android/server/hdmi/HdmiCecLocalDeviceTv.java | 5 +++-- .../android/server/hdmi/HdmiControlService.java | 22 +++++++++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java index 4e8c46f..935714c 100644 --- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java +++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java @@ -327,7 +327,9 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { addAndStartAction(new RoutingControlAction(this, newPath, true, callback)); } + @ServiceThreadOnly int getPowerStatus() { + assertRunOnServiceThread(); return mService.getPowerStatus(); } @@ -428,8 +430,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { @ServiceThreadOnly protected boolean handleGetMenuLanguage(HdmiCecMessage message) { assertRunOnServiceThread(); - // TODO: figure out how to handle failed to get language code. - if (!broadcastMenuLanguage(Locale.getDefault().getISO3Language())) { + if (!broadcastMenuLanguage(mService.getLanguage())) { Slog.w(TAG, "Failed to respond to : " + message.toString()); } return true; diff --git a/services/core/java/com/android/server/hdmi/HdmiControlService.java b/services/core/java/com/android/server/hdmi/HdmiControlService.java index 3dabc11..3021285 100644 --- a/services/core/java/com/android/server/hdmi/HdmiControlService.java +++ b/services/core/java/com/android/server/hdmi/HdmiControlService.java @@ -126,8 +126,10 @@ public final class HdmiControlService extends SystemService { } private class HdmiControlBroadcastReceiver extends BroadcastReceiver { + @ServiceThreadOnly @Override public void onReceive(Context context, Intent intent) { + assertRunOnServiceThread(); switch (intent.getAction()) { case Intent.ACTION_SCREEN_OFF: if (isPowerOnOrTransient()) { @@ -355,6 +357,7 @@ public final class HdmiControlService extends SystemService { super(handler); } + // onChange is set up to run in service thread. @Override public void onChange(boolean selfChange, Uri uri) { String option = uri.getLastPathSegment(); @@ -1661,21 +1664,29 @@ public final class HdmiControlService extends SystemService { } } + @ServiceThreadOnly int getPowerStatus() { + assertRunOnServiceThread(); return mPowerStatus; } + @ServiceThreadOnly boolean isPowerOnOrTransient() { + assertRunOnServiceThread(); return mPowerStatus == HdmiControlManager.POWER_STATUS_ON || mPowerStatus == HdmiControlManager.POWER_STATUS_TRANSIENT_TO_ON; } + @ServiceThreadOnly boolean isPowerStandbyOrTransient() { + assertRunOnServiceThread(); return mPowerStatus == HdmiControlManager.POWER_STATUS_STANDBY || mPowerStatus == HdmiControlManager.POWER_STATUS_TRANSIENT_TO_STANDBY; } + @ServiceThreadOnly boolean isPowerStandby() { + assertRunOnServiceThread(); return mPowerStatus == HdmiControlManager.POWER_STATUS_STANDBY; } @@ -1699,11 +1710,6 @@ public final class HdmiControlService extends SystemService { // the intent, the sequence will continue at onStandby(). } - void nap() { - PowerManager pm = (PowerManager) getContext().getSystemService(Context.POWER_SERVICE); - pm.nap(SystemClock.uptimeMillis()); - } - @ServiceThreadOnly private void onWakeUp() { assertRunOnServiceThread(); @@ -1753,6 +1759,12 @@ public final class HdmiControlService extends SystemService { } } + @ServiceThreadOnly + String getLanguage() { + assertRunOnServiceThread(); + return mLanguage; + } + private void disableDevices(PendingActionClearedCallback callback) { if (mCecController != null) { for (HdmiCecLocalDevice device : mCecController.getLocalDeviceList()) { -- cgit v1.1