Fix getComponentName for DomainVerificationProxy
This was preventing the domain verifier from being printed as part of dumpsys, since PMS checks this to see if the proxy exists. To avoid future issues, also removs the default interface methods in favor of just overriding them in the unavailable variant. Bug: 186665132 Test: manual, dumpsys package dv Test: atest DomainVerificationProxyTest#nonNullComponentName Change-Id: Ib8fb5e07b1650a46a9ebb735f9c640877e58cb22
This commit is contained in:
@@ -31,7 +31,6 @@ import com.android.server.pm.verify.domain.DomainVerificationMessageCodes;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
// TODO(b/170321181): Combine the proxy versions for supporting v1 and v2 at once
|
||||
public interface DomainVerificationProxy {
|
||||
|
||||
String TAG = "DomainVerificationProxy";
|
||||
@@ -81,8 +80,7 @@ public interface DomainVerificationProxy {
|
||||
return new DomainVerificationProxyUnavailable();
|
||||
}
|
||||
|
||||
default void sendBroadcastForPackages(@NonNull Set<String> packageNames) {
|
||||
}
|
||||
void sendBroadcastForPackages(@NonNull Set<String> packageNames);
|
||||
|
||||
/**
|
||||
* Runs a message on the caller's Handler as a result of {@link BaseConnection#schedule(int,
|
||||
@@ -94,18 +92,12 @@ public interface DomainVerificationProxy {
|
||||
* @param messageCode One of the values in {@link DomainVerificationMessageCodes}.
|
||||
* @param object Arbitrary object that was originally included.
|
||||
*/
|
||||
default boolean runMessage(int messageCode, Object object) {
|
||||
return false;
|
||||
}
|
||||
boolean runMessage(int messageCode, Object object);
|
||||
|
||||
default boolean isCallerVerifier(int callingUid) {
|
||||
return false;
|
||||
}
|
||||
boolean isCallerVerifier(int callingUid);
|
||||
|
||||
@Nullable
|
||||
default ComponentName getComponentName() {
|
||||
return null;
|
||||
}
|
||||
ComponentName getComponentName();
|
||||
|
||||
interface BaseConnection {
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.server.pm.verify.domain.proxy;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.content.ComponentName;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -51,4 +52,10 @@ class DomainVerificationProxyCombined implements DomainVerificationProxy {
|
||||
public boolean isCallerVerifier(int callingUid) {
|
||||
return mProxyV2.isCallerVerifier(callingUid) || mProxyV1.isCallerVerifier(callingUid);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ComponentName getComponentName() {
|
||||
return mProxyV2.getComponentName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,32 @@
|
||||
|
||||
package com.android.server.pm.verify.domain.proxy;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.ComponentName;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/** Stub implementation for when the verification agent is unavailable */
|
||||
public class DomainVerificationProxyUnavailable implements DomainVerificationProxy {
|
||||
|
||||
@Override
|
||||
public void sendBroadcastForPackages(@NonNull Set<String> packageNames) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean runMessage(int messageCode, Object object) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCallerVerifier(int callingUid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ComponentName getComponentName() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,6 +298,12 @@ public class DomainVerificationProxyV1 implements DomainVerificationProxy {
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ComponentName getComponentName() {
|
||||
return mVerifierComponent;
|
||||
}
|
||||
|
||||
private static class Response {
|
||||
public final int callingUid;
|
||||
public final int verificationId;
|
||||
|
||||
@@ -466,6 +466,44 @@ class DomainVerificationProxyTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun nonNullComponentName() {
|
||||
val connection = mockConnection()
|
||||
DomainVerificationProxy.makeProxy<Connection>(
|
||||
componentTwo,
|
||||
null,
|
||||
context,
|
||||
manager,
|
||||
collector,
|
||||
connection
|
||||
).run {
|
||||
assertThat(componentName).isEqualTo(componentTwo)
|
||||
}
|
||||
|
||||
DomainVerificationProxy.makeProxy<Connection>(
|
||||
null,
|
||||
componentThree,
|
||||
context,
|
||||
manager,
|
||||
collector,
|
||||
connection
|
||||
).run {
|
||||
assertThat(componentName).isEqualTo(componentThree)
|
||||
}
|
||||
|
||||
DomainVerificationProxy.makeProxy<Connection>(
|
||||
componentTwo,
|
||||
componentThree,
|
||||
context,
|
||||
manager,
|
||||
collector,
|
||||
connection
|
||||
).run {
|
||||
// Higher version takes precedence
|
||||
assertThat(componentName).isEqualTo(componentThree)
|
||||
}
|
||||
}
|
||||
|
||||
private fun mockConnection(block: Connection.() -> Unit = {}) =
|
||||
mockThrowOnUnmocked<Connection> {
|
||||
whenever(isCallerPackage(TEST_CALLING_UID_ACCEPT, TEST_PKG_NAME_ONE)) { true }
|
||||
|
||||
Reference in New Issue
Block a user