Merge "Import translations. DO NOT MERGE" into rvc-dev
diff --git a/src/com/android/settings/core/instrumentation/SettingsIntelligenceLogWriter.java b/src/com/android/settings/core/instrumentation/SettingsIntelligenceLogWriter.java
index 30d8381..d963a55 100644
--- a/src/com/android/settings/core/instrumentation/SettingsIntelligenceLogWriter.java
+++ b/src/com/android/settings/core/instrumentation/SettingsIntelligenceLogWriter.java
@@ -128,7 +128,12 @@
mLogHandler.post(() -> {
mSettingsLogList.add(settingsLog);
});
- mLogHandler.scheduleSendLog();
+ if (action == SettingsEnums.ACTION_CONTEXTUAL_CARD_DISMISS) {
+ // Directly send this event to notify SI instantly that the card is dismissed
+ mLogHandler.sendLog();
+ } else {
+ mLogHandler.scheduleSendLog();
+ }
}
@VisibleForTesting
@@ -136,7 +141,7 @@
final int size = settingsLogs.size();
final ByteArrayOutputStream bout = new ByteArrayOutputStream();
final DataOutputStream output = new DataOutputStream(bout);
- // Data is "size, length, bytearray, length, bytearray ..."
+ // The data format is "size, length, byte array, length, byte array ..."
try {
output.writeInt(size);
for (SettingsLog settingsLog : settingsLogs) {
@@ -159,14 +164,19 @@
private class SendLogHandler extends Handler {
- public SendLogHandler(Looper looper) {
+ SendLogHandler(Looper looper) {
super(looper);
}
- public void scheduleSendLog() {
+ void scheduleSendLog() {
removeCallbacks(mSendLogsRunnable);
postDelayed(mSendLogsRunnable, MESSAGE_DELAY);
}
+
+ void sendLog() {
+ removeCallbacks(mSendLogsRunnable);
+ post(mSendLogsRunnable);
+ }
}
private final Runnable mSendLogsRunnable = () -> {
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java b/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
index 886a12d..744bb4e 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
@@ -57,7 +57,7 @@
static final int CARD_CONTENT_LOADER_ID = 1;
private static final String TAG = "ContextualCardLoader";
- private static final long ELIGIBILITY_CHECKER_TIMEOUT_MS = 250;
+ private static final long ELIGIBILITY_CHECKER_TIMEOUT_MS = 300;
private final ContentObserver mObserver = new ContentObserver(
new Handler(Looper.getMainLooper())) {
diff --git a/src/com/android/settings/homepage/contextualcards/EligibleCardChecker.java b/src/com/android/settings/homepage/contextualcards/EligibleCardChecker.java
index 7fd8a2f..90b7f36 100644
--- a/src/com/android/settings/homepage/contextualcards/EligibleCardChecker.java
+++ b/src/com/android/settings/homepage/contextualcards/EligibleCardChecker.java
@@ -18,8 +18,6 @@
import static android.app.slice.Slice.HINT_ERROR;
-import static com.android.settings.intelligence.ContextualCardProto.ContextualCard.Category.STICKY_VALUE;
-
import android.app.settings.SettingsEnums;
import android.content.ContentResolver;
import android.content.Context;
@@ -43,7 +41,7 @@
public class EligibleCardChecker implements Callable<ContextualCard> {
private static final String TAG = "EligibleCardChecker";
- private static final long LATCH_TIMEOUT_MS = 200;
+ private static final long LATCH_TIMEOUT_MS = 300;
private final Context mContext;
@@ -96,11 +94,6 @@
return false;
}
- if (card.getCategory() == STICKY_VALUE) {
- Log.d(TAG, "Sticky card, skip checking. Uri = " + card.getSliceUri());
- return true;
- }
-
final Slice slice = bindSlice(uri);
if (isSliceToggleable(slice)) {
diff --git a/src/com/android/settings/network/telephony/DefaultSubscriptionController.java b/src/com/android/settings/network/telephony/DefaultSubscriptionController.java
index 779802a..1d82f65 100644
--- a/src/com/android/settings/network/telephony/DefaultSubscriptionController.java
+++ b/src/com/android/settings/network/telephony/DefaultSubscriptionController.java
@@ -34,6 +34,7 @@
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.network.SubscriptionUtil;
import com.android.settings.network.SubscriptionsChangeListener;
@@ -64,7 +65,6 @@
public DefaultSubscriptionController(Context context, String preferenceKey) {
super(context, preferenceKey);
mManager = context.getSystemService(SubscriptionManager.class);
- mTelecomManager = mContext.getSystemService(TelecomManager.class);
mChangeListener = new SubscriptionsChangeListener(context, this);
}
@@ -184,12 +184,12 @@
*/
public PhoneAccountHandle getDefaultCallingAccountHandle() {
final PhoneAccountHandle currentSelectPhoneAccount =
- mTelecomManager.getUserSelectedOutgoingPhoneAccount();
+ getTelecomManager().getUserSelectedOutgoingPhoneAccount();
if (currentSelectPhoneAccount == null) {
return null;
}
final List<PhoneAccountHandle> accountHandles =
- mTelecomManager.getCallCapablePhoneAccounts(false);
+ getTelecomManager().getCallCapablePhoneAccounts(false);
final PhoneAccountHandle emergencyAccountHandle = new PhoneAccountHandle(
PSTN_CONNECTION_SERVICE_COMPONENT, EMERGENCY_ACCOUNT_HANDLE_ID);
if (currentSelectPhoneAccount.equals(emergencyAccountHandle)) {
@@ -203,14 +203,30 @@
return null;
}
+ @VisibleForTesting
+ TelecomManager getTelecomManager() {
+ if (mTelecomManager == null) {
+ mTelecomManager = mContext.getSystemService(TelecomManager.class);
+ }
+ return mTelecomManager;
+ }
+
+ @VisibleForTesting
+ PhoneAccount getPhoneAccount(PhoneAccountHandle handle) {
+ return getTelecomManager().getPhoneAccount(handle);
+ }
+
/**
* Check if calling account bind to subscription
*
* @param handle {@link PhoneAccountHandle} for specific calling account
*/
public boolean isCallingAccountBindToSubscription(PhoneAccountHandle handle) {
- return mTelecomManager.getPhoneAccount(handle)
- .hasCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION);
+ final PhoneAccount account = getPhoneAccount(handle);
+ if (account == null) {
+ return false;
+ }
+ return account.hasCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION);
}
/**
@@ -220,7 +236,11 @@
* @return label of calling account
*/
public CharSequence getLabelFromCallingAccount(PhoneAccountHandle handle) {
- CharSequence label = mTelecomManager.getPhoneAccount(handle).getLabel();
+ CharSequence label = null;
+ final PhoneAccount account = getPhoneAccount(handle);
+ if (account != null) {
+ label = account.getLabel();
+ }
if (label != null) {
label = mContext.getPackageManager().getUserBadgedLabel(label, handle.getUserHandle());
}
diff --git a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
index 26c206d..d6f66a1 100644
--- a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
+++ b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
@@ -168,7 +168,6 @@
private Context mContext;
private TelephonyManager mTelephonyManager;
- private boolean mAllowed5gNetworkType;
private boolean mIsGlobalCdma;
private boolean mIs5gEntryDisplayed;
private boolean mShow4gForLTE;
@@ -206,9 +205,6 @@
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
final boolean isNrEnabledFromCarrierConfig = carrierConfig != null
&& carrierConfig.getBoolean(CarrierConfigManager.KEY_NR_ENABLED_BOOL);
- mAllowed5gNetworkType = checkSupportedRadioBitmask(
- mTelephonyManager.getAllowedNetworkTypes(),
- TelephonyManager.NETWORK_TYPE_BITMASK_NR);
mSupported5gRadioAccessFamily = isNrEnabledFromCarrierConfig
&& checkSupportedRadioBitmask(mTelephonyManager.getSupportedRadioAccessFamily(),
TelephonyManager.NETWORK_TYPE_BITMASK_NR);
@@ -572,7 +568,7 @@
}
/**
- * Add 5G option. Only show the UI when device supported 5G and allowed 5G.
+ * Add 5G option. Only show the UI when device supported 5G.
*/
private void add5gEntry(int value) {
boolean isNRValue = value >= TelephonyManagerConstants.NETWORK_MODE_NR_ONLY;
@@ -585,15 +581,13 @@
mIs5gEntryDisplayed = false;
Log.d(LOG_TAG, "Hide 5G option. "
+ " supported5GRadioAccessFamily: " + mSupported5gRadioAccessFamily
- + " allowed5GNetworkType: " + mAllowed5gNetworkType
+ " isNRValue: " + isNRValue);
}
}
private void addGlobalEntry() {
Log.d(LOG_TAG, "addGlobalEntry. "
- + " supported5GRadioAccessFamily: " + mSupported5gRadioAccessFamily
- + " allowed5GNetworkType: " + mAllowed5gNetworkType);
+ + " supported5GRadioAccessFamily: " + mSupported5gRadioAccessFamily);
mEntries.add(mContext.getString(R.string.network_global));
if (showNrList()) {
mEntriesValue.add(
@@ -605,7 +599,7 @@
}
private boolean showNrList() {
- return mSupported5gRadioAccessFamily && mAllowed5gNetworkType;
+ return mSupported5gRadioAccessFamily;
}
/**
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/EligibleCardCheckerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/EligibleCardCheckerTest.java
index e236919..23ae2f3 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/EligibleCardCheckerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/EligibleCardCheckerTest.java
@@ -18,15 +18,11 @@
import static android.app.slice.Slice.HINT_ERROR;
-import static com.android.settings.intelligence.ContextualCardProto.ContextualCard.Category.STICKY_VALUE;
-
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
import android.content.Context;
import android.net.Uri;
@@ -69,32 +65,6 @@
}
@Test
- public void isCardEligibleToDisplay_stickyCard_returnTrue() {
- final ContextualCard card = new ContextualCard.Builder()
- .setName("test_card")
- .setCardType(ContextualCard.CardType.SLICE)
- .setCategory(STICKY_VALUE)
- .setSliceUri(CustomSliceRegistry.FLASHLIGHT_SLICE_URI)
- .build();
-
- assertThat(mEligibleCardChecker.isCardEligibleToDisplay(card)).isTrue();
- }
-
- @Test
- public void isCardEligibleToDisplay_stickyCard_shouldNotPrebind() {
- final ContextualCard card = new ContextualCard.Builder()
- .setName("test_card")
- .setCardType(ContextualCard.CardType.SLICE)
- .setCategory(STICKY_VALUE)
- .setSliceUri(CustomSliceRegistry.FLASHLIGHT_SLICE_URI)
- .build();
-
- mEligibleCardChecker.isCardEligibleToDisplay(card);
-
- verify(mEligibleCardChecker, never()).bindSlice(CustomSliceRegistry.FLASHLIGHT_SLICE_URI);
- }
-
- @Test
public void isCardEligibleToDisplay_toggleSlice_hasInlineActionShouldBeTrue() {
final ContextualWifiSlice wifiSlice = new ContextualWifiSlice(mContext);
final Slice slice = wifiSlice.getSlice();
diff --git a/tests/robotests/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java
index dbdad50..e20241b 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java
@@ -21,6 +21,7 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -32,6 +33,9 @@
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
+import androidx.preference.ListPreference;
+import androidx.preference.PreferenceScreen;
+
import com.android.settings.R;
import com.android.settings.network.SubscriptionUtil;
@@ -46,9 +50,6 @@
import java.util.Arrays;
-import androidx.preference.ListPreference;
-import androidx.preference.PreferenceScreen;
-
@RunWith(RobolectricTestRunner.class)
public class DefaultSubscriptionControllerTest {
@Mock
@@ -92,6 +93,20 @@
}
@Test
+ public void isCallingAccountBindToSubscription_invalidAccount_withoutCrash() {
+ doReturn(null).when(mController).getPhoneAccount(any());
+
+ mController.isCallingAccountBindToSubscription(null);
+ }
+
+ @Test
+ public void getLabelFromCallingAccount_invalidAccount_emptyString() {
+ doReturn(null).when(mController).getPhoneAccount(any());
+
+ assertThat(mController.getLabelFromCallingAccount(null)).isEqualTo("");
+ }
+
+ @Test
public void displayPreference_twoSubscriptionsSub1Default_correctListPreferenceValues() {
final SubscriptionInfo sub1 = createMockSub(111, "sub1");
final SubscriptionInfo sub2 = createMockSub(222, "sub2");
diff --git a/tests/robotests/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceControllerTest.java
index a818852..7f4b33c 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceControllerTest.java
@@ -60,7 +60,6 @@
private static final int SUB_ID = 2;
public static final String KEY = "enabled_network";
- private static final long ALLOWED_ALL_NETWORK_TYPE = -1;
private static final long DISABLED_5G_NETWORK_TYPE = ~TelephonyManager.NETWORK_TYPE_BITMASK_NR;
@Mock
@@ -98,7 +97,6 @@
doReturn(mPersistableBundle).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
mPreference = new ListPreference(mContext);
mController = new EnabledNetworkModePreferenceController(mContext, KEY);
- mockAllowedNetworkTypes(ALLOWED_ALL_NETWORK_TYPE);
mockAccessFamily(TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA);
mController.init(mLifecycle, SUB_ID);
mPreference.setKey(mController.getPreferenceKey());
@@ -185,76 +183,6 @@
}
@Test
- public void updateState_disAllowed5g_5gOptionHidden() {
- mockEnabledNetworkMode(TelephonyManagerConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA);
- mockAccessFamily(TelephonyManager.NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA);
- mockAllowedNetworkTypes(DISABLED_5G_NETWORK_TYPE);
- mController.init(mLifecycle, SUB_ID);
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID,
- TelephonyManagerConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA);
-
- mController.updateState(mPreference);
-
- assertThat(mPreference.getEntryValues())
- .asList()
- .doesNotContain(
- String.valueOf(TelephonyManager.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA));
- }
-
- @Test
- public void updateState_disAllowed5g_selectOn4gOption() {
- mockEnabledNetworkMode(TelephonyManagerConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA);
- mockAccessFamily(TelephonyManager.NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA);
- mockAllowedNetworkTypes(DISABLED_5G_NETWORK_TYPE);
- mController.init(mLifecycle, SUB_ID);
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID,
- TelephonyManagerConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA);
-
- mController.updateState(mPreference);
-
- assertThat(mPreference.getValue()).isEqualTo(
- String.valueOf(
- TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA));
- }
-
- @Test
- public void updateState_GlobalDisAllowed5g_GlobalWithoutNR() {
- mockAccessFamily(TelephonyManager.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA);
- mockAllowedNetworkTypes(DISABLED_5G_NETWORK_TYPE);
- mController.init(mLifecycle, SUB_ID);
- mPersistableBundle.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID,
- TelephonyManagerConstants.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA);
-
- mController.updateState(mPreference);
-
- assertThat(mPreference.getEntryValues())
- .asList()
- .doesNotContain(
- String.valueOf(TelephonyManager.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA));
- }
-
- @Test
- public void updateState_GlobalDisAllowed5g_SelectOnGlobal() {
- mockAccessFamily(TelephonyManager.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA);
- mockAllowedNetworkTypes(DISABLED_5G_NETWORK_TYPE);
- mController.init(mLifecycle, SUB_ID);
- mPersistableBundle.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID,
- TelephonyManagerConstants.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA);
-
- mController.updateState(mPreference);
-
- assertThat(mPreference.getValue()).isEqualTo(
- String.valueOf(
- TelephonyManagerConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA));
- }
-
- @Test
public void updateState_updateByNetworkMode() {
mockEnabledNetworkMode(TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_GSM_WCDMA);
Settings.Global.putInt(mContext.getContentResolver(),
@@ -351,10 +279,6 @@
}
}
- private void mockAllowedNetworkTypes(long allowedNetworkType) {
- doReturn(allowedNetworkType).when(mTelephonyManager).getAllowedNetworkTypes();
- }
-
private void mockAccessFamily(int networkMode) {
doReturn(MobileNetworkUtils.getRafFromNetworkType(networkMode))
.when(mTelephonyManager)