Stop tethering when the current user is not allowed to do entitlement check
This commit ensures that EntitlementManager sends the appropriate error code to the receiver when the current user is not allowed to perform entitlement check. This error code also listened by the tethering module, where it would stop tethering when receiving such error code. Test: atest TetheringTests:EntitlementManagerTest Bug: 376792293 Change-Id: I2dd18f9df9ad7cab542f8877b9fc86600c248144
This commit is contained in:
parent
5671e9d15d
commit
0adbb0277b
2 changed files with 16 additions and 1 deletions
|
|
@ -167,6 +167,11 @@ public class EntitlementManager {
|
|||
} else {
|
||||
mLog.e("Current user (" + currentUserId
|
||||
+ ") is not allowed to perform entitlement check.");
|
||||
// If the user is not allowed to perform an entitlement check
|
||||
// (e.g., a non-admin user), notify the receiver immediately.
|
||||
// This is necessary because the entitlement check app cannot
|
||||
// be launched to conduct the check and deliver the results.
|
||||
receiver.send(TETHER_ERROR_PROVISIONING_FAILED, null);
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -188,8 +188,9 @@ public final class EntitlementManagerTest {
|
|||
if (intent != null) {
|
||||
assertUiTetherProvisioningIntent(type, config, receiver, intent);
|
||||
uiProvisionCount++;
|
||||
// If the intent is null, the result is sent by the underlying method.
|
||||
receiver.send(fakeEntitlementResult, null);
|
||||
}
|
||||
receiver.send(fakeEntitlementResult, null);
|
||||
return intent;
|
||||
}
|
||||
|
||||
|
|
@ -644,6 +645,15 @@ public final class EntitlementManagerTest {
|
|||
mEnMgr.startProvisioningIfNeeded(TETHERING_USB, true);
|
||||
mLooper.dispatchAll();
|
||||
assertEquals(expectedUiProvisionCount, mDeps.uiProvisionCount);
|
||||
if (expectedUiProvisionCount == 0) { // Failed to launch entitlement UI.
|
||||
assertLatestEntitlementResult(TETHERING_USB, TETHER_ERROR_PROVISIONING_FAILED, false);
|
||||
verify(mTetherProvisioningFailedListener).onTetherProvisioningFailed(TETHERING_USB,
|
||||
FAILED_TETHERING_REASON);
|
||||
} else {
|
||||
assertLatestEntitlementResult(TETHERING_USB, TETHER_ERROR_NO_ERROR, false);
|
||||
verify(mTetherProvisioningFailedListener, never()).onTetherProvisioningFailed(anyInt(),
|
||||
anyString());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Reference in a new issue