Loading services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java +7 −1 Original line number Diff line number Diff line Loading @@ -737,6 +737,9 @@ abstract class HdmiCecLocalDevice { } } void setAutoDeviceOff(boolean enabled) { } /** * Called when a hot-plug event issued. * Loading Loading @@ -829,8 +832,11 @@ abstract class HdmiCecLocalDevice { * * @param initiatedByCec true if this power sequence is initiated * by the reception the CEC messages like <Standby> * @param standbyAction Intent action that drives the standby process, * either {@link HdmiControlService#STANDBY_SCREEN_OFF} or * {@link HdmiControlService#STANDBY_SHUTDOWN} */ protected void onStandby(boolean initiatedByCec) {} protected void onStandby(boolean initiatedByCec, int standbyAction) {} /** * Disable device. {@code callback} is used to get notified when all pending Loading services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java +40 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.os.PowerManager; import android.os.PowerManager.WakeLock; import android.os.RemoteException; import android.os.SystemProperties; import android.provider.Settings.Global; import android.util.Slog; import com.android.internal.util.IndentingPrintWriter; Loading @@ -47,8 +48,17 @@ final class HdmiCecLocalDevicePlayback extends HdmiCecLocalDevice { // Lazily initialized - should call getWakeLock() to get the instance. private ActiveWakeLock mWakeLock; // If true, turn off TV upon standby. False by default. private boolean mAutoTvOff; HdmiCecLocalDevicePlayback(HdmiControlService service) { super(service, HdmiDeviceInfo.DEVICE_PLAYBACK); mAutoTvOff = mService.readBooleanSetting(Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED, false); // The option is false by default. Update settings db as well to have the right // initial setting on UI. mService.writeBooleanSetting(Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED, mAutoTvOff); } @Override Loading Loading @@ -141,6 +151,35 @@ final class HdmiCecLocalDevicePlayback extends HdmiCecLocalDevice { } } @Override @ServiceThreadOnly protected void onStandby(boolean initiatedByCec, int standbyAction) { assertRunOnServiceThread(); if (!mService.isControlEnabled() || initiatedByCec) { return; } switch (standbyAction) { case HdmiControlService.STANDBY_SCREEN_OFF: if (mAutoTvOff) { mService.sendCecCommand( HdmiCecMessageBuilder.buildStandby(mAddress, Constants.ADDR_TV)); } break; case HdmiControlService.STANDBY_SHUTDOWN: // ACTION_SHUTDOWN is taken as a signal to power off all the devices. mService.sendCecCommand( HdmiCecMessageBuilder.buildStandby(mAddress, Constants.ADDR_BROADCAST)); break; } } @Override @ServiceThreadOnly void setAutoDeviceOff(boolean enabled) { assertRunOnServiceThread(); mAutoTvOff = enabled; } @ServiceThreadOnly void setActiveSource(boolean on) { assertRunOnServiceThread(); Loading Loading @@ -295,6 +334,7 @@ final class HdmiCecLocalDevicePlayback extends HdmiCecLocalDevice { protected void dump(final IndentingPrintWriter pw) { super.dump(pw); pw.println("mIsActiveSource: " + mIsActiveSource); pw.println("mAutoTvOff:" + mAutoTvOff); } // Wrapper interface over PowerManager.WakeLock Loading services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java +2 −1 Original line number Diff line number Diff line Loading @@ -1583,6 +1583,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { } } @Override @ServiceThreadOnly void setAutoDeviceOff(boolean enabled) { assertRunOnServiceThread(); Loading Loading @@ -1659,7 +1660,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { @Override @ServiceThreadOnly protected void onStandby(boolean initiatedByCec) { protected void onStandby(boolean initiatedByCec, int standbyAction) { assertRunOnServiceThread(); // Seq #11 if (!mService.isControlEnabled()) { Loading services/core/java/com/android/server/hdmi/HdmiControlService.java +19 −7 Original line number Diff line number Diff line Loading @@ -106,6 +106,12 @@ public final class HdmiControlService extends SystemService { static final int INITIATED_BY_WAKE_UP_MESSAGE = 3; static final int INITIATED_BY_HOTPLUG = 4; // The reason code representing the intent action that drives the standby // procedure. The procedure starts either by Intent.ACTION_SCREEN_OFF or // Intent.ACTION_SHUTDOWN. static final int STANDBY_SCREEN_OFF = 0; static final int STANDBY_SHUTDOWN = 1; /** * Interface to report send result. */ Loading Loading @@ -143,7 +149,7 @@ public final class HdmiControlService extends SystemService { switch (intent.getAction()) { case Intent.ACTION_SCREEN_OFF: if (isPowerOnOrTransient()) { onStandby(); onStandby(STANDBY_SCREEN_OFF); } break; case Intent.ACTION_SCREEN_ON: Loading @@ -157,6 +163,11 @@ public final class HdmiControlService extends SystemService { onLanguageChanged(language); } break; case Intent.ACTION_SHUTDOWN: if (isPowerOnOrTransient()) { onStandby(STANDBY_SHUTDOWN); } break; } } Loading Loading @@ -510,8 +521,9 @@ public final class HdmiControlService extends SystemService { setCecOption(OPTION_CEC_AUTO_WAKEUP, toInt(enabled)); break; case Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED: if (isTvDeviceEnabled()) { tv().setAutoDeviceOff(enabled); for (int type : mLocalDevices) { HdmiCecLocalDevice localDevice = mCecController.getLocalDevice(type); localDevice.setAutoDeviceOff(enabled); } // No need to propagate to HAL. break; Loading Loading @@ -1994,7 +2006,7 @@ public final class HdmiControlService extends SystemService { } @ServiceThreadOnly private void onStandby() { private void onStandby(final int standbyAction) { assertRunOnServiceThread(); if (!canGoToStandby()) return; mPowerStatus = HdmiControlManager.POWER_STATUS_TRANSIENT_TO_STANDBY; Loading @@ -2008,7 +2020,7 @@ public final class HdmiControlService extends SystemService { Slog.v(TAG, "On standby-action cleared:" + device.mDeviceType); devices.remove(device); if (devices.isEmpty()) { onStandbyCompleted(); onStandbyCompleted(standbyAction); // We will not clear local devices here, since some OEM/SOC will keep passing // the received packets until the application processor enters to the sleep // actually. Loading Loading @@ -2062,7 +2074,7 @@ public final class HdmiControlService extends SystemService { } @ServiceThreadOnly private void onStandbyCompleted() { private void onStandbyCompleted(int standbyAction) { assertRunOnServiceThread(); Slog.v(TAG, "onStandbyCompleted"); Loading @@ -2071,7 +2083,7 @@ public final class HdmiControlService extends SystemService { } mPowerStatus = HdmiControlManager.POWER_STATUS_STANDBY; for (HdmiCecLocalDevice device : mCecController.getLocalDeviceList()) { device.onStandby(mStandbyMessageReceived); device.onStandby(mStandbyMessageReceived, standbyAction); } mStandbyMessageReceived = false; mAddressAllocated = false; Loading Loading
services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java +7 −1 Original line number Diff line number Diff line Loading @@ -737,6 +737,9 @@ abstract class HdmiCecLocalDevice { } } void setAutoDeviceOff(boolean enabled) { } /** * Called when a hot-plug event issued. * Loading Loading @@ -829,8 +832,11 @@ abstract class HdmiCecLocalDevice { * * @param initiatedByCec true if this power sequence is initiated * by the reception the CEC messages like <Standby> * @param standbyAction Intent action that drives the standby process, * either {@link HdmiControlService#STANDBY_SCREEN_OFF} or * {@link HdmiControlService#STANDBY_SHUTDOWN} */ protected void onStandby(boolean initiatedByCec) {} protected void onStandby(boolean initiatedByCec, int standbyAction) {} /** * Disable device. {@code callback} is used to get notified when all pending Loading
services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java +40 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.os.PowerManager; import android.os.PowerManager.WakeLock; import android.os.RemoteException; import android.os.SystemProperties; import android.provider.Settings.Global; import android.util.Slog; import com.android.internal.util.IndentingPrintWriter; Loading @@ -47,8 +48,17 @@ final class HdmiCecLocalDevicePlayback extends HdmiCecLocalDevice { // Lazily initialized - should call getWakeLock() to get the instance. private ActiveWakeLock mWakeLock; // If true, turn off TV upon standby. False by default. private boolean mAutoTvOff; HdmiCecLocalDevicePlayback(HdmiControlService service) { super(service, HdmiDeviceInfo.DEVICE_PLAYBACK); mAutoTvOff = mService.readBooleanSetting(Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED, false); // The option is false by default. Update settings db as well to have the right // initial setting on UI. mService.writeBooleanSetting(Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED, mAutoTvOff); } @Override Loading Loading @@ -141,6 +151,35 @@ final class HdmiCecLocalDevicePlayback extends HdmiCecLocalDevice { } } @Override @ServiceThreadOnly protected void onStandby(boolean initiatedByCec, int standbyAction) { assertRunOnServiceThread(); if (!mService.isControlEnabled() || initiatedByCec) { return; } switch (standbyAction) { case HdmiControlService.STANDBY_SCREEN_OFF: if (mAutoTvOff) { mService.sendCecCommand( HdmiCecMessageBuilder.buildStandby(mAddress, Constants.ADDR_TV)); } break; case HdmiControlService.STANDBY_SHUTDOWN: // ACTION_SHUTDOWN is taken as a signal to power off all the devices. mService.sendCecCommand( HdmiCecMessageBuilder.buildStandby(mAddress, Constants.ADDR_BROADCAST)); break; } } @Override @ServiceThreadOnly void setAutoDeviceOff(boolean enabled) { assertRunOnServiceThread(); mAutoTvOff = enabled; } @ServiceThreadOnly void setActiveSource(boolean on) { assertRunOnServiceThread(); Loading Loading @@ -295,6 +334,7 @@ final class HdmiCecLocalDevicePlayback extends HdmiCecLocalDevice { protected void dump(final IndentingPrintWriter pw) { super.dump(pw); pw.println("mIsActiveSource: " + mIsActiveSource); pw.println("mAutoTvOff:" + mAutoTvOff); } // Wrapper interface over PowerManager.WakeLock Loading
services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java +2 −1 Original line number Diff line number Diff line Loading @@ -1583,6 +1583,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { } } @Override @ServiceThreadOnly void setAutoDeviceOff(boolean enabled) { assertRunOnServiceThread(); Loading Loading @@ -1659,7 +1660,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { @Override @ServiceThreadOnly protected void onStandby(boolean initiatedByCec) { protected void onStandby(boolean initiatedByCec, int standbyAction) { assertRunOnServiceThread(); // Seq #11 if (!mService.isControlEnabled()) { Loading
services/core/java/com/android/server/hdmi/HdmiControlService.java +19 −7 Original line number Diff line number Diff line Loading @@ -106,6 +106,12 @@ public final class HdmiControlService extends SystemService { static final int INITIATED_BY_WAKE_UP_MESSAGE = 3; static final int INITIATED_BY_HOTPLUG = 4; // The reason code representing the intent action that drives the standby // procedure. The procedure starts either by Intent.ACTION_SCREEN_OFF or // Intent.ACTION_SHUTDOWN. static final int STANDBY_SCREEN_OFF = 0; static final int STANDBY_SHUTDOWN = 1; /** * Interface to report send result. */ Loading Loading @@ -143,7 +149,7 @@ public final class HdmiControlService extends SystemService { switch (intent.getAction()) { case Intent.ACTION_SCREEN_OFF: if (isPowerOnOrTransient()) { onStandby(); onStandby(STANDBY_SCREEN_OFF); } break; case Intent.ACTION_SCREEN_ON: Loading @@ -157,6 +163,11 @@ public final class HdmiControlService extends SystemService { onLanguageChanged(language); } break; case Intent.ACTION_SHUTDOWN: if (isPowerOnOrTransient()) { onStandby(STANDBY_SHUTDOWN); } break; } } Loading Loading @@ -510,8 +521,9 @@ public final class HdmiControlService extends SystemService { setCecOption(OPTION_CEC_AUTO_WAKEUP, toInt(enabled)); break; case Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED: if (isTvDeviceEnabled()) { tv().setAutoDeviceOff(enabled); for (int type : mLocalDevices) { HdmiCecLocalDevice localDevice = mCecController.getLocalDevice(type); localDevice.setAutoDeviceOff(enabled); } // No need to propagate to HAL. break; Loading Loading @@ -1994,7 +2006,7 @@ public final class HdmiControlService extends SystemService { } @ServiceThreadOnly private void onStandby() { private void onStandby(final int standbyAction) { assertRunOnServiceThread(); if (!canGoToStandby()) return; mPowerStatus = HdmiControlManager.POWER_STATUS_TRANSIENT_TO_STANDBY; Loading @@ -2008,7 +2020,7 @@ public final class HdmiControlService extends SystemService { Slog.v(TAG, "On standby-action cleared:" + device.mDeviceType); devices.remove(device); if (devices.isEmpty()) { onStandbyCompleted(); onStandbyCompleted(standbyAction); // We will not clear local devices here, since some OEM/SOC will keep passing // the received packets until the application processor enters to the sleep // actually. Loading Loading @@ -2062,7 +2074,7 @@ public final class HdmiControlService extends SystemService { } @ServiceThreadOnly private void onStandbyCompleted() { private void onStandbyCompleted(int standbyAction) { assertRunOnServiceThread(); Slog.v(TAG, "onStandbyCompleted"); Loading @@ -2071,7 +2083,7 @@ public final class HdmiControlService extends SystemService { } mPowerStatus = HdmiControlManager.POWER_STATUS_STANDBY; for (HdmiCecLocalDevice device : mCecController.getLocalDeviceList()) { device.onStandby(mStandbyMessageReceived); device.onStandby(mStandbyMessageReceived, standbyAction); } mStandbyMessageReceived = false; mAddressAllocated = false; Loading