feat: Add work profile customization and fix issues (#6167)

* Fix work profile unpause authentication prompt

Skip credential challenge when enabling/disabling work profile by passing null Intent parameter to requestQuietModeEnabled(). This prevents password/biometric prompts for secure folders when toggling work profile state.

- Use 3-parameter requestQuietModeEnabled() with null Intent on Android P+
- Fallback to 2-parameter version for older Android versions
- Resolves authentication prompt issue when unpausing work profile

* Fix work profile pause/unpause without authentication prompts

* Fix work profile state detection on initial load

Fixed bug where work profile quiet mode flag was not set correctly on initial app load when multiple user profiles exist. Changed direct assignment (=) to OR assignment (|=) to preserve quiet state across all work profiles.

This ensures FLAG_WORK_PROFILE_QUIET_MODE_ENABLED is set properly both on initial load (LoaderTask) and during runtime pause/unpause events (PackageUpdatedTask).

* Add work profile tab customization features

- Add workProfileTabBackgroundColor preference for selected tab color
- Add workProfileTabContainerBackground toggle for scroll protection
- Update DrawableTokens to use custom colors from preferences
- Add UI controls in App Drawer preferences
- Control tab background visibility on scroll

Features:
1. Custom color picker for selected work/personal tab button
2. Toggle to show/hide background protection when scrolling

* Fix work profile state detection bug

- Query UserManager.isQuietModeEnabled() directly for real-time state
- Call updateUserQuietMode() to keep cached state synchronized
- Fixes stale quiet mode state causing incorrect UI display

Root cause: LoaderTask was using cached UserManagerState values that
could become stale if work profile state changed between initialization
and app loading.

* Fix work profile unpause authentication prompt

Skip credential challenge when enabling/disabling work profile by passing null Intent parameter to requestQuietModeEnabled(). This prevents password/biometric prompts for secure folders when toggling work profile state.

- Use 3-parameter requestQuietModeEnabled() with null Intent on Android P+
- Fallback to 2-parameter version for older Android versions
- Resolves authentication prompt issue when unpausing work profile

* Fix work profile pause/unpause without authentication prompts

* Fix work profile state detection on initial load

Fixed bug where work profile quiet mode flag was not set correctly on initial app load when multiple user profiles exist. Changed direct assignment (=) to OR assignment (|=) to preserve quiet state across all work profiles.

This ensures FLAG_WORK_PROFILE_QUIET_MODE_ENABLED is set properly both on initial load (LoaderTask) and during runtime pause/unpause events (PackageUpdatedTask).

* Add work profile tab customization features

- Add workProfileTabBackgroundColor preference for selected tab color
- Add workProfileTabContainerBackground toggle for scroll protection
- Update DrawableTokens to use custom colors from preferences
- Add UI controls in App Drawer preferences
- Control tab background visibility on scroll

Features:
1. Custom color picker for selected work/personal tab button
2. Toggle to show/hide background protection when scrolling

* Fix work profile state detection bug

- Query UserManager.isQuietModeEnabled() directly for real-time state
- Call updateUserQuietMode() to keep cached state synchronized
- Fixes stale quiet mode state causing incorrect UI display

Root cause: LoaderTask was using cached UserManagerState values that
could become stale if work profile state changed between initialization
and app loading.

* Fix spotless formatting in DrawableTokens.kt

* fix: cleanup

---------

Co-authored-by: Ankit Kushwaha <ankkushwaha@microsoft.com>
Co-authored-by: Pun Butrach <pun.butrach@gmail.com>
This commit is contained in:
authored and GitHub committed 2026-02-03 23:10:45 +07:00
1 parent 9c397acb95
commit 42b39904f9
9 files changed
+78 -11

No files matched your search

@@ -834,9 +834,14 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
protected void updateHeaderScroll(int scrolledOffset) {
if (PreferenceExtensionsKt.firstBlocking(pref2.getHideAppDrawerSearchBar()))
return;
// Check if tab container background should be shown
boolean showTabContainerBackground = PreferenceExtensionsKt.firstBlocking(
pref2.getWorkProfileTabContainerBackground());
float prog = Utilities.boundToRange((float) scrolledOffset / mHeaderThreshold, 0f, 1f);
int headerColor = getHeaderColor(prog);
int tabsAlpha = mHeader.getPeripheralProtectionHeight(/* expectedHeight */ false) == 0 ? 0
int tabsAlpha = (!showTabContainerBackground || mHeader.getPeripheralProtectionHeight(/* expectedHeight */ false) == 0) ? 0
: (int) (Utilities.boundToRange(
(scrolledOffset + mHeader.mSnappedScrolledY) / mHeaderThreshold, 0f, 1f)
* 255);