Messaging: Remove unused code

Change-Id: I8093bb3e305ae323f7069bf42f9e83f8c8647cc7
This commit is contained in:
Michael W
2024-12-26 15:54:37 +01:00
parent 0069df879a
commit e29b158fba
69 changed files with 42 additions and 3228 deletions
@@ -480,24 +480,4 @@ public class MmsHttpClient {
}
return null;
}
/**
* Get NAI using hidden SystemProperties.get(String)
*
* @return the NAI string as system property
*/
private static String getNaiBySystemProperty() {
try {
final Class systemPropertiesClass = Class.forName("android.os.SystemProperties");
if (systemPropertiesClass != null) {
final Method method = systemPropertiesClass.getMethod("get", String.class);
if (method != null) {
return (String) method.invoke(null, NAI_PROPERTY);
}
}
} catch (Exception e) {
Log.w(MmsService.TAG, "SystemProperties.get failed " + e);
}
return null;
}
}
@@ -36,32 +36,6 @@ public class MmsManager {
// Cached computed overrides for carrier configuration values
private static final SparseArray<Bundle> sConfigOverridesMap = new SparseArray<>();
/**
* Set the size of thread pool for request execution.
*
* Default is 4
*
* Note: if system MMS API is used, this has no effect
*
* @param size thread pool size
*/
public static void setThreadPoolSize(int size) {
MmsService.setThreadPoolSize(size);
}
/**
* Set whether to use wake lock while sending or downloading MMS.
*
* Default value is true
*
* Note: if system MMS API is used, this has no effect
*
* @param useWakeLock true to use wake lock, false otherwise
*/
public static void setUseWakeLock(final boolean useWakeLock) {
MmsService.setUseWakeLock(useWakeLock);
}
/**
* Set the optional carrier config values loader
*
@@ -98,23 +98,11 @@ abstract class MmsRequest implements Parcelable {
// Thread pool for transferring PDU with MMS apps
protected final ExecutorService mPduTransferExecutor = Executors.newCachedThreadPool();
// Whether this request should acquire wake lock
private boolean mUseWakeLock;
protected MmsRequest(final String locationUrl, final Uri pduUri,
final PendingIntent pendingIntent) {
mLocationUrl = locationUrl;
mPduUri = pduUri;
mPendingIntent = pendingIntent;
mUseWakeLock = true;
}
void setUseWakeLock(final boolean useWakeLock) {
mUseWakeLock = useWakeLock;
}
boolean getUseWakeLock() {
return mUseWakeLock;
}
/**
@@ -376,7 +364,6 @@ abstract class MmsRequest implements Parcelable {
@Override
public void writeToParcel(Parcel parcel, int flags) {
parcel.writeByte((byte) (mUseWakeLock ? 1 : 0));
parcel.writeString(mLocationUrl);
parcel.writeParcelable(mPduUri, 0);
parcel.writeParcelable(mPendingIntent, 0);
@@ -384,7 +371,6 @@ abstract class MmsRequest implements Parcelable {
protected MmsRequest(final Parcel in) {
final ClassLoader classLoader = MmsRequest.class.getClassLoader();
mUseWakeLock = in.readByte() != 0;
mLocationUrl = in.readString();
mPduUri = in.readParcelable(classLoader);
mPendingIntent = in.readParcelable(classLoader);
-104
View File
@@ -22,7 +22,6 @@ import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.IBinder;
import android.os.PowerManager;
import android.os.Process;
import android.telephony.SmsManager;
import android.util.Log;
@@ -45,20 +44,11 @@ public class MmsService extends Service {
private static final String EXTRA_REQUEST = "request";
private static final String EXTRA_MYPID = "mypid";
private static final String WAKELOCK_ID = "mmslib_wakelock";
/**
* Thread pool size for each request queue
*/
private static volatile int sThreadPoolSize = DEFAULT_THREAD_POOL_SIZE;
/**
* Optional wake lock to use
*/
private static volatile boolean sUseWakeLock = true;
private static volatile PowerManager.WakeLock sWakeLock = null;
private static final Object sWakeLockLock = new Object();
/**
* Carrier configuration values loader
*/
@@ -74,25 +64,6 @@ public class MmsService extends Service {
*/
private static volatile UserAgentInfoLoader sUserAgentInfoLoader = null;
/**
* Set the size of thread pool for request execution.
* Default is DEFAULT_THREAD_POOL_SIZE
*
* @param size thread pool size
*/
static void setThreadPoolSize(final int size) {
sThreadPoolSize = size;
}
/**
* Set whether to use wake lock
*
* @param useWakeLock true to use wake lock, false otherwise
*/
static void setUseWakeLock(final boolean useWakeLock) {
sUseWakeLock = useWakeLock;
}
/**
* Set the optional carrier config values
*
@@ -164,52 +135,6 @@ public class MmsService extends Service {
}
}
/**
* Acquire the wake lock
*
* @param context the context to use
*/
private static void acquireWakeLock(final Context context) {
synchronized (sWakeLockLock) {
if (sWakeLock == null) {
final PowerManager pm =
(PowerManager) context.getSystemService(Context.POWER_SERVICE);
sWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKELOCK_ID);
}
sWakeLock.acquire();
}
}
/**
* Release the wake lock
*/
private static void releaseWakeLock() {
boolean releasedEmptyWakeLock = false;
synchronized (sWakeLockLock) {
if (sWakeLock != null) {
sWakeLock.release();
} else {
releasedEmptyWakeLock = true;
}
}
if (releasedEmptyWakeLock) {
Log.w(TAG, "Releasing empty wake lock");
}
}
/**
* Check if wake lock is not held (e.g. when service stops)
*/
private static void verifyWakeLockNotHeld() {
boolean wakeLockHeld = false;
synchronized (sWakeLockLock) {
wakeLockHeld = sWakeLock != null && sWakeLock.isHeld();
}
if (wakeLockHeld) {
Log.e(TAG, "Wake lock still held!");
}
}
// Remember my PID to discard restarted intent
private static volatile int sMyPid = -1;
@@ -253,28 +178,6 @@ public class MmsService extends Service {
// Service stop task
private final Runnable mServiceStopRunnable = this::tryStopService;
/**
* Start the service with a request
*
* @param context the Context to use
* @param request the request to start
*/
public static void startRequest(final Context context, final MmsRequest request) {
final boolean useWakeLock = sUseWakeLock;
request.setUseWakeLock(useWakeLock);
final Intent intent = new Intent(context, MmsService.class);
intent.putExtra(EXTRA_REQUEST, request);
intent.putExtra(EXTRA_MYPID, getMyPid());
if (useWakeLock) {
acquireWakeLock(context);
}
if (context.startService(intent) == null) {
if (useWakeLock) {
releaseWakeLock();
}
}
}
@Override
public void onCreate() {
super.onCreate();
@@ -331,9 +234,6 @@ public class MmsService extends Service {
} catch (Exception e) {
Log.w(TAG, "Unexpected execution failure", e);
} finally {
if (request.getUseWakeLock()) {
releaseWakeLock();
}
releaseService();
}
});
@@ -344,9 +244,6 @@ public class MmsService extends Service {
Log.w(TAG, "Executing request failed " + e);
request.returnResult(this, SmsManager.MMS_ERROR_UNSPECIFIED,
null/*response*/, 0/*httpStatusCode*/);
if (request.getUseWakeLock()) {
releaseWakeLock();
}
}
} else {
Log.w(TAG, "Empty request");
@@ -434,7 +331,6 @@ public class MmsService extends Service {
if (stopped != null) {
if (stopped) {
Log.i(TAG, "Service successfully stopped");
verifyWakeLockNotHeld();
} else {
Log.i(TAG, "Service stopping cancelled");
}
@@ -26,7 +26,6 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
/**
* Encoded-string-value = Text-string | Value-length Char-set Text-string
@@ -224,43 +223,6 @@ public class EncodedStringValue implements Cloneable {
return ret;
}
/**
* Extract an EncodedStringValue[] from a given String.
*/
public static EncodedStringValue[] extract(String src) {
String[] values = src.split(";");
ArrayList<EncodedStringValue> list = new ArrayList<>();
for (int i = 0; i < values.length; i++) {
if (values[i].length() > 0) {
list.add(new EncodedStringValue(values[i]));
}
}
int len = list.size();
if (len > 0) {
return list.toArray(new EncodedStringValue[len]);
} else {
return null;
}
}
/**
* Concatenate an EncodedStringValue[] into a single String.
*/
public static String concat(EncodedStringValue[] addr) {
StringBuilder sb = new StringBuilder();
int maxIndex = addr.length - 1;
for (int i = 0; i <= maxIndex; i++) {
sb.append(addr[i].getString());
if (i < maxIndex) {
sb.append(";");
}
}
return sb.toString();
}
public static EncodedStringValue copy(EncodedStringValue value) {
if (value == null) {
return null;