Merge "Revert "Restore preferred activity filter if it not inside"" am: e6439f8866
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1503894 Change-Id: I1289e70475b5ac9d72c770cfbe9c63e2b5f5cb5c
This commit is contained in:
@@ -254,43 +254,6 @@ public class PreferredComponent {
|
|||||||
return numMatch == NS;
|
return numMatch == NS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean sameSet(PreferredComponent pc) {
|
|
||||||
if (mSetPackages == null || pc == null || pc.mSetPackages == null
|
|
||||||
|| !sameComponent(pc.mComponent)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final int otherPackageCount = pc.mSetPackages.length;
|
|
||||||
final int packageCount = mSetPackages.length;
|
|
||||||
int numMatch = 0;
|
|
||||||
for (int i = 0; i < otherPackageCount; i++) {
|
|
||||||
boolean good = false;
|
|
||||||
for (int j = 0; j < packageCount; j++) {
|
|
||||||
if (mSetPackages[j].equals(pc.mSetPackages[j])
|
|
||||||
&& mSetClasses[j].equals(pc.mSetClasses[j])) {
|
|
||||||
numMatch++;
|
|
||||||
good = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!good) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return numMatch == packageCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns true if the preferred component represents the provided ComponentName. */
|
|
||||||
private boolean sameComponent(ComponentName comp) {
|
|
||||||
if (mComponent == null || comp == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (mComponent.getPackageName().equals(comp.getPackageName())
|
|
||||||
&& mComponent.getClassName().equals(comp.getClassName())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSuperset(List<ResolveInfo> query, boolean excludeSetupWizardPackage) {
|
public boolean isSuperset(List<ResolveInfo> query, boolean excludeSetupWizardPackage) {
|
||||||
if (mSetPackages == null) {
|
if (mSetPackages == null) {
|
||||||
return query == null;
|
return query == null;
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import android.content.IntentFilter;
|
|||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
import com.android.server.IntentResolver;
|
import com.android.server.IntentResolver;
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class PreferredIntentResolver
|
public class PreferredIntentResolver
|
||||||
extends IntentResolver<PreferredActivity, PreferredActivity> {
|
extends IntentResolver<PreferredActivity, PreferredActivity> {
|
||||||
@@ -46,24 +45,4 @@ public class PreferredIntentResolver
|
|||||||
protected IntentFilter getIntentFilter(@NonNull PreferredActivity input) {
|
protected IntentFilter getIntentFilter(@NonNull PreferredActivity input) {
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldAddPreferredActivity(PreferredActivity pa) {
|
|
||||||
ArrayList<PreferredActivity> pal = findFilters(pa);
|
|
||||||
if (pal == null || pal.isEmpty()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!pa.mPref.mAlways) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final int activityCount = pal.size();
|
|
||||||
for (int i = 0; i < activityCount; i++) {
|
|
||||||
PreferredActivity cur = pal.get(i);
|
|
||||||
if (cur.mPref.mAlways
|
|
||||||
&& cur.mPref.mMatch == (pa.mPref.mMatch & IntentFilter.MATCH_CATEGORY_MASK)
|
|
||||||
&& cur.mPref.sameSet(pa.mPref)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1410,7 +1410,8 @@ public final class Settings {
|
|||||||
PreferredActivity pa = new PreferredActivity(parser);
|
PreferredActivity pa = new PreferredActivity(parser);
|
||||||
if (pa.mPref.getParseError() == null) {
|
if (pa.mPref.getParseError() == null) {
|
||||||
final PreferredIntentResolver resolver = editPreferredActivitiesLPw(userId);
|
final PreferredIntentResolver resolver = editPreferredActivitiesLPw(userId);
|
||||||
if (resolver.shouldAddPreferredActivity(pa)) {
|
ArrayList<PreferredActivity> pal = resolver.findFilters(pa);
|
||||||
|
if (pal == null || pal.size() == 0 || pa.mPref.mAlways) {
|
||||||
resolver.addFilter(pa);
|
resolver.addFilter(pa);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user