am 83bb765b: Merge "Add IntentFilter auto verification - part 7" into mnc-dev
* commit '83bb765b046a3c6d90abbd65545d4532f647ae14': Add IntentFilter auto verification - part 7
This commit is contained in:
@@ -48,19 +48,18 @@ public final class IntentFilterVerificationInfo implements Parcelable {
|
||||
private static final String ATTR_PACKAGE_NAME = "packageName";
|
||||
private static final String ATTR_STATUS = "status";
|
||||
|
||||
private ArrayList<String> mDomains;
|
||||
private ArraySet<String> mDomains = new ArraySet<>();
|
||||
private String mPackageName;
|
||||
private int mMainStatus;
|
||||
|
||||
public IntentFilterVerificationInfo() {
|
||||
mPackageName = null;
|
||||
mDomains = new ArrayList<>();
|
||||
mMainStatus = INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED;
|
||||
}
|
||||
|
||||
public IntentFilterVerificationInfo(String packageName, ArrayList<String> domains) {
|
||||
mPackageName = packageName;
|
||||
mDomains = domains;
|
||||
mDomains.addAll(domains);
|
||||
mMainStatus = INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED;
|
||||
}
|
||||
|
||||
@@ -73,14 +72,6 @@ public final class IntentFilterVerificationInfo implements Parcelable {
|
||||
readFromParcel(source);
|
||||
}
|
||||
|
||||
public ArrayList<String> getDomains() {
|
||||
return mDomains;
|
||||
}
|
||||
|
||||
public ArraySet<String> getDomainsSet() {
|
||||
return new ArraySet<>(mDomains);
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return mPackageName;
|
||||
}
|
||||
@@ -98,6 +89,14 @@ public final class IntentFilterVerificationInfo implements Parcelable {
|
||||
}
|
||||
}
|
||||
|
||||
public ArraySet<String> getDomains() {
|
||||
return mDomains;
|
||||
}
|
||||
|
||||
public void setDomains(ArrayList<String> list) {
|
||||
mDomains = new ArraySet<>(list);
|
||||
}
|
||||
|
||||
public String getDomainsString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String str : mDomains) {
|
||||
@@ -145,7 +144,6 @@ public final class IntentFilterVerificationInfo implements Parcelable {
|
||||
}
|
||||
mMainStatus = status;
|
||||
|
||||
mDomains = new ArrayList<>();
|
||||
int outerDepth = parser.getDepth();
|
||||
int type;
|
||||
while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
|
||||
@@ -201,15 +199,16 @@ public final class IntentFilterVerificationInfo implements Parcelable {
|
||||
private void readFromParcel(Parcel source) {
|
||||
mPackageName = source.readString();
|
||||
mMainStatus = source.readInt();
|
||||
mDomains = new ArrayList<>();
|
||||
source.readStringList(mDomains);
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
source.readStringList(list);
|
||||
mDomains.addAll(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(mPackageName);
|
||||
dest.writeInt(mMainStatus);
|
||||
dest.writeStringList(mDomains);
|
||||
dest.writeStringList(new ArrayList<>(mDomains));
|
||||
}
|
||||
|
||||
public static final Creator<IntentFilterVerificationInfo> CREATOR =
|
||||
@@ -221,5 +220,4 @@ public final class IntentFilterVerificationInfo implements Parcelable {
|
||||
return new IntentFilterVerificationInfo[size];
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -2161,6 +2161,8 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
mSettings.mFingerprint = Build.FINGERPRINT;
|
||||
}
|
||||
|
||||
primeDomainVerificationsLPw(false);
|
||||
|
||||
// All the changes are done during package scanning.
|
||||
mSettings.updateInternalDatabaseVersion();
|
||||
|
||||
@@ -2178,8 +2180,6 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
mIntentFilterVerifier = new IntentVerifierProxy(mContext,
|
||||
mIntentFilterVerifierComponent);
|
||||
|
||||
primeDomainVerificationsLPw(false);
|
||||
|
||||
} // synchronized (mPackages)
|
||||
} // synchronized (mInstallLock)
|
||||
|
||||
@@ -2277,9 +2277,9 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
}
|
||||
|
||||
private void primeDomainVerificationsLPw(boolean logging) {
|
||||
Slog.d(TAG, "Start priming domain verification");
|
||||
Slog.d(TAG, "Start priming domain verifications");
|
||||
boolean updated = false;
|
||||
ArrayList<String> allHosts = new ArrayList<>();
|
||||
ArraySet<String> allHostsSet = new ArraySet<>();
|
||||
for (PackageParser.Package pkg : mPackages.values()) {
|
||||
final String packageName = pkg.packageName;
|
||||
if (!hasDomainURLs(pkg)) {
|
||||
@@ -2299,18 +2299,20 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
for (PackageParser.Activity a : pkg.activities) {
|
||||
for (ActivityIntentInfo filter : a.intents) {
|
||||
if (hasValidDomains(filter, false)) {
|
||||
allHosts.addAll(filter.getHostsList());
|
||||
allHostsSet.addAll(filter.getHostsList());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (allHosts.size() == 0) {
|
||||
allHosts.add("*");
|
||||
if (allHostsSet.size() == 0) {
|
||||
allHostsSet.add("*");
|
||||
}
|
||||
ArrayList<String> allHostsList = new ArrayList<>(allHostsSet);
|
||||
IntentFilterVerificationInfo ivi =
|
||||
mSettings.createIntentFilterVerificationIfNeededLPw(packageName, allHosts);
|
||||
mSettings.createIntentFilterVerificationIfNeededLPw(packageName, allHostsList);
|
||||
if (ivi != null) {
|
||||
// We will always log this
|
||||
Slog.d(TAG, "Priming domain verifications for package: " + packageName);
|
||||
Slog.d(TAG, "Priming domain verifications for package: " + packageName +
|
||||
" with hosts:" + ivi.getDomainsString());
|
||||
ivi.setStatus(INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS);
|
||||
updated = true;
|
||||
}
|
||||
@@ -2319,12 +2321,14 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
Slog.d(TAG, "No priming domain verifications for package: " + packageName);
|
||||
}
|
||||
}
|
||||
allHosts.clear();
|
||||
allHostsSet.clear();
|
||||
}
|
||||
if (updated) {
|
||||
scheduleWriteSettingsLocked();
|
||||
if (logging) {
|
||||
Slog.d(TAG, "Will need to write primed domain verifications");
|
||||
}
|
||||
}
|
||||
Slog.d(TAG, "End priming domain verification");
|
||||
Slog.d(TAG, "End priming domain verifications");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -985,6 +985,13 @@ final class Settings {
|
||||
if (ivi == null) {
|
||||
ivi = new IntentFilterVerificationInfo(packageName, domains);
|
||||
ps.setIntentFilterVerificationInfo(ivi);
|
||||
Slog.d(PackageManagerService.TAG,
|
||||
"Creating new IntentFilterVerificationInfo for packageName: " + packageName);
|
||||
} else {
|
||||
ivi.setDomains(domains);
|
||||
Slog.d(PackageManagerService.TAG,
|
||||
"Setting domains to existing IntentFilterVerificationInfo for packageName: " +
|
||||
packageName + " and with domains: " + ivi.getDomainsString());
|
||||
}
|
||||
return ivi;
|
||||
}
|
||||
@@ -1021,7 +1028,7 @@ final class Settings {
|
||||
|
||||
// Then, if we set a ALWAYS status, then put NEVER status for Apps whose IntentFilter
|
||||
// domains overlap the domains of the current package
|
||||
ArraySet<String> currentDomains = current.getIntentFilterVerificationInfo().getDomainsSet();
|
||||
ArraySet<String> currentDomains = current.getIntentFilterVerificationInfo().getDomains();
|
||||
if (status == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS) {
|
||||
for (PackageSetting ps : mPackages.values()) {
|
||||
if (ps == null || ps.pkg.packageName.equals(packageName)) continue;
|
||||
@@ -1029,7 +1036,7 @@ final class Settings {
|
||||
if (ivi == null) {
|
||||
continue;
|
||||
}
|
||||
ArraySet<String> set = ivi.getDomainsSet();
|
||||
ArraySet<String> set = ivi.getDomains();
|
||||
set.retainAll(currentDomains);
|
||||
if (set.size() > 0) {
|
||||
ps.setDomainVerificationStatusForUser(
|
||||
|
||||
Reference in New Issue
Block a user