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

Commit b774efbc authored by lpeter's avatar lpeter
Browse files

Flag removal: improve_home_app_behavior

FLAG: EXEMPT removing android.content.pm.improve_home_app_behavior

Bug: 409605182
Test: atest com.android.settings.applications.appinfo.AppButtonsPreferenceController
Test: atest atest com.android.settings.spa.app.appinfo.AppButtonRepositoryTest
Test: atest CtsPackageManagerTestCases
Change-Id: I2e276a5068dc4b2b57b3f7f397acfcfbb7db282d
parent dcf663bb
Loading
Loading
Loading
Loading
+3 −9
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ import android.content.IntentFilter;
import android.content.om.OverlayInfo;
import android.content.om.OverlayManager;
import android.content.pm.ApplicationInfo;
import android.content.pm.Flags;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
@@ -462,14 +461,9 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp
                    // there is more than one candidate
                    enabled = (mHomePackages.size() > 1);
                } else if (mPackageInfo.packageName.equals(currentDefaultHome.getPackageName())) {
                    if (Flags.improveHomeAppBehavior()) {
                    // Allow uninstallation of current home app if it is a non-system app
                    // and/or there are other candidate apps available.
                        if (mPackageInfo.applicationInfo.isSystemApp()
                                || mHomePackages.size() == 1) {
                            enabled = false;
                        }
                    } else {
                    if (mPackageInfo.applicationInfo.isSystemApp() || mHomePackages.size() == 1) {
                        enabled = false;
                    }
                }
+2 −8
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.content.ComponentName
import android.content.Context
import android.content.om.OverlayManager
import android.content.pm.ApplicationInfo
import android.content.pm.Flags
import android.content.pm.PackageManager
import android.content.pm.ResolveInfo
import android.util.Log
@@ -124,13 +123,8 @@ class AppButtonRepository(private val context: Context) {
            homePackageInfo.homePackages.size == 1 -> true

            packageName == homePackageInfo.currentDefaultHome?.packageName -> {
                if (Flags.improveHomeAppBehavior()) {
                // Disallow the uninstallation of the current home app if it is a system app.
                return applicationInfo.isSystemApp()
                } else {
                    // Disallow if this is the explicit default home app.
                    return true
                }
            }

            else -> false
+0 −4
Original line number Diff line number Diff line
@@ -45,13 +45,11 @@ import android.content.Intent;
import android.content.om.OverlayInfo;
import android.content.om.OverlayManager;
import android.content.pm.ApplicationInfo;
import android.content.pm.Flags;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.RemoteException;
import android.os.UserManager;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.RequiresFlagsEnabled;
import android.platform.test.flag.junit.SetFlagsRule;
import android.util.ArraySet;
import android.view.View;
@@ -360,7 +358,6 @@ public class AppButtonsPreferenceControllerTest {
    }

    @Test
    @RequiresFlagsEnabled(Flags.FLAG_IMPROVE_HOME_APP_BEHAVIOR)
    public void updateUninstallButton_isNotSystemAndIsCurrentHomeAndHasOneHome_setButtonDisable() {
        doReturn(false).when(mController).isSystemPackage(any(), any(), any());
        doReturn(new ComponentName(PACKAGE_NAME, "cls")).when(mPackageManager).getHomeActivities(
@@ -374,7 +371,6 @@ public class AppButtonsPreferenceControllerTest {
    }

    @Test
    @RequiresFlagsEnabled(Flags.FLAG_IMPROVE_HOME_APP_BEHAVIOR)
    public void updateUninstallButton_isNotSystemAndIsCurrentHomeAndHasOtherHome_setButtonEnable() {
        doReturn(false).when(mController).isSystemPackage(any(), any(), any());
        doReturn(new ComponentName(PACKAGE_NAME, "cls")).when(mPackageManager).getHomeActivities(
+0 −5
Original line number Diff line number Diff line
@@ -21,10 +21,8 @@ import android.content.ComponentName
import android.content.Context
import android.content.pm.ActivityInfo
import android.content.pm.ApplicationInfo
import android.content.pm.Flags
import android.content.pm.PackageManager
import android.content.pm.ResolveInfo
import android.platform.test.annotations.RequiresFlagsEnabled
import androidx.core.os.bundleOf
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -130,7 +128,6 @@ class AppButtonRepositoryTest {
    }

    @Test
    @RequiresFlagsEnabled(Flags.FLAG_IMPROVE_HOME_APP_BEHAVIOR)
    fun uninstallDisallowedDueToHomeApp_isNotSystemAndIsCurrentHomeAndHasOnlyOneHomeApp() {
        val app = ApplicationInfo().apply {
            packageName = PACKAGE_NAME
@@ -147,7 +144,6 @@ class AppButtonRepositoryTest {
    }

    @Test
    @RequiresFlagsEnabled(Flags.FLAG_IMPROVE_HOME_APP_BEHAVIOR)
    fun uninstallDisallowedDueToHomeApp_isNotSystemAndIsCurrentHomeAndHasOtherHomeApps() {
        val app = ApplicationInfo().apply {
            packageName = PACKAGE_NAME
@@ -164,7 +160,6 @@ class AppButtonRepositoryTest {
    }

    @Test
    @RequiresFlagsEnabled(Flags.FLAG_IMPROVE_HOME_APP_BEHAVIOR)
    fun uninstallDisallowedDueToHomeApp_isSystemAndIsCurrentHomeAndHasOtherHomeApps() {
        val app = ApplicationInfo().apply {
            packageName = PACKAGE_NAME