Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a240e7ee authored by Anton Potapov's avatar Anton Potapov
Browse files

Fix work tile setup when adding work profile

Test: Auto + manual
 - Add work profile -> QS tile is added
 - Remove work profile -> QS tile is removed
 - Reboot the device -> QS tile is in place
 - Reorder tiles, reboot the device -> order is persisted
Fixes: 234639083
Change-Id: I4481a3f28f9d1f0c30618afaf78179e0033f50fb
parent 8165fae2
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ public interface QSHost {
    void removeCallback(Callback callback);
    void removeTile(String tileSpec);
    void removeTiles(Collection<String> specs);
    void unmarkTileAsAutoAdded(String tileSpec);

    int indexOf(String tileSpec);

+0 −5
Original line number Diff line number Diff line
@@ -427,11 +427,6 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, P
        mMainExecutor.execute(() -> changeTileSpecs(tileSpecs -> tileSpecs.removeAll(specs)));
    }

    @Override
    public void unmarkTileAsAutoAdded(String spec) {
        if (mAutoTiles != null) mAutoTiles.unmarkTileAsAutoAdded(spec);
    }

    /**
     * Add a tile to the end
     *
+0 −1
Original line number Diff line number Diff line
@@ -101,7 +101,6 @@ public class WorkModeTile extends QSTileImpl<BooleanState> implements
    @MainThread
    public void onManagedProfileRemoved() {
        mHost.removeTile(getTileSpec());
        mHost.unmarkTileAsAutoAdded(getTileSpec());
    }

    @Override
+2 −1
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ class UserTrackerImpl internal constructor(
            // These get called when a managed profile goes in or out of quiet mode.
            addAction(Intent.ACTION_MANAGED_PROFILE_AVAILABLE)
            addAction(Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE)

            addAction(Intent.ACTION_MANAGED_PROFILE_ADDED)
            addAction(Intent.ACTION_MANAGED_PROFILE_REMOVED)
            addAction(Intent.ACTION_MANAGED_PROFILE_UNLOCKED)
        }
@@ -129,6 +129,7 @@ class UserTrackerImpl internal constructor(
            Intent.ACTION_USER_INFO_CHANGED,
            Intent.ACTION_MANAGED_PROFILE_AVAILABLE,
            Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE,
            Intent.ACTION_MANAGED_PROFILE_ADDED,
            Intent.ACTION_MANAGED_PROFILE_REMOVED,
            Intent.ACTION_MANAGED_PROFILE_UNLOCKED -> {
                handleProfilesChanged()
+7 −9
Original line number Diff line number Diff line
@@ -154,9 +154,7 @@ public class AutoTileManager implements UserAwareController {
        if (!mAutoTracker.isAdded(SAVER)) {
            mDataSaverController.addCallback(mDataSaverListener);
        }
        if (!mAutoTracker.isAdded(WORK)) {
        mManagedProfileController.addCallback(mProfileCallback);
        }
        if (!mAutoTracker.isAdded(NIGHT)
                && ColorDisplayManager.isNightDisplayAvailable(mContext)) {
            mNightDisplayListener.setCallback(mNightDisplayCallback);
@@ -275,18 +273,18 @@ public class AutoTileManager implements UserAwareController {
        return mCurrentUser.getIdentifier();
    }

    public void unmarkTileAsAutoAdded(String tabSpec) {
        mAutoTracker.setTileRemoved(tabSpec);
    }

    private final ManagedProfileController.Callback mProfileCallback =
            new ManagedProfileController.Callback() {
                @Override
                public void onManagedProfileChanged() {
                    if (mAutoTracker.isAdded(WORK)) return;
                    if (mManagedProfileController.hasActiveProfile()) {
                        if (mAutoTracker.isAdded(WORK)) return;
                        mHost.addTile(WORK);
                        mAutoTracker.setTileAdded(WORK);
                    } else {
                        if (!mAutoTracker.isAdded(WORK)) return;
                        mHost.removeTile(WORK);
                        mAutoTracker.setTileRemoved(WORK);
                    }
                }

@@ -429,7 +427,7 @@ public class AutoTileManager implements UserAwareController {
                initSafetyTile();
            } else if (!isSafetyCenterEnabled && mAutoTracker.isAdded(mSafetySpec)) {
                mHost.removeTile(mSafetySpec);
                mHost.unmarkTileAsAutoAdded(mSafetySpec);
                mAutoTracker.setTileRemoved(mSafetySpec);
            }
        }
    };
Loading