Change index of carrier_settings_euicc_key
Since we need to user EuiccManager#ACTION_MANAGE_EMBEDDED_SUBSCRIPTIONS
to start the activity of this key, this CL moves the index of this key
from queryXmlResources to queryRawData.
Bug: 36525840
Test: TeleServiceTests
Merged-In: I2912a1d221eaaff1e8e56f290c0ce3ce9d5e6653
Change-Id: I2912a1d221eaaff1e8e56f290c0ce3ce9d5e6653
diff --git a/src/com/android/phone/PhoneSearchIndexablesProvider.java b/src/com/android/phone/PhoneSearchIndexablesProvider.java
index 171f74f..209d100 100644
--- a/src/com/android/phone/PhoneSearchIndexablesProvider.java
+++ b/src/com/android/phone/PhoneSearchIndexablesProvider.java
@@ -16,28 +16,31 @@
package com.android.phone;
+import static android.provider.SearchIndexablesContract.COLUMN_INDEX_NON_INDEXABLE_KEYS_KEY_VALUE;
+import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_CLASS_NAME;
+import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_ICON_RESID;
+import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_ACTION;
+import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS;
+import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE;
+import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_RANK;
+import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_RESID;
+import static android.provider.SearchIndexablesContract.INDEXABLES_RAW_COLUMNS;
+import static android.provider.SearchIndexablesContract.INDEXABLES_XML_RES_COLUMNS;
+import static android.provider.SearchIndexablesContract.NON_INDEXABLES_KEYS_COLUMNS;
+
import android.content.Context;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.os.UserManager;
import android.provider.SearchIndexableResource;
+import android.provider.SearchIndexablesContract.RawData;
import android.provider.SearchIndexablesProvider;
-
-import static android.provider.SearchIndexablesContract.COLUMN_INDEX_NON_INDEXABLE_KEYS_KEY_VALUE;
-import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_RANK;
-import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_RESID;
-import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_CLASS_NAME;
-import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_ICON_RESID;
-import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_ACTION;
-import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE;
-import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS;
-
-import static android.provider.SearchIndexablesContract.INDEXABLES_RAW_COLUMNS;
-import static android.provider.SearchIndexablesContract.INDEXABLES_XML_RES_COLUMNS;
-import static android.provider.SearchIndexablesContract.NON_INDEXABLES_KEYS_COLUMNS;
+import android.support.annotation.VisibleForTesting;
+import android.telephony.euicc.EuiccManager;
public class PhoneSearchIndexablesProvider extends SearchIndexablesProvider {
private static final String TAG = "PhoneSearchIndexablesProvider";
+ private UserManager mUserManager;
private static SearchIndexableResource[] INDEXABLE_RES = new SearchIndexableResource[] {
new SearchIndexableResource(1, R.xml.network_setting_fragment,
@@ -47,6 +50,7 @@
@Override
public boolean onCreate() {
+ mUserManager = (UserManager) getContext().getSystemService(Context.USER_SERVICE);
return true;
}
@@ -71,25 +75,50 @@
@Override
public Cursor queryRawData(String[] projection) {
MatrixCursor cursor = new MatrixCursor(INDEXABLES_RAW_COLUMNS);
+ Context context = getContext();
+ String title = context.getString(R.string.carrier_settings_euicc);
+ cursor.newRow()
+ .add(RawData.COLUMN_RANK, 0)
+ .add(RawData.COLUMN_TITLE, title)
+ .add(
+ RawData.COLUMN_KEYWORDS,
+ context.getString(R.string.keywords_carrier_settings_euicc))
+ .add(RawData.COLUMN_SCREEN_TITLE, title)
+ .add(RawData.COLUMN_KEY, "esim_list_profile")
+ .add(
+ RawData.COLUMN_INTENT_ACTION,
+ EuiccManager.ACTION_MANAGE_EMBEDDED_SUBSCRIPTIONS)
+ .add(
+ RawData.COLUMN_INTENT_TARGET_PACKAGE,
+ context.getPackageName());
return cursor;
}
@Override
public Cursor queryNonIndexableKeys(String[] projection) {
MatrixCursor cursor = new MatrixCursor(NON_INDEXABLES_KEYS_COLUMNS);
- final UserManager userManager = (UserManager) getContext().getSystemService(
- Context.USER_SERVICE);
- if (!userManager.isAdminUser()) {
+ if (!mUserManager.isAdminUser()) {
final String[] values = new String[]{"preferred_network_mode_key", "button_roaming_key",
"cdma_lte_data_service_key", "enabled_networks_key", "enhanced_4g_lte",
"button_apn_key", "button_carrier_sel_key", "carrier_settings_key",
- "cdma_system_select_key", "carrier_settings_euicc_key"};
+ "cdma_system_select_key", "esim_list_profile"};
for (String nik : values) {
- final Object[] ref = new Object[NON_INDEXABLES_KEYS_COLUMNS.length];
- ref[COLUMN_INDEX_NON_INDEXABLE_KEYS_KEY_VALUE] = nik;
- cursor.addRow(ref);
+ cursor.addRow(createNonIndexableRow(nik));
}
+ } else if (isEuiccSettingsHidden()) {
+ cursor.addRow(createNonIndexableRow("esim_list_profile" /* key */));
}
+ cursor.addRow(createNonIndexableRow("carrier_settings_euicc_key" /* key */));
return cursor;
}
+
+ @VisibleForTesting boolean isEuiccSettingsHidden() {
+ return !MobileNetworkSettings.showEuiccSettings(getContext());
+ }
+
+ private Object[] createNonIndexableRow(String key) {
+ final Object[] ref = new Object[NON_INDEXABLES_KEYS_COLUMNS.length];
+ ref[COLUMN_INDEX_NON_INDEXABLE_KEYS_KEY_VALUE] = key;
+ return ref;
+ }
}