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