Fix the bug of not showing lock screen before entering Smart Lock page.

Controller can't find the target preference to handle the click event.
Store the preference keys to match the clicked item.

Fixes: 158716163
Test: run robotest and manually test the click behavior

Change-Id: Ie243206ceffef013c56c4ea29c14fe56da510fb6
This commit is contained in:
Stanley Wang
2020-06-22 14:38:37 +08:00
parent 6217af3fe1
commit f1a0801c00
2 changed files with 30 additions and 7 deletions

View File

@@ -16,10 +16,8 @@
package com.android.settings.security.trustagent;
import static com.android.settings.security.trustagent.TrustAgentListPreferenceController
.PREF_KEY_SECURITY_CATEGORY;
import static com.android.settings.security.trustagent.TrustAgentListPreferenceController
.PREF_KEY_TRUST_AGENT;
import static com.android.settings.security.trustagent.TrustAgentListPreferenceController.PREF_KEY_SECURITY_CATEGORY;
import static com.android.settings.security.trustagent.TrustAgentListPreferenceController.PREF_KEY_TRUST_AGENT;
import static com.google.common.truth.Truth.assertThat;
@@ -172,6 +170,26 @@ public class TrustAgentListPreferenceControllerTest {
verify(mCategory, never()).addPreference(any(Preference.class));
}
@Test
public void onResume_controllerShouldHasKey() {
final List<TrustAgentManager.TrustAgentComponentInfo> agents = new ArrayList<>();
final TrustAgentManager.TrustAgentComponentInfo agent =
mock(TrustAgentManager.TrustAgentComponentInfo.class);
agent.title = "Test_title";
agent.summary = "test summary";
agent.componentName = new ComponentName("pkg", "agent");
agent.admin = null;
agents.add(agent);
when(mTrustAgentManager.getActiveTrustAgents(mActivity, mLockPatternUtils))
.thenReturn(agents);
final String key = PREF_KEY_TRUST_AGENT + 0;
mController.displayPreference(mScreen);
mController.onResume();
assertThat(mController.mTrustAgentsKeyList).containsExactly(key);
}
@Test
public void updateDynamicRawDataToIndex_shouldIndexAgents() {
final List<TrustAgentManager.TrustAgentComponentInfo> agents = new ArrayList<>();
@@ -190,5 +208,4 @@ public class TrustAgentListPreferenceControllerTest {
assertThat(indexRaws).hasSize(1);
}
}