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

Commit 3fd73a64 authored by Lei Yu's avatar Lei Yu Committed by Android (Google) Code Review
Browse files

Merge "Add "FILTER_NOT_HIDE" to filter out the apps." into nyc-mr1-dev

parents e03f970a 4bf191ca
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -37,4 +37,7 @@

    <!-- Intent key for package name values -->
    <string name="config_helpIntentNameKey" translatable="false"></string>

    <!-- The apps that need to be hided when they are disabled -->
    <string-array name="config_hideWhenDisabled_packageNames"></string-array>
</resources>
 No newline at end of file
+38 −1
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import android.util.Log;
import android.util.SparseArray;

import com.android.internal.util.ArrayUtils;
import com.android.settingslib.R;

import java.io.File;
import java.text.Collator;
@@ -621,7 +622,7 @@ public class ApplicationsState {
            }

            if (filter != null) {
                filter.init();
                filter.init(mContext);
            }

            List<AppEntry> apps;
@@ -1280,6 +1281,9 @@ public class ApplicationsState {

    public interface AppFilter {
        void init();
        default void init(Context context) {
            init();
        }
        boolean filterApp(AppEntry info);
    }

@@ -1398,6 +1402,33 @@ public class ApplicationsState {
        }
    };

    public static final AppFilter FILTER_NOT_HIDE = new AppFilter() {
        private String[] mHidePackageNames;

        public void init(Context context) {
            mHidePackageNames = context.getResources()
                .getStringArray(R.array.config_hideWhenDisabled_packageNames);
        }

        @Override
        public void init() {
        }

        @Override
        public boolean filterApp(AppEntry entry) {
            if (ArrayUtils.contains(mHidePackageNames, entry.info.packageName)) {
                if (!entry.info.enabled) {
                    return false;
                } else if (entry.info.enabledSetting ==
                    PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED) {
                    return false;
                }
            }

            return true;
        }
    };

    public static class VolumeFilter implements AppFilter {
        private final String mVolumeUuid;

@@ -1424,6 +1455,12 @@ public class ApplicationsState {
            mSecondFilter = second;
        }

        @Override
        public void init(Context context) {
            mFirstFilter.init(context);
            mSecondFilter.init(context);
        }

        @Override
        public void init() {
            mFirstFilter.init();