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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user