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

Commit 68b3fd1b authored by Behnam Heydarshahi's avatar Behnam Heydarshahi Committed by Android (Google) Code Review
Browse files

Merge "Clean up QS_QUICK_REBIND_ACTIVE_TILES flag" into main

parents 18e0e095 2b836bf0
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -359,16 +359,6 @@ flag {
   bug: "311147395"
}

flag {
  name: "qs_quick_rebind_active_tiles"
  namespace: "systemui"
  description: "Rebind active custom tiles quickly."
  bug: "362526228"
  metadata {
    purpose: PURPOSE_BUGFIX
  }
}

flag {
    name: "coroutine_tracing"
    namespace: "systemui"
+5 −10
Original line number Diff line number Diff line
@@ -48,7 +48,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;

import com.android.systemui.Flags;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.dagger.qualifiers.Main;
@@ -469,7 +468,6 @@ public class TileLifecycleManager extends BroadcastReceiver implements
        if (info.lowMemory) {
            delay = LOW_MEMORY_BIND_RETRY_DELAY;
        } else {
            if (Flags.qsQuickRebindActiveTiles()) {
            final long elapsedTimeSinceLastRebind = now - mLastRebind;
            final boolean justAttemptedRebind =
                    elapsedTimeSinceLastRebind < DEFAULT_BIND_RETRY_DELAY;
@@ -478,9 +476,6 @@ public class TileLifecycleManager extends BroadcastReceiver implements
            } else {
                delay = DEFAULT_BIND_RETRY_DELAY;
            }
            } else {
                delay = DEFAULT_BIND_RETRY_DELAY;
            }

            mLastRebind = now;
        }
+2 −72
Original line number Diff line number Diff line
@@ -16,12 +16,10 @@
package com.android.systemui.qs.external;

import static android.os.PowerExemptionManager.REASON_TILE_ONCLICK;
import static android.platform.test.flag.junit.FlagsParameterization.allCombinationsOf;
import static android.service.quicksettings.TileService.START_ACTIVITY_NEEDS_PENDING_INTENT;

import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession;
import static com.android.systemui.Flags.FLAG_QS_QUICK_REBIND_ACTIVE_TILES;

import static com.google.common.truth.Truth.assertThat;

@@ -60,14 +58,12 @@ import android.os.Handler;
import android.os.HandlerThread;
import android.os.IDeviceIdleController;
import android.os.UserHandle;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.FlagsParameterization;
import android.service.quicksettings.IQSService;
import android.service.quicksettings.IQSTileService;
import android.service.quicksettings.TileService;

import androidx.annotation.Nullable;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;

import com.android.systemui.SysuiTestCase;
@@ -86,20 +82,10 @@ import org.mockito.InOrder;
import org.mockito.Mockito;
import org.mockito.MockitoSession;

import platform.test.runner.parameterized.ParameterizedAndroidJunit4;
import platform.test.runner.parameterized.Parameters;

import java.util.List;

@SmallTest
@RunWith(ParameterizedAndroidJunit4.class)
@RunWith(AndroidJUnit4.class)
public class TileLifecycleManagerTest extends SysuiTestCase {

    @Parameters(name = "{0}")
    public static List<FlagsParameterization> getParams() {
        return allCombinationsOf(FLAG_QS_QUICK_REBIND_ACTIVE_TILES);
    }

    private final PackageManagerAdapter mMockPackageManagerAdapter =
            mock(PackageManagerAdapter.class);
    private final BroadcastDispatcher mMockBroadcastDispatcher =
@@ -119,11 +105,6 @@ public class TileLifecycleManagerTest extends SysuiTestCase {
    private TestContextWrapper mWrappedContext;
    private MockitoSession mMockitoSession;

    public TileLifecycleManagerTest(FlagsParameterization flags) {
        super();
        mSetFlagsRule.setFlagsParameterization(flags);
    }

    @Before
    public void setUp() throws Exception {
        setPackageEnabled(true);
@@ -406,7 +387,6 @@ public class TileLifecycleManagerTest extends SysuiTestCase {
        verify(mMockTileService, times(2)).onStartListening();
    }

    @EnableFlags(FLAG_QS_QUICK_REBIND_ACTIVE_TILES)
    @Test
    public void testKillProcessWhenTileServiceIsActive_withRebindFlagOn() throws Exception {
        mStateManager.onStartListening();
@@ -425,27 +405,6 @@ public class TileLifecycleManagerTest extends SysuiTestCase {
        verify(mMockTileService, times(2)).onStartListening();
    }

    @DisableFlags(FLAG_QS_QUICK_REBIND_ACTIVE_TILES)
    @Test
    public void testKillProcessWhenTileServiceIsActive_withRebindFlagOff() throws Exception {
        mStateManager.onStartListening();
        mStateManager.executeSetBindService(true);
        mExecutor.runAllReady();
        verifyBind(1);
        verify(mMockTileService, times(1)).onStartListening();

        mStateManager.onBindingDied(mTileServiceComponentName);
        mExecutor.runAllReady();
        mClock.advanceTime(1000);
        mExecutor.runAllReady();
        verifyBind(0); // the rebind happens after 4 more seconds

        mClock.advanceTime(4000);
        mExecutor.runAllReady();
        verifyBind(1);
    }

    @EnableFlags(FLAG_QS_QUICK_REBIND_ACTIVE_TILES)
    @Test
    public void testKillProcessWhenTileServiceIsActiveTwice_withRebindFlagOn_delaysSecondRebind()
            throws Exception {
@@ -476,35 +435,6 @@ public class TileLifecycleManagerTest extends SysuiTestCase {
        verifyBind(1);
    }

    @DisableFlags(FLAG_QS_QUICK_REBIND_ACTIVE_TILES)
    @Test
    public void testKillProcessWhenTileServiceIsActiveTwice_withRebindFlagOff_rebindsFromFirstKill()
            throws Exception {
        mStateManager.onStartListening();
        mStateManager.executeSetBindService(true);
        mExecutor.runAllReady();
        verifyBind(1);
        verify(mMockTileService, times(1)).onStartListening();

        mStateManager.onBindingDied(mTileServiceComponentName); // rebind scheduled for 5 seconds
        mExecutor.runAllReady();
        mClock.advanceTime(1000);
        mExecutor.runAllReady();

        verifyBind(0); // it would bind in 4 more seconds

        mStateManager.onBindingDied(mTileServiceComponentName); // this does not affect the rebind
        mExecutor.runAllReady();
        mClock.advanceTime(1000);
        mExecutor.runAllReady();

        verifyBind(0); // only 2 seconds passed from first kill

        mClock.advanceTime(3000);
        mExecutor.runAllReady();
        verifyBind(1); // the rebind scheduled 5 seconds from the first kill should now happen
    }

    @Test
    public void testKillProcessLowMemory() throws Exception {
        doAnswer(invocation -> {