From ca51b89e8905997030552c6281a9496fa67771d6 Mon Sep 17 00:00:00 2001 From: Bruno Martins Date: Tue, 30 Dec 2025 00:01:18 +0000 Subject: [PATCH 001/765] Revert "SystemUI: Add support for clock auto-hiding" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 7c39df7cc5dff33681103dc3d06c2243551ddf17. Reason for the revert: It has bugs and will be implemented differently without messing up with AOSP code. Steps to reproduce clock visibility issues: - Enable auto-hide feature - Go to home screen (clock will hidden) ✅ - Open any app (clock will appear) ✅ - Lock device and notice that clock will show up in the statusbar ❌ Change-Id: I6946c10b670807f47eb6c9d2e735d2f675ed7fd7 --- packages/SystemUI/res/layout/status_bar.xml | 4 +- packages/SystemUI/res/layout/system_icons.xml | 1 - packages/SystemUI/res/values/attrs.xml | 1 - .../ui/binder/HomeStatusBarViewBinder.kt | 12 -- .../systemui/statusbar/policy/Clock.java | 136 +++--------------- 5 files changed, 17 insertions(+), 137 deletions(-) diff --git a/packages/SystemUI/res/layout/status_bar.xml b/packages/SystemUI/res/layout/status_bar.xml index 6a21d8f2cfb76..01eddd75ce66e 100644 --- a/packages/SystemUI/res/layout/status_bar.xml +++ b/packages/SystemUI/res/layout/status_bar.xml @@ -20,7 +20,7 @@ diff --git a/packages/SystemUI/res/layout/system_icons.xml b/packages/SystemUI/res/layout/system_icons.xml index 527c75eaced3b..90a03cb1f87bd 100644 --- a/packages/SystemUI/res/layout/system_icons.xml +++ b/packages/SystemUI/res/layout/system_icons.xml @@ -63,7 +63,6 @@ android:paddingEnd="@dimen/status_bar_clock_end_padding" android:gravity="center_vertical" android:visibility="gone" - systemui:isStatusBar="true" /> diff --git a/packages/SystemUI/res/values/attrs.xml b/packages/SystemUI/res/values/attrs.xml index 0458a28bcd147..8bc3eed59062b 100644 --- a/packages/SystemUI/res/values/attrs.xml +++ b/packages/SystemUI/res/values/attrs.xml @@ -46,7 +46,6 @@ - diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/binder/HomeStatusBarViewBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/binder/HomeStatusBarViewBinder.kt index f300b54a79233..c5b2fb6762b34 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/binder/HomeStatusBarViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/binder/HomeStatusBarViewBinder.kt @@ -424,8 +424,6 @@ constructor( activeClock.setIsActiveClock(true) } - val showClock = finalVisibility.visibility == View.VISIBLE - // Hide all clocks first leftClock.visibility = View.GONE centerClock.visibility = View.GONE @@ -433,16 +431,6 @@ constructor( // Show only the active one activeClock.adjustVisibility(finalVisibility) - - leftClock.setVisibleByModernization( - showClock && activeClock === leftClock - ) - centerClock.setVisibleByModernization( - showClock && activeClock === centerClock - ) - rightClock.setVisibleByModernization( - showClock && activeClock === rightClock - ) } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java index ceb57dfecacc4..71c69ee966829 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java @@ -17,9 +17,7 @@ package com.android.systemui.statusbar.policy; import android.annotation.NonNull; -import android.app.ActivityManager; import android.app.StatusBarManager; -import android.app.WindowConfiguration; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -30,7 +28,6 @@ import android.graphics.Rect; import android.icu.lang.UCharacter; import android.icu.text.DateTimePatternGenerator; -import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.os.Parcelable; @@ -58,9 +55,6 @@ import com.android.systemui.res.R; import com.android.systemui.settings.UserTracker; import com.android.systemui.shade.shared.flag.ShadeWindowGoesAround; -import com.android.systemui.shared.system.ActivityManagerWrapper; -import com.android.systemui.shared.system.TaskStackChangeListener; -import com.android.systemui.shared.system.TaskStackChangeListeners; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.core.StatusBarRootModernization; import com.android.systemui.statusbar.phone.ui.StatusBarIconController; @@ -96,13 +90,11 @@ public class Clock extends TextView implements private final CommandQueue mCommandQueue; private int mCurrentUserId; - private boolean mClockAutoHide = false; private boolean mClockVisibleByPolicy = true; private boolean mClockVisibleByUser = true; private boolean mAttached; private boolean mScreenReceiverRegistered; - private boolean mTaskStackListenerRegistered; private Calendar mCalendar; private String mContentDescriptionFormatString; private SimpleDateFormat mClockFormat; @@ -120,10 +112,6 @@ public class Clock extends TextView implements private boolean mShowSeconds; private Handler mSecondsHandler; - private boolean mIsStatusBar; - private boolean mIsActiveClock = true; - private boolean mVisibleByModernization = true; - /** * Color to be set on this {@link TextView}, when wallpaperTextColor is not utilized. */ @@ -155,31 +143,19 @@ public Clock(Context context, AttributeSet attrs, int defStyle) { mAmPmStyle = LineageSettings.System.getInt(mContext.getContentResolver(), LineageSettings.System.STATUS_BAR_AM_PM, AM_PM_STYLE_GONE); mContentObserver = new ContentObserver(null) { - final Uri clockAmPmUri = LineageSettings.System.getUriFor( - LineageSettings.System.STATUS_BAR_AM_PM); - final Uri clockAutoHideUri = LineageSettings.System.getUriFor( - LineageSettings.System.STATUS_BAR_CLOCK_AUTO_HIDE); - @Override - public void onChange(boolean selfChange, Uri uri) { - if (clockAmPmUri.equals(uri)) { - mAmPmStyle = LineageSettings.System.getInt( - mContext.getContentResolver(), - LineageSettings.System.STATUS_BAR_AM_PM, AM_PM_STYLE_GONE); - // Force refresh of dependent variables. - mContentDescriptionFormatString = ""; - mDateTimePatternGenerator = null; - mContext.getMainExecutor().execute(() -> { - updateClock(true); - }); - } else if (clockAutoHideUri.equals(uri)) { - handleTaskStackListener( - LineageSettings.System.getInt(mContext.getContentResolver(), - LineageSettings.System.STATUS_BAR_CLOCK_AUTO_HIDE, 0) != 0); - } + public void onChange(boolean selfChange) { + mAmPmStyle = LineageSettings.System.getInt( + mContext.getContentResolver(), + LineageSettings.System.STATUS_BAR_AM_PM, AM_PM_STYLE_GONE); + // Force refresh of dependent variables. + mContentDescriptionFormatString = ""; + mDateTimePatternGenerator = null; + mContext.getMainExecutor().execute(() -> { + updateClock(true); + }); } }; - mIsStatusBar = a.getBoolean(R.styleable.Clock_isStatusBar, mIsStatusBar); mNonAdaptedColor = getCurrentTextColor(); } finally { a.recycle(); @@ -220,7 +196,7 @@ public void onRestoreInstanceState(Parcelable state) { mClockVisibleByUser = bundle.getBoolean(VISIBLE_BY_USER, true); mShowSeconds = bundle.getBoolean(SHOW_SECONDS, false); if (bundle.containsKey(VISIBILITY)) { - setVisibility(bundle.getInt(VISIBILITY)); + super.setVisibility(bundle.getInt(VISIBILITY)); } } @@ -247,12 +223,6 @@ protected void onAttachedToWindow() { mContext.getContentResolver().registerContentObserver( LineageSettings.System.getUriFor(LineageSettings.System.STATUS_BAR_AM_PM), false, mContentObserver); - mContext.getContentResolver().registerContentObserver( - LineageSettings.System.getUriFor( - LineageSettings.System.STATUS_BAR_CLOCK_AUTO_HIDE), - false, mContentObserver); - mContentObserver.onChange(false, LineageSettings.System.getUriFor( - LineageSettings.System.STATUS_BAR_CLOCK_AUTO_HIDE)); mCommandQueue.addCallback(this); mUserTracker.addCallback(mUserChangedCallback, mContext.getMainExecutor()); mCurrentUserId = mUserTracker.getUserId(); @@ -289,21 +259,6 @@ protected void onDetachedFromWindow() { Dependency.get(TunerService.class).removeTunable(this); mCommandQueue.removeCallback(this); mUserTracker.removeCallback(mUserChangedCallback); - handleTaskStackListener(false); - } - } - - private void handleTaskStackListener(boolean register) { - if (!mIsStatusBar) { - // We don't support clock auto hide for quick settings. - return; - } - if (register && !mTaskStackListenerRegistered) { - TaskStackChangeListeners.getInstance().registerTaskStackListener(mTaskStackListener); - mTaskStackListenerRegistered = true; - } else if (!register && mTaskStackListenerRegistered) { - TaskStackChangeListeners.getInstance().unregisterTaskStackListener(mTaskStackListener); - mTaskStackListenerRegistered = false; } } @@ -345,32 +300,15 @@ public void onReceive(Context context, Intent intent) { @Override public void setVisibility(int visibility) { - // In a multi clock setup, only the active clock is allowed to become visible. - // Inactive clocks can still be hidden. - if (!mIsActiveClock && visibility == View.VISIBLE) { - return; - } - - if (visibility == View.VISIBLE && !shouldBeVisible()) { - return; + if (!StatusBarRootModernization.isEnabled()) { + if (visibility == View.VISIBLE && !shouldBeVisible()) { + return; + } } super.setVisibility(visibility); } - public void setIsActiveClock(boolean active) { - mIsActiveClock = active; - } - - public void setVisibleByModernization(boolean visible) { - if (mVisibleByModernization == visible) return; - mVisibleByModernization = visible; - - if (StatusBarRootModernization.isEnabled()) { - setVisibility(shouldBeVisible() ? View.VISIBLE : View.GONE); - } - } - private void setClockVisibleByUser(boolean visible) { StatusBarRootModernization.assertInLegacyMode(); @@ -386,11 +324,7 @@ private void setClockVisibilityByPolicy(boolean visible) { } private boolean shouldBeVisible() { - if (StatusBarRootModernization.isEnabled()) { - return mVisibleByModernization && !mClockAutoHide; - } - - return !mClockAutoHide && mClockVisibleByPolicy && mClockVisibleByUser; + return mClockVisibleByPolicy && mClockVisibleByUser; } private void updateClockVisibility() { @@ -527,27 +461,6 @@ private void updateShowSeconds() { } } - private void updateShowClock() { - ActivityManager.RunningTaskInfo runningTask = - ActivityManagerWrapper.getInstance().getRunningTask(); - final int activityType = runningTask != null - ? runningTask.configuration.windowConfiguration.getActivityType() - : WindowConfiguration.ACTIVITY_TYPE_UNDEFINED; - final boolean clockAutoHide = activityType == WindowConfiguration.ACTIVITY_TYPE_HOME; - - if (mClockAutoHide == clockAutoHide) { - return; - } - - mClockAutoHide = clockAutoHide; - - if (StatusBarRootModernization.isEnabled()) { - setVisibility(shouldBeVisible() ? View.VISIBLE : View.GONE); - } else { - updateClockVisibility(); - } - } - private final CharSequence getSmallTime() { Context context = getContext(); boolean is24 = DateFormat.is24HourFormat(context, mCurrentUserId); @@ -687,22 +600,5 @@ public void run() { mSecondsHandler.postAtTime(this, SystemClock.uptimeMillis() / 1000 * 1000 + 1000); } }; - - private final TaskStackChangeListener mTaskStackListener = new TaskStackChangeListener() { - @Override - public void onTaskStackChanged() { - updateShowClock(); - } - - @Override - public void onTaskRemoved(int taskId) { - updateShowClock(); - } - - @Override - public void onTaskMovedToFront(int taskId) { - updateShowClock(); - } - }; } From 42b365274c036a4485e50db7eaad791965f87178 Mon Sep 17 00:00:00 2001 From: Bruno Martins Date: Tue, 30 Dec 2025 00:04:51 +0000 Subject: [PATCH 002/765] fixup! SystemUI: Clock position customization Clean up unnecessary stuff and run through ktfmt. Change-Id: I8a08407580cb28deb1291932731a41ff09df63f5 --- .../ui/binder/HomeStatusBarViewBinder.kt | 129 +++++++++--------- 1 file changed, 63 insertions(+), 66 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/binder/HomeStatusBarViewBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/binder/HomeStatusBarViewBinder.kt index c5b2fb6762b34..745abe842ad3b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/binder/HomeStatusBarViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/binder/HomeStatusBarViewBinder.kt @@ -58,7 +58,6 @@ import com.android.systemui.statusbar.policy.Clock import javax.inject.Inject import kotlinx.coroutines.Job import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.update @@ -101,10 +100,10 @@ constructor( } private data class ClockState( - val visibilityModel: VisibilityModel, val denyListed: Boolean, val hideForHun: Boolean, - val position: Int + val position: Int, + val visibilityModel: VisibilityModel, ) override fun bind( @@ -138,48 +137,58 @@ constructor( repeatOnLifecycle(Lifecycle.State.CREATED) { val context = view.context - val clockState = MutableStateFlow( - ClockState( - visibilityModel = VisibilityModel(View.GONE, true), - denyListed = false, - hideForHun = false, - position = context.contentResolver.readClockPosition() + val clockState = + MutableStateFlow( + ClockState( + denyListed = false, + hideForHun = false, + position = context.contentResolver.readClockPosition(), + visibilityModel = VisibilityModel(View.GONE, true), + ) ) - ) val iconHideListUri: Uri = Settings.Secure.getUriFor(StatusBarIconController.ICON_HIDE_LIST) val statusBarClockUri: Uri = LineageSettings.System.getUriFor(LineageSettings.System.STATUS_BAR_CLOCK) - val contentObserver = object : ContentObserver(Handler(Looper.getMainLooper())) { - override fun onChange(selfChange: Boolean, uri: Uri?) { - clockState.update { current -> - when (uri) { - iconHideListUri -> current.copy( - denyListed = StatusBarIconController.getIconHideList(context, - Settings.Secure.getString(context.contentResolver, - StatusBarIconController.ICON_HIDE_LIST) - ).contains("clock") - ) - statusBarClockUri -> current.copy( - position = context.contentResolver.readClockPosition() - ) - else -> current + val contentObserver = + object : ContentObserver(Handler(Looper.getMainLooper())) { + override fun onChange(selfChange: Boolean, uri: Uri?) { + clockState.update { current -> + when (uri) { + iconHideListUri -> + current.copy( + denyListed = + StatusBarIconController.getIconHideList( + context, + Settings.Secure.getString( + context.contentResolver, + StatusBarIconController.ICON_HIDE_LIST, + ), + ) + .contains("clock") + ) + statusBarClockUri -> + current.copy( + position = context.contentResolver.readClockPosition() + ) + else -> current + } } } } - } - - context.contentResolver.registerContentObserver( - iconHideListUri, false, contentObserver, UserHandle.USER_ALL - ) - context.contentResolver.registerContentObserver( - statusBarClockUri, false, contentObserver, UserHandle.USER_ALL - ) - contentObserver.onChange(false, iconHideListUri) - contentObserver.onChange(false, statusBarClockUri) + val urisToObserve = listOf(iconHideListUri, statusBarClockUri) + urisToObserve.forEach { uri -> + context.contentResolver.registerContentObserver( + uri, + false, + contentObserver, + UserHandle.USER_ALL, + ) + contentObserver.onChange(false, uri) + } // Ensure cleanup when lifecycle ends val job = coroutineContext[Job] @@ -370,35 +379,33 @@ constructor( launch { combine( - viewModel.isClockVisible, - viewModel.hideStartSideContentForHeadsUp - ) { visibilityModel, hideForHun -> - visibilityModel to hideForHun - }.collect { (visibilityModel, hideForHun) -> - clockState.update { current -> - current.copy( - visibilityModel = visibilityModel, - hideForHun = hideForHun - ) + viewModel.isClockVisible, + viewModel.hideStartSideContentForHeadsUp, + ) { visibilityModel, hideForHun -> + visibilityModel to hideForHun + } + .collect { (visibilityModel, hideForHun) -> + clockState.update { current -> + current.copy( + visibilityModel = visibilityModel, + hideForHun = hideForHun, + ) + } } - } } - var activeClock: Clock = leftClock - activeClock.setIsActiveClock(true) - centerClock.setIsActiveClock(false) - rightClock.setIsActiveClock(false) - launch { clockState.collect { state -> // We only want to hide left clock for HUN - val hunBlocksClock = state.position == CLOCK_POSITION_LEFT - && state.hideForHun + val hunBlocksClock = + state.position == CLOCK_POSITION_LEFT && state.hideForHun // Apply denylist on top of ViewModel visibility val finalVisibility = - if (state.visibilityModel.visibility == View.VISIBLE && - !hunBlocksClock && !state.denyListed + if ( + state.visibilityModel.visibility == View.VISIBLE && + !hunBlocksClock && + !state.denyListed ) { state.visibilityModel } else { @@ -406,7 +413,7 @@ constructor( } // Pick active clock view - val newActiveClock: Clock = + val activeClock: Clock = when (state.position) { CLOCK_POSITION_CENTER -> centerClock ?: leftClock CLOCK_POSITION_RIGHT -> rightClock ?: leftClock @@ -414,16 +421,6 @@ constructor( else -> leftClock } - if (newActiveClock !== activeClock) { - // Deactivate previous clock - activeClock.setIsActiveClock(false) - activeClock.visibility = View.GONE - - // Activate new one - activeClock = newActiveClock - activeClock.setIsActiveClock(true) - } - // Hide all clocks first leftClock.visibility = View.GONE centerClock.visibility = View.GONE @@ -517,7 +514,7 @@ constructor( this, LineageSettings.System.STATUS_BAR_CLOCK, CLOCK_POSITION_LEFT, - UserHandle.USER_CURRENT + UserHandle.USER_CURRENT, ) } From 06cb2a10c5d364794eb994f7a68e83ee390721ae Mon Sep 17 00:00:00 2001 From: Bruno Martins Date: Mon, 29 Dec 2025 23:59:33 +0000 Subject: [PATCH 003/765] SystemUI: Re-implement clock auto-hiding feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cédric Bellegarde Change-Id: Idb0501b3d6903eac8e3768b25fd9b80852ba8fb7 --- .../ui/binder/HomeStatusBarViewBinder.kt | 60 ++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/binder/HomeStatusBarViewBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/binder/HomeStatusBarViewBinder.kt index 745abe842ad3b..742affd8bb618 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/binder/HomeStatusBarViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/binder/HomeStatusBarViewBinder.kt @@ -18,6 +18,7 @@ package com.android.systemui.statusbar.pipeline.shared.ui.binder import android.animation.Animator import android.animation.AnimatorListenerAdapter +import android.app.WindowConfiguration import android.content.ContentResolver import android.database.ContentObserver import android.net.Uri @@ -35,6 +36,9 @@ import com.android.systemui.display.dagger.SystemUIDisplaySubcomponent.PerDispla import com.android.systemui.lifecycle.repeatWhenAttached import com.android.systemui.res.R import com.android.systemui.scene.shared.flag.SceneContainerFlag +import com.android.systemui.shared.system.ActivityManagerWrapper +import com.android.systemui.shared.system.TaskStackChangeListener +import com.android.systemui.shared.system.TaskStackChangeListeners import com.android.systemui.statusbar.chips.mediaprojection.domain.model.MediaProjectionStopDialogModel import com.android.systemui.statusbar.chips.ui.binder.OngoingActivityChipBinder import com.android.systemui.statusbar.chips.ui.binder.OngoingActivityChipViewBinding @@ -100,6 +104,7 @@ constructor( } private data class ClockState( + val autoHide: Boolean, val denyListed: Boolean, val hideForHun: Boolean, val position: Int, @@ -140,6 +145,7 @@ constructor( val clockState = MutableStateFlow( ClockState( + autoHide = false, denyListed = false, hideForHun = false, position = context.contentResolver.readClockPosition(), @@ -147,16 +153,48 @@ constructor( ) ) + val clockAutoHideUri: Uri = + LineageSettings.System.getUriFor( + LineageSettings.System.STATUS_BAR_CLOCK_AUTO_HIDE + ) val iconHideListUri: Uri = Settings.Secure.getUriFor(StatusBarIconController.ICON_HIDE_LIST) val statusBarClockUri: Uri = LineageSettings.System.getUriFor(LineageSettings.System.STATUS_BAR_CLOCK) + val taskStackListener = + object : TaskStackChangeListener { + override fun onTaskStackChanged() { + val autoHide = shouldClockAutoHideForCurrentTask() + + if (clockState.value.autoHide != autoHide) { + clockState.update { it.copy(autoHide = autoHide) } + } + } + } + val contentObserver = object : ContentObserver(Handler(Looper.getMainLooper())) { override fun onChange(selfChange: Boolean, uri: Uri?) { clockState.update { current -> when (uri) { + clockAutoHideUri -> { + val enabled = + context.contentResolver.readClockAutoHide() != 0 + + if (enabled) { + TaskStackChangeListeners.getInstance() + .registerTaskStackListener(taskStackListener) + } else { + TaskStackChangeListeners.getInstance() + .unregisterTaskStackListener(taskStackListener) + } + + current.copy( + autoHide = + enabled && shouldClockAutoHideForCurrentTask() + ) + } iconHideListUri -> current.copy( denyListed = @@ -179,7 +217,7 @@ constructor( } } - val urisToObserve = listOf(iconHideListUri, statusBarClockUri) + val urisToObserve = listOf(clockAutoHideUri, iconHideListUri, statusBarClockUri) urisToObserve.forEach { uri -> context.contentResolver.registerContentObserver( uri, @@ -195,6 +233,8 @@ constructor( job?.invokeOnCompletion { runCatching { context.contentResolver.unregisterContentObserver(contentObserver) + TaskStackChangeListeners.getInstance() + .unregisterTaskStackListener(taskStackListener) } } @@ -405,6 +445,7 @@ constructor( if ( state.visibilityModel.visibility == View.VISIBLE && !hunBlocksClock && + !state.autoHide && !state.denyListed ) { state.visibilityModel @@ -509,6 +550,15 @@ constructor( } } + private fun ContentResolver.readClockAutoHide(): Int { + return LineageSettings.System.getIntForUser( + this, + LineageSettings.System.STATUS_BAR_CLOCK_AUTO_HIDE, + 0, + UserHandle.USER_CURRENT, + ) + } + private fun ContentResolver.readClockPosition(): Int { return LineageSettings.System.getIntForUser( this, @@ -518,6 +568,14 @@ constructor( ) } + private fun shouldClockAutoHideForCurrentTask(): Boolean { + return ActivityManagerWrapper.getInstance() + .runningTask + ?.configuration + ?.windowConfiguration + ?.activityType == WindowConfiguration.ACTIVITY_TYPE_HOME + } + private fun SystemEventAnimationState.isAnimatingChip() = when (this) { AnimatingIn, From 8eabeabd173cacbef8dd51f001a7e1a6f50d2d04 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Mon, 29 Dec 2025 12:17:32 +0100 Subject: [PATCH 004/765] fixup! SystemUI: Add customization to show battery percent I don't understand the point of hiding attribution. Reformat with ktfmt while we are at it. Change-Id: Ibaf09804baed4be781b72edc09dc8a129b52d741 --- .../battery/data/repository/BatteryRepository.kt | 16 +++++++++++----- .../battery/ui/composable/BatteryWithPercent.kt | 1 - .../battery/ui/composable/UnifiedBattery.kt | 3 +-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/data/repository/BatteryRepository.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/data/repository/BatteryRepository.kt index ec96ed84d81f7..c52f9ce702fa6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/data/repository/BatteryRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/data/repository/BatteryRepository.kt @@ -175,8 +175,10 @@ constructor( fun readMode(): Int { return LineageSettings.System.getIntForUser( - resolver, LineageSettings.System.STATUS_BAR_SHOW_BATTERY_PERCENT, - BatteryRepository.SHOW_PERCENT_HIDDEN, UserHandle.USER_CURRENT + resolver, + LineageSettings.System.STATUS_BAR_SHOW_BATTERY_PERCENT, + BatteryRepository.SHOW_PERCENT_HIDDEN, + UserHandle.USER_CURRENT, ) } @@ -187,8 +189,12 @@ constructor( } } - resolver.registerContentObserver(uri, /* notifyForDescendants = */ false, - observer, UserHandle.USER_ALL) + resolver.registerContentObserver( + uri, + /* notifyForDescendants = */ false, + observer, + UserHandle.USER_ALL, + ) // Emit current value immediately trySend(readMode()) @@ -200,7 +206,7 @@ constructor( .stateIn( scope = scope, started = SharingStarted.Lazily, - initialValue = BatteryRepository.SHOW_PERCENT_HIDDEN + initialValue = BatteryRepository.SHOW_PERCENT_HIDDEN, ) /** Get and re-fetch the estimate every 2 minutes while active */ diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/ui/composable/BatteryWithPercent.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/ui/composable/BatteryWithPercent.kt index f149f1b8d40f8..a5531f3054675 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/ui/composable/BatteryWithPercent.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/ui/composable/BatteryWithPercent.kt @@ -82,7 +82,6 @@ fun BatteryWithPercent( viewModel = viewModel, isDarkProvider = isDarkProvider, modifier = Modifier.height(batteryHeight).wrapContentWidth(), - suppressAttribution = showPercent, ) } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/ui/composable/UnifiedBattery.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/ui/composable/UnifiedBattery.kt index 314d225940000..39bb6c01f21ce 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/ui/composable/UnifiedBattery.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/ui/composable/UnifiedBattery.kt @@ -162,7 +162,6 @@ fun UnifiedBattery( viewModel: BatteryViewModel, isDarkProvider: () -> IsAreaDark, modifier: Modifier, - suppressAttribution: Boolean = false, ) { var bounds by remember { mutableStateOf(Rect()) } @@ -175,7 +174,7 @@ fun UnifiedBattery( } BatteryLayout( - attribution = if (suppressAttribution) null else viewModel.attribution, + attribution = viewModel.attribution, levelProvider = { viewModel.level }, isFullProvider = { viewModel.isFull }, glyphsProvider = { viewModel.glyphList }, From e991e6999bfb0e27516d896ee4e3dcdfb43e77f4 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Sun, 28 Dec 2025 22:49:08 +0100 Subject: [PATCH 005/765] SystemUI: Bring back good ol' circle battery style once again Change-Id: I0357c8d71f15f71d86bf0e4fab8b7f4487e6efb3 --- .../ui/view/BatteryStatusEventComposeChip.kt | 5 + .../data/repository/BatteryRepository.kt | 80 +++++++- .../domain/interactor/BatteryInteractor.kt | 3 + .../battery/ui/composable/UnifiedBattery.kt | 183 +++++++++++++++--- .../battery/ui/viewmodel/BatteryViewModel.kt | 15 ++ 5 files changed, 260 insertions(+), 26 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/events/ui/view/BatteryStatusEventComposeChip.kt b/packages/SystemUI/src/com/android/systemui/statusbar/events/ui/view/BatteryStatusEventComposeChip.kt index 5b04ec64910b9..bb2255a693648 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/events/ui/view/BatteryStatusEventComposeChip.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/events/ui/view/BatteryStatusEventComposeChip.kt @@ -41,6 +41,7 @@ import com.android.systemui.res.R import com.android.systemui.statusbar.core.NewStatusBarIcons import com.android.systemui.statusbar.core.RudimentaryBattery import com.android.systemui.statusbar.events.BackgroundAnimatableView +import com.android.systemui.statusbar.pipeline.battery.data.repository.BatteryRepository import com.android.systemui.statusbar.pipeline.battery.domain.interactor.BatteryInteractor import com.android.systemui.statusbar.pipeline.battery.shared.ui.BatteryColors import com.android.systemui.statusbar.pipeline.battery.shared.ui.BatteryGlyph @@ -106,7 +107,9 @@ private fun UnifiedBatteryChip(level: Int) { val height = with(LocalDensity.current) { BatteryViewModel.STATUS_BAR_BATTERY_HEIGHT.toDp() } BatteryLayout( attribution = BatteryGlyph.Bolt, // Always charging + iconStyleProvider = { BatteryRepository.ICON_STYLE_DEFAULT }, levelProvider = { level }, + showLevelProvider = { false }, isFullProvider = { isFull }, glyphsProvider = { level.glyphRepresentation() }, colorsProvider = { BatteryColors.DarkTheme.Charging }, @@ -124,7 +127,9 @@ private fun BatteryAndPercentChip(level: Int) { Row(verticalAlignment = Alignment.CenterVertically) { BatteryLayout( attribution = BatteryGlyph.Bolt, // Always charging + iconStyleProvider = { BatteryRepository.ICON_STYLE_DEFAULT }, levelProvider = { level }, + showLevelProvider = { false }, isFullProvider = { isFull }, glyphsProvider = { emptyList() }, colorsProvider = { BatteryColors.DarkTheme.Charging }, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/data/repository/BatteryRepository.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/data/repository/BatteryRepository.kt index c52f9ce702fa6..04d35c99aeff3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/data/repository/BatteryRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/data/repository/BatteryRepository.kt @@ -69,6 +69,12 @@ interface BatteryRepository { /** State unknown means that we can't detect a battery */ val isStateUnknown: Flow + /** + * [LineageSettings.System.STATUS_BAR_BATTERY_STYLE]. A user setting to indicate the battery + * style in the home screen status bar + */ + val batteryIconStyle: StateFlow + /** * [LineageSettings.System.STATUS_BAR_SHOW_BATTERY_PERCENT]. A user setting to indicate whether * we should show the battery percentage in the home screen status bar @@ -76,6 +82,10 @@ interface BatteryRepository { val showBatteryPercentMode: StateFlow companion object { + const val ICON_STYLE_DEFAULT = 0 + const val ICON_STYLE_CIRCLE = 1 + const val ICON_STYLE_TEXT = 2 + const val ICON_STYLE_CIRCLE_DOTTED = 3 const val SHOW_PERCENT_HIDDEN = 0 const val SHOW_PERCENT_INSIDE = 1 const val SHOW_PERCENT_NEXT_TO = 2 @@ -165,19 +175,19 @@ constructor( override val isStateUnknown = batteryState.map { it.isStateUnknown } - override val showBatteryPercentMode = + override val batteryIconStyle = callbackFlow { val resolver = context.contentResolver val uri = LineageSettings.System.getUriFor( - LineageSettings.System.STATUS_BAR_SHOW_BATTERY_PERCENT + LineageSettings.System.STATUS_BAR_BATTERY_STYLE ) fun readMode(): Int { return LineageSettings.System.getIntForUser( resolver, - LineageSettings.System.STATUS_BAR_SHOW_BATTERY_PERCENT, - BatteryRepository.SHOW_PERCENT_HIDDEN, + LineageSettings.System.STATUS_BAR_BATTERY_STYLE, + BatteryRepository.ICON_STYLE_DEFAULT, UserHandle.USER_CURRENT, ) } @@ -203,6 +213,68 @@ constructor( } .distinctUntilChanged() .flowOn(bgDispatcher) + .stateIn( + scope = scope, + started = SharingStarted.Lazily, + initialValue = BatteryRepository.ICON_STYLE_DEFAULT, + ) + + override val showBatteryPercentMode = + callbackFlow { + val resolver = context.contentResolver + val uris = + listOf( + LineageSettings.System.getUriFor( + LineageSettings.System.STATUS_BAR_BATTERY_STYLE + ), + LineageSettings.System.getUriFor( + LineageSettings.System.STATUS_BAR_SHOW_BATTERY_PERCENT + ), + ) + + fun readMode(): Int { + val iconStyle = + LineageSettings.System.getIntForUser( + resolver, + LineageSettings.System.STATUS_BAR_BATTERY_STYLE, + BatteryRepository.ICON_STYLE_DEFAULT, + UserHandle.USER_CURRENT, + ) + return if (iconStyle == BatteryRepository.ICON_STYLE_TEXT) { + BatteryRepository.SHOW_PERCENT_NEXT_TO + } else { + LineageSettings.System.getIntForUser( + resolver, + LineageSettings.System.STATUS_BAR_SHOW_BATTERY_PERCENT, + BatteryRepository.SHOW_PERCENT_HIDDEN, + UserHandle.USER_CURRENT, + ) + } + } + + val observer = + object : ContentObserver(Handler(Looper.getMainLooper())) { + override fun onChange(selfChange: Boolean) { + trySend(readMode()) + } + } + + for (uri in uris) { + resolver.registerContentObserver( + uri, + /* notifyForDescendants = */ false, + observer, + UserHandle.USER_ALL, + ) + } + + // Emit current value immediately + trySend(readMode()) + + awaitClose { resolver.unregisterContentObserver(observer) } + } + .distinctUntilChanged() + .flowOn(bgDispatcher) .stateIn( scope = scope, started = SharingStarted.Lazily, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/domain/interactor/BatteryInteractor.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/domain/interactor/BatteryInteractor.kt index a1c9d95680d6d..6251deaf03aa5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/domain/interactor/BatteryInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/domain/interactor/BatteryInteractor.kt @@ -74,6 +74,9 @@ class BatteryInteractor @Inject constructor( /** @see [BatteryRepository.isPowerSaveEnabled] */ val powerSave = repo.isPowerSaveEnabled + /** @see [BatteryRepository.batteryIconStyle] */ + val batteryIconStyle: StateFlow = repo.batteryIconStyle + /** @see [BatteryRepository.showBatteryPercentMode] */ val showBatteryPercentMode: StateFlow = repo.showBatteryPercentMode diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/ui/composable/UnifiedBattery.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/ui/composable/UnifiedBattery.kt index 39bb6c01f21ce..ed2797bea089f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/ui/composable/UnifiedBattery.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/ui/composable/UnifiedBattery.kt @@ -32,10 +32,12 @@ import androidx.compose.ui.geometry.Size import androidx.compose.ui.graphics.BlendMode import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.CompositingStrategy +import androidx.compose.ui.graphics.PathEffect import androidx.compose.ui.graphics.drawscope.Stroke import androidx.compose.ui.graphics.drawscope.clipRect import androidx.compose.ui.graphics.drawscope.inset import androidx.compose.ui.graphics.drawscope.scale +import androidx.compose.ui.graphics.drawscope.withTransform import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.layout.Layout import androidx.compose.ui.layout.Measurable @@ -44,12 +46,17 @@ import androidx.compose.ui.layout.MeasureResult import androidx.compose.ui.layout.MeasureScope import androidx.compose.ui.layout.layoutId import androidx.compose.ui.layout.onLayoutRectChanged +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.drawText +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.rememberTextMeasurer import androidx.compose.ui.unit.Constraints -import androidx.compose.ui.util.fastFirst +import androidx.compose.ui.unit.sp import androidx.compose.ui.util.fastFirstOrNull import com.android.systemui.common.ui.compose.load import com.android.systemui.compose.modifiers.sysuiResTag import com.android.systemui.statusbar.phone.domain.interactor.IsAreaDark +import com.android.systemui.statusbar.pipeline.battery.data.repository.BatteryRepository import com.android.systemui.statusbar.pipeline.battery.shared.ui.BatteryColors import com.android.systemui.statusbar.pipeline.battery.shared.ui.BatteryFrame import com.android.systemui.statusbar.pipeline.battery.shared.ui.BatteryGlyph @@ -175,7 +182,9 @@ fun UnifiedBattery( BatteryLayout( attribution = viewModel.attribution, + iconStyleProvider = { viewModel.batteryIconStyle }, levelProvider = { viewModel.level }, + showLevelProvider = { viewModel.isBatteryPercentInsideIconSettingEnabled }, isFullProvider = { viewModel.isFull }, glyphsProvider = { viewModel.glyphList }, colorsProvider = colorProvider, @@ -192,7 +201,9 @@ fun UnifiedBattery( @Composable fun BatteryLayout( attribution: BatteryGlyph?, + iconStyleProvider: () -> Int, levelProvider: () -> Int?, + showLevelProvider: () -> Boolean, isFullProvider: () -> Boolean, glyphsProvider: () -> List, colorsProvider: () -> BatteryColors, @@ -201,30 +212,49 @@ fun BatteryLayout( ) { Layout( content = { - BatteryBody( - pathSpec = BatteryFrame.bodyPathSpec, - levelProvider = levelProvider, - glyphsProvider = glyphsProvider, - isFullProvider = isFullProvider, - colorsProvider = colorsProvider, - modifier = Modifier.layoutId(BatteryMeasurePolicy.LayoutId.Frame), - contentDescription = contentDescription, - ) - if (attribution != null) { - BatteryAttribution( + val iconStyle = iconStyleProvider() + + if ( + iconStyle == BatteryRepository.ICON_STYLE_CIRCLE || + iconStyle == BatteryRepository.ICON_STYLE_CIRCLE_DOTTED + ) { + CircleBatteryBody( attr = attribution, + iconStyleProvider = iconStyleProvider, + levelProvider = levelProvider, + showLevelProvider = showLevelProvider, colorsProvider = colorsProvider, - modifier = - Modifier.layoutId( - BatteryMeasurePolicy.LayoutId.Attribution(wrapped = attribution) - ), + modifier = Modifier.layoutId(BatteryMeasurePolicy.LayoutId.FrameCircle), + contentDescription = contentDescription, ) + } else if (iconStyle == BatteryRepository.ICON_STYLE_TEXT) { + // Empty on purpose } else { - BatteryCap( - colorsProvider = colorsProvider, + BatteryBody( + pathSpec = BatteryFrame.bodyPathSpec, + levelProvider = levelProvider, + glyphsProvider = glyphsProvider, isFullProvider = isFullProvider, - modifier = Modifier.layoutId(BatteryMeasurePolicy.LayoutId.Cap), + colorsProvider = colorsProvider, + modifier = Modifier.layoutId(BatteryMeasurePolicy.LayoutId.Frame), + contentDescription = contentDescription, ) + if (attribution != null) { + BatteryAttribution( + attr = attribution, + colorsProvider = colorsProvider, + modifier = + Modifier.layoutId( + BatteryMeasurePolicy.LayoutId.Attribution(wrapped = attribution) + ), + ) + } else { + BatteryCap( + colorsProvider = colorsProvider, + isFullProvider = isFullProvider, + modifier = Modifier.layoutId(BatteryMeasurePolicy.LayoutId.Cap), + ) + } } }, measurePolicy = BatteryMeasurePolicy(), @@ -237,6 +267,8 @@ class BatteryMeasurePolicy : MeasurePolicy { sealed class LayoutId { data object Frame : LayoutId() + data object FrameCircle : LayoutId() + data object Cap : LayoutId() // We don't have to depend on the whole [BatteryGlyph] here, we just need to know the @@ -248,7 +280,10 @@ class BatteryMeasurePolicy : MeasurePolicy { measurables: List, constraints: Constraints, ): MeasureResult { - val batteryFrame = measurables.fastFirst { it.layoutId == LayoutId.Frame } + val batteryFrame = + measurables.fastFirstOrNull { + it.layoutId == LayoutId.Frame || it.layoutId == LayoutId.FrameCircle + } ?: return layout(0, 0) {} // We will scale the entire battery icon based on the given height val scale = constraints.maxHeight / BatteryFrame.innerHeight @@ -258,8 +293,18 @@ class BatteryMeasurePolicy : MeasurePolicy { batteryFrame.measure( constraints = constraints.copy( - minWidth = batterySize.width.roundToInt(), - maxWidth = batterySize.width.roundToInt(), + minWidth = + if (batteryFrame.layoutId == LayoutId.FrameCircle) { + batterySize.height.roundToInt() + } else { + batterySize.width.roundToInt() + }, + maxWidth = + if (batteryFrame.layoutId == LayoutId.FrameCircle) { + batterySize.height.roundToInt() + } else { + batterySize.width.roundToInt() + }, minHeight = batterySize.height.roundToInt(), maxHeight = batterySize.height.roundToInt(), ) @@ -322,6 +367,100 @@ class BatteryMeasurePolicy : MeasurePolicy { } } +@Composable +fun CircleBatteryBody( + attr: BatteryGlyph?, + iconStyleProvider: () -> Int, + levelProvider: () -> Int?, + showLevelProvider: () -> Boolean, + colorsProvider: () -> BatteryColors, + modifier: Modifier = Modifier, + contentDescription: String = "", +) { + val textMeasurer = rememberTextMeasurer() + + Canvas(modifier = modifier, contentDescription = contentDescription) { + val iconStyle = iconStyleProvider() + val level = levelProvider() + val showLevel = showLevelProvider() + val colors = colorsProvider() + + val strokeWidth = size.height / 6.5f + val radius = size.height / 2f - strokeWidth / 2f + val center = Offset(size.width / 2, size.height / 2) + + // Draw thin gray ring first + drawCircle(colors.backgroundOnly, radius, center, style = Stroke(strokeWidth)) + + // Draw colored arc representing charge level + if (level != null && level > 0) { + drawArc( + colors.attribution, + 270f, + 3.6f * level, + useCenter = false, + topLeft = Offset(center.x - radius, center.y - radius), + size = Size(radius * 2, radius * 2), + style = + Stroke( + strokeWidth, + pathEffect = + if (iconStyle == BatteryRepository.ICON_STYLE_CIRCLE_DOTTED) { + PathEffect.dashPathEffect(floatArrayOf(3f, 2f), 0f) + } else { + null + }, + ), + ) + } + + if (attr != null) { + // Draw attribution + inset(strokeWidth * 2f) { + val attrScale = attr.scaleTo(size.width, size.height) + val pathBounds = attr.path.getBounds() + + withTransform({ + scale(attrScale, Offset.Zero) + translate( + (size.width - (pathBounds.width * attrScale)) / 2f, + (size.height - (pathBounds.height * attrScale)) / 2f, + ) + }) { + drawPath( + path = attr.path, + color = Color.Black, + style = Stroke(2f), + blendMode = BlendMode.Clear, + ) + drawPath(attr.path, colors.attribution) + } + } + } else if (showLevel && level != null && level < 100) { + // Draw charge level + val textLayoutResult = + textMeasurer.measure( + text = level.toString(), + style = + TextStyle( + color = colors.attribution, + fontSize = 6.sp, + fontWeight = FontWeight.Bold, + ), + ) + + drawText( + textLayoutResult = textLayoutResult, + topLeft = + Offset( + size.width / 2 - textLayoutResult.size.width / 2f, + size.height / 2 - textLayoutResult.size.height / 2f, + ), + ) + } + } +} + /** * Draws just the round-rect piece of the battery frame. If [glyphsProvider] is non-empty, then this * composable also renders the glyphs centered in the frame. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/ui/viewmodel/BatteryViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/ui/viewmodel/BatteryViewModel.kt index 1f271dae9c36c..2a3e7c0827d20 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/ui/viewmodel/BatteryViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/battery/ui/viewmodel/BatteryViewModel.kt @@ -24,6 +24,7 @@ import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.lifecycle.ExclusiveActivatable import com.android.systemui.lifecycle.Hydrator import com.android.systemui.res.R +import com.android.systemui.statusbar.pipeline.battery.data.repository.BatteryRepository import com.android.systemui.statusbar.pipeline.battery.domain.interactor.BatteryAttributionModel.Charging import com.android.systemui.statusbar.pipeline.battery.domain.interactor.BatteryAttributionModel.Defend import com.android.systemui.statusbar.pipeline.battery.domain.interactor.BatteryAttributionModel.PowerSave @@ -78,6 +79,13 @@ sealed class BatteryViewModel( source = interactor.showPercentNextToIcon, ) + val isBatteryPercentInsideIconSettingEnabled: Boolean by + hydrator.hydratedStateOf( + traceName = "isBatteryPercentInsideIconSettingEnabled", + initialValue = interactor.showPercentInsideIcon.value, + source = interactor.showPercentInsideIcon, + ) + /** A [List] representation of the current [level] */ private val levelGlyphs: Flow> = interactor.level.map { it?.glyphRepresentation() ?: emptyList() } @@ -213,6 +221,13 @@ sealed class BatteryViewModel( }, ) + val batteryIconStyle: Int by + hydrator.hydratedStateOf( + traceName = "batteryIconStyle", + initialValue = BatteryRepository.ICON_STYLE_DEFAULT, + source = interactor.batteryIconStyle, + ) + /** For use in the shade, where we might need to show an estimate */ val batteryTimeRemainingEstimate: String? by hydrator.hydratedStateOf( From 2c38dcd8667eb2c42e3614d452dcd8703fe4ae44 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Sun, 23 Nov 2025 20:10:41 +0100 Subject: [PATCH 006/765] aconfig: Use old storage if /metadata is not available Change-Id: I71e74f07b358679f693cbd5e1f9a0ad1647d505d --- .../com/android/internal/pm/pkg/component/AconfigFlags.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/java/com/android/internal/pm/pkg/component/AconfigFlags.java b/core/java/com/android/internal/pm/pkg/component/AconfigFlags.java index 13b71e71bab4e..dc58171f59f5f 100644 --- a/core/java/com/android/internal/pm/pkg/component/AconfigFlags.java +++ b/core/java/com/android/internal/pm/pkg/component/AconfigFlags.java @@ -101,7 +101,8 @@ public AconfigFlags() { } private static boolean useNewStorage() { - return newStoragePublicApi() && Flags.useNewAconfigStorage(); + return newStoragePublicApi() && Flags.useNewAconfigStorage() && + Environment.getMetadataDirectory().exists(); } private void loadServerOverrides() { From 3e221a55192dd4d1587640fc1791dd84eacc172c Mon Sep 17 00:00:00 2001 From: Oliver Scott Date: Thu, 24 Oct 2024 17:33:50 -0400 Subject: [PATCH 007/765] Stop domain verification delegated from UIDs blocked by network policy Issue: calyxos#889 Change-Id: I00278802bdf9e9d2ff2c8e94304a14cceb1a2c0d --- data/etc/Android.bp | 2 +- packages/StatementService/Android.bp | 4 +-- packages/StatementService/AndroidManifest.xml | 1 + .../StatementServiceApplication.kt | 1 + .../domain/BootCompletedReceiver.kt | 1 + .../domain/DomainVerificationUtils.kt | 32 +++++++++++++++++++ .../statementservice/domain/DomainVerifier.kt | 12 +++++++ 7 files changed, 50 insertions(+), 3 deletions(-) diff --git a/data/etc/Android.bp b/data/etc/Android.bp index 272e891b1d5de..98278f4529ffd 100644 --- a/data/etc/Android.bp +++ b/data/etc/Android.bp @@ -185,7 +185,7 @@ prebuilt_etc { prebuilt_etc { name: "privapp_whitelist_com.android.statementservice", - product_specific: true, + system_ext_specific: true, sub_dir: "permissions", src: "com.android.statementservice.xml", filename_from_src: true, diff --git a/packages/StatementService/Android.bp b/packages/StatementService/Android.bp index a1422c0b40d8e..f0ddf4b6d84e0 100644 --- a/packages/StatementService/Android.bp +++ b/packages/StatementService/Android.bp @@ -31,8 +31,8 @@ android_app { proguard_flags_files: ["proguard.flags"], }, target_sdk_version: "29", - sdk_version: "system_current", - product_specific: true, + platform_apis: true, + system_ext_specific: true, privileged: true, required: [ "privapp_whitelist_com.android.statementservice", diff --git a/packages/StatementService/AndroidManifest.xml b/packages/StatementService/AndroidManifest.xml index 42cd143149546..0cc5b210f33c0 100644 --- a/packages/StatementService/AndroidManifest.xml +++ b/packages/StatementService/AndroidManifest.xml @@ -26,6 +26,7 @@ + diff --git a/packages/StatementService/src/com/android/statementservice/StatementServiceApplication.kt b/packages/StatementService/src/com/android/statementservice/StatementServiceApplication.kt index 6af8004c40154..fabe07eebdf90 100644 --- a/packages/StatementService/src/com/android/statementservice/StatementServiceApplication.kt +++ b/packages/StatementService/src/com/android/statementservice/StatementServiceApplication.kt @@ -29,6 +29,7 @@ class StatementServiceApplication : Application() { if (userManager.isUserUnlocked) { // WorkManager can only schedule when the user data directories are unencrypted (after // the user has entered their lock password. + DomainVerificationUtils.registerNetworkPolicyListener(this) DomainVerificationUtils.schedulePeriodicCheckUnlocked(WorkManager.getInstance(this)) DomainVerificationUtils.schedulePeriodicUpdateUnlocked(WorkManager.getInstance(this)) } diff --git a/packages/StatementService/src/com/android/statementservice/domain/BootCompletedReceiver.kt b/packages/StatementService/src/com/android/statementservice/domain/BootCompletedReceiver.kt index 7b5da832b9d75..3f13469910cbe 100644 --- a/packages/StatementService/src/com/android/statementservice/domain/BootCompletedReceiver.kt +++ b/packages/StatementService/src/com/android/statementservice/domain/BootCompletedReceiver.kt @@ -43,6 +43,7 @@ class BootCompletedReceiver : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { if (intent.action != Intent.ACTION_BOOT_COMPLETED) return val workManager = WorkManager.getInstance(context) + DomainVerificationUtils.registerNetworkPolicyListener(context) DomainVerificationUtils.schedulePeriodicCheckUnlocked(workManager) workManager.beginUniqueWork( PACKAGE_BOOT_REQUEST_KEY, diff --git a/packages/StatementService/src/com/android/statementservice/domain/DomainVerificationUtils.kt b/packages/StatementService/src/com/android/statementservice/domain/DomainVerificationUtils.kt index 157a800d0e09d..0ebe06ea656b6 100644 --- a/packages/StatementService/src/com/android/statementservice/domain/DomainVerificationUtils.kt +++ b/packages/StatementService/src/com/android/statementservice/domain/DomainVerificationUtils.kt @@ -16,6 +16,8 @@ package com.android.statementservice.domain +import android.content.Context +import android.net.NetworkPolicyManager import androidx.work.Constraints import androidx.work.ExistingPeriodicWorkPolicy import androidx.work.NetworkType @@ -36,6 +38,9 @@ object DomainVerificationUtils { private const val UPDATE_WORKER_ENABLED = false + private val uidBlockedReasons = mutableMapOf() + private var networkPolicyListener: NetworkPolicyManager.Listener? = null + /** * In a majority of cases, the initial requests will be enough to verify domains, since they * are also restricted to [NetworkType.CONNECTED], but for cases where they aren't sufficient, @@ -113,4 +118,31 @@ object DomainVerificationUtils { } } } + + fun getUidBlockedReasons(uid: Int) : Int? { + return uidBlockedReasons[uid] + } + + fun registerNetworkPolicyListener(context: Context) { + if (networkPolicyListener != null) { + unregisterNetworkPolicyListener(context) + } + networkPolicyListener = object : NetworkPolicyManager.Listener() { + override fun onBlockedReasonChanged( + uid: Int, + oldBlockedReasons: Int, + newBlockedReasons: Int + ) { + uidBlockedReasons[uid] = newBlockedReasons + } + } + val networkPolicyManager = context.getSystemService(NetworkPolicyManager::class.java) + networkPolicyManager?.registerListener(networkPolicyListener) + } + + private fun unregisterNetworkPolicyListener(context: Context) { + val networkPolicyManager = context.getSystemService(NetworkPolicyManager::class.java) + networkPolicyManager?.unregisterListener(networkPolicyListener) + networkPolicyListener = null + } } diff --git a/packages/StatementService/src/com/android/statementservice/domain/DomainVerifier.kt b/packages/StatementService/src/com/android/statementservice/domain/DomainVerifier.kt index c7f6c184fd22b..b0858629b085c 100644 --- a/packages/StatementService/src/com/android/statementservice/domain/DomainVerifier.kt +++ b/packages/StatementService/src/com/android/statementservice/domain/DomainVerifier.kt @@ -17,7 +17,10 @@ package com.android.statementservice.domain import android.content.Context +import android.content.pm.PackageManager import android.content.pm.verify.domain.DomainVerificationManager +import android.net.ConnectivityManager.BLOCKED_REASON_APP_BACKGROUND +import android.net.ConnectivityManager.BLOCKED_REASON_NONE import android.net.Network import android.util.Log import androidx.collection.LruCache @@ -92,6 +95,15 @@ class DomainVerifier private constructor( val assetMatcher = synchronized(targetAssetCache) { targetAssetCache[packageName] } .takeIf { it!!.isPresent } ?: return Triple(WorkResult.failure(), VerifyStatus.FAILURE_PACKAGE_MANAGER, null) + val packageUid = appContext.packageManager.getPackageUid( + packageName, + PackageManager.PackageInfoFlags.of(0) + ) + // Fail if no blocked reason is set or for any reason other than APP_BACKGROUND and NONE + if (DomainVerificationUtils.getUidBlockedReasons(packageUid) + ?.and(BLOCKED_REASON_APP_BACKGROUND.inv())?.and(BLOCKED_REASON_NONE.inv()) != 0) { + return Triple(WorkResult.failure(), VerifyStatus.NO_RESPONSE, null) + } return verifyHost(host, assetMatcher.get(), network) } From d89dcff8cf0a2690050ece006a8fdcd04e5449e1 Mon Sep 17 00:00:00 2001 From: HZ <99131470+hustler-not-chatty@users.noreply.github.com> Date: Wed, 2 Nov 2022 20:24:42 +0800 Subject: [PATCH 008/765] AlertWindowNotification: Correctly load app label Passes User ID to AlertWindowNotification to make sure that we can correctly load app label for the ones installed in work profile. Test: Install an app that can display over other apps in the work profile, watch the notification title and content when it's drawing over other apps. It should now display app label, rather than its package name. Change-Id: I872c0c0f6870a09c4ef1c372d7a87dec156f91fc --- .../server/wm/AlertWindowNotification.java | 15 +++++++++++---- .../core/java/com/android/server/wm/Session.java | 3 ++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/wm/AlertWindowNotification.java b/services/core/java/com/android/server/wm/AlertWindowNotification.java index c589feae56ca2..51c93a6293b44 100644 --- a/services/core/java/com/android/server/wm/AlertWindowNotification.java +++ b/services/core/java/com/android/server/wm/AlertWindowNotification.java @@ -24,6 +24,7 @@ import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; import static android.provider.Settings.ACTION_MANAGE_APP_OVERLAY_PERMISSION; +import android.annotation.UserIdInt; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationChannelGroup; @@ -37,6 +38,7 @@ import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; +import android.os.UserHandle; import com.android.internal.R; import com.android.internal.util.ImageUtils; @@ -53,11 +55,14 @@ class AlertWindowNotification { private String mNotificationTag; private final NotificationManager mNotificationManager; private final String mPackageName; + private final @UserIdInt int mUserId; private boolean mPosted; - AlertWindowNotification(WindowManagerService service, String packageName) { + AlertWindowNotification(WindowManagerService service, String packageName, + @UserIdInt int userId) { mService = service; mPackageName = packageName; + mUserId = userId; mNotificationManager = (NotificationManager) mService.mContext.getSystemService(NOTIFICATION_SERVICE); mNotificationTag = CHANNEL_PREFIX + mPackageName; @@ -100,7 +105,7 @@ private void onPostNotification() { final Context context = mService.mContext; final PackageManager pm = context.getPackageManager(); - final ApplicationInfo aInfo = getApplicationInfo(pm, mPackageName); + final ApplicationInfo aInfo = getApplicationInfoAsUser(pm, mPackageName, mUserId); final String appName = (aInfo != null) ? pm.getApplicationLabel(aInfo).toString() : mPackageName; @@ -138,6 +143,7 @@ private PendingIntent getContentIntent(Context context, String packageName) { final Intent intent = new Intent(ACTION_MANAGE_APP_OVERLAY_PERMISSION, Uri.fromParts("package", packageName, null)); intent.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK); + intent.putExtra(Intent.EXTRA_USER_HANDLE, UserHandle.of(mUserId)); // Calls into activity manager... return PendingIntent.getActivity(context, mRequestCode, intent, FLAG_CANCEL_CURRENT | FLAG_IMMUTABLE); @@ -168,9 +174,10 @@ private void createNotificationChannel(Context context, String appName) { } - private ApplicationInfo getApplicationInfo(PackageManager pm, String packageName) { + private ApplicationInfo getApplicationInfoAsUser(PackageManager pm, String packageName, + @UserIdInt int userId) { try { - return pm.getApplicationInfo(packageName, 0); + return pm.getApplicationInfoAsUser(packageName, 0, userId); } catch (PackageManager.NameNotFoundException e) { return null; } diff --git a/services/core/java/com/android/server/wm/Session.java b/services/core/java/com/android/server/wm/Session.java index 5b36a9b089bdb..1c69365f5c4bd 100644 --- a/services/core/java/com/android/server/wm/Session.java +++ b/services/core/java/com/android/server/wm/Session.java @@ -814,7 +814,8 @@ void onWindowSurfaceVisibilityChanged(WindowState window, boolean visible) { if (mAlertWindows.isEmpty()) { cancelAlertWindowNotification(); } else if (mAlertWindowNotification == null && !isSatellitePointingUiPackage()) { - mAlertWindowNotification = new AlertWindowNotification(mService, mPackageName); + mAlertWindowNotification = new AlertWindowNotification(mService, mPackageName, + UserHandle.getUserId(mUid)); if (mShowingAlertWindowNotificationAllowed) { mAlertWindowNotification.post(); } From 9fe90735dabc784054d571bbeb0f59cc489e3d16 Mon Sep 17 00:00:00 2001 From: SuperDroidBond Date: Sun, 11 Sep 2022 15:59:12 +0530 Subject: [PATCH 009/765] toast: fix bg color not changing with theme change Signed-off-by: SuperDroidBond Change-Id: I0d3a1995fa35d47e246cedef670357d31e004b50 --- core/res/res/drawable/toast_frame.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/res/res/drawable/toast_frame.xml b/core/res/res/drawable/toast_frame.xml index a8cdef6d05f13..34987394b2ece 100644 --- a/core/res/res/drawable/toast_frame.xml +++ b/core/res/res/drawable/toast_frame.xml @@ -17,7 +17,7 @@ --> - + From 08398768d4d6503963715ac4d4ad63f9371ac3f3 Mon Sep 17 00:00:00 2001 From: Luca Stefani Date: Thu, 22 May 2025 17:13:25 +0200 Subject: [PATCH 010/765] fixup! Firewall: Transport-based toggle support (1/3) Strip unwanted policies when updating background restriction rules and fix one strict equality with a bit check. Change-Id: I51628940f64fe98c930168dc0fe2e487f63ccfde --- .../server/net/NetworkPolicyManagerService.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java index c75bcfed0d1b2..0b726e46c25de 100644 --- a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java +++ b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java @@ -3461,10 +3461,10 @@ private void setUidPolicyUncheckedUL(int uid, int oldPolicy, int policy, boolean if (!isUidValidForAllowlistRulesUL(uid)) { notifyApp = false; } else { - final boolean wasDenied = oldPolicy == POLICY_REJECT_METERED_BACKGROUND; - final boolean isDenied = policy == POLICY_REJECT_METERED_BACKGROUND; - final boolean wasAllowed = oldPolicy == POLICY_ALLOW_METERED_BACKGROUND; - final boolean isAllowed = policy == POLICY_ALLOW_METERED_BACKGROUND; + final boolean wasDenied = (oldPolicy & POLICY_REJECT_METERED_BACKGROUND) != 0; + final boolean isDenied = (policy & POLICY_REJECT_METERED_BACKGROUND) != 0; + final boolean wasAllowed = (oldPolicy & POLICY_ALLOW_METERED_BACKGROUND) != 0; + final boolean isAllowed = (policy & POLICY_ALLOW_METERED_BACKGROUND) != 0; final boolean wasBlocked = wasDenied || (mRestrictBackground && !wasAllowed); final boolean isBlocked = isDenied || (mRestrictBackground && !isAllowed); if ((wasAllowed && (!isAllowed || isDenied)) @@ -3874,7 +3874,7 @@ private int getRestrictBackgroundStatusInternal(int uid) { } finally { Binder.restoreCallingIdentity(token); } - if (policy == POLICY_REJECT_METERED_BACKGROUND) { + if ((policy & POLICY_REJECT_METERED_BACKGROUND) != 0) { // App is restricted. return RESTRICT_BACKGROUND_STATUS_ENABLED; } From 45634e9eaca80fa99d5da3867e5ec5823abaf658 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Sun, 12 Dec 2021 15:12:23 +0100 Subject: [PATCH 011/765] Don't pass repeated back key events to app if custom action is set up Some apps may react to back key long press and it doesn't make sense to allow them to do that if 'Back long press action' is set to anything other than 'No action'. Change-Id: Iacac909d6a288cacf964c89d9586d572d14d1871 --- .../java/com/android/server/policy/PhoneWindowManager.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index f96fb4fa6011e..84a0fb7ee0b5f 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -5041,6 +5041,12 @@ && isWakeKeyWhenScreenOff(keyCode)) { // focus before processing the back event. mWindowManagerInternal.moveFocusToAdjacentEmbeddedActivityIfNeeded(); mBackKeyHandled = false; + + // Don't pass repeated events to app if user has custom long press action + // set up in settings + if (event.getRepeatCount() > 0 && hasLongPressOnBackBehavior()) { + result &= ~ACTION_PASS_TO_USER; + } } else { if (!hasLongPressOnBackBehavior()) { mBackKeyHandled |= backKeyPress(); From 8c2a4273dc93f26813f1dd7c9ea3d0474f25825a Mon Sep 17 00:00:00 2001 From: Pranav Vashi Date: Sun, 14 Sep 2025 20:28:05 +0530 Subject: [PATCH 012/765] SystemUI: Plug in non-MSDL haptic feedback for QS tiles Change-Id: I75fe2e39df4433b40836fb4526d52845dab36178 Signed-off-by: Pranav Vashi --- .../haptics/msdl/qs/TileHapticsViewModel.kt | 83 +++++++++++++++---- 1 file changed, 67 insertions(+), 16 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/haptics/msdl/qs/TileHapticsViewModel.kt b/packages/SystemUI/src/com/android/systemui/haptics/msdl/qs/TileHapticsViewModel.kt index 70a40d9337245..745ea3430bef7 100644 --- a/packages/SystemUI/src/com/android/systemui/haptics/msdl/qs/TileHapticsViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/haptics/msdl/qs/TileHapticsViewModel.kt @@ -16,6 +16,8 @@ package com.android.systemui.haptics.msdl.qs +import android.os.VibrationAttributes +import android.os.VibrationEffect import android.service.quicksettings.Tile import androidx.compose.runtime.Stable import com.android.systemui.Flags @@ -23,6 +25,7 @@ import com.android.systemui.animation.Expandable import com.android.systemui.dagger.SysUISingleton import com.android.systemui.lifecycle.ExclusiveActivatable import com.android.systemui.qs.panels.ui.viewmodel.TileViewModel +import com.android.systemui.statusbar.VibratorHelper import com.android.systemui.util.kotlin.pairwise import com.google.android.msdl.data.model.MSDLToken import com.google.android.msdl.domain.MSDLPlayer @@ -44,6 +47,7 @@ class TileHapticsViewModel @AssistedInject constructor( private val msdlPlayer: MSDLPlayer, + private val vibratorHelper: VibratorHelper, @Assisted private val tileViewModel: TileViewModel, ) : ExclusiveActivatable() { @@ -91,20 +95,72 @@ constructor( private val hapticsState: Flow = merge(toggleHapticsState, interactionHapticsState) + private val vibrationAttrs = + VibrationAttributes.Builder() + .setUsage(VibrationAttributes.USAGE_TOUCH) + .setFlags(VibrationAttributes.FLAG_PIPELINED_EFFECT) + .build() + + private val clickEffect = VibrationEffect.createPredefined(VibrationEffect.EFFECT_CLICK) + private val heavyClick = VibrationEffect.createPredefined(VibrationEffect.EFFECT_HEAVY_CLICK) + + private val areAllPrimitivesSupported by lazy { + vibratorHelper.areAllPrimitivesSupported( + VibrationEffect.Composition.PRIMITIVE_CLICK, + VibrationEffect.Composition.PRIMITIVE_THUD, + ) ?: false + } + + private val composedHeavyClick by lazy { + VibrationEffect.startComposition() + .addPrimitive(VibrationEffect.Composition.PRIMITIVE_THUD, 1f) + .compose() + } + + private val composedClick by lazy { + VibrationEffect.startComposition() + .addPrimitive(VibrationEffect.Composition.PRIMITIVE_CLICK) + .compose() + } + + private fun vibrateToggle() = vibratorHelper.vibrate(composedClick, vibrationAttrs) + + private fun vibrateLongPress() = vibratorHelper.vibrate(composedHeavyClick, vibrationAttrs) + override suspend fun onActivated(): Nothing { try { - hapticsState.collect { hapticsState -> - val tokenToPlay: MSDLToken? = - when (hapticsState) { - TileHapticsState.TOGGLE_ON -> MSDLToken.SWITCH_ON - TileHapticsState.TOGGLE_OFF -> MSDLToken.SWITCH_OFF - TileHapticsState.LONG_PRESS -> MSDLToken.LONG_PRESS - TileHapticsState.NO_HAPTICS -> null + hapticsState.collect { state -> + if (state == TileHapticsState.NO_HAPTICS) return@collect + + if (Flags.msdlFeedback()) { + val token = + when (state) { + TileHapticsState.TOGGLE_ON -> MSDLToken.SWITCH_ON + TileHapticsState.TOGGLE_OFF -> MSDLToken.SWITCH_OFF + TileHapticsState.LONG_PRESS -> MSDLToken.LONG_PRESS + else -> null + } + token?.let { msdlPlayer.playToken(it) } + } else { + if (areAllPrimitivesSupported) { + when (state) { + TileHapticsState.TOGGLE_ON, + TileHapticsState.TOGGLE_OFF -> vibrateToggle() + TileHapticsState.LONG_PRESS -> vibrateLongPress() + else -> Unit + } + } else { + when (state) { + TileHapticsState.TOGGLE_ON, + TileHapticsState.TOGGLE_OFF -> + vibratorHelper.vibrate(clickEffect, vibrationAttrs) + TileHapticsState.LONG_PRESS -> + vibratorHelper.vibrate(heavyClick, vibrationAttrs) + else -> Unit + } } - tokenToPlay?.let { - msdlPlayer.playToken(it) - resetStates() } + resetStates() } awaitCancellation() } finally { @@ -178,10 +234,5 @@ constructor( class TileHapticsViewModelFactoryProvider @Inject constructor(private val tileHapticsViewModelFactory: TileHapticsViewModel.Factory) { - fun getHapticsViewModelFactory(): TileHapticsViewModel.Factory? = - if (Flags.msdlFeedback()) { - tileHapticsViewModelFactory - } else { - null - } + fun getHapticsViewModelFactory(): TileHapticsViewModel.Factory? = tileHapticsViewModelFactory } From 2acc2e54c6db9575101711319c594bb5210776e9 Mon Sep 17 00:00:00 2001 From: pjgowtham Date: Sun, 22 Jun 2025 11:00:08 +0530 Subject: [PATCH 013/765] UdfpsHelper: Track brightness mirror to hide/show Udfps dim layer This provides a much deeper integration with Udfps dim layer and the new brightness slider such that we don't need to look for APIs that can track temporary brightness. That is because when the brightness mirror is shown, there is no necessity for the Udfps dim layer to be present. This change also isn't functional with the legacy slider. It also fixes the issue where the dim layer is hidden with QS expansion -> Device Control where the alternate bouncer is brought up. Tests : Ensure that appropriate transparency of the dim layer is set when dragging or selecting the preferred brightness with the slider. Change-Id: I53f78cbcfd3b42a3b5dbe6110424687ebfac102d Signed-off-by: Pranav Vashi --- .../systemui/biometrics/UdfpsController.java | 5 ++ .../biometrics/UdfpsControllerOverlay.kt | 5 +- .../systemui/biometrics/UdfpsHelper.kt | 48 ++++++------------- 3 files changed, 24 insertions(+), 34 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java index 13094fc126297..9ebb79e41cf33 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java @@ -99,6 +99,7 @@ import com.android.systemui.plugins.FalsingManager; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.power.domain.interactor.PowerInteractor; +import com.android.systemui.settings.brightness.domain.interactor.BrightnessMirrorShowingInteractor; import com.android.systemui.shade.ShadeDisplayAware; import com.android.systemui.shade.domain.interactor.ShadeInteractor; import com.android.systemui.shared.system.SysUiStatsLog; @@ -185,6 +186,7 @@ public class UdfpsController implements DozeReceiver, Dumpable { @NonNull private final AlternateBouncerInteractor mAlternateBouncerInteractor; @NonNull private final UdfpsOverlayInteractor mUdfpsOverlayInteractor; @NonNull private final PowerInteractor mPowerInteractor; + @NonNull private final BrightnessMirrorShowingInteractor mBrightnessMirrorShowingInteractor; @NonNull private final CoroutineScope mScope; @NonNull private final InputManager mInputManager; @NonNull private final SelectedUserInteractor mSelectedUserInteractor; @@ -297,6 +299,7 @@ public void showUdfpsOverlay(long requestId, int sensorId, int reason, mShadeInteractor, mUdfpsOverlayInteractor, mPowerInteractor, + mBrightnessMirrorShowingInteractor, mScope ))); } @@ -695,6 +698,7 @@ public UdfpsController(@NonNull @Main Context context, Lazy promptUdfpsTouchOverlayViewModel, @NonNull UdfpsOverlayInteractor udfpsOverlayInteractor, @NonNull PowerInteractor powerInteractor, + @NonNull BrightnessMirrorShowingInteractor brightnessMirrorShowingInteractor, @Application CoroutineScope scope, UserActivityNotifier userActivityNotifier) { mContext = context; @@ -739,6 +743,7 @@ public UdfpsController(@NonNull @Main Context context, mAlternateBouncerInteractor = alternateBouncerInteractor; mUdfpsOverlayInteractor = udfpsOverlayInteractor; mPowerInteractor = powerInteractor; + mBrightnessMirrorShowingInteractor = brightnessMirrorShowingInteractor; mScope = scope; mInputManager = inputManager; mSelectedUserInteractor = selectedUserInteractor; diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt index 0ec0a91eb328c..c3eef1f06aa65 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt @@ -52,6 +52,7 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInterac import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.power.domain.interactor.PowerInteractor import com.android.systemui.res.R +import com.android.systemui.settings.brightness.domain.interactor.BrightnessMirrorShowingInteractor import com.android.systemui.shade.domain.interactor.ShadeInteractor import com.android.systemui.statusbar.policy.KeyguardStateController import dagger.Lazy @@ -88,6 +89,7 @@ constructor( private val shadeInteractor: ShadeInteractor, private val udfpsOverlayInteractor: UdfpsOverlayInteractor, private val powerInteractor: PowerInteractor, + private val brightnessMirrorShowingInteractor: BrightnessMirrorShowingInteractor, @Application private val scope: CoroutineScope, ) { private val currentStateUpdatedToOffAodOrDozing: Flow = @@ -119,7 +121,8 @@ constructor( ) private val udfpsHelper: UdfpsHelper? = if (useFrameworkDimming) { - UdfpsHelper(context, windowManager, shadeInteractor, requestReason) + UdfpsHelper(context, windowManager, shadeInteractor, requestReason, + brightnessMirrorShowingInteractor) } else { null } diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsHelper.kt b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsHelper.kt index d16db5e8cbfe4..cd44c14db3de0 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsHelper.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsHelper.kt @@ -1,17 +1,6 @@ /* - * Copyright (C) 2024 The LineageOS Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2024-2025 The LineageOS Project + * SPDX-License-Identifier: Apache-2.0 */ package com.android.systemui.biometrics @@ -32,6 +21,7 @@ import androidx.core.view.isVisible import androidx.lifecycle.Lifecycle import androidx.lifecycle.repeatOnLifecycle import com.android.systemui.lifecycle.repeatWhenAttached +import com.android.systemui.settings.brightness.domain.interactor.BrightnessMirrorShowingInteractor import com.android.systemui.shade.domain.interactor.ShadeInteractor import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job @@ -49,6 +39,7 @@ class UdfpsHelper( private val windowManager: WindowManager, private val shadeInteractor: ShadeInteractor, @RequestReason val requestReason: Int, + private val brightnessMirrorShowingInteractor: BrightnessMirrorShowingInteractor, private var view: View = View(context).apply { setBackgroundColor(Color.BLACK) visibility = View.GONE @@ -56,7 +47,6 @@ class UdfpsHelper( ) { private val displayManager = context.getSystemService(DisplayManager::class.java)!! private val isKeyguard = requestReason == REASON_AUTH_KEYGUARD - private var newIsQsExpanded = false private val currentBrightness: Float get() = displayManager.getBrightness(Display.DEFAULT_DISPLAY) @@ -165,16 +155,23 @@ class UdfpsHelper( fun addDimLayer() { brightnessToAlpha() windowManager.addView(view, dimLayoutParams) + displayManager.registerDisplayListener( + displayListener, + null, + /* eventFlags */ 0, + DisplayManager.PRIVATE_EVENT_TYPE_DISPLAY_BRIGHTNESS, + ) } fun removeDimLayer() { windowManager.removeView(view) + displayManager.unregisterDisplayListener(displayListener) } init { view.repeatWhenAttached { repeatOnLifecycle(Lifecycle.State.CREATED) { - listenForQsExpansion(this) + listenForBrightnessMirror(this) if (isKeyguard) { listenForShadeTouchability(this) @@ -187,25 +184,10 @@ class UdfpsHelper( } } - // We don't have ways to get temporary brightness when operating the brightness slider. - // Therefore, the dim layer is hidden when the slider is expected to be utilized. - private suspend fun listenForQsExpansion(scope: CoroutineScope): Job { + private suspend fun listenForBrightnessMirror(scope: CoroutineScope): Job { return scope.launch { - shadeInteractor.qsExpansion.collect { qsExpansion -> - if (qsExpansion == 1f && !newIsQsExpanded) { - newIsQsExpanded = true - displayManager.registerDisplayListener( - displayListener, - null, - /* eventFlags */ 0, - DisplayManager.PRIVATE_EVENT_TYPE_DISPLAY_BRIGHTNESS, - ) - view.isVisible = false - } else if (qsExpansion == 0f && newIsQsExpanded) { - newIsQsExpanded = false - displayManager.unregisterDisplayListener(displayListener) - view.isVisible = true - } + brightnessMirrorShowingInteractor.isShowing.collect { + view.isVisible = !it } } } From ff25ebb8b957c4451abc6b37bfd7c1f57989d47c Mon Sep 17 00:00:00 2001 From: Sam Mortimer Date: Sat, 13 Jan 2018 23:26:48 -0800 Subject: [PATCH 014/765] SystemUI: Network Traffic [1/3] Co-authored-by: LuK1337 Co-authored-by: Wolfram Liebchen Change-Id: Ib947832860970a3bccfac70d27a4761f6164d3d5 --- packages/SystemUI/LineageManifest.xml | 5 +- packages/SystemUI/res/layout/status_bar.xml | 53 +++++++++++++++++++ .../phone/PhoneStatusBarTransitions.java | 15 ++++++ .../fragment/CollapsedStatusBarFragment.java | 51 ++++++++++++++++++ 4 files changed, 123 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/LineageManifest.xml b/packages/SystemUI/LineageManifest.xml index 09d3e1006ae53..b39dcfe5e2728 100644 --- a/packages/SystemUI/LineageManifest.xml +++ b/packages/SystemUI/LineageManifest.xml @@ -1,7 +1,7 @@ + + diff --git a/packages/SystemUI/res/layout/status_bar.xml b/packages/SystemUI/res/layout/status_bar.xml index 01eddd75ce66e..127bde6cdd369 100644 --- a/packages/SystemUI/res/layout/status_bar.xml +++ b/packages/SystemUI/res/layout/status_bar.xml @@ -118,6 +118,24 @@ android:orientation="horizontal" android:clipChildren="false"/> + + + + + + @@ -130,6 +148,23 @@ android:gravity="center_horizontal|center_vertical" /> + + + + + + + + + + + + { mEndSideAlphaController.setAlpha(alpha, SOURCE_SYSTEM_EVENT_ANIMATOR); + mNetworkTrafficStartAlphaController.setAlpha(alpha, SOURCE_SYSTEM_EVENT_ANIMATOR); + mNetworkTrafficCenterAlphaController.setAlpha(alpha, SOURCE_SYSTEM_EVENT_ANIMATOR); + mNetworkTrafficEndAlphaController.setAlpha(alpha, SOURCE_SYSTEM_EVENT_ANIMATOR); return Unit.INSTANCE; }, (translationX) -> { mEndSideContent.setTranslationX(translationX); + mNetworkTrafficHolderStart.setTranslationX(translationX); + mNetworkTrafficHolderCenter.setTranslationX(translationX); + mNetworkTrafficHolderEnd.setTranslationX(translationX); return Unit.INSTANCE; }, /*isAnimationRunning*/ false); } From 8e33c48f4dca9a296a17b11253416095790a19b8 Mon Sep 17 00:00:00 2001 From: Bruno Martins Date: Mon, 17 Sep 2018 11:52:04 +0100 Subject: [PATCH 015/765] fw/b: Add support for runtime toggle of navbar Co-authored-by: Adnan Begovic Co-authored-by: jhenrique09 Co-authored-by: LuK1337 Co-authored-by: Paul Keith Co-authored-by: Timo Wendt Change-Id: I4a6d3f89bc171c3921875b24c077cb78c03517ad --- .../server/power/PowerManagerService.java | 27 +++++++++---- .../com/android/server/wm/DisplayPolicy.java | 38 ++++++++++++++++++- 2 files changed, 56 insertions(+), 9 deletions(-) diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java index 5f7dbcc50aa4d..c2692806bf2e4 100644 --- a/services/core/java/com/android/server/power/PowerManagerService.java +++ b/services/core/java/com/android/server/power/PowerManagerService.java @@ -1223,6 +1223,8 @@ interface PowerPropertiesWrapper { private static native boolean nativeSetPowerMode(int mode, boolean enabled); private static native boolean nativeForceSuspend(); + private boolean mForceNavbar; + // Whether proximity check on wake is enabled by default private boolean mProximityWakeEnabledByDefaultConfig; @@ -1595,6 +1597,9 @@ private void systemReady() { resolver.registerContentObserver(LineageSettings.Secure.getUriFor( LineageSettings.Secure.KEYBOARD_BRIGHTNESS), false, mSettingsObserver, UserHandle.USER_ALL); + resolver.registerContentObserver(LineageSettings.System.getUriFor( + LineageSettings.System.FORCE_SHOW_NAVBAR), + false, mSettingsObserver, UserHandle.USER_ALL); // Register for broadcasts from other components of the system. IntentFilter filter = new IntentFilter(); @@ -1742,6 +1747,10 @@ private void updateSettingsLocked() { LineageSettings.Secure.KEYBOARD_BRIGHTNESS, mKeyboardBrightnessDefault, UserHandle.USER_CURRENT); + mForceNavbar = LineageSettings.System.getIntForUser(resolver, + LineageSettings.System.FORCE_SHOW_NAVBAR, + 0, UserHandle.USER_CURRENT) == 1; + mDirty |= DIRTY_SETTINGS; } @@ -3204,15 +3213,17 @@ private void updateUserActivitySummaryLocked(long now, int dirty) { if (wakefulness == WAKEFULNESS_AWAKE) { if (mButtonsLight != null) { float buttonBrightness = BRIGHTNESS_OFF_FLOAT; - if (isValidBrightness( - mButtonBrightnessOverrideFromWindowManager)) { - if (mButtonBrightnessOverrideFromWindowManager > - PowerManager.BRIGHTNESS_MIN) { - buttonBrightness = - mButtonBrightnessOverrideFromWindowManager; + if (!mForceNavbar) { + if (isValidBrightness( + mButtonBrightnessOverrideFromWindowManager)) { + if (mButtonBrightnessOverrideFromWindowManager > + PowerManager.BRIGHTNESS_MIN) { + buttonBrightness = + mButtonBrightnessOverrideFromWindowManager; + } + } else if (isValidButtonBrightness(mButtonBrightness)) { + buttonBrightness = mButtonBrightness; } - } else if (isValidButtonBrightness(mButtonBrightness)) { - buttonBrightness = mButtonBrightness; } if (!mButtonLightOnKeypressOnly) { diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index 44df355d6756a..0ee6214e195c5 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -86,9 +86,11 @@ import android.app.LoadedApk; import android.app.ResourcesManager; import android.app.WindowConfiguration; +import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.res.Resources; +import android.database.ContentObserver; import android.graphics.Insets; import android.graphics.PixelFormat; import android.graphics.Rect; @@ -149,6 +151,8 @@ import com.android.server.wallpaper.WallpaperManagerInternal; import com.android.wm.shell.Flags; +import lineageos.providers.LineageSettings; + import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; @@ -241,6 +245,7 @@ StatusBarManagerInternal getStatusBarManagerInternal() { private volatile boolean mHasStatusBar; private volatile boolean mHasNavigationBar; + private volatile boolean mForceNavbar; // Can the navigation bar ever move to the side? private volatile boolean mNavigationBarCanMove; private volatile boolean mNavigationBarAlwaysShowOnSideGesture; @@ -381,6 +386,8 @@ StatusBarManagerInternal getStatusBarManagerInternal() { private RefreshRatePolicy mRefreshRatePolicy; + private SettingsObserver mSettingsObserver; + /** * If true, attach the navigation bar to the current transition app. * The value is read from config_attachNavBarToAppDuringTransition and could be overlaid by RRO @@ -418,6 +425,24 @@ public void handleMessage(Message msg) { } } + private class SettingsObserver extends ContentObserver { + public SettingsObserver(Handler handler) { + super(handler); + + ContentResolver resolver = mContext.getContentResolver(); + resolver.registerContentObserver(LineageSettings.System.getUriFor( + LineageSettings.System.FORCE_SHOW_NAVBAR), false, this, + UserHandle.USER_ALL); + + updateSettings(); + } + + @Override + public void onChange(boolean selfChange) { + updateSettings(); + } + } + DisplayPolicy(WindowManagerService service, DisplayContent displayContent) { mService = service; mContext = displayContent.isDefaultDisplay ? service.mContext @@ -672,6 +697,9 @@ public void onAppTransitionFinishedLocked(IBinder token) { } else if ("0".equals(navBarOverride)) { mHasNavigationBar = true; } + + // Register content observer only for main display + mSettingsObserver = new SettingsObserver(mHandler); } else { mHasStatusBar = false; mHasNavigationBar = mDisplayContent.isSystemDecorationsSupported(); @@ -718,6 +746,14 @@ void systemReady() { } } + public void updateSettings() { + ContentResolver resolver = mContext.getContentResolver(); + + mForceNavbar = LineageSettings.System.getIntForUser(resolver, + LineageSettings.System.FORCE_SHOW_NAVBAR, 0, + UserHandle.USER_CURRENT) == 1; + } + private int getDisplayId() { return mDisplayContent.getDisplayId(); } @@ -766,7 +802,7 @@ public int getDockMode() { } public boolean hasNavigationBar() { - return mHasNavigationBar; + return mHasNavigationBar || mForceNavbar; } void updateHasNavigationBarIfNeeded() { From 63e3c8276fabad029a6d6894f7607c160a9822f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Pra=C5=BE=C3=A1k?= Date: Thu, 9 Jan 2020 11:37:29 +0100 Subject: [PATCH 016/765] SystemUI: add FloatingRotationButton for hw-key devices Add floating rotation button for hardware key devices. Screenshot: https://imgur.com/a/KPNGD43 Co-authored-by: Timi Change-Id: I26953cb83edc28483b88cad61affade526647cbe Signed-off-by: Pranav Vashi --- .../rotation/FloatingRotationButton.java | 11 ++- .../shared/rotation/RotationButton.java | 1 + .../statusbar/phone/PhoneStatusBarView.java | 77 ++++++++++++++++++- 3 files changed, 87 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/rotation/FloatingRotationButton.java b/packages/SystemUI/shared/src/com/android/systemui/shared/rotation/FloatingRotationButton.java index dfb62c0b2eb02..08b32160f0631 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/rotation/FloatingRotationButton.java +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/rotation/FloatingRotationButton.java @@ -73,6 +73,7 @@ public class FloatingRotationButton implements RotationButton { private AnimatedVectorDrawable mAnimatedDrawable; private boolean mIsShowing; + private boolean mCanShow = true; private int mDisplayRotation; private boolean mIsTaskbarVisible = false; @@ -154,7 +155,7 @@ public View getCurrentView() { @Override public boolean show() { - if (mIsShowing) { + if (!mCanShow || mIsShowing) { return false; } @@ -251,6 +252,14 @@ public void setDarkIntensity(float darkIntensity) { mKeyButtonView.setDarkIntensity(darkIntensity); } + @Override + public void setCanShowRotationButton(boolean canShow) { + mCanShow = canShow; + if (!mCanShow) { + hide(); + } + } + @Override public void onTaskbarStateChanged(boolean taskbarVisible, boolean taskbarStashed) { mIsTaskbarVisible = taskbarVisible; diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/rotation/RotationButton.java b/packages/SystemUI/shared/src/com/android/systemui/shared/rotation/RotationButton.java index a44472ae96c02..43d6e384f1530 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/rotation/RotationButton.java +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/rotation/RotationButton.java @@ -40,6 +40,7 @@ default void onDestroy() {} default boolean isVisible() { return false; } + default void setCanShowRotationButton(boolean canShow) {} default void onTaskbarStateChanged(boolean taskbarVisible, boolean taskbarStashed) {} default void updateIcon(int lightIconColor, int darkIconColor) { } default void setOnClickListener(View.OnClickListener onClickListener) { } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java index 954c3911cccb1..64bc6796baa05 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java @@ -21,15 +21,21 @@ import android.content.res.Configuration; import android.graphics.Insets; import android.graphics.Rect; +import android.inputmethodservice.InputMethodService; +import android.os.IBinder; +import android.os.RemoteException; import android.util.AttributeSet; import android.util.Log; +import android.view.ContextThemeWrapper; import android.view.Display; import android.view.DisplayCutout; +import android.view.IWindowManager; import android.view.MotionEvent; import android.view.Surface; import android.view.View; import android.view.ViewGroup; import android.view.WindowInsets; +import android.view.WindowManagerGlobal; import android.view.accessibility.AccessibilityEvent; import android.widget.FrameLayout; import android.widget.LinearLayout; @@ -37,12 +43,17 @@ import androidx.annotation.NonNull; import com.android.internal.policy.SystemBarUtils; +import com.android.settingslib.Utils; import com.android.systemui.Dependency; import com.android.systemui.Flags; import com.android.systemui.Gefingerpoken; import com.android.systemui.res.R; import com.android.systemui.shade.ShadeExpandsOnStatusBarLongPress; import com.android.systemui.shade.StatusBarLongPressGestureDetector; +import com.android.systemui.shared.rotation.FloatingRotationButton; +import com.android.systemui.shared.rotation.RotationButtonController; +import com.android.systemui.statusbar.CommandQueue; +import com.android.systemui.statusbar.CommandQueue.Callbacks; import com.android.systemui.statusbar.core.StatusBarConnectedDisplays; import com.android.systemui.statusbar.phone.userswitcher.StatusBarUserSwitcherContainer; import com.android.systemui.statusbar.window.StatusBarWindowControllerStore; @@ -53,11 +64,13 @@ import java.util.Objects; import java.util.function.BooleanSupplier; -public class PhoneStatusBarView extends FrameLayout { +public class PhoneStatusBarView extends FrameLayout implements Callbacks { private static final String TAG = "PhoneStatusBarView"; + private final CommandQueue mCommandQueue; private final StatusBarWindowControllerStore mStatusBarWindowControllerStore; private int mRotationOrientation = -1; + private RotationButtonController mRotationButtonController; @Nullable private View mCutoutSpace; @Nullable @@ -84,7 +97,52 @@ public class PhoneStatusBarView extends FrameLayout { public PhoneStatusBarView(Context context, AttributeSet attrs) { super(context, attrs); + mCommandQueue = Dependency.get(CommandQueue.class); mStatusBarWindowControllerStore = Dependency.get(StatusBarWindowControllerStore.class); + + // Only create FRB here if there is no navbar + if (!hasNavigationBar()) { + final Context lightContext = new ContextThemeWrapper(context, + Utils.getThemeAttr(context, R.attr.lightIconTheme)); + final Context darkContext = new ContextThemeWrapper(context, + Utils.getThemeAttr(context, R.attr.darkIconTheme)); + final int lightIconColor = + Utils.getColorAttrDefaultColor(lightContext, R.attr.singleToneColor); + final int darkIconColor = + Utils.getColorAttrDefaultColor(darkContext, R.attr.singleToneColor); + final FloatingRotationButton floatingRotationButton = new FloatingRotationButton( + context, + R.string.accessibility_rotate_button, R.layout.rotate_suggestion, + R.id.rotate_suggestion, R.dimen.floating_rotation_button_min_margin, + R.dimen.rounded_corner_content_padding, + R.dimen.floating_rotation_button_taskbar_left_margin, + R.dimen.floating_rotation_button_taskbar_bottom_margin, + R.dimen.floating_rotation_button_diameter, R.dimen.key_button_ripple_max_width, + R.bool.floating_rotation_button_position_left); + + mRotationButtonController = new RotationButtonController(lightContext, lightIconColor, + darkIconColor, R.drawable.ic_sysbar_rotate_button_ccw_start_0, + R.drawable.ic_sysbar_rotate_button_ccw_start_90, + R.drawable.ic_sysbar_rotate_button_cw_start_0, + R.drawable.ic_sysbar_rotate_button_cw_start_90, + () -> getDisplay().getRotation()); + mRotationButtonController.setRotationButton(floatingRotationButton, null); + } + } + + @Override + public void onRotationProposal(final int rotation, boolean isValid) { + if (mRotationButtonController != null && !hasNavigationBar()) { + mRotationButtonController.onRotationProposal(rotation, isValid); + } + } + + private boolean hasNavigationBar() { + try { + IWindowManager windowManager = WindowManagerGlobal.getWindowManagerService(); + return windowManager.hasNavigationBar(Display.DEFAULT_DISPLAY); + } catch (RemoteException ex) { } + return false; } void setLongPressGestureDetector( @@ -132,12 +190,20 @@ protected void onAttachedToWindow() { updateLayoutForCutout(); updateWindowHeight(); } + + if (mRotationButtonController != null && !hasNavigationBar()) { + mCommandQueue.addCallback(this); + } } @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); mDisplayCutout = null; + + if (mRotationButtonController != null) { + mCommandQueue.removeCallback(this); + } } // Per b/300629388, we let the PhoneStatusBarView detect onConfigurationChanged to @@ -270,6 +336,15 @@ public boolean onInterceptTouchEvent(MotionEvent event) { } } + @Override + public void setImeWindowStatus(int displayId, int vis, int backDisposition, + boolean showImeSwitcher) { + if (mRotationButtonController != null) { + final boolean imeShown = (vis & InputMethodService.IME_VISIBLE) != 0; + mRotationButtonController.getRotationButton().setCanShowRotationButton(!imeShown); + } + } + public void updateResources() { mCutoutSideNudge = getResources().getDimensionPixelSize( R.dimen.display_cutout_margin_consumption); From 8a46798d698895d933007e9cc9dc48f25ca90a1a Mon Sep 17 00:00:00 2001 From: Utkarsh Gupta Date: Thu, 28 Dec 2017 21:55:45 +0100 Subject: [PATCH 017/765] Allow screen unpinning on devices without navbar Change-Id: Iedfc08f4d95bbee3c8578c0d2450b90739e63603 Screen Pinning: Show correct text for on screen nav. Similar to I09c2ef661bff272cb4f7ca43bac0e45f4b20a4d4, we're not getting an instance of PhoneWindowManager which we can rely on to update dynamically. TICKET: OPO-393 Change-Id: Iacf8221066461fb6940dd88432e665812545c3ff Signed-off-by: Pranav Vashi --- packages/SystemUI/res/values/cm_strings.xml | 6 ++++++ .../navigationbar/ScreenPinningNotify.java | 16 +++++++++++++++- .../recents/ScreenPinningRequest.java | 16 ++++++++++------ .../server/policy/PhoneWindowManager.java | 19 ++++++++++++++++++- 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/packages/SystemUI/res/values/cm_strings.xml b/packages/SystemUI/res/values/cm_strings.xml index f918477d575bc..381dc02c91103 100644 --- a/packages/SystemUI/res/values/cm_strings.xml +++ b/packages/SystemUI/res/values/cm_strings.xml @@ -129,4 +129,10 @@ Remove the 3 second wait HEVC encoding Use the more efficient HEVC encoder + + + This keeps it in view until you unpin. Touch & hold Back to unpin. + + + To unpin this screen, touch & hold Back button diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/ScreenPinningNotify.java b/packages/SystemUI/src/com/android/systemui/navigationbar/ScreenPinningNotify.java index 1e40dd9945d28..06994346210fd 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/ScreenPinningNotify.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/ScreenPinningNotify.java @@ -17,8 +17,10 @@ package com.android.systemui.navigationbar; import android.content.Context; +import android.os.RemoteException; import android.os.SystemClock; import android.util.Slog; +import android.view.WindowManagerGlobal; import android.widget.Toast; import com.android.systemui.SysUIToast; @@ -60,7 +62,9 @@ public void showEscapeToast(boolean isGestureNavEnabled, boolean isRecentsButton if (mLastToast != null) { mLastToast.cancel(); } - mLastToast = makeAllUserToastAndShow(isGestureNavEnabled + mLastToast = makeAllUserToastAndShow(!hasSoftNavigationBar() + ? R.string.screen_pinning_toast_no_navbar + : isGestureNavEnabled ? R.string.screen_pinning_toast_gesture_nav : isRecentsButtonVisible ? R.string.screen_pinning_toast @@ -73,4 +77,14 @@ private Toast makeAllUserToastAndShow(int resId) { toast.show(); return toast; } + + private boolean hasSoftNavigationBar() { + try { + return WindowManagerGlobal.getWindowManagerService() + .hasNavigationBar(mContext.getDisplayId()); + } catch (RemoteException e) { + Slog.e(TAG, "Failed to check soft navigation bar", e); + return false; + } + } } diff --git a/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java b/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java index a1281ec23f92b..d83ccfc16f206 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java +++ b/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java @@ -302,16 +302,20 @@ && hasSoftNavigationBar(mContext.getDisplayId()) && !isLargeScreen(mContext)) { mLayout.findViewById(R.id.screen_pinning_recents_group).setVisibility(VISIBLE); mLayout.findViewById(R.id.screen_pinning_home_bg_light).setVisibility(INVISIBLE); mLayout.findViewById(R.id.screen_pinning_home_bg).setVisibility(INVISIBLE); - descriptionStringResId = touchExplorationEnabled - ? R.string.screen_pinning_description_accessible - : R.string.screen_pinning_description; + descriptionStringResId = !hasSoftNavigationBar(displayId) + ? R.string.screen_pinning_description_no_navbar + : touchExplorationEnabled + ? R.string.screen_pinning_description_accessible + : R.string.screen_pinning_description; } else { mLayout.findViewById(R.id.screen_pinning_recents_group).setVisibility(INVISIBLE); mLayout.findViewById(R.id.screen_pinning_home_bg_light).setVisibility(VISIBLE); mLayout.findViewById(R.id.screen_pinning_home_bg).setVisibility(VISIBLE); - descriptionStringResId = touchExplorationEnabled - ? R.string.screen_pinning_description_recents_invisible_accessible - : R.string.screen_pinning_description_recents_invisible; + descriptionStringResId = !hasSoftNavigationBar(displayId) + ? R.string.screen_pinning_description_no_navbar + : touchExplorationEnabled + ? R.string.screen_pinning_description_recents_invisible_accessible + : R.string.screen_pinning_description_recents_invisible; } NavigationBarView navigationBarView = diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index 84a0fb7ee0b5f..1d13ca4af41ba 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -1703,7 +1703,10 @@ private void powerVeryLongPress() { } private void backLongPress() { - if (hasLongPressOnBackBehavior()) { + if (unpinActivity()) { + mBackKeyHandled = true; + performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, "Back - Long Press"); + } else if (hasLongPressOnBackBehavior()) { mBackKeyHandled = true; long now = SystemClock.uptimeMillis(); @@ -4285,6 +4288,20 @@ private boolean dispatchKeyToKeyHandlers(KeyEvent event) { return false; } + private boolean unpinActivity() { + if (!hasNavigationBar()) { + try { + if (ActivityTaskManager.getService().isInLockTaskMode()) { + ActivityTaskManager.getService().stopSystemLockTaskMode(); + return true; + } + } catch (RemoteException e) { + // ignore + } + } + return false; + } + // TODO(b/117479243): handle it in InputPolicy /** {@inheritDoc} */ @Override From c8a5cc8d69775adcc6c35e9274ce4ed80d31408b Mon Sep 17 00:00:00 2001 From: basamaryan Date: Sun, 14 Dec 2025 18:41:47 -0800 Subject: [PATCH 018/765] SettingsProvider: Add default resource for disable_window_blurs Enable device-specific overlay to change the default state of cross-window blurs. Change-Id: Ia2c921435e5eae33be450e7ddb48ac41e75c3961 --- packages/SettingsProvider/res/values/defaults.xml | 3 +++ .../src/com/android/providers/settings/DatabaseHelper.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml index 94aa955f0282b..55d35d4e1755a 100644 --- a/packages/SettingsProvider/res/values/defaults.xml +++ b/packages/SettingsProvider/res/values/defaults.xml @@ -224,6 +224,9 @@ false + + false + 1 diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java index a3eab5da11005..113c98d1310a0 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java @@ -2342,6 +2342,9 @@ private void loadGlobalSettings(SQLiteDatabase db) { loadIntegerSetting(stmt, Settings.Global.CELL_ON, R.integer.def_cell_on); + loadBooleanSetting(stmt, Settings.Global.DISABLE_WINDOW_BLURS, + R.bool.def_disable_window_blurs); + // Enable or disable Cell Broadcast SMS loadSetting(stmt, Settings.Global.CDMA_CELL_BROADCAST_SMS, RILConstants.CDMA_CELL_BROADCAST_SMS_DISABLED); From 08f39772b7954e510f6fbb912b174762ecb74f05 Mon Sep 17 00:00:00 2001 From: Quallenauge Date: Sat, 19 Feb 2022 22:28:20 +0100 Subject: [PATCH 019/765] Biometrics: Allow disabling of fingerprint cleanups Don't schedule cleanups at all if the driver doesn't support enumerate function. Change-Id: If9e1b82bc551e2fd06218b1720f5986633c1ab55 --- .../sensors/fingerprint/aidl/FingerprintProvider.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintProvider.java b/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintProvider.java index 45f49669a0542..3b178ec751023 100644 --- a/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintProvider.java +++ b/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintProvider.java @@ -137,6 +137,8 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi @Nullable private IVirtualHal mVhal; @Nullable private String mHalInstanceNameCurrent; + private boolean mCleanup; + private final class BiometricTaskStackListener extends TaskStackListener { @Override public void onTaskStackChanged() { @@ -206,6 +208,9 @@ public FingerprintProvider(@NonNull Context context, mTestHalEnabled = testHalEnabled; mBiometricHandlerProvider = biometricHandlerProvider; + mCleanup = context.getResources().getBoolean( + org.lineageos.platform.internal.R.bool.config_cleanupUnusedFingerprints); + initAuthenticationBroadcastReceiver(); initFingerprintDanglingBroadcastReceiver(); initSensors(resetLockoutRequiresHardwareAuthToken, props, gestureAvailabilityDispatcher); @@ -674,6 +679,9 @@ public void scheduleInternalCleanup(int sensorId, int userId, @Override public void scheduleInternalCleanup(int sensorId, int userId, @Nullable ClientMonitorCallback callback, boolean favorHalEnrollments) { + if (!mCleanup) { + return; + } mHandler.post(() -> { final FingerprintInternalCleanupClient client = new FingerprintInternalCleanupClient(mContext, From 6177236550352a98f7819f39c6759a7b2c18fe04 Mon Sep 17 00:00:00 2001 From: Pranav Vashi Date: Thu, 7 Sep 2023 21:42:22 +0530 Subject: [PATCH 020/765] base: Add stub files Signed-off-by: Pranav Vashi --- core/res/res/values/cr_arrays.xml | 8 ++++++++ core/res/res/values/cr_attrs.xml | 12 ++++++++++++ core/res/res/values/cr_colors.xml | 8 ++++++++ core/res/res/values/cr_config.xml | 8 ++++++++ core/res/res/values/cr_dimens.xml | 8 ++++++++ core/res/res/values/cr_strings.xml | 8 ++++++++ core/res/res/values/cr_styles.xml | 8 ++++++++ core/res/res/values/cr_symbols.xml | 8 ++++++++ packages/SystemUI/res/values-night/cr_colors.xml | 8 ++++++++ packages/SystemUI/res/values/cr_arrays.xml | 8 ++++++++ packages/SystemUI/res/values/cr_attrs.xml | 8 ++++++++ packages/SystemUI/res/values/cr_colors.xml | 8 ++++++++ packages/SystemUI/res/values/cr_config.xml | 8 ++++++++ packages/SystemUI/res/values/cr_dimens.xml | 8 ++++++++ packages/SystemUI/res/values/cr_strings.xml | 8 ++++++++ packages/SystemUI/res/values/cr_styles.xml | 8 ++++++++ packages/SystemUI/res/values/cr_symbols.xml | 8 ++++++++ 17 files changed, 140 insertions(+) create mode 100644 core/res/res/values/cr_arrays.xml create mode 100644 core/res/res/values/cr_attrs.xml create mode 100644 core/res/res/values/cr_colors.xml create mode 100644 core/res/res/values/cr_config.xml create mode 100644 core/res/res/values/cr_dimens.xml create mode 100644 core/res/res/values/cr_strings.xml create mode 100644 core/res/res/values/cr_styles.xml create mode 100644 core/res/res/values/cr_symbols.xml create mode 100644 packages/SystemUI/res/values-night/cr_colors.xml create mode 100644 packages/SystemUI/res/values/cr_arrays.xml create mode 100644 packages/SystemUI/res/values/cr_attrs.xml create mode 100644 packages/SystemUI/res/values/cr_colors.xml create mode 100644 packages/SystemUI/res/values/cr_config.xml create mode 100644 packages/SystemUI/res/values/cr_dimens.xml create mode 100644 packages/SystemUI/res/values/cr_strings.xml create mode 100644 packages/SystemUI/res/values/cr_styles.xml create mode 100644 packages/SystemUI/res/values/cr_symbols.xml diff --git a/core/res/res/values/cr_arrays.xml b/core/res/res/values/cr_arrays.xml new file mode 100644 index 0000000000000..418d200cd2af7 --- /dev/null +++ b/core/res/res/values/cr_arrays.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/core/res/res/values/cr_attrs.xml b/core/res/res/values/cr_attrs.xml new file mode 100644 index 0000000000000..34d5221eae65e --- /dev/null +++ b/core/res/res/values/cr_attrs.xml @@ -0,0 +1,12 @@ + + + + + + + + + diff --git a/core/res/res/values/cr_colors.xml b/core/res/res/values/cr_colors.xml new file mode 100644 index 0000000000000..418d200cd2af7 --- /dev/null +++ b/core/res/res/values/cr_colors.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/core/res/res/values/cr_config.xml b/core/res/res/values/cr_config.xml new file mode 100644 index 0000000000000..418d200cd2af7 --- /dev/null +++ b/core/res/res/values/cr_config.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/core/res/res/values/cr_dimens.xml b/core/res/res/values/cr_dimens.xml new file mode 100644 index 0000000000000..418d200cd2af7 --- /dev/null +++ b/core/res/res/values/cr_dimens.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/core/res/res/values/cr_strings.xml b/core/res/res/values/cr_strings.xml new file mode 100644 index 0000000000000..dd13dbc59551c --- /dev/null +++ b/core/res/res/values/cr_strings.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/core/res/res/values/cr_styles.xml b/core/res/res/values/cr_styles.xml new file mode 100644 index 0000000000000..418d200cd2af7 --- /dev/null +++ b/core/res/res/values/cr_styles.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/core/res/res/values/cr_symbols.xml b/core/res/res/values/cr_symbols.xml new file mode 100644 index 0000000000000..418d200cd2af7 --- /dev/null +++ b/core/res/res/values/cr_symbols.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/packages/SystemUI/res/values-night/cr_colors.xml b/packages/SystemUI/res/values-night/cr_colors.xml new file mode 100644 index 0000000000000..418d200cd2af7 --- /dev/null +++ b/packages/SystemUI/res/values-night/cr_colors.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/packages/SystemUI/res/values/cr_arrays.xml b/packages/SystemUI/res/values/cr_arrays.xml new file mode 100644 index 0000000000000..418d200cd2af7 --- /dev/null +++ b/packages/SystemUI/res/values/cr_arrays.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/packages/SystemUI/res/values/cr_attrs.xml b/packages/SystemUI/res/values/cr_attrs.xml new file mode 100644 index 0000000000000..418d200cd2af7 --- /dev/null +++ b/packages/SystemUI/res/values/cr_attrs.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/packages/SystemUI/res/values/cr_colors.xml b/packages/SystemUI/res/values/cr_colors.xml new file mode 100644 index 0000000000000..418d200cd2af7 --- /dev/null +++ b/packages/SystemUI/res/values/cr_colors.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/packages/SystemUI/res/values/cr_config.xml b/packages/SystemUI/res/values/cr_config.xml new file mode 100644 index 0000000000000..418d200cd2af7 --- /dev/null +++ b/packages/SystemUI/res/values/cr_config.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/packages/SystemUI/res/values/cr_dimens.xml b/packages/SystemUI/res/values/cr_dimens.xml new file mode 100644 index 0000000000000..418d200cd2af7 --- /dev/null +++ b/packages/SystemUI/res/values/cr_dimens.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/packages/SystemUI/res/values/cr_strings.xml b/packages/SystemUI/res/values/cr_strings.xml new file mode 100644 index 0000000000000..dd13dbc59551c --- /dev/null +++ b/packages/SystemUI/res/values/cr_strings.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/packages/SystemUI/res/values/cr_styles.xml b/packages/SystemUI/res/values/cr_styles.xml new file mode 100644 index 0000000000000..418d200cd2af7 --- /dev/null +++ b/packages/SystemUI/res/values/cr_styles.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/packages/SystemUI/res/values/cr_symbols.xml b/packages/SystemUI/res/values/cr_symbols.xml new file mode 100644 index 0000000000000..418d200cd2af7 --- /dev/null +++ b/packages/SystemUI/res/values/cr_symbols.xml @@ -0,0 +1,8 @@ + + + + + From 19b98fd16615b87ed23b749ed520158069e6267e Mon Sep 17 00:00:00 2001 From: Pranav Vashi Date: Wed, 13 Jul 2022 21:05:54 +0530 Subject: [PATCH 021/765] SystemUI: Update black theme package overlay Signed-off-by: Pranav Vashi --- .../src/com/android/systemui/theme/ThemeOverlayApplier.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayApplier.java b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayApplier.java index fe928c381156c..9bfc193a508e3 100644 --- a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayApplier.java +++ b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayApplier.java @@ -68,7 +68,7 @@ public class ThemeOverlayApplier implements Dumpable { static final String SYSUI_PACKAGE = "com.android.systemui"; static final String OVERLAY_BLACK_THEME = - "org.lineageos.overlay.customization.blacktheme"; + "com.android.system.theme.black"; static final String OVERLAY_CATEGORY_DYNAMIC_COLOR = "android.theme.customization.dynamic_color"; From 9dc95a234be0855dfe1231b9710a012f0b3bdee5 Mon Sep 17 00:00:00 2001 From: Pranav Vashi Date: Wed, 7 Oct 2020 13:11:29 +0530 Subject: [PATCH 022/765] base: Export bodyFontFamily and bodyFontFamilyMedium symbols * So that they can be used in apps like launcher and settings. Signed-off-by: Pranav Vashi --- core/res/res/values/symbols.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index a0ae922789e2b..0ce6e1ed859e4 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -4193,6 +4193,8 @@ + + From 9d84f67be454c9e59f5973f1a49989ab802d92ff Mon Sep 17 00:00:00 2001 From: Pranav Vashi Date: Sun, 29 Dec 2019 19:31:38 +0530 Subject: [PATCH 023/765] Wire up default fonts with config Signed-off-by: Pranav Vashi --- core/res/res/layout/time_picker_material.xml | 2 +- core/res/res/values/config.xml | 4 ++-- .../res/values/donottranslate_material.xml | 24 +++++++++---------- core/res/res/values/styles.xml | 4 ++-- core/res/res/values/styles_material.xml | 16 ++++++------- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/core/res/res/layout/time_picker_material.xml b/core/res/res/layout/time_picker_material.xml index 75973798219ef..ee733f1f39e86 100644 --- a/core/res/res/layout/time_picker_material.xml +++ b/core/res/res/layout/time_picker_material.xml @@ -44,7 +44,7 @@ android:paddingTop="20dp" android:paddingBottom="20dp" android:includeFontPadding="false" - android:fontFamily="sans-serif-medium" + android:fontFamily="@string/config_bodyFontFamilyMedium" android:textSize="34sp" android:textColor="@color/white" android:text="@string/time_picker_header_text"/> diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 2bffe6d3972d3..110367f2ea9fb 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -5298,7 +5298,7 @@ 90 - + sans-serif @@ -5383,7 +5383,7 @@ true - @string/font_family_button_material + sans-serif-medium sans-serif diff --git a/core/res/res/values/donottranslate_material.xml b/core/res/res/values/donottranslate_material.xml index 9cf9f6cfa86df..24ae4d430a947 100644 --- a/core/res/res/values/donottranslate_material.xml +++ b/core/res/res/values/donottranslate_material.xml @@ -16,17 +16,17 @@ - sans-serif-light - sans-serif - sans-serif - sans-serif - sans-serif - sans-serif-medium - sans-serif - sans-serif - sans-serif-medium - sans-serif - sans-serif - sans-serif-medium + @string/config_lightFontFamily + @string/config_bodyFontFamily + @string/config_bodyFontFamily + @string/config_bodyFontFamily + @string/config_headlineFontFamily + @string/config_headlineFontFamilyMedium + @string/config_headlineFontFamily + @string/config_bodyFontFamily + @string/config_bodyFontFamilyMedium + @string/config_bodyFontFamily + @string/config_bodyFontFamily + @string/config_headlineFontFamilyMedium diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml index 3f75fd90284bc..840b3f5ed0f17 100644 --- a/core/res/res/values/styles.xml +++ b/core/res/res/values/styles.xml @@ -283,7 +283,7 @@ please see styles_device_defaults.xml. @@ -999,7 +999,7 @@ please see styles_device_defaults.xml. diff --git a/core/res/res/values/styles_material.xml b/core/res/res/values/styles_material.xml index 4f714af08e2a0..9c32b1fd8a8e7 100644 --- a/core/res/res/values/styles_material.xml +++ b/core/res/res/values/styles_material.xml @@ -429,7 +429,7 @@ please see styles_device_defaults.xml. From 2173eea3339690e9fabaaeca98d8efaae43a9a3e Mon Sep 17 00:00:00 2001 From: Pranav Vashi Date: Sun, 5 Jun 2022 01:53:48 +0530 Subject: [PATCH 024/765] base: Use font configs instead hardcoded fonts Signed-off-by: Pranav Vashi Signed-off-by: AnierinB --- .../res/layout/accessibility_button_chooser_item.xml | 2 +- .../layout/accessibility_enable_service_warning.xml | 12 ++++++------ .../layout/accessibility_shortcut_chooser_item.xml | 4 ++-- core/res/res/layout/immersive_mode_cling.xml | 6 +++--- .../res/layout/input_method_switch_dialog_new.xml | 2 +- .../res/layout/input_method_switch_item_header.xml | 2 +- core/res/res/layout/input_method_switch_item_new.xml | 4 ++-- packages/SystemUI/res/layout/contaminant_dialog.xml | 4 ++-- .../SystemUI/res/layout/immersive_mode_cling.xml | 6 +++--- .../res/layout/shutdown_dialog_finder_active.xml | 6 +++--- packages/SystemUI/res/layout/smart_action_button.xml | 2 +- packages/SystemUI/res/layout/smart_reply_button.xml | 2 +- packages/SystemUI/res/values/styles.xml | 6 +++--- .../android/systemui/volume/SegmentedButtons.java | 10 ++++++++-- 14 files changed, 37 insertions(+), 31 deletions(-) diff --git a/core/res/res/layout/accessibility_button_chooser_item.xml b/core/res/res/layout/accessibility_button_chooser_item.xml index 33d6fa2862f76..70905ca19192d 100644 --- a/core/res/res/layout/accessibility_button_chooser_item.xml +++ b/core/res/res/layout/accessibility_button_chooser_item.xml @@ -45,7 +45,7 @@ android:textAppearance="?attr/textAppearanceSmall" android:textColor="?attr/textColorPrimary" android:textSize="12sp" - android:fontFamily="sans-serif-condensed" + android:fontFamily="@*android:string/config_bodyFontFamily" android:gravity="top|center_horizontal" android:minLines="2" android:maxLines="2" diff --git a/core/res/res/layout/accessibility_enable_service_warning.xml b/core/res/res/layout/accessibility_enable_service_warning.xml index 01ef10177c5a3..fc6f498375193 100644 --- a/core/res/res/layout/accessibility_enable_service_warning.xml +++ b/core/res/res/layout/accessibility_enable_service_warning.xml @@ -51,7 +51,7 @@ android:gravity="center" android:textSize="20sp" android:textColor="?android:attr/textColorPrimary" - android:fontFamily="google-sans-medium"/> + android:fontFamily="@*android:string/config_headlineFontFamily"/> + android:fontFamily="@*android:string/config_bodyFontFamily"/> + android:fontFamily="@*android:string/config_headlineFontFamily"/> + android:fontFamily="@*android:string/config_bodyFontFamily"/> + android:fontFamily="@*android:string/config_headlineFontFamily"/> + android:fontFamily="@*android:string/config_bodyFontFamily" /> + android:fontFamily="@*android:string/config_bodyFontFamily"/> + android:fontFamily="@*android:string/config_bodyFontFamily"/> diff --git a/core/res/res/layout/immersive_mode_cling.xml b/core/res/res/layout/immersive_mode_cling.xml index 4e869b76b5100..385c7191365ce 100644 --- a/core/res/res/layout/immersive_mode_cling.xml +++ b/core/res/res/layout/immersive_mode_cling.xml @@ -44,7 +44,7 @@ android:text="@string/immersive_cling_title" android:textColor="@androidprv:color/materialColorOnSurface" android:textSize="24sp" - android:fontFamily="google-sans" /> + android:fontFamily="@*android:string/config_headlineFontFamily" /> + android:fontFamily="@*android:string/config_bodyFontFamily" />