summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmds/statsd/src/atoms.proto13
-rw-r--r--config/hiddenapi-greylist.txt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java4
-rw-r--r--services/core/java/com/android/server/AlarmManagerService.java25
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java37
-rw-r--r--services/core/java/com/android/server/connectivity/NetdEventListenerService.java9
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/AbUpdateInstaller.java4
-rw-r--r--services/tests/mockingservicestests/src/com/android/server/AlarmManagerServiceTest.java21
-rw-r--r--telephony/java/android/telephony/SmsManager.java31
-rw-r--r--telephony/java/android/telephony/SmsMessage.java137
-rw-r--r--telephony/java/android/telephony/TelephonyManager.java4
-rw-r--r--telephony/java/com/android/internal/telephony/GsmAlphabet.java11
-rw-r--r--telephony/java/com/android/internal/telephony/Sms7BitEncodingTranslator.java39
-rw-r--r--telephony/java/com/android/internal/telephony/cdma/SmsMessage.java11
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/SmsMessage.java29
15 files changed, 203 insertions, 174 deletions
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto
index 24df8838e100..7646c3c89014 100644
--- a/cmds/statsd/src/atoms.proto
+++ b/cmds/statsd/src/atoms.proto
@@ -994,6 +994,19 @@ message WakeupAlarmOccurred {
// Name of source package (for historical reasons, since BatteryStats tracked it).
optional string package_name = 3;
+
+ // These enum values match the STANDBY_BUCKET_XXX constants defined in UsageStatsManager.java.
+ enum Bucket {
+ UNKNOWN = 0;
+ EXEMPTED = 5;
+ ACTIVE = 10;
+ WORKING_SET = 20;
+ FREQUENT = 30;
+ RARE = 40;
+ NEVER = 50;
+ }
+ // The App Standby bucket of the app that scheduled the alarm at the time the alarm fired.
+ optional Bucket app_standby_bucket = 4;
}
/**
diff --git a/config/hiddenapi-greylist.txt b/config/hiddenapi-greylist.txt
index c267e779983a..82d0fbe32993 100644
--- a/config/hiddenapi-greylist.txt
+++ b/config/hiddenapi-greylist.txt
@@ -1431,8 +1431,6 @@ Lcom/android/internal/telephony/Sms7BitEncodingTranslator;->DBG:Z
Lcom/android/internal/telephony/Sms7BitEncodingTranslator;->mTranslationTableCDMA:Landroid/util/SparseIntArray;
Lcom/android/internal/telephony/Sms7BitEncodingTranslator;->mTranslationTableCommon:Landroid/util/SparseIntArray;
Lcom/android/internal/telephony/Sms7BitEncodingTranslator;->mTranslationTableGSM:Landroid/util/SparseIntArray;
-Lcom/android/internal/telephony/Sms7BitEncodingTranslator;->translate(Ljava/lang/CharSequence;)Ljava/lang/String;
-Lcom/android/internal/telephony/Sms7BitEncodingTranslator;->useCdmaFormatForMoSms()Z
Lcom/android/internal/telephony/SmsApplication$SmsApplicationData;->mApplicationName:Ljava/lang/String;
Lcom/android/internal/telephony/SmsApplication;->configurePreferredActivity(Landroid/content/pm/PackageManager;Landroid/content/ComponentName;I)V
Lcom/android/internal/telephony/SmsApplication;->getApplicationCollection(Landroid/content/Context;)Ljava/util/Collection;
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
index 7e016bb000ad..04637add0ebc 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
@@ -35,7 +35,6 @@ import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.SOURCE;
-import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningTaskInfo;
import android.app.ActivityTaskManager;
@@ -61,6 +60,7 @@ import android.widget.FrameLayout;
import androidx.annotation.IntDef;
import androidx.annotation.MainThread;
+import androidx.annotation.Nullable;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.statusbar.IStatusBarService;
@@ -139,7 +139,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
@Nullable private BubbleStackView.SurfaceSynchronizer mSurfaceSynchronizer;
private BubbleData mBubbleData;
- private BubbleStackView mStackView;
+ @Nullable private BubbleStackView mStackView;
// Bubbles get added to the status bar view
private final StatusBarWindowController mStatusBarWindowController;
diff --git a/services/core/java/com/android/server/AlarmManagerService.java b/services/core/java/com/android/server/AlarmManagerService.java
index cb61259ec53d..dfbb55a02ec7 100644
--- a/services/core/java/com/android/server/AlarmManagerService.java
+++ b/services/core/java/com/android/server/AlarmManagerService.java
@@ -1698,8 +1698,6 @@ class AlarmManagerService extends SystemService {
return;
}
- type = fixTypeIfAuto(type);
-
// Sanity check the window length. This will catch people mistakenly
// trying to pass an end-of-window timestamp rather than a duration.
if (windowLength > AlarmManager.INTERVAL_HALF_DAY) {
@@ -1815,21 +1813,6 @@ class AlarmManagerService extends SystemService {
}
/**
- * In case of cars, we need to avoid scheduling wakeup alarms, since we don't want the system
- * to wake up from suspend arbitrarily to perform app work.
- */
- private int fixTypeIfAuto(int type) {
- if (mInjector.isAutomotive()) {
- if (type == AlarmManager.ELAPSED_REALTIME_WAKEUP) {
- type = AlarmManager.ELAPSED_REALTIME;
- } else if (type == AlarmManager.RTC_WAKEUP) {
- type = AlarmManager.RTC;
- }
- }
- return type;
- }
-
- /**
* Return the minimum time that should elapse before an app in the specified bucket
* can receive alarms again
*/
@@ -2232,7 +2215,6 @@ class AlarmManagerService extends SystemService {
pw.print(" mLastTickSet="); pw.println(sdf.format(new Date(mLastTickSet)));
pw.print(" mLastTickAdded="); pw.println(sdf.format(new Date(mLastTickAdded)));
pw.print(" mLastTickRemoved="); pw.println(sdf.format(new Date(mLastTickRemoved)));
- pw.print(" mIsAutomotive="); pw.println(mInjector.isAutomotive());
if (RECORD_ALARMS_IN_HISTORY) {
pw.println();
@@ -3899,12 +3881,9 @@ class AlarmManagerService extends SystemService {
static class Injector {
private long mNativeData;
private Context mContext;
- private final boolean mIsAutomotive;
Injector(Context context) {
mContext = context;
- mIsAutomotive = context.getPackageManager().hasSystemFeature(
- PackageManager.FEATURE_AUTOMOTIVE);
}
void init() {
@@ -3993,10 +3972,6 @@ class AlarmManagerService extends SystemService {
ClockReceiver getClockReceiver(AlarmManagerService service) {
return service.new ClockReceiver();
}
-
- boolean isAutomotive() {
- return mIsAutomotive;
- }
}
private class AlarmThread extends Thread
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index a809d2194256..7a9375373557 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -8457,18 +8457,43 @@ public class ActivityManagerService extends IActivityManager.Stub
}
}
- if (DEBUG_POWER) {
- Slog.w(TAG, "noteWakupAlarm[ sourcePkg=" + sourcePkg + ", sourceUid=" + sourceUid
- + ", workSource=" + workSource + ", tag=" + tag + "]");
- }
+ int standbyBucket = 0;
mBatteryStatsService.noteWakupAlarm(sourcePkg, sourceUid, workSource, tag);
if (workSource != null) {
- StatsLog.write(StatsLog.WAKEUP_ALARM_OCCURRED, workSource, tag, sourcePkg);
+ String workSourcePackage = workSource.getName(0);
+ int workSourceUid = workSource.getAttributionUid();
+ if (workSourcePackage == null) {
+ workSourcePackage = sourcePkg;
+ workSourceUid = sourceUid;
+ }
+
+ if (mUsageStatsService != null) {
+ standbyBucket = mUsageStatsService.getAppStandbyBucket(workSourcePackage,
+ UserHandle.getUserId(workSourceUid), SystemClock.elapsedRealtime());
+ }
+
+ StatsLog.write(StatsLog.WAKEUP_ALARM_OCCURRED, workSource, tag, sourcePkg,
+ standbyBucket);
+ if (DEBUG_POWER) {
+ Slog.w(TAG, "noteWakeupAlarm[ sourcePkg=" + sourcePkg + ", sourceUid=" + sourceUid
+ + ", workSource=" + workSource + ", tag=" + tag + ", standbyBucket="
+ + standbyBucket + " wsName=" + workSourcePackage + ")]");
+ }
} else {
+ if (mUsageStatsService != null) {
+ standbyBucket = mUsageStatsService.getAppStandbyBucket(sourcePkg,
+ UserHandle.getUserId(sourceUid), SystemClock.elapsedRealtime());
+ }
StatsLog.write_non_chained(StatsLog.WAKEUP_ALARM_OCCURRED, sourceUid, null, tag,
- sourcePkg);
+ sourcePkg, standbyBucket);
+ if (DEBUG_POWER) {
+ Slog.w(TAG, "noteWakeupAlarm[ sourcePkg=" + sourcePkg + ", sourceUid=" + sourceUid
+ + ", workSource=" + workSource + ", tag=" + tag + ", standbyBucket="
+ + standbyBucket + "]");
+ }
}
+
}
@Override
diff --git a/services/core/java/com/android/server/connectivity/NetdEventListenerService.java b/services/core/java/com/android/server/connectivity/NetdEventListenerService.java
index e40949b785d9..dbc339b01c89 100644
--- a/services/core/java/com/android/server/connectivity/NetdEventListenerService.java
+++ b/services/core/java/com/android/server/connectivity/NetdEventListenerService.java
@@ -27,21 +27,19 @@ import android.net.NetworkCapabilities;
import android.net.metrics.ConnectStats;
import android.net.metrics.DnsEvent;
import android.net.metrics.INetdEventListener;
-import android.net.metrics.IpConnectivityLog;
import android.net.metrics.NetworkMetrics;
import android.net.metrics.WakeupEvent;
import android.net.metrics.WakeupStats;
import android.os.RemoteException;
import android.text.format.DateUtils;
-import android.util.Log;
import android.util.ArrayMap;
+import android.util.Log;
import android.util.SparseArray;
import android.util.StatsLog;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.BitUtils;
-import com.android.internal.util.IndentingPrintWriter;
import com.android.internal.util.RingBuffer;
import com.android.internal.util.TokenBucket;
import com.android.server.connectivity.metrics.nano.IpConnectivityLogClass.IpConnectivityEvent;
@@ -307,6 +305,11 @@ public class NetdEventListenerService extends INetdEventListener.Stub {
}
}
+ @Override
+ public int getInterfaceVersion() throws RemoteException {
+ return this.VERSION;
+ }
+
private void addWakeupEvent(WakeupEvent event) {
String iface = event.iface;
mWakeupEvents.append(event);
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/AbUpdateInstaller.java b/services/devicepolicy/java/com/android/server/devicepolicy/AbUpdateInstaller.java
index 5acf83aeb890..a9662c919a64 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/AbUpdateInstaller.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/AbUpdateInstaller.java
@@ -85,6 +85,10 @@ class AbUpdateInstaller extends UpdateInstaller {
map.put(
UpdateEngine.ErrorCodeConstants.PAYLOAD_HASH_MISMATCH_ERROR,
InstallSystemUpdateCallback.UPDATE_ERROR_UPDATE_FILE_INVALID);
+ // TODO(b/133396459): replace with a constant.
+ map.put(
+ 26 /* kDownloadMetadataSignatureMismatch */,
+ InstallSystemUpdateCallback.UPDATE_ERROR_UPDATE_FILE_INVALID);
// Error constants corresponding to errors related to devices bad state.
map.put(
diff --git a/services/tests/mockingservicestests/src/com/android/server/AlarmManagerServiceTest.java b/services/tests/mockingservicestests/src/com/android/server/AlarmManagerServiceTest.java
index 77e2517d7752..cdcdf9195ad5 100644
--- a/services/tests/mockingservicestests/src/com/android/server/AlarmManagerServiceTest.java
+++ b/services/tests/mockingservicestests/src/com/android/server/AlarmManagerServiceTest.java
@@ -68,7 +68,6 @@ import android.app.usage.UsageStatsManagerInternal;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.PackageManager;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
@@ -122,8 +121,6 @@ public class AlarmManagerServiceTest {
private AlarmManagerService.ClockReceiver mClockReceiver;
@Mock
private PowerManager.WakeLock mWakeLock;
- @Mock
- private PackageManager mMockPackageManager;
private MockitoSession mMockingSession;
private Injector mInjector;
@@ -241,11 +238,6 @@ public class AlarmManagerServiceTest {
PowerManager.WakeLock getAlarmWakeLock() {
return mWakeLock;
}
-
- @Override
- boolean isAutomotive() {
- return mIsAutomotiveOverride;
- }
}
@Before
@@ -272,7 +264,6 @@ public class AlarmManagerServiceTest {
when(mMockContext.getContentResolver()).thenReturn(mMockResolver);
doReturn("min_futurity=0,min_interval=0").when(() ->
Settings.Global.getString(mMockResolver, Settings.Global.ALARM_MANAGER_CONSTANTS));
- when(mMockContext.getPackageManager()).thenReturn(mMockPackageManager);
mInjector = new Injector(mMockContext);
mService = new AlarmManagerService(mMockContext, mInjector);
@@ -1024,18 +1015,6 @@ public class AlarmManagerServiceTest {
assertAlarmTypeConversion(typesToSet, typesExpected);
}
- /**
- * Confirm that wakeup alarms are never set for automotive.
- */
- @Test
- public void alarmTypesForAuto() throws Exception {
- mInjector.mIsAutomotiveOverride = true;
- final int[] typesToSet = {ELAPSED_REALTIME_WAKEUP, ELAPSED_REALTIME, RTC_WAKEUP, RTC};
- final int[] typesExpected = {ELAPSED_REALTIME, ELAPSED_REALTIME, ELAPSED_REALTIME,
- ELAPSED_REALTIME};
- assertAlarmTypeConversion(typesToSet, typesExpected);
- }
-
private void assertAlarmTypeConversion(int[] typesToSet, int[] typesExpected) throws Exception {
for (int i = 0; i < typesToSet.length; i++) {
setTestAlarm(typesToSet[i], 1234, getNewMockPendingIntent());
diff --git a/telephony/java/android/telephony/SmsManager.java b/telephony/java/android/telephony/SmsManager.java
index 8c20afecca80..68602354d3b0 100644
--- a/telephony/java/android/telephony/SmsManager.java
+++ b/telephony/java/android/telephony/SmsManager.java
@@ -721,20 +721,17 @@ public final class SmsManager {
}
/**
- * Divide a message text into several fragments, none bigger than
- * the maximum SMS message size.
+ * Divide a message text into several fragments, none bigger than the maximum SMS message size.
*
- * @param text the original message. Must not be null.
- * @return an <code>ArrayList</code> of strings that, in order,
- * comprise the original message
- *
- * @throws IllegalArgumentException if text is null
+ * @param text the original message. Must not be null.
+ * @return an <code>ArrayList</code> of strings that, in order, comprise the original message.
+ * @throws IllegalArgumentException if text is null.
*/
public ArrayList<String> divideMessage(String text) {
if (null == text) {
throw new IllegalArgumentException("text is null");
}
- return SmsMessage.fragmentText(text);
+ return SmsMessage.fragmentText(text, getSubscriptionId());
}
/**
@@ -1965,16 +1962,22 @@ public final class SmsManager {
}
/**
- * Get default sms subscription id
+ * Get default sms subscription id.
+ *
+ * <p class="note"><strong>Note:</strong>This returns a value different from
+ * {@link SubscriptionManager#getDefaultSmsSubscriptionId} if the user has not chosen a default.
+ * In this case it returns the active subscription id if there's only one active subscription
+ * available.
*
- * @return the user-defined default SMS subscription id or
- * {@link SubscriptionManager#INVALID_SUBSCRIPTION_ID} if no default is set.
+ * @return the user-defined default SMS subscription id, or the active subscription id if
+ * there's only one active subscription available, otherwise
+ * {@link SubscriptionManager#INVALID_SUBSCRIPTION_ID}.
*/
public static int getDefaultSmsSubscriptionId() {
try {
- return SubscriptionManager.getDefaultSmsSubscriptionId();
- } catch (NullPointerException ex) {
- return -1;
+ return getISmsServiceOrThrow().getPreferredSmsSubscription();
+ } catch (RemoteException e) {
+ return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
}
}
diff --git a/telephony/java/android/telephony/SmsMessage.java b/telephony/java/android/telephony/SmsMessage.java
index 2aa4768d3f00..7d4bcb740f61 100644
--- a/telephony/java/android/telephony/SmsMessage.java
+++ b/telephony/java/android/telephony/SmsMessage.java
@@ -337,27 +337,45 @@ public class SmsMessage {
*/
/**
- * Calculates the number of SMS's required to encode the message body and
- * the number of characters remaining until the next message.
+ * Calculates the number of SMS's required to encode the message body and the number of
+ * characters remaining until the next message.
*
* @param msgBody the message to encode
- * @param use7bitOnly if true, characters that are not part of the
- * radio-specific 7-bit encoding are counted as single
- * space chars. If false, and if the messageBody contains
- * non-7-bit encodable characters, length is calculated
- * using a 16-bit encoding.
- * @return an int[4] with int[0] being the number of SMS's
- * required, int[1] the number of code units used, and
- * int[2] is the number of code units remaining until the
- * next message. int[3] is an indicator of the encoding
- * code unit size (see the ENCODING_* definitions in SmsConstants)
+ * @param use7bitOnly if true, characters that are not part of the radio-specific 7-bit encoding
+ * are counted as single space chars. If false, and if the messageBody contains non-7-bit
+ * encodable characters, length is calculated using a 16-bit encoding.
+ * @return an int[4] with int[0] being the number of SMS's required, int[1] the number of code
+ * units used, and int[2] is the number of code units remaining until the next message.
+ * int[3] is an indicator of the encoding code unit size (see the ENCODING_* definitions in
+ * SmsConstants).
*/
public static int[] calculateLength(CharSequence msgBody, boolean use7bitOnly) {
+ return calculateLength(msgBody, use7bitOnly, SmsManager.getDefaultSmsSubscriptionId());
+ }
+
+ /**
+ * Calculates the number of SMS's required to encode the message body and the number of
+ * characters remaining until the next message.
+ *
+ * @param msgBody the message to encode
+ * @param use7bitOnly if true, characters that are not part of the radio-specific 7-bit encoding
+ * are counted as single space chars. If false, and if the messageBody contains non-7-bit
+ * encodable characters, length is calculated using a 16-bit encoding.
+ * @param subId Subscription to take SMS format.
+ * @return an int[4] with int[0] being the number of SMS's required, int[1] the number of code
+ * units used, and int[2] is the number of code units remaining until the next message.
+ * int[3] is an indicator of the encoding code unit size (see the ENCODING_* definitions in
+ * SmsConstants).
+ * @hide
+ */
+ public static int[] calculateLength(CharSequence msgBody, boolean use7bitOnly, int subId) {
// this function is for MO SMS
- TextEncodingDetails ted = (useCdmaFormatForMoSms()) ?
- com.android.internal.telephony.cdma.SmsMessage.calculateLength(msgBody, use7bitOnly,
- true) :
- com.android.internal.telephony.gsm.SmsMessage.calculateLength(msgBody, use7bitOnly);
+ TextEncodingDetails ted =
+ useCdmaFormatForMoSms(subId)
+ ? com.android.internal.telephony.cdma.SmsMessage.calculateLength(
+ msgBody, use7bitOnly, true)
+ : com.android.internal.telephony.gsm.SmsMessage.calculateLength(
+ msgBody, use7bitOnly);
int ret[] = new int[4];
ret[0] = ted.msgCount;
ret[1] = ted.codeUnitCount;
@@ -367,21 +385,37 @@ public class SmsMessage {
}
/**
- * Divide a message text into several fragments, none bigger than
- * the maximum SMS message text size.
+ * Divide a message text into several fragments, none bigger than the maximum SMS message text
+ * size.
*
* @param text text, must not be null.
- * @return an <code>ArrayList</code> of strings that, in order,
- * comprise the original msg text
- *
+ * @return an <code>ArrayList</code> of strings that, in order, comprise the original msg text.
* @hide
*/
@UnsupportedAppUsage
public static ArrayList<String> fragmentText(String text) {
+ return fragmentText(text, SmsManager.getDefaultSmsSubscriptionId());
+ }
+
+ /**
+ * Divide a message text into several fragments, none bigger than the maximum SMS message text
+ * size.
+ *
+ * @param text text, must not be null.
+ * @param subId Subscription to take SMS format.
+ * @return an <code>ArrayList</code> of strings that, in order, comprise the original msg text.
+ * @hide
+ */
+ public static ArrayList<String> fragmentText(String text, int subId) {
// This function is for MO SMS
- TextEncodingDetails ted = (useCdmaFormatForMoSms()) ?
- com.android.internal.telephony.cdma.SmsMessage.calculateLength(text, false, true) :
- com.android.internal.telephony.gsm.SmsMessage.calculateLength(text, false);
+ final boolean isCdma = useCdmaFormatForMoSms(subId);
+
+ TextEncodingDetails ted =
+ isCdma
+ ? com.android.internal.telephony.cdma.SmsMessage.calculateLength(
+ text, false, true)
+ : com.android.internal.telephony.gsm.SmsMessage.calculateLength(
+ text, false);
// TODO(cleanup): The code here could be rolled into the logic
// below cleanly if these MAX_* constants were defined more
@@ -427,18 +461,19 @@ public class SmsMessage {
String newMsgBody = null;
Resources r = Resources.getSystem();
if (r.getBoolean(com.android.internal.R.bool.config_sms_force_7bit_encoding)) {
- newMsgBody = Sms7BitEncodingTranslator.translate(text);
+ newMsgBody = Sms7BitEncodingTranslator.translate(text, isCdma);
}
if (TextUtils.isEmpty(newMsgBody)) {
newMsgBody = text;
}
+
int pos = 0; // Index in code units.
int textLen = newMsgBody.length();
ArrayList<String> result = new ArrayList<String>(ted.msgCount);
while (pos < textLen) {
int nextPos = 0; // Counts code units.
if (ted.codeUnitSize == SmsConstants.ENCODING_7BIT) {
- if (useCdmaFormatForMoSms() && ted.msgCount == 1) {
+ if (isCdma && ted.msgCount == 1) {
// For a singleton CDMA message, the encoding must be ASCII...
nextPos = pos + Math.min(limit, textLen - pos);
} else {
@@ -461,25 +496,39 @@ public class SmsMessage {
}
/**
- * Calculates the number of SMS's required to encode the message body and
- * the number of characters remaining until the next message, given the
- * current encoding.
+ * Calculates the number of SMS's required to encode the message body and the number of
+ * characters remaining until the next message, given the current encoding.
*
* @param messageBody the message to encode
- * @param use7bitOnly if true, characters that are not part of the radio
- * specific (GSM / CDMA) alphabet encoding are converted to as a
- * single space characters. If false, a messageBody containing
- * non-GSM or non-CDMA alphabet characters are encoded using
- * 16-bit encoding.
- * @return an int[4] with int[0] being the number of SMS's required, int[1]
- * the number of code units used, and int[2] is the number of code
- * units remaining until the next message. int[3] is the encoding
- * type that should be used for the message.
+ * @param use7bitOnly if true, characters that are not part of the radio specific (GSM / CDMA)
+ * alphabet encoding are converted to as a single space characters. If false, a messageBody
+ * containing non-GSM or non-CDMA alphabet characters are encoded using 16-bit encoding.
+ * @return an int[4] with int[0] being the number of SMS's required, int[1] the number of code
+ * units used, and int[2] is the number of code units remaining until the next message.
+ * int[3] is the encoding type that should be used for the message.
*/
public static int[] calculateLength(String messageBody, boolean use7bitOnly) {
return calculateLength((CharSequence)messageBody, use7bitOnly);
}
+ /**
+ * Calculates the number of SMS's required to encode the message body and the number of
+ * characters remaining until the next message, given the current encoding.
+ *
+ * @param messageBody the message to encode
+ * @param use7bitOnly if true, characters that are not part of the radio specific (GSM / CDMA)
+ * alphabet encoding are converted to as a single space characters. If false, a messageBody
+ * containing non-GSM or non-CDMA alphabet characters are encoded using 16-bit encoding.
+ * @param subId Subscription to take SMS format.
+ * @return an int[4] with int[0] being the number of SMS's required, int[1] the number of code
+ * units used, and int[2] is the number of code units remaining until the next message.
+ * int[3] is the encoding type that should be used for the message.
+ * @hide
+ */
+ public static int[] calculateLength(String messageBody, boolean use7bitOnly, int subId) {
+ return calculateLength((CharSequence) messageBody, use7bitOnly, subId);
+ }
+
/*
* TODO(cleanup): It looks like there is now no useful reason why
* apps should generate pdus themselves using these routines,
@@ -510,8 +559,12 @@ public class SmsMessage {
*/
public static SubmitPdu getSubmitPdu(String scAddress,
String destinationAddress, String message, boolean statusReportRequested) {
- return getSubmitPdu(scAddress, destinationAddress, message, statusReportRequested,
- SubscriptionManager.getDefaultSmsSubscriptionId());
+ return getSubmitPdu(
+ scAddress,
+ destinationAddress,
+ message,
+ statusReportRequested,
+ SmsManager.getDefaultSmsSubscriptionId());
}
/**
@@ -834,7 +887,7 @@ public class SmsMessage {
@UnsupportedAppUsage
private static boolean useCdmaFormatForMoSms() {
// IMS is registered with SMS support, check the SMS format supported
- return useCdmaFormatForMoSms(SubscriptionManager.getDefaultSmsSubscriptionId());
+ return useCdmaFormatForMoSms(SmsManager.getDefaultSmsSubscriptionId());
}
/**
@@ -863,7 +916,7 @@ public class SmsMessage {
* @return true if current phone type is cdma, false otherwise.
*/
private static boolean isCdmaVoice() {
- return isCdmaVoice(SubscriptionManager.getDefaultSmsSubscriptionId());
+ return isCdmaVoice(SmsManager.getDefaultSmsSubscriptionId());
}
/**
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 4a58d949ea82..6f3e97a87bb1 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -5247,7 +5247,7 @@ public class TelephonyManager {
*/
public String getMmsUserAgent() {
if (mContext == null) return null;
- return mContext.getResources().getString(
+ return SubscriptionManager.getResourcesForSubId(mContext, getSubId()).getString(
com.android.internal.R.string.config_mms_user_agent);
}
@@ -5256,7 +5256,7 @@ public class TelephonyManager {
*/
public String getMmsUAProfUrl() {
if (mContext == null) return null;
- return mContext.getResources().getString(
+ return SubscriptionManager.getResourcesForSubId(mContext, getSubId()).getString(
com.android.internal.R.string.config_mms_user_agent_profile_url);
}
diff --git a/telephony/java/com/android/internal/telephony/GsmAlphabet.java b/telephony/java/com/android/internal/telephony/GsmAlphabet.java
index a774cdc8a280..87975897bc02 100644
--- a/telephony/java/com/android/internal/telephony/GsmAlphabet.java
+++ b/telephony/java/com/android/internal/telephony/GsmAlphabet.java
@@ -16,19 +16,17 @@
package com.android.internal.telephony;
+import android.annotation.UnsupportedAppUsage;
import android.content.res.Resources;
+import android.os.Build;
+import android.telephony.Rlog;
import android.text.TextUtils;
import android.util.SparseIntArray;
-import android.annotation.UnsupportedAppUsage;
-import android.os.Build;
-import android.telephony.Rlog;
+import com.android.internal.R;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
-import com.android.internal.telephony.SmsConstants;
-import com.android.internal.R;
-
import java.util.ArrayList;
import java.util.List;
@@ -868,7 +866,6 @@ public class GsmAlphabet {
ted.msgCount = 1;
ted.codeUnitsRemaining = SmsConstants.MAX_USER_DATA_SEPTETS - septets;
}
- ted.codeUnitSize = SmsConstants.ENCODING_7BIT;
return ted;
}
diff --git a/telephony/java/com/android/internal/telephony/Sms7BitEncodingTranslator.java b/telephony/java/com/android/internal/telephony/Sms7BitEncodingTranslator.java
index 439eaeac8de1..a360c646de5c 100644
--- a/telephony/java/com/android/internal/telephony/Sms7BitEncodingTranslator.java
+++ b/telephony/java/com/android/internal/telephony/Sms7BitEncodingTranslator.java
@@ -16,19 +16,14 @@
package com.android.internal.telephony;
-import android.telephony.Rlog;
-import android.os.Build;
-import android.util.SparseIntArray;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
-import android.telephony.SmsManager;
-import android.telephony.TelephonyManager;
+import android.os.Build;
+import android.telephony.Rlog;
+import android.util.SparseIntArray;
-import com.android.internal.util.XmlUtils;
import com.android.internal.telephony.cdma.sms.UserData;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
+import com.android.internal.util.XmlUtils;
public class Sms7BitEncodingTranslator {
private static final String TAG = "Sms7BitEncodingTranslator";
@@ -47,17 +42,14 @@ public class Sms7BitEncodingTranslator {
private static final String XML_TO_TAG = "to";
/**
- * Translates each message character that is not supported by GSM 7bit
- * alphabet into a supported one
+ * Translates each message character that is not supported by GSM 7bit alphabet into a supported
+ * one.
*
- * @param message
- * message to be translated
- * @param throwsException
- * if true and some error occurs during translation, an exception
- * is thrown; otherwise a null String is returned
- * @return translated message or null if some error occur
+ * @param message message to be translated.
+ * @param isCdmaFormat true if cdma format should be used.
+ * @return translated message or null if some error occur.
*/
- public static String translate(CharSequence message) {
+ public static String translate(CharSequence message, boolean isCdmaFormat) {
if (message == null) {
Rlog.w(TAG, "Null message can not be translated");
return null;
@@ -80,7 +72,6 @@ public class Sms7BitEncodingTranslator {
(mTranslationTableGSM != null && mTranslationTableGSM.size() > 0) ||
(mTranslationTableCDMA != null && mTranslationTableCDMA.size() > 0)) {
char[] output = new char[size];
- boolean isCdmaFormat = useCdmaFormatForMoSms();
for (int i = 0; i < size; i++) {
output[i] = translateIfNeeded(message.charAt(i), isCdmaFormat);
}
@@ -159,16 +150,6 @@ public class Sms7BitEncodingTranslator {
}
}
- private static boolean useCdmaFormatForMoSms() {
- if (!SmsManager.getDefault().isImsSmsSupported()) {
- // use Voice technology to determine SMS format.
- return TelephonyManager.getDefault().getCurrentPhoneType()
- == PhoneConstants.PHONE_TYPE_CDMA;
- }
- // IMS is registered with SMS support, check the SMS format supported
- return (SmsConstants.FORMAT_3GPP2.equals(SmsManager.getDefault().getImsSmsFormat()));
- }
-
/**
* Load the whole translation table file from the framework resource
* encoded in XML.
diff --git a/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java b/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java
index a31fa0b6a725..f2ebc9808134 100644
--- a/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java
+++ b/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java
@@ -16,18 +16,18 @@
package com.android.internal.telephony.cdma;
-import android.os.Parcel;
+import android.content.res.Resources;
import android.os.SystemProperties;
import android.telephony.PhoneNumberUtils;
+import android.telephony.Rlog;
import android.telephony.SmsCbLocation;
import android.telephony.SmsCbMessage;
import android.telephony.cdma.CdmaSmsCbProgramData;
-import android.telephony.Rlog;
-import android.util.Log;
import android.text.TextUtils;
-import android.content.res.Resources;
+import android.util.Log;
import com.android.internal.telephony.GsmAlphabet.TextEncodingDetails;
+import com.android.internal.telephony.Sms7BitEncodingTranslator;
import com.android.internal.telephony.SmsAddress;
import com.android.internal.telephony.SmsConstants;
import com.android.internal.telephony.SmsHeader;
@@ -41,7 +41,6 @@ import com.android.internal.telephony.cdma.sms.UserData;
import com.android.internal.telephony.uicc.IccUtils;
import com.android.internal.util.BitwiseInputStream;
import com.android.internal.util.HexDump;
-import com.android.internal.telephony.Sms7BitEncodingTranslator;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
@@ -418,7 +417,7 @@ public class SmsMessage extends SmsMessageBase {
CharSequence newMsgBody = null;
Resources r = Resources.getSystem();
if (r.getBoolean(com.android.internal.R.bool.config_sms_force_7bit_encoding)) {
- newMsgBody = Sms7BitEncodingTranslator.translate(messageBody);
+ newMsgBody = Sms7BitEncodingTranslator.translate(messageBody, true);
}
if (TextUtils.isEmpty(newMsgBody)) {
newMsgBody = messageBody;
diff --git a/telephony/java/com/android/internal/telephony/gsm/SmsMessage.java b/telephony/java/com/android/internal/telephony/gsm/SmsMessage.java
index 19465a44e4e8..e2365710899e 100644
--- a/telephony/java/com/android/internal/telephony/gsm/SmsMessage.java
+++ b/telephony/java/com/android/internal/telephony/gsm/SmsMessage.java
@@ -16,34 +16,33 @@
package com.android.internal.telephony.gsm;
+import static com.android.internal.telephony.SmsConstants.ENCODING_16BIT;
+import static com.android.internal.telephony.SmsConstants.ENCODING_7BIT;
+import static com.android.internal.telephony.SmsConstants.ENCODING_8BIT;
+import static com.android.internal.telephony.SmsConstants.ENCODING_KSC5601;
+import static com.android.internal.telephony.SmsConstants.ENCODING_UNKNOWN;
+import static com.android.internal.telephony.SmsConstants.MAX_USER_DATA_BYTES;
+import static com.android.internal.telephony.SmsConstants.MAX_USER_DATA_SEPTETS;
+import static com.android.internal.telephony.SmsConstants.MessageClass;
+
+import android.content.res.Resources;
import android.telephony.PhoneNumberUtils;
-import android.text.format.Time;
import android.telephony.Rlog;
-import android.content.res.Resources;
import android.text.TextUtils;
+import android.text.format.Time;
import com.android.internal.telephony.EncodeException;
import com.android.internal.telephony.GsmAlphabet;
import com.android.internal.telephony.GsmAlphabet.TextEncodingDetails;
-import com.android.internal.telephony.uicc.IccUtils;
+import com.android.internal.telephony.Sms7BitEncodingTranslator;
import com.android.internal.telephony.SmsHeader;
import com.android.internal.telephony.SmsMessageBase;
-import com.android.internal.telephony.Sms7BitEncodingTranslator;
+import com.android.internal.telephony.uicc.IccUtils;
import java.io.ByteArrayOutputStream;
import java.io.UnsupportedEncodingException;
import java.text.ParseException;
-import static com.android.internal.telephony.SmsConstants.MessageClass;
-import static com.android.internal.telephony.SmsConstants.ENCODING_UNKNOWN;
-import static com.android.internal.telephony.SmsConstants.ENCODING_7BIT;
-import static com.android.internal.telephony.SmsConstants.ENCODING_8BIT;
-import static com.android.internal.telephony.SmsConstants.ENCODING_16BIT;
-import static com.android.internal.telephony.SmsConstants.ENCODING_KSC5601;
-import static com.android.internal.telephony.SmsConstants.MAX_USER_DATA_SEPTETS;
-import static com.android.internal.telephony.SmsConstants.MAX_USER_DATA_BYTES;
-import static com.android.internal.telephony.SmsConstants.MAX_USER_DATA_BYTES_WITH_HEADER;
-
/**
* A Short Message Service message.
*
@@ -914,7 +913,7 @@ public class SmsMessage extends SmsMessageBase {
CharSequence newMsgBody = null;
Resources r = Resources.getSystem();
if (r.getBoolean(com.android.internal.R.bool.config_sms_force_7bit_encoding)) {
- newMsgBody = Sms7BitEncodingTranslator.translate(msgBody);
+ newMsgBody = Sms7BitEncodingTranslator.translate(msgBody, false);
}
if (TextUtils.isEmpty(newMsgBody)) {
newMsgBody = msgBody;