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
@@ -68,7 +68,6 @@ import com.android.messaging.sms.MmsUtils;
import com.android.messaging.ui.UIIntents;
import com.android.messaging.util.Assert;
import com.android.messaging.util.AvatarUriUtil;
import com.android.messaging.util.BugleGservices;
import com.android.messaging.util.BugleGservicesKeys;
import com.android.messaging.util.BuglePrefs;
import com.android.messaging.util.BuglePrefsKeys;
@@ -605,10 +604,9 @@ public class BugleNotifications {
// Find out the last time we dinged for this conversation
Long lastTime = sLastMessageDingTime.get(conversationId);
if (sTimeBetweenDingsMs == 0) {
sTimeBetweenDingsMs = BugleGservices.get().getInt(
BugleGservicesKeys.NOTIFICATION_TIME_BETWEEN_RINGS_SECONDS,
BugleGservicesKeys.NOTIFICATION_TIME_BETWEEN_RINGS_SECONDS_DEFAULT) *
1000;
sTimeBetweenDingsMs =
BugleGservicesKeys.NOTIFICATION_TIME_BETWEEN_RINGS_SECONDS_DEFAULT *
1000;
}
if (lastTime == null
|| SystemClock.elapsedRealtime() - lastTime > sTimeBetweenDingsMs) {
@@ -27,17 +27,13 @@ import android.database.sqlite.SQLiteQueryBuilder;
import android.database.sqlite.SQLiteStatement;
import android.util.SparseArray;
import com.android.messaging.Factory;
import com.android.messaging.R;
import com.android.messaging.util.Assert;
import com.android.messaging.util.BugleGservicesKeys;
import com.android.messaging.util.DebugUtils;
import com.android.messaging.util.LogUtil;
import com.android.messaging.util.UiUtils;
import java.util.Locale;
import java.util.Stack;
import java.util.regex.Pattern;
public class DatabaseWrapper {
private static final String TAG = LogUtil.BUGLE_DATABASE_TAG;
@@ -45,12 +41,6 @@ public class DatabaseWrapper {
private final SQLiteDatabase mDatabase;
private final Context mContext;
private final boolean mLog;
/**
* Set mExplainQueryPlanRegexp (via {@link BugleGservicesKeys#EXPLAIN_QUERY_PLAN_REGEXP}
* to regex matching queries to see query plans. For example, ".*" to show all query plans.
*/
// See
private final String mExplainQueryPlanRegexp;
private static final int sTimingThreshold = 50; // in milliseconds
public static final int INDEX_INSERT_MESSAGE_PART = 0;
@@ -77,8 +67,6 @@ public class DatabaseWrapper {
DatabaseWrapper(final Context context, final SQLiteDatabase db) {
mLog = LogUtil.isLoggable(LogUtil.BUGLE_DATABASE_PERF_TAG, LogUtil.VERBOSE);
mExplainQueryPlanRegexp = Factory.get().getBugleGservices().getString(
BugleGservicesKeys.EXPLAIN_QUERY_PLAN_REGEXP, null);
mDatabase = db;
mContext = context;
mCompiledStatements = new SparseArray<SQLiteStatement>();
@@ -96,10 +84,6 @@ public class DatabaseWrapper {
return compiled;
}
private void maybePlayDebugNoise() {
DebugUtils.maybePlayDebugNoise(mContext, DebugUtils.DEBUG_SOUND_DB_OP);
}
private static void printTiming(final long t1, final String msg) {
final int transactionDepth = sTransactionDepth.get().size();
final long t2 = System.currentTimeMillis();
@@ -190,64 +174,10 @@ public class DatabaseWrapper {
}
}
private void explainQueryPlan(final SQLiteQueryBuilder qb, final SQLiteDatabase db,
final String[] projection, final String selection,
@SuppressWarnings("unused")
final String[] queryArgs,
final String groupBy,
@SuppressWarnings("unused")
final String having,
final String sortOrder, final String limit) {
final String queryString = qb.buildQuery(
projection,
selection,
groupBy,
null/*having*/,
sortOrder,
limit);
explainQueryPlan(db, queryString, queryArgs);
}
private void explainQueryPlan(final SQLiteDatabase db, final String sql,
final String[] queryArgs) {
if (!Pattern.matches(mExplainQueryPlanRegexp, sql)) {
return;
}
final Cursor planCursor = db.rawQuery("explain query plan " + sql, queryArgs);
try {
if (planCursor != null && planCursor.moveToFirst()) {
final int detailColumn = planCursor.getColumnIndex("detail");
final StringBuilder sb = new StringBuilder();
do {
sb.append(planCursor.getString(detailColumn));
sb.append("\n");
} while (planCursor.moveToNext());
if (sb.length() > 0) {
sb.setLength(sb.length() - 1);
}
LogUtil.v(TAG, "for query " + sql + "\nplan is: "
+ sb);
}
} catch (final Exception e) {
LogUtil.w(TAG, "Query plan failed ", e);
} finally {
if (planCursor != null) {
planCursor.close();
}
}
}
public Cursor query(final String searchTable, final String[] projection,
final String selection, final String[] selectionArgs, final String groupBy,
final String having, final String orderBy, final String limit) {
if (mExplainQueryPlanRegexp != null) {
final SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setTables(searchTable);
explainQueryPlan(qb, mDatabase, projection, selection, selectionArgs,
groupBy, having, orderBy, limit);
}
maybePlayDebugNoise();
long t1 = 0;
if (mLog) {
t1 = System.currentTimeMillis();
@@ -274,11 +204,6 @@ public class DatabaseWrapper {
public Cursor query(final SQLiteQueryBuilder qb,
final String[] projection, final String selection, final String[] queryArgs,
final String groupBy, final String having, final String sortOrder, final String limit) {
if (mExplainQueryPlanRegexp != null) {
explainQueryPlan(qb, mDatabase, projection, selection, queryArgs,
groupBy, having, sortOrder, limit);
}
maybePlayDebugNoise();
long t1 = 0;
if (mLog) {
t1 = System.currentTimeMillis();
@@ -300,7 +225,6 @@ public class DatabaseWrapper {
if (mLog) {
t1 = System.currentTimeMillis();
}
maybePlayDebugNoise();
final long retval =
DatabaseUtils.queryNumEntries(mDatabase, table, selection, selectionArgs);
if (mLog){
@@ -313,14 +237,10 @@ public class DatabaseWrapper {
}
public Cursor rawQuery(final String sql, final String[] args) {
if (mExplainQueryPlanRegexp != null) {
explainQueryPlan(mDatabase, sql, args);
}
long t1 = 0;
if (mLog) {
t1 = System.currentTimeMillis();
}
maybePlayDebugNoise();
final Cursor cursor = mDatabase.rawQuery(sql, args);
if (mLog) {
printTiming(
@@ -336,7 +256,6 @@ public class DatabaseWrapper {
if (mLog) {
t1 = System.currentTimeMillis();
}
maybePlayDebugNoise();
int count = 0;
try {
count = mDatabase.update(table, values, selection, selectionArgs);
@@ -356,7 +275,6 @@ public class DatabaseWrapper {
if (mLog) {
t1 = System.currentTimeMillis();
}
maybePlayDebugNoise();
int count = 0;
try {
count = mDatabase.delete(table, whereClause, whereArgs);
@@ -378,7 +296,6 @@ public class DatabaseWrapper {
if (mLog) {
t1 = System.currentTimeMillis();
}
maybePlayDebugNoise();
long rowId = -1;
try {
rowId = mDatabase.insert(table, nullColumnHack, values);
@@ -398,7 +315,6 @@ public class DatabaseWrapper {
if (mLog) {
t1 = System.currentTimeMillis();
}
maybePlayDebugNoise();
long rowId = -1;
try {
rowId = mDatabase.replace(table, nullColumnHack, values);
@@ -421,7 +337,6 @@ public class DatabaseWrapper {
if (mLog) {
t1 = System.currentTimeMillis();
}
maybePlayDebugNoise();
try {
mDatabase.execSQL(sql, bindArgs);
} catch (SQLiteFullException ex) {
@@ -439,7 +354,6 @@ public class DatabaseWrapper {
if (mLog) {
t1 = System.currentTimeMillis();
}
maybePlayDebugNoise();
try {
mDatabase.execSQL(sql);
} catch (SQLiteFullException ex) {
@@ -457,7 +371,6 @@ public class DatabaseWrapper {
if (mLog) {
t1 = System.currentTimeMillis();
}
maybePlayDebugNoise();
final SQLiteStatement statement = mDatabase.compileStatement(sql);
int rowsUpdated = 0;
try {
@@ -51,7 +51,6 @@ import com.android.messaging.sms.MmsUtils;
import com.android.messaging.ui.UIIntents;
import com.android.messaging.util.Assert;
import com.android.messaging.util.AvatarUriUtil;
import com.android.messaging.util.BugleGservices;
import com.android.messaging.util.BugleGservicesKeys;
import com.android.messaging.util.ContentType;
import com.android.messaging.util.ConversationIdSet;
@@ -1009,13 +1008,9 @@ public abstract class MessageNotificationState extends NotificationState {
private static int getMaxMessagesInConversationNotification() {
if (!BugleNotifications.isWearCompanionAppInstalled()) {
return BugleGservices.get().getInt(
BugleGservicesKeys.MAX_MESSAGES_IN_CONVERSATION_NOTIFICATION,
BugleGservicesKeys.MAX_MESSAGES_IN_CONVERSATION_NOTIFICATION_DEFAULT);
return BugleGservicesKeys.MAX_MESSAGES_IN_CONVERSATION_NOTIFICATION_DEFAULT;
}
return BugleGservices.get().getInt(
BugleGservicesKeys.MAX_MESSAGES_IN_CONVERSATION_NOTIFICATION_WITH_WEARABLE,
BugleGservicesKeys.MAX_MESSAGES_IN_CONVERSATION_NOTIFICATION_WITH_WEARABLE_DEFAULT);
return BugleGservicesKeys.MAX_MESSAGES_IN_CONVERSATION_NOTIFICATION_WITH_WEARABLE_DEFAULT;
}
/**
@@ -452,8 +452,6 @@ public class MessagingContentProvider extends ContentProvider {
defaultSmsApp = "None";
}
writer.println("Default SMS app: " + defaultSmsApp);
// Now dump logs
LogUtil.dump(writer);
}
@Override
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +28,6 @@ import com.android.messaging.datamodel.action.SyncMessagesAction;
import com.android.messaging.datamodel.data.ParticipantData;
import com.android.messaging.sms.MmsUtils;
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.BuglePrefsKeys;
@@ -206,13 +206,11 @@ public class SyncManager {
* @return 0 if allowed to run now, else delay in ms
*/
public long delayUntilFullSync(final long startTimestamp) {
final BugleGservices bugleGservices = BugleGservices.get();
final BuglePrefs prefs = BuglePrefs.getApplicationPrefs();
final long lastFullSyncTime = prefs.getLong(BuglePrefsKeys.LAST_FULL_SYNC_TIME, -1L);
final long smsFullSyncBackoffTimeMillis = bugleGservices.getLong(
BugleGservicesKeys.SMS_FULL_SYNC_BACKOFF_TIME_MILLIS,
BugleGservicesKeys.SMS_FULL_SYNC_BACKOFF_TIME_MILLIS_DEFAULT);
final long smsFullSyncBackoffTimeMillis =
BugleGservicesKeys.SMS_FULL_SYNC_BACKOFF_TIME_MILLIS_DEFAULT;
final long noFullSyncBefore = (lastFullSyncTime < 0 ? startTimestamp :
lastFullSyncTime + smsFullSyncBackoffTimeMillis);
@@ -1,127 +0,0 @@
/*
* Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.messaging.datamodel.action;
import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.NonNull;
import com.android.messaging.Factory;
import com.android.messaging.datamodel.DatabaseHelper;
import com.android.messaging.util.DebugUtils;
import com.android.messaging.util.LogUtil;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class DumpDatabaseAction extends Action implements Parcelable {
private static final String TAG = LogUtil.BUGLE_DATAMODEL_TAG;
public static final String DUMP_NAME = "db_copy.db";
private static final int BUFFER_SIZE = 16384;
/**
* Copy the database to external storage
*/
public static void dumpDatabase() {
final DumpDatabaseAction action = new DumpDatabaseAction();
action.start();
}
private DumpDatabaseAction() {
}
@Override
protected Object executeAction() {
final Context context = Factory.get().getApplicationContext();
final String dbName = DatabaseHelper.DATABASE_NAME;
BufferedOutputStream bos = null;
BufferedInputStream bis = null;
long originalSize = 0;
final File inFile = context.getDatabasePath(dbName);
if (inFile.exists() && inFile.isFile()) {
originalSize = inFile.length();
}
final File outFile = DebugUtils.getDebugFile(DUMP_NAME, true);
if (outFile != null) {
int totalBytes = 0;
try {
bos = new BufferedOutputStream(new FileOutputStream(outFile));
bis = new BufferedInputStream(new FileInputStream(inFile));
final byte[] buffer = new byte[BUFFER_SIZE];
int bytesRead;
while ((bytesRead = bis.read(buffer)) > 0) {
bos.write(buffer, 0, bytesRead);
totalBytes += bytesRead;
}
} catch (final IOException e) {
LogUtil.w(TAG, "Exception copying the database;"
+ " destination may not be complete.", e);
} finally {
if (bos != null) {
try {
bos.close();
} catch (final IOException e) {
// Nothing to do
}
}
if (bis != null) {
try {
bis.close();
} catch (final IOException e) {
// Nothing to do
}
}
DebugUtils.ensureReadable(outFile);
LogUtil.i(TAG, "Dump complete; orig size: " + originalSize +
", copy size: " + totalBytes);
}
}
return null;
}
private DumpDatabaseAction(final Parcel in) {
super(in);
}
public static final Parcelable.Creator<DumpDatabaseAction> CREATOR
= new Parcelable.Creator<DumpDatabaseAction>() {
@Override
public DumpDatabaseAction createFromParcel(final Parcel in) {
return new DumpDatabaseAction(in);
}
@Override
public DumpDatabaseAction[] newArray(final int size) {
return new DumpDatabaseAction[size];
}
};
@Override
public void writeToParcel(@NonNull final Parcel parcel, final int flags) {
writeActionToParcel(parcel, flags);
}
}
@@ -1,156 +0,0 @@
/*
* Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.messaging.datamodel.action;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import android.provider.Telephony.Threads;
import android.provider.Telephony.ThreadsColumns;
import androidx.annotation.NonNull;
import com.android.messaging.Factory;
import com.android.messaging.mmslib.SqliteWrapper;
import com.android.messaging.util.DebugUtils;
import com.android.messaging.util.LogUtil;
public class LogTelephonyDatabaseAction extends Action implements Parcelable {
// Because we use sanitizePII, we should also use BUGLE_TAG
private static final String TAG = LogUtil.BUGLE_TAG;
private static final String[] ALL_THREADS_PROJECTION = {
Threads._ID,
Threads.DATE,
Threads.MESSAGE_COUNT,
Threads.RECIPIENT_IDS,
Threads.SNIPPET,
Threads.SNIPPET_CHARSET,
Threads.READ,
Threads.ERROR,
Threads.HAS_ATTACHMENT };
// Constants from the Telephony Database
private static final int ID = 0;
private static final int DATE = 1;
private static final int MESSAGE_COUNT = 2;
private static final int RECIPIENT_IDS = 3;
private static final int SNIPPET = 4;
private static final int SNIPPET_CHAR_SET = 5;
private static final int READ = 6;
private static final int ERROR = 7;
private static final int HAS_ATTACHMENT = 8;
/**
* Log telephony data to logcat
*/
public static void dumpDatabase() {
final LogTelephonyDatabaseAction action = new LogTelephonyDatabaseAction();
action.start();
}
private LogTelephonyDatabaseAction() {
}
@Override
protected Object executeAction() {
final Context context = Factory.get().getApplicationContext();
if (!DebugUtils.isDebugEnabled()) {
LogUtil.e(TAG, "Can't log telephony database unless debugging is enabled");
return null;
}
if (!LogUtil.isLoggable(TAG, LogUtil.DEBUG)) {
LogUtil.w(TAG, "Can't log telephony database unless DEBUG is turned on for TAG: " +
TAG);
return null;
}
LogUtil.d(TAG, "\n");
LogUtil.d(TAG, "Dump of canoncial_addresses table");
LogUtil.d(TAG, "*********************************");
Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(),
Uri.parse("content://mms-sms/canonical-addresses"), null, null, null, null);
if (cursor == null) {
LogUtil.w(TAG, "null Cursor in content://mms-sms/canonical-addresses");
} else {
try {
while (cursor.moveToNext()) {
long id = cursor.getLong(0);
String number = cursor.getString(1);
LogUtil.d(TAG, LogUtil.sanitizePII("id: " + id + " number: " + number));
}
} finally {
cursor.close();
}
}
LogUtil.d(TAG, "\n");
LogUtil.d(TAG, "Dump of threads table");
LogUtil.d(TAG, "*********************");
cursor = SqliteWrapper.query(context, context.getContentResolver(),
Threads.CONTENT_URI.buildUpon().appendQueryParameter("simple", "true").build(),
ALL_THREADS_PROJECTION, null, null, "date ASC");
try {
while (cursor.moveToNext()) {
LogUtil.d(TAG, LogUtil.sanitizePII("threadId: " + cursor.getLong(ID) +
" " + ThreadsColumns.DATE + " : " + cursor.getLong(DATE) +
" " + ThreadsColumns.MESSAGE_COUNT + " : " + cursor.getInt(MESSAGE_COUNT) +
" " + ThreadsColumns.SNIPPET + " : " + cursor.getString(SNIPPET) +
" " + ThreadsColumns.READ + " : " + cursor.getInt(READ) +
" " + ThreadsColumns.ERROR + " : " + cursor.getInt(ERROR) +
" " + ThreadsColumns.HAS_ATTACHMENT + " : " +
cursor.getInt(HAS_ATTACHMENT) +
" " + ThreadsColumns.RECIPIENT_IDS + " : " +
cursor.getString(RECIPIENT_IDS)));
}
} finally {
cursor.close();
}
return null;
}
private LogTelephonyDatabaseAction(final Parcel in) {
super(in);
}
public static final Parcelable.Creator<LogTelephonyDatabaseAction> CREATOR
= new Parcelable.Creator<LogTelephonyDatabaseAction>() {
@Override
public LogTelephonyDatabaseAction createFromParcel(final Parcel in) {
return new LogTelephonyDatabaseAction(in);
}
@Override
public LogTelephonyDatabaseAction[] newArray(final int size) {
return new LogTelephonyDatabaseAction[size];
}
};
@Override
public void writeToParcel(@NonNull final Parcel parcel, final int flags) {
writeActionToParcel(parcel, flags);
}
}
@@ -271,9 +271,6 @@ public class ProcessDownloadedMmsAction extends Action {
if (downloadedData != null) {
final RetrieveConf retrieveConf =
MmsSender.parseRetrieveConf(downloadedData, subId);
if (MmsUtils.isDumpMmsEnabled()) {
MmsUtils.dumpPdu(downloadedData, retrieveConf);
}
if (retrieveConf != null) {
// Insert the downloaded MMS into telephony
final Uri notificationUri = actionParameters.getParcelable(
@@ -35,7 +35,6 @@ import com.android.messaging.datamodel.DatabaseWrapper;
import com.android.messaging.datamodel.MessagingContentProvider;
import com.android.messaging.datamodel.data.MessageData;
import com.android.messaging.datamodel.data.ParticipantData;
import com.android.messaging.util.BugleGservices;
import com.android.messaging.util.BugleGservicesKeys;
import com.android.messaging.util.BuglePrefs;
import com.android.messaging.util.BuglePrefsKeys;
@@ -153,12 +152,8 @@ public class ProcessPendingMessagesAction extends Action implements Parcelable {
final ProcessPendingMessagesAction action = new ProcessPendingMessagesAction();
action.actionParameters.putInt(KEY_SUB_ID, subId);
final long initialBackoffMs = BugleGservices.get().getLong(
BugleGservicesKeys.INITIAL_MESSAGE_RESEND_DELAY_MS,
BugleGservicesKeys.INITIAL_MESSAGE_RESEND_DELAY_MS_DEFAULT);
final long maxDelayMs = BugleGservices.get().getLong(
BugleGservicesKeys.MAX_MESSAGE_RESEND_DELAY_MS,
BugleGservicesKeys.MAX_MESSAGE_RESEND_DELAY_MS_DEFAULT);
final long initialBackoffMs = BugleGservicesKeys.INITIAL_MESSAGE_RESEND_DELAY_MS_DEFAULT;
final long maxDelayMs = BugleGservicesKeys.MAX_MESSAGE_RESEND_DELAY_MS_DEFAULT;
long delayMs;
long nextDelayMs = initialBackoffMs;
do {
@@ -43,7 +43,6 @@ import com.android.messaging.sms.DatabaseMessages.MmsMessage;
import com.android.messaging.sms.DatabaseMessages.SmsMessage;
import com.android.messaging.sms.MmsUtils;
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.BuglePrefsKeys;
@@ -76,10 +75,8 @@ public class SyncMessagesAction extends Action implements Parcelable {
* Start a full sync (backed off a few seconds to avoid pulling sending/receiving messages).
*/
public static void fullSync() {
final BugleGservices bugleGservices = BugleGservices.get();
final long smsSyncBackoffTimeMillis = bugleGservices.getLong(
BugleGservicesKeys.SMS_SYNC_BACKOFF_TIME_MILLIS,
BugleGservicesKeys.SMS_SYNC_BACKOFF_TIME_MILLIS_DEFAULT);
final long smsSyncBackoffTimeMillis =
BugleGservicesKeys.SMS_SYNC_BACKOFF_TIME_MILLIS_DEFAULT;
final long now = System.currentTimeMillis();
// TODO: Could base this off most recent message in db but now should be okay...
@@ -94,10 +91,8 @@ public class SyncMessagesAction extends Action implements Parcelable {
* Start an incremental sync to pull messages since last sync (backed off a few seconds)..
*/
public static void sync() {
final BugleGservices bugleGservices = BugleGservices.get();
final long smsSyncBackoffTimeMillis = bugleGservices.getLong(
BugleGservicesKeys.SMS_SYNC_BACKOFF_TIME_MILLIS,
BugleGservicesKeys.SMS_SYNC_BACKOFF_TIME_MILLIS_DEFAULT);
final long smsSyncBackoffTimeMillis =
BugleGservicesKeys.SMS_SYNC_BACKOFF_TIME_MILLIS_DEFAULT;
final long now = System.currentTimeMillis();
// TODO: Could base this off most recent message in db but now should be okay...
@@ -195,20 +190,16 @@ public class SyncMessagesAction extends Action implements Parcelable {
@Override
protected Bundle doBackgroundWork() {
final BugleGservices bugleGservices = BugleGservices.get();
final DatabaseWrapper db = DataModel.get().getDatabase();
final int maxMessagesToScan = bugleGservices.getInt(
BugleGservicesKeys.SMS_SYNC_BATCH_MAX_MESSAGES_TO_SCAN,
BugleGservicesKeys.SMS_SYNC_BATCH_MAX_MESSAGES_TO_SCAN_DEFAULT);
final int maxMessagesToScan =
BugleGservicesKeys.SMS_SYNC_BATCH_MAX_MESSAGES_TO_SCAN_DEFAULT;
final int initialMaxMessagesToUpdate = actionParameters.getInt(KEY_MAX_UPDATE);
final int smsSyncSubsequentBatchSizeMin = bugleGservices.getInt(
BugleGservicesKeys.SMS_SYNC_BATCH_SIZE_MIN,
BugleGservicesKeys.SMS_SYNC_BATCH_SIZE_MIN_DEFAULT);
final int smsSyncSubsequentBatchSizeMax = bugleGservices.getInt(
BugleGservicesKeys.SMS_SYNC_BATCH_SIZE_MAX,
BugleGservicesKeys.SMS_SYNC_BATCH_SIZE_MAX_DEFAULT);
final int smsSyncSubsequentBatchSizeMin =
BugleGservicesKeys.SMS_SYNC_BATCH_SIZE_MIN_DEFAULT;
final int smsSyncSubsequentBatchSizeMax =
BugleGservicesKeys.SMS_SYNC_BATCH_SIZE_MAX_DEFAULT;
// Cap sync size to GServices limits
final int maxMessagesToUpdate = Math.max(smsSyncSubsequentBatchSizeMin,
@@ -512,10 +503,8 @@ public class SyncMessagesAction extends Action implements Parcelable {
* @return Target number of messages to sync for next batch
*/
private static int nextBatchSize(final int messagesUpdated, final long txnTimeMillis) {
final BugleGservices bugleGservices = BugleGservices.get();
final long smsSyncSubsequentBatchTimeLimitMillis = bugleGservices.getLong(
BugleGservicesKeys.SMS_SYNC_BATCH_TIME_LIMIT_MILLIS,
BugleGservicesKeys.SMS_SYNC_BATCH_TIME_LIMIT_MILLIS_DEFAULT);
final long smsSyncSubsequentBatchTimeLimitMillis =
BugleGservicesKeys.SMS_SYNC_BATCH_TIME_LIMIT_MILLIS_DEFAULT;
if (txnTimeMillis <= 0) {
return 0;
@@ -30,7 +30,6 @@ import com.android.messaging.datamodel.DatabaseHelper.MessageColumns;
import com.android.messaging.datamodel.DatabaseHelper.PartColumns;
import com.android.messaging.datamodel.DatabaseHelper.ParticipantColumns;
import com.android.messaging.util.Assert;
import com.android.messaging.util.BugleGservices;
import com.android.messaging.util.BugleGservicesKeys;
import com.android.messaging.util.ContentType;
import com.android.messaging.util.Dates;
@@ -396,9 +395,7 @@ public class ConversationMessageData {
if (!TextUtils.isEmpty(firstTextPart)) {
sb.append(firstTextPart);
}
separator = BugleGservices.get().getString(
BugleGservicesKeys.MMS_TEXT_CONCAT_SEPARATOR,
BugleGservicesKeys.MMS_TEXT_CONCAT_SEPARATOR_DEFAULT);
separator = BugleGservicesKeys.MMS_TEXT_CONCAT_SEPARATOR_DEFAULT;
}
final String partText = part.getText();
if (!TextUtils.isEmpty(partText)) {
@@ -34,7 +34,6 @@ import com.android.messaging.sms.MmsUtils;
import com.android.messaging.util.Assert;
import com.android.messaging.util.Assert.DoesNotRunOnMainThread;
import com.android.messaging.util.Assert.RunsOnMainThread;
import com.android.messaging.util.BugleGservices;
import com.android.messaging.util.BugleGservicesKeys;
import com.android.messaging.util.LogUtil;
import com.android.messaging.util.PhoneUtils;
@@ -471,9 +470,7 @@ public class DraftMessageData extends BindableData implements ReadDraftDataActio
}
private int getAttachmentLimit() {
return BugleGservices.get().getInt(
BugleGservicesKeys.MMS_ATTACHMENT_LIMIT,
BugleGservicesKeys.MMS_ATTACHMENT_LIMIT_DEFAULT);
return BugleGservicesKeys.MMS_ATTACHMENT_LIMIT_DEFAULT;
}
public void removeAttachment(final MessagePartData attachment) {
@@ -32,10 +32,8 @@ import com.android.messaging.datamodel.DatabaseHelper.MessageColumns;
import com.android.messaging.datamodel.DatabaseWrapper;
import com.android.messaging.sms.MmsUtils;
import com.android.messaging.util.Assert;
import com.android.messaging.util.BugleGservices;
import com.android.messaging.util.BugleGservicesKeys;
import com.android.messaging.util.Dates;
import com.android.messaging.util.DebugUtils;
import com.android.messaging.util.OsUtil;
import java.util.ArrayList;
@@ -564,17 +562,13 @@ public class MessageData implements Parcelable {
}
public final boolean getInResendWindow(final long now) {
final long maxAgeToResend = BugleGservices.get().getLong(
BugleGservicesKeys.MESSAGE_RESEND_TIMEOUT_MS,
BugleGservicesKeys.MESSAGE_RESEND_TIMEOUT_MS_DEFAULT);
final long maxAgeToResend = BugleGservicesKeys.MESSAGE_RESEND_TIMEOUT_MS_DEFAULT;
final long age = now - mRetryStartTimestamp;
return age < maxAgeToResend;
}
public final boolean getInDownloadWindow(final long now) {
final long maxAgeToRedownload = BugleGservices.get().getLong(
BugleGservicesKeys.MESSAGE_DOWNLOAD_TIMEOUT_MS,
BugleGservicesKeys.MESSAGE_DOWNLOAD_TIMEOUT_MS_DEFAULT);
final long maxAgeToRedownload = BugleGservicesKeys.MESSAGE_DOWNLOAD_TIMEOUT_MS_DEFAULT;
final long age = now - mRetryStartTimestamp;
return age < maxAgeToRedownload;
}
@@ -586,11 +580,9 @@ public class MessageData implements Parcelable {
return false;
}
// Should show option for manual download if status is manual download or failed
// If debug is enabled, allow to download an expired or unavailable message.
return (status == BUGLE_STATUS_INCOMING_DOWNLOAD_FAILED ||
status == BUGLE_STATUS_INCOMING_YET_TO_MANUAL_DOWNLOAD ||
// If debug is enabled, allow to download an expired or unavailable message.
(DebugUtils.isDebugEnabled()
&& status == BUGLE_STATUS_INCOMING_EXPIRED_OR_NOT_AVAILABLE));
status == BUGLE_STATUS_INCOMING_YET_TO_MANUAL_DOWNLOAD);
}
public boolean canDownloadMessage() {
@@ -611,11 +603,9 @@ public class MessageData implements Parcelable {
return false;
}
// Can redownload if status is manual download not started or download failed
// If debug is enabled, allow to download an expired or unavailable message.
return (mStatus == BUGLE_STATUS_INCOMING_DOWNLOAD_FAILED ||
mStatus == BUGLE_STATUS_INCOMING_YET_TO_MANUAL_DOWNLOAD ||
// If debug is enabled, allow to download an expired or unavailable message.
(DebugUtils.isDebugEnabled()
&& mStatus == BUGLE_STATUS_INCOMING_EXPIRED_OR_NOT_AVAILABLE));
mStatus == BUGLE_STATUS_INCOMING_YET_TO_MANUAL_DOWNLOAD);
}
static boolean getShowResendMessage(final int status) {