Implement the necessary methods for identifying the DENY / FORCE_ALLOW

causes for logging purposes.

Bug: 147095027
Test: atest frameworks/base/core/tests/coretests/src/android/content/integrity/
Test: atest frameworks/base/services/tests/servicestests/src/com/android/server/integrity
Change-Id: Id502287b22fc54fd1585f81b313fb466d1f8442c
This commit is contained in:
Omer Nebil Yaveroglu
2020-01-29 12:18:10 +00:00
committed by Ömer Nebil Yaveroğlu
parent aff240adcc
commit 84f7c3fb53
10 changed files with 307 additions and 31 deletions

View File

@@ -204,6 +204,16 @@ public abstract class AtomicFormula extends IntegrityFormula {
}
}
@Override
public boolean isAppCertificateFormula() {
return false;
}
@Override
public boolean isInstallerFormula() {
return false;
}
@Override
public String toString() {
if (mValue == null || mOperator == null) {
@@ -374,6 +384,16 @@ public abstract class AtomicFormula extends IntegrityFormula {
return getStringMetadataValue(appInstallMetadata, getKey()).equals(mValue);
}
@Override
public boolean isAppCertificateFormula() {
return getKey() == APP_CERTIFICATE;
}
@Override
public boolean isInstallerFormula() {
return getKey() == INSTALLER_NAME || getKey() == INSTALLER_CERTIFICATE;
}
@Override
public String toString() {
if (mValue == null || mIsHashedValue == null) {
@@ -530,6 +550,16 @@ public abstract class AtomicFormula extends IntegrityFormula {
return getBooleanMetadataValue(appInstallMetadata, getKey()) == mValue;
}
@Override
public boolean isAppCertificateFormula() {
return false;
}
@Override
public boolean isInstallerFormula() {
return false;
}
@Override
public String toString() {
if (mValue == null) {

View File

@@ -130,6 +130,16 @@ public final class CompoundFormula extends IntegrityFormula implements Parcelabl
}
}
@Override
public boolean isAppCertificateFormula() {
return getFormulas().stream().anyMatch(formula -> formula.isAppCertificateFormula());
}
@Override
public boolean isInstallerFormula() {
return getFormulas().stream().anyMatch(formula -> formula.isInstallerFormula());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();

View File

@@ -135,6 +135,21 @@ public abstract class IntegrityFormula {
*/
public abstract @Tag boolean matches(AppInstallMetadata appInstallMetadata);
/**
* Returns true when the formula (or one of its atomic formulas) has app certificate as key.
*
* @hide
*/
public abstract @Tag boolean isAppCertificateFormula();
/**
* Returns true when the formula (or one of its atomic formulas) has installer package name
* or installer certificate as key.
*
* @hide
*/
public abstract @Tag boolean isInstallerFormula();
/**
* Write an {@link IntegrityFormula} to {@link android.os.Parcel}.
*