Snap for 6574919 from cf74512519 to mainline-release

Change-Id: I37d4265da2b39d1a14399d8164e74d1247b8e373
This commit is contained in:
android-build-team Robot
2020-06-10 07:09:38 +00:00
16 changed files with 157 additions and 27 deletions

View File

@@ -3181,7 +3181,7 @@
<activity android:name="Settings$BluetoothDeviceDetailActivity" <activity android:name="Settings$BluetoothDeviceDetailActivity"
android:label="@string/device_details_title" android:label="@string/device_details_title"
android:permission="android.permission.BLUETOOTH_PRIVILEGED"> android:permission="android.permission.BLUETOOTH_ADMIN">
<intent-filter android:priority="1"> <intent-filter android:priority="1">
<action android:name="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS" /> <action android:name="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />

View File

@@ -47,4 +47,11 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"/> android:textColor="?android:attr/textColorSecondary"/>
<TextView
android:id="@+id/blob_size"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"/>
</LinearLayout> </LinearLayout>

View File

@@ -16,7 +16,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android" <resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="yes" msgid="1999566976857398962">"\"Ja\""</string> <string name="yes" msgid="1999566976857398962">"Ja"</string>
<string name="no" msgid="5541738710521607130">"Nein"</string> <string name="no" msgid="5541738710521607130">"Nein"</string>
<string name="create" msgid="986997212165228751">"Erstellen"</string> <string name="create" msgid="986997212165228751">"Erstellen"</string>
<string name="allow" msgid="3763244945363657722">"Zulassen"</string> <string name="allow" msgid="3763244945363657722">"Zulassen"</string>

View File

@@ -8706,6 +8706,11 @@
to the user's IT admin. [CHAR LIMIT=NONE] --> to the user's IT admin. [CHAR LIMIT=NONE] -->
<string name="interact_across_profiles_summary_2">Only connect apps if you trust them not to share personal data with your IT admin.</string> <string name="interact_across_profiles_summary_2">Only connect apps if you trust them not to share personal data with your IT admin.</string>
<!-- Settings text. This text lets a user know that they can disconnect work and personal apps from
the Privacy page in settings, This is only shown when the connected app page is launched via
an app, not when navigated to via settings. [CHAR LIMIT=NONE] -->
<string name="interact_across_profiles_summary_3">You can disconnect apps anytime in your device\u2019s privacy settings.</string>
<!-- Dialog title. This dialog is shown when a user tries to connect a work app to a personal <!-- Dialog title. This dialog is shown when a user tries to connect a work app to a personal
app (e.g. their work Calendar to their personal Calendar), and it's confirming that they should app (e.g. their work Calendar to their personal Calendar), and it's confirming that they should
connect the apps only if they trust the work app with their personal data. [CHAR LIMIT=NONE] --> connect the apps only if they trust the work app with their personal data. [CHAR LIMIT=NONE] -->
@@ -9491,6 +9496,9 @@
<!-- Runtime permissions preference summary, shown when the app requests no permissions. [CHAR LIMIT=40] --> <!-- Runtime permissions preference summary, shown when the app requests no permissions. [CHAR LIMIT=40] -->
<string name="runtime_permissions_summary_no_permissions_requested">No permissions requested</string> <string name="runtime_permissions_summary_no_permissions_requested">No permissions requested</string>
<!-- Runtime permissions preference summary, which describes what the permission manager does. [CHAR LIMIT=40] -->
<string name="runtime_permissions_summary_control_app_access">Control app access to your data</string>
<!-- Label for showing all apps in list [CHAR LIMIT=30] --> <!-- Label for showing all apps in list [CHAR LIMIT=30] -->
<string name="filter_all_apps">All apps</string> <string name="filter_all_apps">All apps</string>
<!-- Label for showing enabled apps in list [CHAR LIMIT=30] --> <!-- Label for showing enabled apps in list [CHAR LIMIT=30] -->

View File

@@ -77,9 +77,9 @@
<Preference <Preference
android:key="manage_perms" android:key="manage_perms"
android:title="@string/app_permissions" android:title="@string/app_permissions"
android:summary="@string/runtime_permissions_summary_control_app_access"
android:order="12" android:order="12"
settings:keywords="@string/keywords_app_permissions" settings:keywords="@string/keywords_app_permissions">
settings:controller="com.android.settings.applications.AppPermissionsPreferenceController">
<intent android:action="android.intent.action.MANAGE_PERMISSIONS"/> <intent android:action="android.intent.action.MANAGE_PERMISSIONS"/>
</Preference> </Preference>

View File

@@ -38,4 +38,9 @@
<Preference <Preference
android:summary="@string/interact_across_profiles_summary_2" android:summary="@string/interact_across_profiles_summary_2"
android:selectable="false" /> android:selectable="false" />
<Preference
android:key="interact_across_profiles_extra_summary"
android:summary="@string/interact_across_profiles_summary_3"
android:selectable="false"/>
</PreferenceScreen> </PreferenceScreen>

View File

@@ -52,10 +52,9 @@
<Preference <Preference
android:key="privacy_manage_perms" android:key="privacy_manage_perms"
android:title="@string/app_permissions" android:title="@string/app_permissions"
android:summary="@string/summary_placeholder" android:summary="@string/runtime_permissions_summary_control_app_access"
settings:allowDividerAbove="true" settings:allowDividerAbove="true"
settings:searchable="false" settings:searchable="false">
settings:controller="com.android.settings.applications.AppPermissionsPreferenceController">
<intent android:action="android.intent.action.MANAGE_PERMISSIONS"/> <intent android:action="android.intent.action.MANAGE_PERMISSIONS"/>
</Preference> </Preference>

View File

@@ -63,6 +63,8 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
"interact_across_profiles_settings_switch"; "interact_across_profiles_settings_switch";
private static final String INTERACT_ACROSS_PROFILES_HEADER = "interact_across_profiles_header"; private static final String INTERACT_ACROSS_PROFILES_HEADER = "interact_across_profiles_header";
public static final String INSTALL_APP_BANNER_KEY = "install_app_banner"; public static final String INSTALL_APP_BANNER_KEY = "install_app_banner";
public static final String INTERACT_ACROSS_PROFILE_EXTRA_SUMMARY_KEY =
"interact_across_profiles_extra_summary";
public static final String EXTRA_SHOW_FRAGMENT_ARGS = ":settings:show_fragment_args"; public static final String EXTRA_SHOW_FRAGMENT_ARGS = ":settings:show_fragment_args";
public static final String INTENT_KEY = "intent"; public static final String INTENT_KEY = "intent";
@@ -79,6 +81,7 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
private boolean mInstalledInWork; private boolean mInstalledInWork;
private String mAppLabel; private String mAppLabel;
private Intent mInstallAppIntent; private Intent mInstallAppIntent;
private boolean mIsPageLaunchedByApp;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@@ -106,6 +109,8 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
mInstallBanner = findPreference(INSTALL_APP_BANNER_KEY); mInstallBanner = findPreference(INSTALL_APP_BANNER_KEY);
mInstallBanner.setOnPreferenceClickListener(this); mInstallBanner.setOnPreferenceClickListener(this);
mIsPageLaunchedByApp = launchedByApp();
// refreshUi checks that the user can still configure the appOp, return to the // refreshUi checks that the user can still configure the appOp, return to the
// previous page if it can't. // previous page if it can't.
if (!refreshUi()) { if (!refreshUi()) {
@@ -113,14 +118,23 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
} }
addAppTitleAndIcons(mPersonalProfile, mWorkProfile); addAppTitleAndIcons(mPersonalProfile, mWorkProfile);
styleActionBar(); styleActionBar();
maybeShowExtraSummary();
logPageLaunchMetrics(); logPageLaunchMetrics();
} }
private void maybeShowExtraSummary() {
Preference extraSummary = findPreference(INTERACT_ACROSS_PROFILE_EXTRA_SUMMARY_KEY);
if (extraSummary == null) {
return;
}
extraSummary.setVisible(mIsPageLaunchedByApp);
}
private void logPageLaunchMetrics() { private void logPageLaunchMetrics() {
if (!mCrossProfileApps.canConfigureInteractAcrossProfiles(mPackageName)) { if (!mCrossProfileApps.canConfigureInteractAcrossProfiles(mPackageName)) {
logNonConfigurableAppMetrics(); logNonConfigurableAppMetrics();
} }
if (launchedByApp()) { if (mIsPageLaunchedByApp) {
logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_LAUNCHED_FROM_APP); logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_LAUNCHED_FROM_APP);
} else { } else {
logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_LAUNCHED_FROM_SETTINGS); logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_LAUNCHED_FROM_SETTINGS);
@@ -262,7 +276,7 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_USER_CONSENTED); logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_USER_CONSENTED);
enableInteractAcrossProfiles(true); enableInteractAcrossProfiles(true);
refreshUi(); refreshUi();
if (launchedByApp()) { if (mIsPageLaunchedByApp) {
setIntentAndFinish(/* appChanged= */ true); setIntentAndFinish(/* appChanged= */ true);
} }
} }

View File

@@ -158,6 +158,7 @@ public class BlobInfoListView extends ListActivity {
holder.blobId.setText(getString(R.string.blob_id_text, blob.getId())); holder.blobId.setText(getString(R.string.blob_id_text, blob.getId()));
holder.blobExpiry.setText(getString(R.string.blob_expires_text, holder.blobExpiry.setText(getString(R.string.blob_expires_text,
SharedDataUtils.formatTime(blob.getExpiryTimeMs()))); SharedDataUtils.formatTime(blob.getExpiryTimeMs())));
holder.blobSize.setText(SharedDataUtils.formatSize(blob.getSizeBytes()));
return convertView; return convertView;
} }
} }

View File

@@ -30,6 +30,7 @@ class BlobInfoViewHolder {
TextView blobLabel; TextView blobLabel;
TextView blobId; TextView blobId;
TextView blobExpiry; TextView blobExpiry;
TextView blobSize;
static BlobInfoViewHolder createOrRecycle(LayoutInflater inflater, View convertView) { static BlobInfoViewHolder createOrRecycle(LayoutInflater inflater, View convertView) {
if (convertView != null) { if (convertView != null) {
@@ -42,6 +43,7 @@ class BlobInfoViewHolder {
holder.blobLabel = convertView.findViewById(R.id.blob_label); holder.blobLabel = convertView.findViewById(R.id.blob_label);
holder.blobId = convertView.findViewById(R.id.blob_id); holder.blobId = convertView.findViewById(R.id.blob_id);
holder.blobExpiry = convertView.findViewById(R.id.blob_expiry); holder.blobExpiry = convertView.findViewById(R.id.blob_expiry);
holder.blobSize = convertView.findViewById(R.id.blob_size);
convertView.setTag(holder); convertView.setTag(holder);
return holder; return holder;
} }

View File

@@ -93,11 +93,13 @@ public class LeaseInfoListView extends ListActivity {
final TextView blobLabel = headerView.findViewById(R.id.blob_label); final TextView blobLabel = headerView.findViewById(R.id.blob_label);
final TextView blobId = headerView.findViewById(R.id.blob_id); final TextView blobId = headerView.findViewById(R.id.blob_id);
final TextView blobExpiry = headerView.findViewById(R.id.blob_expiry); final TextView blobExpiry = headerView.findViewById(R.id.blob_expiry);
final TextView blobSize = headerView.findViewById(R.id.blob_size);
blobLabel.setText(mBlobInfo.getLabel()); blobLabel.setText(mBlobInfo.getLabel());
blobLabel.setTypeface(Typeface.DEFAULT_BOLD); blobLabel.setTypeface(Typeface.DEFAULT_BOLD);
blobId.setText(getString(R.string.blob_id_text, mBlobInfo.getId())); blobId.setText(getString(R.string.blob_id_text, mBlobInfo.getId()));
blobExpiry.setVisibility(View.GONE); blobExpiry.setVisibility(View.GONE);
blobSize.setText(SharedDataUtils.formatSize(mBlobInfo.getSizeBytes()));
return headerView; return headerView;
} }

View File

@@ -39,4 +39,9 @@ class SharedDataUtils {
CALENDAR.setTimeInMillis(millis); CALENDAR.setTimeInMillis(millis);
return FORMATTER.format(CALENDAR.getTime()); return FORMATTER.format(CALENDAR.getTime());
} }
static String formatSize(long sizeBytes) {
final double sizeInMb = sizeBytes / (1024.0 * 1024.0);
return String.format("%.2f MB", sizeInMb);
}
} }

View File

@@ -42,6 +42,7 @@ import android.telephony.SignalStrength;
import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener; import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
import android.telephony.TelephonyDisplayInfo;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.telephony.UiccCardInfo; import android.telephony.UiccCardInfo;
import android.telephony.euicc.EuiccManager; import android.telephony.euicc.EuiccManager;
@@ -138,6 +139,7 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
}; };
private SubscriptionInfo mSubscriptionInfo; private SubscriptionInfo mSubscriptionInfo;
private TelephonyDisplayInfo mTelephonyDisplayInfo;
private final int mSlotIndex; private final int mSlotIndex;
private TelephonyManager mTelephonyManager; private TelephonyManager mTelephonyManager;
@@ -269,7 +271,8 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
mTelephonyManager.listen(mPhoneStateListener, mTelephonyManager.listen(mPhoneStateListener,
PhoneStateListener.LISTEN_DATA_CONNECTION_STATE PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
| PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
| PhoneStateListener.LISTEN_SERVICE_STATE); | PhoneStateListener.LISTEN_SERVICE_STATE
| PhoneStateListener.LISTEN_DISPLAY_INFO_CHANGED);
mSubscriptionManager.addOnSubscriptionsChangedListener( mSubscriptionManager.addOnSubscriptionsChangedListener(
mContext.getMainExecutor(), mOnSubscriptionsChangedListener); mContext.getMainExecutor(), mOnSubscriptionsChangedListener);
registerImsRegistrationCallback(mSubscriptionInfo.getSubscriptionId()); registerImsRegistrationCallback(mSubscriptionInfo.getSubscriptionId());
@@ -493,6 +496,7 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
} }
private void updateNetworkType() { private void updateNetworkType() {
// TODO: all of this should be based on TelephonyDisplayInfo instead of just the 5G logic
if (mSubscriptionInfo == null) { if (mSubscriptionInfo == null) {
final String unknownNetworkType = final String unknownNetworkType =
getNetworkTypeName(TelephonyManager.NETWORK_TYPE_UNKNOWN); getNetworkTypeName(TelephonyManager.NETWORK_TYPE_UNKNOWN);
@@ -507,6 +511,10 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
final int subId = mSubscriptionInfo.getSubscriptionId(); final int subId = mSubscriptionInfo.getSubscriptionId();
final int actualDataNetworkType = mTelephonyManager.getDataNetworkType(); final int actualDataNetworkType = mTelephonyManager.getDataNetworkType();
final int actualVoiceNetworkType = mTelephonyManager.getVoiceNetworkType(); final int actualVoiceNetworkType = mTelephonyManager.getVoiceNetworkType();
final int overrideNetworkType = mTelephonyDisplayInfo == null
? TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE
: mTelephonyDisplayInfo.getOverrideNetworkType();
if (TelephonyManager.NETWORK_TYPE_UNKNOWN != actualDataNetworkType) { if (TelephonyManager.NETWORK_TYPE_UNKNOWN != actualDataNetworkType) {
dataNetworkTypeName = getNetworkTypeName(actualDataNetworkType); dataNetworkTypeName = getNetworkTypeName(actualDataNetworkType);
} }
@@ -514,6 +522,12 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
voiceNetworkTypeName = getNetworkTypeName(actualVoiceNetworkType); voiceNetworkTypeName = getNetworkTypeName(actualVoiceNetworkType);
} }
if (overrideNetworkType == TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE
|| overrideNetworkType == TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA) {
dataNetworkTypeName = "NR NSA";
voiceNetworkTypeName = "NR NSA";
}
boolean show4GForLTE = false; boolean show4GForLTE = false;
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId); final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
if (carrierConfig != null) { if (carrierConfig != null) {
@@ -743,6 +757,12 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
updateServiceState(serviceState); updateServiceState(serviceState);
updateRoamingStatus(serviceState); updateRoamingStatus(serviceState);
} }
@Override
public void onDisplayInfoChanged(@NonNull TelephonyDisplayInfo displayInfo) {
mTelephonyDisplayInfo = displayInfo;
updateNetworkType();
}
}; };
} }
@@ -788,7 +808,7 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
// case TelephonyManager.NETWORK_TYPE_LTE_CA: // case TelephonyManager.NETWORK_TYPE_LTE_CA:
// return "LTE_CA"; // return "LTE_CA";
case TelephonyManager.NETWORK_TYPE_NR: case TelephonyManager.NETWORK_TYPE_NR:
return "NR"; return "NR SA";
default: default:
return "UNKNOWN"; return "UNKNOWN";
} }

View File

@@ -44,6 +44,7 @@ import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnCreate; import com.android.settingslib.core.lifecycle.events.OnCreate;
import com.android.settingslib.core.lifecycle.events.OnResume; import com.android.settingslib.core.lifecycle.events.OnResume;
import com.android.settingslib.core.lifecycle.events.OnSaveInstanceState; import com.android.settingslib.core.lifecycle.events.OnSaveInstanceState;
import com.android.settingslib.search.SearchIndexableRaw;
import java.util.List; import java.util.List;
@@ -134,34 +135,68 @@ public class TrustAgentListPreferenceController extends AbstractPreferenceContro
updateTrustAgents(); updateTrustAgents();
} }
@Override
public void updateDynamicRawDataToIndex(List<SearchIndexableRaw> rawData) {
if (!isAvailable()) {
return;
}
final List<TrustAgentManager.TrustAgentComponentInfo> agents = getActiveTrustAgents(
mContext);
if (agents == null) {
return;
}
for (int i = 0, size = agents.size(); i < size; i++) {
final SearchIndexableRaw raw = new SearchIndexableRaw(mContext);
final TrustAgentManager.TrustAgentComponentInfo agent = agents.get(i);
raw.key = PREF_KEY_TRUST_AGENT + i;
raw.title = agent.title;
rawData.add(raw);
}
}
/**
* @return The active trust agents from TrustAgentManager.
*/
private List<TrustAgentManager.TrustAgentComponentInfo> getActiveTrustAgents(Context context) {
return mTrustAgentManager.getActiveTrustAgents(context, mLockPatternUtils);
}
private void updateTrustAgents() { private void updateTrustAgents() {
if (mSecurityCategory == null) { if (mSecurityCategory == null) {
return; return;
} }
// If for some reason the preference is no longer available, don't proceed to add.
if (!isAvailable()) {
return;
}
final List<TrustAgentManager.TrustAgentComponentInfo> agents = getActiveTrustAgents(
mContext);
if (agents == null) {
return;
}
// First remove all old trust agents. // First remove all old trust agents.
while (true) { for (int i = 0, size = agents.size(); i < size; i++) {
final Preference oldAgent = mSecurityCategory.findPreference(PREF_KEY_TRUST_AGENT); String key = PREF_KEY_TRUST_AGENT + i;
final Preference oldAgent = mSecurityCategory.findPreference(key);
if (oldAgent == null) { if (oldAgent == null) {
break; break;
} else { } else {
mSecurityCategory.removePreference(oldAgent); mSecurityCategory.removePreference(oldAgent);
} }
} }
// If for some reason the preference is no longer available, don't proceed to add.
if (!isAvailable()) {
return;
}
// Then add new ones. // Then add new ones.
final boolean hasSecurity = mLockPatternUtils.isSecure(MY_USER_ID); final boolean hasSecurity = mLockPatternUtils.isSecure(MY_USER_ID);
final List<TrustAgentManager.TrustAgentComponentInfo> agents = for (int i = 0, size = agents.size(); i < size; i++) {
mTrustAgentManager.getActiveTrustAgents(mContext, mLockPatternUtils);
if (agents == null) {
return;
}
for (TrustAgentManager.TrustAgentComponentInfo agent : agents) {
final RestrictedPreference trustAgentPreference = final RestrictedPreference trustAgentPreference =
new RestrictedPreference(mSecurityCategory.getContext()); new RestrictedPreference(mSecurityCategory.getContext());
trustAgentPreference.setKey(PREF_KEY_TRUST_AGENT); TrustAgentManager.TrustAgentComponentInfo agent = agents.get(i);
trustAgentPreference.setKey(PREF_KEY_TRUST_AGENT + i);
trustAgentPreference.setTitle(agent.title); trustAgentPreference.setTitle(agent.title);
trustAgentPreference.setSummary(agent.summary); trustAgentPreference.setSummary(agent.summary);
// Create intent for this preference. // Create intent for this preference.

View File

@@ -113,7 +113,8 @@ public class SharedDataPreferenceControllerTest {
accessors.add(two); accessors.add(two);
final List<BlobInfo> tmp = new ArrayList<>(); final List<BlobInfo> tmp = new ArrayList<>();
tmp.add(new BlobInfo(10, System.currentTimeMillis(), "testing blob 1", accessors)); tmp.add(new BlobInfo(10, System.currentTimeMillis(), "testing blob 1", 54 * 1024 * 1024,
accessors));
return tmp; return tmp;
} }
} }

View File

@@ -44,6 +44,7 @@ import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.security.SecuritySettings; import com.android.settings.security.SecuritySettings;
import com.android.settings.testutils.FakeFeatureFactory; import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settingslib.core.lifecycle.Lifecycle; import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.search.SearchIndexableRaw;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@@ -111,10 +112,20 @@ public class TrustAgentListPreferenceControllerTest {
@Test @Test
public void onResume_shouldClearOldAgents() { public void onResume_shouldClearOldAgents() {
final Preference oldAgent = new Preference(mActivity); final Preference oldAgent = new Preference(mActivity);
oldAgent.setKey(PREF_KEY_TRUST_AGENT); oldAgent.setKey(PREF_KEY_TRUST_AGENT + 0);
when(mCategory.findPreference(PREF_KEY_TRUST_AGENT)) when(mCategory.findPreference(PREF_KEY_TRUST_AGENT + 0))
.thenReturn(oldAgent) .thenReturn(oldAgent)
.thenReturn(null); .thenReturn(null);
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);
mController.displayPreference(mScreen); mController.displayPreference(mScreen);
mController.onResume(); mController.onResume();
@@ -160,4 +171,24 @@ public class TrustAgentListPreferenceControllerTest {
verify(mCategory, never()).addPreference(any(Preference.class)); verify(mCategory, never()).addPreference(any(Preference.class));
} }
@Test
public void updateDynamicRawDataToIndex_shouldIndexAgents() {
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 List<SearchIndexableRaw> indexRaws = new ArrayList<>();
mController.updateDynamicRawDataToIndex(indexRaws);
assertThat(indexRaws).hasSize(1);
}
} }