Messaging: Remove GServices

We don't have an actual implementation returning anything but the
defaults, so apply the defaults directly anywhere we need them

Change-Id: Ic651b4b13977799f2f4d2c702c430798fbff77f8
This commit is contained in:
Michael W
2024-12-26 14:55:12 +01:00
parent 7f22a3eea7
commit a2f67b4f7b
64 changed files with 91 additions and 3763 deletions
@@ -31,8 +31,6 @@ import android.util.SparseArray;
import com.android.messaging.datamodel.data.ParticipantData;
import com.android.messaging.mmslib.SqliteWrapper;
import com.android.messaging.util.BugleGservices;
import com.android.messaging.util.BugleGservicesKeys;
import com.android.messaging.util.LogUtil;
import com.android.messaging.util.PhoneUtils;
@@ -336,11 +334,6 @@ public class BugleApnSettingsLoader implements ApnSettingsLoader {
}
private void loadLocked(final int subId, final String apnName, final List<Apn> apns) {
// Try Gservices first
loadFromGservices(apns);
if (apns.size() > 0) {
return;
}
// Try system APN table
loadFromSystem(subId, apnName, apns);
if (apns.size() > 0) {
@@ -353,26 +346,6 @@ public class BugleApnSettingsLoader implements ApnSettingsLoader {
}
}
/**
* Load from Gservices if APN setting is set in Gservices
*
* @param apns the list used to return results
*/
private void loadFromGservices(final List<Apn> apns) {
final BugleGservices gservices = BugleGservices.get();
final String mmsc = gservices.getString(BugleGservicesKeys.MMS_MMSC, null);
if (TextUtils.isEmpty(mmsc)) {
return;
}
LogUtil.i(LogUtil.BUGLE_TAG, "Loading APNs from gservices");
final String proxy = gservices.getString(BugleGservicesKeys.MMS_PROXY_ADDRESS, null);
final int port = gservices.getInt(BugleGservicesKeys.MMS_PROXY_PORT, -1);
final Apn apn = BaseApn.from("mms", mmsc, proxy, Integer.toString(port));
if (apn != null) {
apns.add(apn);
}
}
/**
* Load matching APNs from telephony provider.
* We try different combinations of the query to work around some platform quirks.
@@ -22,7 +22,6 @@ import android.support.v7.mms.UserAgentInfoLoader;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import com.android.messaging.util.BugleGservices;
import com.android.messaging.util.BugleGservicesKeys;
import com.android.messaging.util.LogUtil;
import com.android.messaging.util.VersionUtil;
@@ -86,9 +85,7 @@ public class BugleUserAgentInfoLoader implements UserAgentInfoLoader {
}
// if the UAProfUrl isn't set, get it from Gservices
if (TextUtils.isEmpty(mUAProfUrl)) {
mUAProfUrl = BugleGservices.get().getString(
BugleGservicesKeys.MMS_UA_PROFILE_URL,
BugleGservicesKeys.MMS_UA_PROFILE_URL_DEFAULT);
mUAProfUrl = BugleGservicesKeys.MMS_UA_PROFILE_URL_DEFAULT;
}
}
}
+24 -79
View File
@@ -67,7 +67,6 @@ import com.android.messaging.mmslib.pdu.SendConf;
import com.android.messaging.mmslib.pdu.SendReq;
import com.android.messaging.sms.SmsSender.SendResult;
import com.android.messaging.util.Assert;
import com.android.messaging.util.BugleGservices;
import com.android.messaging.util.BugleGservicesKeys;
import com.android.messaging.util.BuglePrefs;
import com.android.messaging.util.ContentType;
@@ -1538,44 +1537,6 @@ public class MmsUtils {
sUseSystemApn = turnOn;
}
/**
* Checks if we should dump sms, based on both the setting and the global debug
* flag
*
* @return if dump sms is enabled
*/
public static boolean isDumpSmsEnabled() {
if (!DebugUtils.isDebugEnabled()) {
return false;
}
return getDumpSmsOrMmsPref(R.string.dump_sms_pref_key, R.bool.dump_sms_pref_default);
}
/**
* Checks if we should dump mms, based on both the setting and the global debug
* flag
*
* @return if dump mms is enabled
*/
public static boolean isDumpMmsEnabled() {
if (!DebugUtils.isDebugEnabled()) {
return false;
}
return getDumpSmsOrMmsPref(R.string.dump_mms_pref_key, R.bool.dump_mms_pref_default);
}
/**
* Load the value of dump sms or mms setting preference
*/
private static boolean getDumpSmsOrMmsPref(final int prefKeyRes, final int defaultKeyRes) {
final Context context = Factory.get().getApplicationContext();
final Resources resources = context.getResources();
final BuglePrefs prefs = BuglePrefs.getApplicationPrefs();
final String key = resources.getString(prefKeyRes);
final boolean defaultValue = resources.getBoolean(defaultKeyRes);
return prefs.getBoolean(key, defaultValue);
}
public static final Uri MMS_PART_CONTENT_URI = Uri.parse("content://mms/part");
/**
@@ -1731,9 +1692,7 @@ public class MmsUtils {
public static MessagePartData createMmsMessagePart(final DatabaseMessages.MmsPart part) {
MessagePartData messagePart = null;
if (part.isText()) {
final int mmsTextLengthLimit =
BugleGservices.get().getInt(BugleGservicesKeys.MMS_TEXT_LIMIT,
BugleGservicesKeys.MMS_TEXT_LIMIT_DEFAULT);
final int mmsTextLengthLimit = BugleGservicesKeys.MMS_TEXT_LIMIT_DEFAULT;
String text = part.mText;
if (text != null && text.length() > mmsTextLengthLimit) {
// Limit the text to a reasonable value. We ran into a situation where a vcard
@@ -1806,44 +1765,30 @@ public class MmsUtils {
int status = MMS_REQUEST_MANUAL_RETRY;
try {
RetrieveConf retrieveConf = null;
if (DebugUtils.isDebugEnabled() &&
MediaScratchFileProvider
.isMediaScratchSpaceUri(Uri.parse(contentLocation))) {
if (LogUtil.isLoggable(TAG, LogUtil.DEBUG)) {
LogUtil.d(TAG, "MmsUtils: Reading MMS from dump file: " + contentLocation);
}
final String fileName = Uri.parse(contentLocation).getPathSegments().get(1);
final byte[] data = DebugUtils.receiveFromDumpFile(fileName);
retrieveConf = receiveFromDumpFile(data);
} else {
if (LogUtil.isLoggable(TAG, LogUtil.DEBUG)) {
LogUtil.d(TAG, "MmsUtils: Downloading MMS via MMS lib API; notification "
+ "message: " + notificationUri);
}
if (subId < 0) {
LogUtil.e(TAG, "MmsUtils: Incoming MMS came from unknown SIM");
throw new MmsFailureException(MMS_REQUEST_NO_RETRY,
"Message from unknown SIM");
}
if (extras == null) {
extras = new Bundle();
}
extras.putParcelable(DownloadMmsAction.EXTRA_NOTIFICATION_URI, notificationUri);
extras.putInt(DownloadMmsAction.EXTRA_SUB_ID, subId);
extras.putString(DownloadMmsAction.EXTRA_SUB_PHONE_NUMBER, subPhoneNumber);
extras.putString(DownloadMmsAction.EXTRA_TRANSACTION_ID, transactionId);
extras.putString(DownloadMmsAction.EXTRA_CONTENT_LOCATION, contentLocation);
extras.putBoolean(DownloadMmsAction.EXTRA_AUTO_DOWNLOAD, autoDownload);
extras.putLong(DownloadMmsAction.EXTRA_RECEIVED_TIMESTAMP,
receivedTimestampInSeconds);
extras.putLong(DownloadMmsAction.EXTRA_EXPIRY, expiry);
MmsSender.downloadMms(context, subId, contentLocation, extras);
return STATUS_PENDING; // Download happens asynchronously; no status to return
if (LogUtil.isLoggable(TAG, LogUtil.DEBUG)) {
LogUtil.d(TAG, "MmsUtils: Downloading MMS via MMS lib API; notification "
+ "message: " + notificationUri);
}
return insertDownloadedMessageAndSendResponse(context, notificationUri, subId,
subPhoneNumber, transactionId, contentLocation, autoDownload,
receivedTimestampInSeconds, expiry, retrieveConf);
if (subId < 0) {
LogUtil.e(TAG, "MmsUtils: Incoming MMS came from unknown SIM");
throw new MmsFailureException(MMS_REQUEST_NO_RETRY,
"Message from unknown SIM");
}
if (extras == null) {
extras = new Bundle();
}
extras.putParcelable(DownloadMmsAction.EXTRA_NOTIFICATION_URI, notificationUri);
extras.putInt(DownloadMmsAction.EXTRA_SUB_ID, subId);
extras.putString(DownloadMmsAction.EXTRA_SUB_PHONE_NUMBER, subPhoneNumber);
extras.putString(DownloadMmsAction.EXTRA_TRANSACTION_ID, transactionId);
extras.putString(DownloadMmsAction.EXTRA_CONTENT_LOCATION, contentLocation);
extras.putBoolean(DownloadMmsAction.EXTRA_AUTO_DOWNLOAD, autoDownload);
extras.putLong(DownloadMmsAction.EXTRA_RECEIVED_TIMESTAMP,
receivedTimestampInSeconds);
extras.putLong(DownloadMmsAction.EXTRA_EXPIRY, expiry);
MmsSender.downloadMms(context, subId, contentLocation, extras);
return STATUS_PENDING; // Download happens asynchronously; no status to return
} catch (final MmsFailureException e) {
LogUtil.e(TAG, "MmsUtils: failed to download message " + notificationUri, e);
+2 -4
View File
@@ -33,7 +33,6 @@ import com.android.messaging.Factory;
import com.android.messaging.R;
import com.android.messaging.receiver.SendStatusReceiver;
import com.android.messaging.util.Assert;
import com.android.messaging.util.BugleGservices;
import com.android.messaging.util.BugleGservicesKeys;
import com.android.messaging.util.LogUtil;
import com.android.messaging.util.PhoneUtils;
@@ -225,9 +224,8 @@ public class SmsSender {
context, subId, dest, messages, serviceCenter, requireDeliveryReport, messageUri);
// Wait for pending intent to come back
synchronized (pendingResult) {
final long smsSendTimeoutInMillis = BugleGservices.get().getLong(
BugleGservicesKeys.SMS_SEND_TIMEOUT_IN_MILLIS,
BugleGservicesKeys.SMS_SEND_TIMEOUT_IN_MILLIS_DEFAULT);
final long smsSendTimeoutInMillis =
BugleGservicesKeys.SMS_SEND_TIMEOUT_IN_MILLIS_DEFAULT;
final long beginTime = SystemClock.elapsedRealtime();
long waitTime = smsSendTimeoutInMillis;
// We could possibly be woken up while still pending