sysui: Observe weather enabled for lockscreen.
Bug: 261757708 Test: manually, unit Change-Id: I7a7830cb8875d74a447b3ee07105899418a084c4 Merged-In: I7a7830cb8875d74a447b3ee07105899418a084c4
This commit is contained in:
@@ -11046,6 +11046,13 @@ public final class Settings {
|
|||||||
public static final String EXTRA_AUTOMATIC_POWER_SAVE_MODE =
|
public static final String EXTRA_AUTOMATIC_POWER_SAVE_MODE =
|
||||||
"extra_automatic_power_save_mode";
|
"extra_automatic_power_save_mode";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether lockscreen weather is enabled.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final String LOCK_SCREEN_WEATHER_ENABLED = "lockscreen_weather_enabled";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These entries are considered common between the personal and the managed profile,
|
* These entries are considered common between the personal and the managed profile,
|
||||||
* since the managed profile doesn't get to change them.
|
* since the managed profile doesn't get to change them.
|
||||||
|
|||||||
@@ -6037,4 +6037,7 @@
|
|||||||
<!-- List of certificate to be used for font fs-verity integrity verification -->
|
<!-- List of certificate to be used for font fs-verity integrity verification -->
|
||||||
<string-array translatable="false" name="config_fontManagerServiceCerts">
|
<string-array translatable="false" name="config_fontManagerServiceCerts">
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Whether to show weather on the lock screen by default. -->
|
||||||
|
<bool name="config_lockscreenWeatherEnabledByDefault">false</bool>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -4917,4 +4917,7 @@
|
|||||||
<java-symbol type="id" name="language_picker_header" />
|
<java-symbol type="id" name="language_picker_header" />
|
||||||
|
|
||||||
<java-symbol type="dimen" name="status_bar_height_default" />
|
<java-symbol type="dimen" name="status_bar_height_default" />
|
||||||
|
|
||||||
|
<!-- Whether to show weather on the lockscreen by default. -->
|
||||||
|
<java-symbol type="bool" name="config_lockscreenWeatherEnabledByDefault" />
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -219,6 +219,7 @@ public class SecureSettings {
|
|||||||
Settings.Secure.ASSIST_LONG_PRESS_HOME_ENABLED,
|
Settings.Secure.ASSIST_LONG_PRESS_HOME_ENABLED,
|
||||||
Settings.Secure.BLUETOOTH_LE_BROADCAST_PROGRAM_INFO,
|
Settings.Secure.BLUETOOTH_LE_BROADCAST_PROGRAM_INFO,
|
||||||
Settings.Secure.BLUETOOTH_LE_BROADCAST_CODE,
|
Settings.Secure.BLUETOOTH_LE_BROADCAST_CODE,
|
||||||
Settings.Secure.BLUETOOTH_LE_BROADCAST_APP_SOURCE_NAME
|
Settings.Secure.BLUETOOTH_LE_BROADCAST_APP_SOURCE_NAME,
|
||||||
|
Settings.Secure.LOCK_SCREEN_WEATHER_ENABLED
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -352,5 +352,6 @@ public class SecureSettingsValidators {
|
|||||||
VALIDATORS.put(Secure.BLUETOOTH_LE_BROADCAST_PROGRAM_INFO, ANY_STRING_VALIDATOR);
|
VALIDATORS.put(Secure.BLUETOOTH_LE_BROADCAST_PROGRAM_INFO, ANY_STRING_VALIDATOR);
|
||||||
VALIDATORS.put(Secure.BLUETOOTH_LE_BROADCAST_CODE, ANY_STRING_VALIDATOR);
|
VALIDATORS.put(Secure.BLUETOOTH_LE_BROADCAST_CODE, ANY_STRING_VALIDATOR);
|
||||||
VALIDATORS.put(Secure.BLUETOOTH_LE_BROADCAST_APP_SOURCE_NAME, ANY_STRING_VALIDATOR);
|
VALIDATORS.put(Secure.BLUETOOTH_LE_BROADCAST_APP_SOURCE_NAME, ANY_STRING_VALIDATOR);
|
||||||
|
VALIDATORS.put(Secure.LOCK_SCREEN_WEATHER_ENABLED, BOOLEAN_VALIDATOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,6 +106,12 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
|
|||||||
updateDoubleLineClock();
|
updateDoubleLineClock();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
private final ContentObserver mShowWeatherObserver = new ContentObserver(null) {
|
||||||
|
@Override
|
||||||
|
public void onChange(boolean change) {
|
||||||
|
setWeatherVisibility();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private final KeyguardUnlockAnimationController.KeyguardUnlockAnimationListener
|
private final KeyguardUnlockAnimationController.KeyguardUnlockAnimationListener
|
||||||
mKeyguardUnlockAnimationListener =
|
mKeyguardUnlockAnimationListener =
|
||||||
@@ -216,7 +222,15 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
|
|||||||
UserHandle.USER_ALL
|
UserHandle.USER_ALL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
mSecureSettings.registerContentObserverForUser(
|
||||||
|
Settings.Secure.LOCK_SCREEN_WEATHER_ENABLED,
|
||||||
|
false, /* notifyForDescendants */
|
||||||
|
mShowWeatherObserver,
|
||||||
|
UserHandle.USER_ALL
|
||||||
|
);
|
||||||
|
|
||||||
updateDoubleLineClock();
|
updateDoubleLineClock();
|
||||||
|
setWeatherVisibility();
|
||||||
|
|
||||||
mKeyguardUnlockAnimationController.addKeyguardUnlockAnimationListener(
|
mKeyguardUnlockAnimationController.addKeyguardUnlockAnimationListener(
|
||||||
mKeyguardUnlockAnimationListener);
|
mKeyguardUnlockAnimationListener);
|
||||||
@@ -449,6 +463,14 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setWeatherVisibility() {
|
||||||
|
if (mWeatherView != null) {
|
||||||
|
mUiExecutor.execute(
|
||||||
|
() -> mWeatherView.setVisibility(
|
||||||
|
mSmartspaceController.isWeatherEnabled() ? View.VISIBLE : View.GONE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the clipChildren property on relevant views, to allow the smartspace to draw out of
|
* Sets the clipChildren property on relevant views, to allow the smartspace to draw out of
|
||||||
* bounds during the unlock transition.
|
* bounds during the unlock transition.
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import android.os.Handler
|
|||||||
import android.os.UserHandle
|
import android.os.UserHandle
|
||||||
import android.provider.Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS
|
import android.provider.Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS
|
||||||
import android.provider.Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS
|
import android.provider.Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS
|
||||||
|
import android.provider.Settings.Secure.LOCK_SCREEN_WEATHER_ENABLED
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.ContextThemeWrapper
|
import android.view.ContextThemeWrapper
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@@ -244,6 +245,17 @@ constructor(
|
|||||||
datePlugin != null && weatherPlugin != null
|
datePlugin != null && weatherPlugin != null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isWeatherEnabled(): Boolean {
|
||||||
|
execution.assertIsMainThread()
|
||||||
|
val defaultValue = context.getResources().getBoolean(
|
||||||
|
com.android.internal.R.bool.config_lockscreenWeatherEnabledByDefault)
|
||||||
|
val showWeather = secureSettings.getIntForUser(
|
||||||
|
LOCK_SCREEN_WEATHER_ENABLED,
|
||||||
|
if (defaultValue) 1 else 0,
|
||||||
|
userTracker.userId) == 1
|
||||||
|
return showWeather
|
||||||
|
}
|
||||||
|
|
||||||
private fun updateBypassEnabled() {
|
private fun updateBypassEnabled() {
|
||||||
val bypassEnabled = bypassController.bypassEnabled
|
val bypassEnabled = bypassController.bypassEnabled
|
||||||
smartspaceViews.forEach { it.setKeyguardBypassEnabled(bypassEnabled) }
|
smartspaceViews.forEach { it.setKeyguardBypassEnabled(bypassEnabled) }
|
||||||
|
|||||||
@@ -300,8 +300,9 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
|
|||||||
ArgumentCaptor<ContentObserver> observerCaptor =
|
ArgumentCaptor<ContentObserver> observerCaptor =
|
||||||
ArgumentCaptor.forClass(ContentObserver.class);
|
ArgumentCaptor.forClass(ContentObserver.class);
|
||||||
mController.init();
|
mController.init();
|
||||||
verify(mSecureSettings).registerContentObserverForUser(any(String.class),
|
verify(mSecureSettings).registerContentObserverForUser(
|
||||||
anyBoolean(), observerCaptor.capture(), eq(UserHandle.USER_ALL));
|
eq(Settings.Secure.LOCKSCREEN_USE_DOUBLE_LINE_CLOCK),
|
||||||
|
anyBoolean(), observerCaptor.capture(), eq(UserHandle.USER_ALL));
|
||||||
ContentObserver observer = observerCaptor.getValue();
|
ContentObserver observer = observerCaptor.getValue();
|
||||||
mExecutor.runAllReady();
|
mExecutor.runAllReady();
|
||||||
|
|
||||||
@@ -347,6 +348,22 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
|
|||||||
assertEquals(0, mController.getClockBottom(10));
|
assertEquals(0, mController.getClockBottom(10));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testChangeLockscreenWeatherEnabledSetsWeatherViewVisible() {
|
||||||
|
when(mSmartspaceController.isWeatherEnabled()).thenReturn(true);
|
||||||
|
ArgumentCaptor<ContentObserver> observerCaptor =
|
||||||
|
ArgumentCaptor.forClass(ContentObserver.class);
|
||||||
|
mController.init();
|
||||||
|
verify(mSecureSettings).registerContentObserverForUser(
|
||||||
|
eq(Settings.Secure.LOCK_SCREEN_WEATHER_ENABLED), anyBoolean(),
|
||||||
|
observerCaptor.capture(), eq(UserHandle.USER_ALL));
|
||||||
|
ContentObserver observer = observerCaptor.getValue();
|
||||||
|
mExecutor.runAllReady();
|
||||||
|
// When a settings change has occurred, check that view is visible.
|
||||||
|
observer.onChange(true);
|
||||||
|
mExecutor.runAllReady();
|
||||||
|
assertEquals(View.VISIBLE, mFakeWeatherView.getVisibility());
|
||||||
|
}
|
||||||
|
|
||||||
private void verifyAttachment(VerificationMode times) {
|
private void verifyAttachment(VerificationMode times) {
|
||||||
verify(mClockRegistry, times).registerClockChangeListener(
|
verify(mClockRegistry, times).registerClockChangeListener(
|
||||||
|
|||||||
Reference in New Issue
Block a user