Refactored TrustAgentUtils to allow agent check injection.

Notes:
- TrustAgentUtils defined a method that allowed callers to determine if a Trust Agent package is allowed to provide trust. If it is, it adds it to the list of available trust agents that can be displayed in the Settings->Security screen.
- The logic used to define what agents are permitted on the device can now be injected.

Test: Ran 'm RunSettingsRoboTest' and added a new test for the TrustAgentFeatureProviderImpl.
Bug: 34354635
Change-Id: I24c54c14bde26073ce6fa907379b86aae2841600
This commit is contained in:
Zachary Iqbal
2017-01-17 14:55:49 -08:00
parent 964bcccd62
commit ccae73f228
8 changed files with 205 additions and 25 deletions

View File

@@ -22,6 +22,8 @@ import android.content.IContentProvider;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import com.android.settings.trustagent.TrustAgentManager;
import com.android.settings.trustagent.TrustAgentManagerImpl;
import com.android.settingslib.drawer.DashboardCategory;
import android.support.v4.content.ContextCompat;
import android.support.v7.preference.Preference;
@@ -37,6 +39,8 @@ import java.util.Map;
/** Implementation for {@code SecurityFeatureProvider}. */
public class SecurityFeatureProviderImpl implements SecurityFeatureProvider {
private TrustAgentManager mTrustAgentManager;
/** Update preferences with data from associated tiles. */
public void updatePreferences(Context context, PreferenceScreen preferenceScreen,
DashboardCategory dashboardCategory) {
@@ -114,4 +118,12 @@ public class SecurityFeatureProviderImpl implements SecurityFeatureProvider {
}
}
}
@Override
public TrustAgentManager getTrustAgentManager() {
if (mTrustAgentManager == null) {
mTrustAgentManager = new TrustAgentManagerImpl();
}
return mTrustAgentManager;
}
}