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

Commit e4f14eb0 authored by Eghosa Ewansiha-Vlachavas's avatar Eghosa Ewansiha-Vlachavas
Browse files

Fallback to home activity from packageManager if supplier returns null

On certain devices home activity is never updated from system ui so the
supplier always returns null. In this case default to getting the home
activity from the package manager to just return sys ui as the home
activity. This returns the behaviour to that of before the refatoring
of `DesktopModeCompatPolicy`

Flag: EXEMPT bug fix
Fixes: 424861043
Test: manual
Change-Id: I4e42ce5b684d95ccd7f30c57a610f223f96e798f
parent 8741aa9c
Loading
Loading
Loading
Loading
+3 −10
Original line number Diff line number Diff line
@@ -49,14 +49,6 @@ public class DesktopModeCompatPolicy {
    public DesktopModeCompatPolicy(@NonNull Context context) {
        mContext = context;
        mSystemUiPackage = context.getResources().getString(R.string.config_systemUi);
        mDefaultHomePackageSupplier = () -> {
            final ComponentName homeActivities = getPackageManager().getHomeActivities(
                    new ArrayList<>());
            if (homeActivities != null) {
                return homeActivities.getPackageName();
            }
            return null;
        };
    }

    public void setDefaultHomePackageSupplier(
@@ -74,8 +66,9 @@ public class DesktopModeCompatPolicy {
        return mPackageManager;
    }

    @Nullable
    private String getDefaultHomePackage() {
        if (mDefaultHomePackageSupplier != null) {
        if (mDefaultHomePackageSupplier != null && mDefaultHomePackageSupplier.get() != null) {
            return mDefaultHomePackageSupplier.get();
        }

@@ -259,7 +252,7 @@ public class DesktopModeCompatPolicy {
     * currently no default home package available.
     */
    private boolean isPartOfDefaultHomePackageOrNoHomeAvailable(@Nullable String packageName) {
        final String defaultHomePackage = mDefaultHomePackageSupplier.get();
        final String defaultHomePackage = getDefaultHomePackage();
        return defaultHomePackage == null || (packageName != null
                && packageName.equals(defaultHomePackage));
    }