Merge "Updating TrustManagerService to react to keyguard visible changes." into tm-dev am: bd5592e65b
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18102036 Change-Id: Ie7fbe9dd1bd1cc6b7b46faa9a4428982ad5d4da4 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -122,16 +122,9 @@ public class TrustAgentWrapper {
|
|||||||
if (!TrustManagerService.ENABLE_ACTIVE_UNLOCK_FLAG) {
|
if (!TrustManagerService.ENABLE_ACTIVE_UNLOCK_FLAG) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!mWaitingForTrustableDowngrade) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// are these the broadcasts we want to listen to
|
// are these the broadcasts we want to listen to
|
||||||
if (Intent.ACTION_SCREEN_OFF.equals(intent.getAction())
|
if (Intent.ACTION_SCREEN_OFF.equals(intent.getAction())) {
|
||||||
|| Intent.ACTION_USER_PRESENT.equals(intent.getAction())) {
|
downgradeToTrustable();
|
||||||
mTrusted = false;
|
|
||||||
mTrustable = true;
|
|
||||||
mWaitingForTrustableDowngrade = false;
|
|
||||||
mTrustManagerService.updateTrust(mUserId, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -480,8 +473,7 @@ public class TrustAgentWrapper {
|
|||||||
final String pathUri = mAlarmIntent.toUri(Intent.URI_INTENT_SCHEME);
|
final String pathUri = mAlarmIntent.toUri(Intent.URI_INTENT_SCHEME);
|
||||||
alarmFilter.addDataPath(pathUri, PatternMatcher.PATTERN_LITERAL);
|
alarmFilter.addDataPath(pathUri, PatternMatcher.PATTERN_LITERAL);
|
||||||
|
|
||||||
IntentFilter trustableFilter = new IntentFilter(Intent.ACTION_USER_PRESENT);
|
IntentFilter trustableFilter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
|
||||||
trustableFilter.addAction(Intent.ACTION_SCREEN_OFF);
|
|
||||||
|
|
||||||
// Schedules a restart for when connecting times out. If the connection succeeds,
|
// Schedules a restart for when connecting times out. If the connection succeeds,
|
||||||
// the restart is canceled in mCallback's onConnected.
|
// the restart is canceled in mCallback's onConnected.
|
||||||
@@ -668,6 +660,19 @@ public class TrustAgentWrapper {
|
|||||||
mTrustable = false;
|
mTrustable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Downgrades the trustagent to trustable as a result of a keyguard or screen related event, and
|
||||||
|
* then updates the trust state of the phone to reflect the change.
|
||||||
|
*/
|
||||||
|
public void downgradeToTrustable() {
|
||||||
|
if (mWaitingForTrustableDowngrade) {
|
||||||
|
mWaitingForTrustableDowngrade = false;
|
||||||
|
mTrusted = false;
|
||||||
|
mTrustable = true;
|
||||||
|
mTrustManagerService.updateTrust(mUserId, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isManagingTrust() {
|
public boolean isManagingTrust() {
|
||||||
return mManagingTrust && !mTrustDisabledByDpm;
|
return mManagingTrust && !mTrustDisabledByDpm;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1184,6 +1184,22 @@ public class TrustManagerService extends SystemService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We downgrade to trustable whenever keyguard changes its showing value.
|
||||||
|
* - becomes showing: something has caused the device to show keyguard which happens due to
|
||||||
|
* user intent to lock the device either through direct action or a timeout
|
||||||
|
* - becomes not showing: keyguard was dismissed and we no longer need to keep the device
|
||||||
|
* unlocked
|
||||||
|
* */
|
||||||
|
private void dispatchTrustableDowngrade() {
|
||||||
|
for (int i = 0; i < mActiveAgents.size(); i++) {
|
||||||
|
AgentInfo info = mActiveAgents.valueAt(i);
|
||||||
|
if (info.userId == mCurrentUser) {
|
||||||
|
info.agent.downgradeToTrustable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private List<String> getTrustGrantedMessages(int userId) {
|
private List<String> getTrustGrantedMessages(int userId) {
|
||||||
if (!mStrongAuthTracker.isTrustAllowedForUser(userId)) {
|
if (!mStrongAuthTracker.isTrustAllowedForUser(userId)) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
@@ -1752,6 +1768,7 @@ public class TrustManagerService extends SystemService {
|
|||||||
refreshDeviceLockedForUser(UserHandle.USER_ALL);
|
refreshDeviceLockedForUser(UserHandle.USER_ALL);
|
||||||
break;
|
break;
|
||||||
case MSG_KEYGUARD_SHOWING_CHANGED:
|
case MSG_KEYGUARD_SHOWING_CHANGED:
|
||||||
|
dispatchTrustableDowngrade();
|
||||||
refreshDeviceLockedForUser(mCurrentUser);
|
refreshDeviceLockedForUser(mCurrentUser);
|
||||||
break;
|
break;
|
||||||
case MSG_START_USER:
|
case MSG_START_USER:
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import androidx.test.ext.junit.rules.ActivityScenarioRule
|
|||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
|
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
|
||||||
import androidx.test.uiautomator.UiDevice
|
import androidx.test.uiautomator.UiDevice
|
||||||
import com.google.common.truth.Truth.assertThat
|
import android.trust.test.lib.wait
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
@@ -74,9 +74,9 @@ class TemporaryAndRenewableTrustTest {
|
|||||||
uiDevice.sleep()
|
uiDevice.sleep()
|
||||||
lockStateTrackingRule.assertLocked()
|
lockStateTrackingRule.assertLocked()
|
||||||
|
|
||||||
|
uiDevice.wakeUp()
|
||||||
trustAgentRule.agent.grantTrust(
|
trustAgentRule.agent.grantTrust(
|
||||||
GRANT_MESSAGE, 0, FLAG_GRANT_TRUST_TEMPORARY_AND_RENEWABLE) {}
|
GRANT_MESSAGE, 0, FLAG_GRANT_TRUST_TEMPORARY_AND_RENEWABLE) {}
|
||||||
uiDevice.wakeUp()
|
|
||||||
|
|
||||||
lockStateTrackingRule.assertLocked()
|
lockStateTrackingRule.assertLocked()
|
||||||
}
|
}
|
||||||
@@ -98,9 +98,9 @@ class TemporaryAndRenewableTrustTest {
|
|||||||
|
|
||||||
lockStateTrackingRule.assertLocked()
|
lockStateTrackingRule.assertLocked()
|
||||||
|
|
||||||
|
uiDevice.wakeUp()
|
||||||
trustAgentRule.agent.grantTrust(
|
trustAgentRule.agent.grantTrust(
|
||||||
GRANT_MESSAGE, 0, FLAG_GRANT_TRUST_TEMPORARY_AND_RENEWABLE) {}
|
GRANT_MESSAGE, 0, FLAG_GRANT_TRUST_TEMPORARY_AND_RENEWABLE) {}
|
||||||
uiDevice.wakeUp()
|
|
||||||
|
|
||||||
lockStateTrackingRule.assertUnlocked()
|
lockStateTrackingRule.assertUnlocked()
|
||||||
}
|
}
|
||||||
@@ -116,6 +116,7 @@ class TemporaryAndRenewableTrustTest {
|
|||||||
uiDevice.sleep()
|
uiDevice.sleep()
|
||||||
|
|
||||||
lockStateTrackingRule.assertLocked()
|
lockStateTrackingRule.assertLocked()
|
||||||
|
uiDevice.wakeUp()
|
||||||
|
|
||||||
Log.i(TAG, "Renewing trust and unlocking")
|
Log.i(TAG, "Renewing trust and unlocking")
|
||||||
var result: GrantTrustResult? = null
|
var result: GrantTrustResult? = null
|
||||||
@@ -124,10 +125,9 @@ class TemporaryAndRenewableTrustTest {
|
|||||||
Log.i(TAG, "Callback received; status=${it.status}")
|
Log.i(TAG, "Callback received; status=${it.status}")
|
||||||
result = it
|
result = it
|
||||||
}
|
}
|
||||||
uiDevice.wakeUp()
|
|
||||||
lockStateTrackingRule.assertUnlocked()
|
lockStateTrackingRule.assertUnlocked()
|
||||||
|
|
||||||
assertThat(result?.status).isEqualTo(STATUS_UNLOCKED_BY_GRANT)
|
wait("callback triggered") { result?.status == STATUS_UNLOCKED_BY_GRANT }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -141,7 +141,6 @@ class TemporaryAndRenewableTrustTest {
|
|||||||
trustAgentRule.agent.revokeTrust()
|
trustAgentRule.agent.revokeTrust()
|
||||||
await(500)
|
await(500)
|
||||||
uiDevice.wakeUp()
|
uiDevice.wakeUp()
|
||||||
await(500)
|
|
||||||
|
|
||||||
trustAgentRule.agent.grantTrust(
|
trustAgentRule.agent.grantTrust(
|
||||||
GRANT_MESSAGE, 0, FLAG_GRANT_TRUST_TEMPORARY_AND_RENEWABLE) {}
|
GRANT_MESSAGE, 0, FLAG_GRANT_TRUST_TEMPORARY_AND_RENEWABLE) {}
|
||||||
|
|||||||
Reference in New Issue
Block a user