Merge "Convert tests mk file to bp."
diff --git a/src/com/android/phone/CallFeaturesSetting.java b/src/com/android/phone/CallFeaturesSetting.java
index 3858595..e5e02fa 100644
--- a/src/com/android/phone/CallFeaturesSetting.java
+++ b/src/com/android/phone/CallFeaturesSetting.java
@@ -26,6 +26,7 @@
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
+import android.content.res.Resources;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.os.UserManager;
@@ -181,9 +182,9 @@
startActivity(intent);
}
};
- builder.setMessage(getResources().getString(
+ builder.setMessage(getResourcesForSubId().getString(
R.string.enable_video_calling_dialog_msg))
- .setNeutralButton(getResources().getString(
+ .setNeutralButton(getResourcesForSubId().getString(
R.string.enable_video_calling_dialog_settings),
networkSettingsClickListener)
.setPositiveButton(android.R.string.ok, null)
@@ -211,9 +212,9 @@
}
mSubscriptionInfoHelper = new SubscriptionInfoHelper(this, getIntent());
- mSubscriptionInfoHelper.setActionBarTitle(
- getActionBar(), getResources(), R.string.call_settings_with_label);
mPhone = mSubscriptionInfoHelper.getPhone();
+ mSubscriptionInfoHelper.setActionBarTitle(
+ getActionBar(), getResourcesForSubId(), R.string.call_settings_with_label);
mTelecomManager = getSystemService(TelecomManager.class);
}
@@ -315,7 +316,7 @@
mButtonAutoRetry = (SwitchPreference) findPreference(BUTTON_RETRY_KEY);
mEnableVideoCalling = (SwitchPreference) findPreference(ENABLE_VIDEO_CALLING_KEY);
- mButtonWifiCalling = findPreference(getResources().getString(
+ mButtonWifiCalling = findPreference(getResourcesForSubId().getString(
R.string.wifi_calling_settings_key));
PersistableBundle carrierConfig =
@@ -424,8 +425,7 @@
} else if (!mImsMgr.isWfcEnabledByPlatform() || !mImsMgr.isWfcProvisionedOnDevice()) {
prefSet.removePreference(mButtonWifiCalling);
} else {
- String title = SubscriptionManager.getResourcesForSubId(mPhone.getContext(),
- mPhone.getSubId()).getString(R.string.wifi_calling);
+ String title = getResourcesForSubId().getString(R.string.wifi_calling);
mButtonWifiCalling.setTitle(title);
int resId = com.android.internal.R.string.wifi_calling_off_summary;
@@ -447,7 +447,7 @@
if (DBG) log("Unexpected WFC mode value: " + wfcMode);
}
}
- mButtonWifiCalling.setSummary(resId);
+ mButtonWifiCalling.setSummary(getResourcesForSubId().getString(resId));
Intent intent = mButtonWifiCalling.getIntent();
if (intent != null) {
intent.putExtra(Settings.EXTRA_SUB_ID, mPhone.getSubId());
@@ -509,9 +509,9 @@
setIntent(newIntent);
mSubscriptionInfoHelper = new SubscriptionInfoHelper(this, getIntent());
- mSubscriptionInfoHelper.setActionBarTitle(
- getActionBar(), getResources(), R.string.call_settings_with_label);
mPhone = mSubscriptionInfoHelper.getPhone();
+ mSubscriptionInfoHelper.setActionBarTitle(
+ getActionBar(), getResourcesForSubId(), R.string.call_settings_with_label);
}
private static void log(String msg) {
@@ -540,4 +540,12 @@
activity.startActivity(intent);
activity.finish();
}
+
+ private Resources getResourcesForSubId() {
+ if (mPhone != null) {
+ return SubscriptionManager.getResourcesForSubId(mPhone.getContext(), mPhone.getSubId());
+ } else {
+ return getResources();
+ }
+ }
}
diff --git a/src/com/android/phone/NotificationMgr.java b/src/com/android/phone/NotificationMgr.java
index 410965b..66017e4 100644
--- a/src/com/android/phone/NotificationMgr.java
+++ b/src/com/android/phone/NotificationMgr.java
@@ -29,7 +29,6 @@
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
-import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Handler;
@@ -564,16 +563,15 @@
builder.build(),
UserHandle.ALL);
} else {
- List<UserInfo> users = mUserManager.getUsers(true);
- for (UserInfo user : users) {
- if (mUserManager.isManagedProfile(user.getUserHandle().getIdentifier())) {
+ List<UserHandle> users = getUsersExcludeDying();
+ for (UserHandle user : users) {
+ if (mUserManager.isManagedProfile(user.getIdentifier())) {
continue;
}
- UserHandle userHandle = user.getUserHandle();
cancelAsUser(
Integer.toString(subId) /* tag */,
CALL_FORWARD_NOTIFICATION,
- userHandle);
+ user);
}
}
}
diff --git a/src/com/android/phone/TelephonyShellCommand.java b/src/com/android/phone/TelephonyShellCommand.java
index 428c006..ebadf88 100644
--- a/src/com/android/phone/TelephonyShellCommand.java
+++ b/src/com/android/phone/TelephonyShellCommand.java
@@ -18,7 +18,6 @@
import android.content.Context;
import android.os.Binder;
-import android.os.Build;
import android.os.PersistableBundle;
import android.os.Process;
import android.os.RemoteException;
@@ -31,6 +30,7 @@
import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.emergency.EmergencyNumberTracker;
+import com.android.internal.telephony.util.TelephonyUtils;
import java.io.PrintWriter;
import java.util.ArrayList;
@@ -623,7 +623,7 @@
private int handleCcCommand() {
// Verify that the user is allowed to run the command. Only allowed in rooted device in a
// non user build.
- if (Binder.getCallingUid() != Process.ROOT_UID || Build.IS_USER) {
+ if (Binder.getCallingUid() != Process.ROOT_UID || TelephonyUtils.IS_USER) {
getErrPrintWriter().println("cc: Permission denied.");
return -1;
}
diff --git a/src/com/android/services/telephony/TelephonyConnection.java b/src/com/android/services/telephony/TelephonyConnection.java
index 49202be..fdece42 100644
--- a/src/com/android/services/telephony/TelephonyConnection.java
+++ b/src/com/android/services/telephony/TelephonyConnection.java
@@ -19,6 +19,7 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
+import android.content.res.Resources;
import android.graphics.drawable.Icon;
import android.net.Uri;
import android.os.AsyncResult;
@@ -42,6 +43,7 @@
import android.telephony.PhoneNumberUtils;
import android.telephony.Rlog;
import android.telephony.ServiceState;
+import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.ims.ImsCallProfile;
import android.text.TextUtils;
@@ -405,7 +407,9 @@
}
}
if (messageId != -1 && getPhone() != null && getPhone().getContext() != null) {
- return getPhone().getContext().getText(messageId);
+ Resources res = SubscriptionManager.getResourcesForSubId(
+ getPhone().getContext(), getPhone().getSubId());
+ return res.getText(messageId);
} else {
return null;
}
@@ -2200,8 +2204,10 @@
: R.string.status_hint_label_wifi_call;
Context context = getPhone().getContext();
+ Resources res =
+ SubscriptionManager.getResourcesForSubId(context, getPhone().getSubId());
setTelephonyStatusHints(new StatusHints(
- context.getString(labelId),
+ res.getString(labelId),
Icon.createWithResource(
context, R.drawable.ic_signal_wifi_4_bar_24dp),
null /* extras */));
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index 63e9f1e..06370b0 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -182,6 +182,8 @@
public boolean isLocked = false;
// Is the emergency number associated with the slot
public boolean hasDialedEmergencyNumber = false;
+ //SimState
+ public int simState;
public SlotStatus(int slotId, int capabilities) {
this.slotId = slotId;
@@ -1664,6 +1666,8 @@
// 4)
// Report Slot's PIN/PUK lock status for sorting later.
int simState = mSubscriptionManagerProxy.getSimStateForSlotIdx(i);
+ // Record SimState.
+ status.simState = simState;
if (simState == TelephonyManager.SIM_STATE_PIN_REQUIRED ||
simState == TelephonyManager.SIM_STATE_PUK_REQUIRED) {
status.isLocked = true;
@@ -1709,6 +1713,15 @@
if (o1.hasDialedEmergencyNumber && !o2.hasDialedEmergencyNumber) {
return 1;
}
+ // Sort by non-absent SIM.
+ if (o1.simState == TelephonyManager.SIM_STATE_ABSENT
+ && o2.simState != TelephonyManager.SIM_STATE_ABSENT) {
+ return -1;
+ }
+ if (o2.simState == TelephonyManager.SIM_STATE_ABSENT
+ && o1.simState != TelephonyManager.SIM_STATE_ABSENT) {
+ return 1;
+ }
// First start by seeing if either of the phone slots are locked. If they
// are, then sort by non-locked SIM first. If they are both locked, sort
// by capability instead.
diff --git a/tests/src/com/android/services/telephony/TelephonyConnectionServiceTest.java b/tests/src/com/android/services/telephony/TelephonyConnectionServiceTest.java
index ab4c067..c00764b 100644
--- a/tests/src/com/android/services/telephony/TelephonyConnectionServiceTest.java
+++ b/tests/src/com/android/services/telephony/TelephonyConnectionServiceTest.java
@@ -23,11 +23,13 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.content.Context;
import android.net.Uri;
import android.os.AsyncResult;
import android.os.Bundle;
@@ -39,6 +41,7 @@
import android.telephony.TelephonyManager;
import android.test.suitebuilder.annotation.SmallTest;
+import androidx.test.InstrumentationRegistry;
import androidx.test.filters.FlakyTest;
import androidx.test.runner.AndroidJUnit4;
@@ -770,6 +773,11 @@
Phone phone = c.getPhone();
c.setOriginalConnection(c.getOriginalConnection());
+ // Use a real context since the method SubscriptionManager.getResourcesForSubId()
+ // needs to interact with a real context.
+ Context targetContext = InstrumentationRegistry.getTargetContext();
+ doReturn(targetContext).when(phone).getContext();
+
// When the registration occurs, we'll capture the handler and message so we can post our
// own messages to it.
ArgumentCaptor<Handler> handlerCaptor = ArgumentCaptor.forClass(Handler.class);