Merge "Fix getComponentName for DomainVerificationProxy" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
bdb2eff6a2
@@ -31,7 +31,6 @@ import com.android.server.pm.verify.domain.DomainVerificationMessageCodes;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
// TODO(b/170321181): Combine the proxy versions for supporting v1 and v2 at once
|
|
||||||
public interface DomainVerificationProxy {
|
public interface DomainVerificationProxy {
|
||||||
|
|
||||||
String TAG = "DomainVerificationProxy";
|
String TAG = "DomainVerificationProxy";
|
||||||
@@ -81,8 +80,7 @@ public interface DomainVerificationProxy {
|
|||||||
return new DomainVerificationProxyUnavailable();
|
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,
|
* 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 messageCode One of the values in {@link DomainVerificationMessageCodes}.
|
||||||
* @param object Arbitrary object that was originally included.
|
* @param object Arbitrary object that was originally included.
|
||||||
*/
|
*/
|
||||||
default boolean runMessage(int messageCode, Object object) {
|
boolean runMessage(int messageCode, Object object);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
default boolean isCallerVerifier(int callingUid) {
|
boolean isCallerVerifier(int callingUid);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
default ComponentName getComponentName() {
|
ComponentName getComponentName();
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface BaseConnection {
|
interface BaseConnection {
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package com.android.server.pm.verify.domain.proxy;
|
package com.android.server.pm.verify.domain.proxy;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
|
import android.content.ComponentName;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -51,4 +52,10 @@ class DomainVerificationProxyCombined implements DomainVerificationProxy {
|
|||||||
public boolean isCallerVerifier(int callingUid) {
|
public boolean isCallerVerifier(int callingUid) {
|
||||||
return mProxyV2.isCallerVerifier(callingUid) || mProxyV1.isCallerVerifier(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;
|
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 */
|
/** Stub implementation for when the verification agent is unavailable */
|
||||||
public class DomainVerificationProxyUnavailable implements DomainVerificationProxy {
|
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();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public ComponentName getComponentName() {
|
||||||
|
return mVerifierComponent;
|
||||||
|
}
|
||||||
|
|
||||||
private static class Response {
|
private static class Response {
|
||||||
public final int callingUid;
|
public final int callingUid;
|
||||||
public final int verificationId;
|
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 = {}) =
|
private fun mockConnection(block: Connection.() -> Unit = {}) =
|
||||||
mockThrowOnUnmocked<Connection> {
|
mockThrowOnUnmocked<Connection> {
|
||||||
whenever(isCallerPackage(TEST_CALLING_UID_ACCEPT, TEST_PKG_NAME_ONE)) { true }
|
whenever(isCallerPackage(TEST_CALLING_UID_ACCEPT, TEST_PKG_NAME_ONE)) { true }
|
||||||
|
|||||||
Reference in New Issue
Block a user