Merge changes Ifb05b969,I74808d8e
* changes: [CEC Configuration] Switch HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED to Shared Preferences [CEC Configuration] Switch HDMI_CEC_ENABLED to Shared Preferences
This commit is contained in:
@@ -1422,7 +1422,8 @@ public final class HdmiControlManager {
|
||||
* Called when HDMI Control (CEC) is enabled/disabled.
|
||||
*
|
||||
* @param isCecEnabled status of HDMI Control
|
||||
* {@link android.provider.Settings.Global#HDMI_CONTROL_ENABLED}: {@code true} if enabled.
|
||||
* {@link android.hardware.hdmi.HdmiControlManager#CEC_SETTING_NAME_HDMI_CEC_ENABLED}:
|
||||
* {@code HDMI_CEC_CONTROL_ENABLED} if enabled.
|
||||
* @param isCecAvailable status of CEC support of the connected display (the TV).
|
||||
* {@code true} if supported.
|
||||
*
|
||||
|
||||
@@ -11049,24 +11049,6 @@ public final class Settings {
|
||||
@Deprecated
|
||||
public static final String INSTALL_NON_MARKET_APPS = Secure.INSTALL_NON_MARKET_APPS;
|
||||
|
||||
/**
|
||||
* Whether HDMI control shall be enabled. If disabled, no CEC/MHL command will be
|
||||
* sent or processed. (0 = false, 1 = true)
|
||||
* @hide
|
||||
*/
|
||||
@Readable
|
||||
public static final String HDMI_CONTROL_ENABLED = "hdmi_control_enabled";
|
||||
|
||||
/**
|
||||
* Whether TV will also turn off other CEC devices when it goes to standby mode.
|
||||
* (0 = false, 1 = true)
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@Readable
|
||||
public static final String HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED =
|
||||
"hdmi_control_auto_device_off_enabled";
|
||||
|
||||
/**
|
||||
* Whether or not media is shown automatically when bypassing as a heads up.
|
||||
* @hide
|
||||
|
||||
@@ -242,9 +242,6 @@
|
||||
<!-- Default for Settings.Secure.AWARE_LOCK_ENABLED -->
|
||||
<bool name="def_aware_lock_enabled">false</bool>
|
||||
|
||||
<!-- Default for setting for Settings.Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED -->
|
||||
<bool name="def_hdmiControlAutoDeviceOff">true</bool>
|
||||
|
||||
<!-- Default for Settings.Secure.SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED -->
|
||||
<bool name="def_swipe_bottom_to_notification_enabled">false</bool>
|
||||
|
||||
|
||||
@@ -800,15 +800,6 @@ class SettingsProtoDumpUtil {
|
||||
GlobalSettingsProto.Gpu.UPDATABLE_DRIVER_SPHAL_LIBRARIES);
|
||||
p.end(gpuToken);
|
||||
|
||||
final long hdmiToken = p.start(GlobalSettingsProto.HDMI);
|
||||
dumpSetting(s, p,
|
||||
Settings.Global.HDMI_CONTROL_ENABLED,
|
||||
GlobalSettingsProto.Hdmi.CONTROL_ENABLED);
|
||||
dumpSetting(s, p,
|
||||
Settings.Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED,
|
||||
GlobalSettingsProto.Hdmi.CONTROL_AUTO_DEVICE_OFF_ENABLED);
|
||||
p.end(hdmiToken);
|
||||
|
||||
dumpSetting(s, p,
|
||||
Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED,
|
||||
GlobalSettingsProto.HEADS_UP_NOTIFICATIONS_ENABLED);
|
||||
|
||||
@@ -4948,16 +4948,7 @@ public class SettingsProvider extends ContentProvider {
|
||||
|
||||
if (currentVersion == 190) {
|
||||
// Version 190: get HDMI auto device off from overlay
|
||||
final SettingsState globalSettings = getGlobalSettingsLocked();
|
||||
final Setting currentSetting = globalSettings.getSettingLocked(
|
||||
Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED);
|
||||
if (currentSetting.isNull()) {
|
||||
globalSettings.insertSettingLocked(
|
||||
Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED,
|
||||
getContext().getResources().getBoolean(
|
||||
R.bool.def_hdmiControlAutoDeviceOff) ? "1" : "0",
|
||||
null, true, SettingsState.SYSTEM_PACKAGE_NAME);
|
||||
}
|
||||
// HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED settings option was removed
|
||||
currentVersion = 191;
|
||||
}
|
||||
|
||||
|
||||
@@ -299,8 +299,6 @@ public class SettingsBackupTest {
|
||||
Settings.Global.GNSS_HAL_LOCATION_REQUEST_DURATION_MILLIS,
|
||||
Settings.Global.GNSS_SATELLITE_BLOCKLIST,
|
||||
Settings.Global.GPRS_REGISTER_CHECK_PERIOD_MS,
|
||||
Settings.Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED,
|
||||
Settings.Global.HDMI_CONTROL_ENABLED,
|
||||
Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED,
|
||||
Settings.Global.HIDDEN_API_POLICY,
|
||||
Settings.Global.FORCE_NON_DEBUGGABLE_FINAL_BUILD_FOR_COMPAT,
|
||||
|
||||
@@ -22,17 +22,11 @@ import android.annotation.IntDef;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.StringDef;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.ContentObserver;
|
||||
import android.hardware.hdmi.HdmiControlManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.SystemProperties;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings.Global;
|
||||
import android.util.ArrayMap;
|
||||
|
||||
@@ -89,8 +83,6 @@ public class HdmiCecConfig {
|
||||
private final ArrayMap<Setting, ArrayMap<SettingChangeListener, Executor>>
|
||||
mSettingChangeListeners = new ArrayMap<>();
|
||||
|
||||
private SettingsObserver mSettingsObserver;
|
||||
|
||||
private LinkedHashMap<String, Setting> mSettings = new LinkedHashMap<>();
|
||||
|
||||
/**
|
||||
@@ -186,18 +178,6 @@ public class HdmiCecConfig {
|
||||
}
|
||||
}
|
||||
|
||||
private class SettingsObserver extends ContentObserver {
|
||||
SettingsObserver(Handler handler) {
|
||||
super(handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChange(boolean selfChange, Uri uri) {
|
||||
String setting = uri.getLastPathSegment();
|
||||
HdmiCecConfig.this.notifyGlobalSettingChanged(setting);
|
||||
}
|
||||
}
|
||||
|
||||
private class Value {
|
||||
private final String mStringValue;
|
||||
private final Integer mIntValue;
|
||||
@@ -518,7 +498,7 @@ public class HdmiCecConfig {
|
||||
private int getStorage(@NonNull Setting setting) {
|
||||
switch (setting.getName()) {
|
||||
case HdmiControlManager.CEC_SETTING_NAME_HDMI_CEC_ENABLED:
|
||||
return STORAGE_GLOBAL_SETTINGS;
|
||||
return STORAGE_SHARED_PREFS;
|
||||
case HdmiControlManager.CEC_SETTING_NAME_HDMI_CEC_VERSION:
|
||||
return STORAGE_SHARED_PREFS;
|
||||
case HdmiControlManager.CEC_SETTING_NAME_ROUTING_CONTROL:
|
||||
@@ -536,7 +516,7 @@ public class HdmiCecConfig {
|
||||
case HdmiControlManager.CEC_SETTING_NAME_TV_WAKE_ON_ONE_TOUCH_PLAY:
|
||||
return STORAGE_SHARED_PREFS;
|
||||
case HdmiControlManager.CEC_SETTING_NAME_TV_SEND_STANDBY_ON_SLEEP:
|
||||
return STORAGE_GLOBAL_SETTINGS;
|
||||
return STORAGE_SHARED_PREFS;
|
||||
case HdmiControlManager.CEC_SETTING_NAME_RC_PROFILE_TV:
|
||||
return STORAGE_SHARED_PREFS;
|
||||
case HdmiControlManager.CEC_SETTING_NAME_RC_PROFILE_SOURCE_HANDLES_ROOT_MENU:
|
||||
@@ -559,7 +539,7 @@ public class HdmiCecConfig {
|
||||
private String getStorageKey(@NonNull Setting setting) {
|
||||
switch (setting.getName()) {
|
||||
case HdmiControlManager.CEC_SETTING_NAME_HDMI_CEC_ENABLED:
|
||||
return Global.HDMI_CONTROL_ENABLED;
|
||||
return setting.getName();
|
||||
case HdmiControlManager.CEC_SETTING_NAME_HDMI_CEC_VERSION:
|
||||
return setting.getName();
|
||||
case HdmiControlManager.CEC_SETTING_NAME_ROUTING_CONTROL:
|
||||
@@ -577,7 +557,7 @@ public class HdmiCecConfig {
|
||||
case HdmiControlManager.CEC_SETTING_NAME_TV_WAKE_ON_ONE_TOUCH_PLAY:
|
||||
return setting.getName();
|
||||
case HdmiControlManager.CEC_SETTING_NAME_TV_SEND_STANDBY_ON_SLEEP:
|
||||
return Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED;
|
||||
return setting.getName();
|
||||
case HdmiControlManager.CEC_SETTING_NAME_RC_PROFILE_TV:
|
||||
return setting.getName();
|
||||
case HdmiControlManager.CEC_SETTING_NAME_RC_PROFILE_SOURCE_HANDLES_ROOT_MENU:
|
||||
@@ -629,17 +609,6 @@ public class HdmiCecConfig {
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyGlobalSettingChanged(String setting) {
|
||||
switch (setting) {
|
||||
case Global.HDMI_CONTROL_ENABLED:
|
||||
notifySettingChanged(HdmiControlManager.CEC_SETTING_NAME_HDMI_CEC_ENABLED);
|
||||
break;
|
||||
case Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED:
|
||||
notifySettingChanged(HdmiControlManager.CEC_SETTING_NAME_TV_SEND_STANDBY_ON_SLEEP);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void notifySettingChanged(@NonNull @CecSettingName String name) {
|
||||
Setting setting = getSetting(name);
|
||||
if (setting == null) {
|
||||
@@ -668,32 +637,6 @@ public class HdmiCecConfig {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method registers Global Setting change observer.
|
||||
* Needs to be called once after initialization of HdmiCecConfig.
|
||||
*/
|
||||
public void registerGlobalSettingsObserver(Looper looper) {
|
||||
Handler handler = new Handler(looper);
|
||||
mSettingsObserver = new SettingsObserver(handler);
|
||||
ContentResolver resolver = mContext.getContentResolver();
|
||||
String[] settings = new String[] {
|
||||
Global.HDMI_CONTROL_ENABLED,
|
||||
Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED,
|
||||
};
|
||||
for (String setting: settings) {
|
||||
resolver.registerContentObserver(Global.getUriFor(setting), false,
|
||||
mSettingsObserver, UserHandle.USER_ALL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method unregisters Global Setting change observer.
|
||||
*/
|
||||
public void unregisterGlobalSettingsObserver() {
|
||||
ContentResolver resolver = mContext.getContentResolver();
|
||||
resolver.unregisterContentObserver(mSettingsObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register change listener for a given setting name using DirectExecutor.
|
||||
*/
|
||||
|
||||
@@ -601,7 +601,6 @@ public class HdmiControlService extends SystemService {
|
||||
if (mMessageValidator == null) {
|
||||
mMessageValidator = new HdmiCecMessageValidator(this);
|
||||
}
|
||||
mHdmiCecConfig.registerGlobalSettingsObserver(mHandler.getLooper());
|
||||
mHdmiCecConfig.registerChangeListener(HdmiControlManager.CEC_SETTING_NAME_HDMI_CEC_ENABLED,
|
||||
new HdmiCecConfig.SettingChangeListener() {
|
||||
@Override
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.android.server.hdmi;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.fail;
|
||||
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.never;
|
||||
@@ -26,13 +25,11 @@ import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.testng.Assert.assertThrows;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.hardware.hdmi.HdmiControlManager;
|
||||
import android.os.test.TestLooper;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
import android.provider.Settings.Global;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.filters.SmallTest;
|
||||
@@ -40,16 +37,12 @@ import androidx.test.filters.SmallTest;
|
||||
import com.android.internal.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@SmallTest
|
||||
@Presubmit
|
||||
@RunWith(JUnit4.class)
|
||||
@@ -366,18 +359,6 @@ public final class HdmiCecConfigTest {
|
||||
HdmiControlManager.CEC_SETTING_NAME_POWER_CONTROL_MODE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getIntValue_GlobalSetting_BasicSanity() {
|
||||
when(mStorageAdapter.retrieveGlobalSetting(
|
||||
Global.HDMI_CONTROL_ENABLED,
|
||||
Integer.toString(HdmiControlManager.HDMI_CEC_CONTROL_ENABLED)))
|
||||
.thenReturn(Integer.toString(HdmiControlManager.HDMI_CEC_CONTROL_DISABLED));
|
||||
HdmiCecConfig hdmiCecConfig = new HdmiCecConfig(mContext, mStorageAdapter);
|
||||
assertThat(hdmiCecConfig.getIntValue(
|
||||
HdmiControlManager.CEC_SETTING_NAME_HDMI_CEC_ENABLED))
|
||||
.isEqualTo(HdmiControlManager.HDMI_CEC_CONTROL_DISABLED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getIntValue_SharedPref_BasicSanity() {
|
||||
when(mStorageAdapter.retrieveSharedPref(
|
||||
@@ -453,16 +434,6 @@ public final class HdmiCecConfigTest {
|
||||
123));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setIntValue_GlobalSetting_BasicSanity() {
|
||||
HdmiCecConfig hdmiCecConfig = new HdmiCecConfig(mContext, mStorageAdapter);
|
||||
hdmiCecConfig.setIntValue(HdmiControlManager.CEC_SETTING_NAME_HDMI_CEC_ENABLED,
|
||||
HdmiControlManager.HDMI_CEC_CONTROL_DISABLED);
|
||||
verify(mStorageAdapter).storeGlobalSetting(
|
||||
Global.HDMI_CONTROL_ENABLED,
|
||||
Integer.toString(HdmiControlManager.HDMI_CEC_CONTROL_DISABLED));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setIntValue_SharedPref_BasicSanity() {
|
||||
HdmiCecConfig hdmiCecConfig = new HdmiCecConfig(mContext, mStorageAdapter);
|
||||
@@ -502,51 +473,4 @@ public final class HdmiCecConfigTest {
|
||||
verify(mSettingChangeListener, never()).onChange(
|
||||
HdmiControlManager.CEC_SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING);
|
||||
}
|
||||
|
||||
/**
|
||||
* Externally modified Global Settings still need to be supported. This test verifies that
|
||||
* setting change notification is being forwarded to listeners registered via HdmiCecConfig.
|
||||
*/
|
||||
@Test
|
||||
@Ignore("b/175381065")
|
||||
public void globalSettingObserver_BasicSanity() throws Exception {
|
||||
CountDownLatch notifyLatch = new CountDownLatch(1);
|
||||
// Get current value of the setting in the system.
|
||||
String originalValue = Global.getString(mContext.getContentResolver(),
|
||||
Global.HDMI_CONTROL_ENABLED);
|
||||
try {
|
||||
HdmiCecConfig hdmiCecConfig = new HdmiCecConfig(mContext, mStorageAdapter);
|
||||
hdmiCecConfig.registerGlobalSettingsObserver(mTestLooper.getLooper());
|
||||
HdmiCecConfig.SettingChangeListener latchUpdateListener =
|
||||
new HdmiCecConfig.SettingChangeListener() {
|
||||
@Override
|
||||
public void onChange(
|
||||
@NonNull @HdmiControlManager.CecSettingName String setting) {
|
||||
notifyLatch.countDown();
|
||||
assertThat(setting).isEqualTo(
|
||||
HdmiControlManager.CEC_SETTING_NAME_HDMI_CEC_ENABLED);
|
||||
}
|
||||
};
|
||||
hdmiCecConfig.registerChangeListener(
|
||||
HdmiControlManager.CEC_SETTING_NAME_HDMI_CEC_ENABLED,
|
||||
latchUpdateListener);
|
||||
|
||||
// Flip the value of the setting.
|
||||
String valueToSet = ((originalValue == null || originalValue.equals("1")) ? "0" : "1");
|
||||
Global.putString(mContext.getContentResolver(), Global.HDMI_CONTROL_ENABLED,
|
||||
valueToSet);
|
||||
assertThat(Global.getString(mContext.getContentResolver(),
|
||||
Global.HDMI_CONTROL_ENABLED)).isEqualTo(valueToSet);
|
||||
mTestLooper.dispatchAll();
|
||||
|
||||
if (!notifyLatch.await(TIMEOUT_CONTENT_CHANGE_SEC, TimeUnit.SECONDS)) {
|
||||
fail("Timed out waiting for the notify callback");
|
||||
}
|
||||
hdmiCecConfig.unregisterGlobalSettingsObserver();
|
||||
} finally {
|
||||
// Restore the previous value of the setting in the system.
|
||||
Global.putString(mContext.getContentResolver(), Global.HDMI_CONTROL_ENABLED,
|
||||
originalValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user