Add "FILTER_NOT_HIDE" to filter out the apps.
The "FILTER_NOT_HIDE" is used to filter out apps that "blacklisted" by the carrier. So when user insert a specific sim card, these apps disapper in settings > apps totally unless user enable them. Bug: 31823872 Test: Manual Change-Id: I62ec13806d70f68e6cd3cbd014e7513cda36358c
This commit is contained in:
@@ -37,4 +37,7 @@
|
|||||||
|
|
||||||
<!-- Intent key for package name values -->
|
<!-- Intent key for package name values -->
|
||||||
<string name="config_helpIntentNameKey" translatable="false"></string>
|
<string name="config_helpIntentNameKey" translatable="false"></string>
|
||||||
</resources>
|
|
||||||
|
<!-- The apps that need to be hided when they are disabled -->
|
||||||
|
<string-array name="config_hideWhenDisabled_packageNames"></string-array>
|
||||||
|
</resources>
|
||||||
@@ -47,6 +47,7 @@ import android.util.Log;
|
|||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
|
|
||||||
import com.android.internal.util.ArrayUtils;
|
import com.android.internal.util.ArrayUtils;
|
||||||
|
import com.android.settingslib.R;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.text.Collator;
|
import java.text.Collator;
|
||||||
@@ -621,7 +622,7 @@ public class ApplicationsState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (filter != null) {
|
if (filter != null) {
|
||||||
filter.init();
|
filter.init(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<AppEntry> apps;
|
List<AppEntry> apps;
|
||||||
@@ -1280,6 +1281,9 @@ public class ApplicationsState {
|
|||||||
|
|
||||||
public interface AppFilter {
|
public interface AppFilter {
|
||||||
void init();
|
void init();
|
||||||
|
default void init(Context context) {
|
||||||
|
init();
|
||||||
|
}
|
||||||
boolean filterApp(AppEntry info);
|
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 {
|
public static class VolumeFilter implements AppFilter {
|
||||||
private final String mVolumeUuid;
|
private final String mVolumeUuid;
|
||||||
|
|
||||||
@@ -1424,6 +1455,12 @@ public class ApplicationsState {
|
|||||||
mSecondFilter = second;
|
mSecondFilter = second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(Context context) {
|
||||||
|
mFirstFilter.init(context);
|
||||||
|
mSecondFilter.init(context);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
mFirstFilter.init();
|
mFirstFilter.init();
|
||||||
|
|||||||
Reference in New Issue
Block a user