Revert "[Mainline]Remove PhoneFactory.addLocalLog and PhoneFactory.localLog"
This reverts commit bf3c3c43792c7790dc6cc743c493d1c6eeca3401.
Reason for revert: This change was made to decouple TelephonyProvider
from telephony but that's not needed for R now. Adding local log back
to debug SMS db loss issue.
Bug: 153021568
Change-Id: I80b6c8dafe1d5b20572d40c0e730796ebe24807d
diff --git a/Android.bp b/Android.bp
index 24ea902..b5498d5 100644
--- a/Android.bp
+++ b/Android.bp
@@ -4,6 +4,7 @@
srcs: ["src/**/*.java", "proto/**/*.proto"],
platform_apis: true,
certificate: "platform",
+ libs: ["telephony-common"],
static_libs: ["android-common", "telephonyprovider-protos"],
}
diff --git a/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java b/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java
index 120bb1c..068f209 100644
--- a/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java
+++ b/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java
@@ -48,6 +48,7 @@
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.telephony.PhoneFactory;
import com.google.android.mms.pdu.EncodedStringValue;
import com.google.android.mms.pdu.PduHeaders;
@@ -293,6 +294,11 @@
// Memory optimization - close idle connections after 30s of inactivity
setIdleConnectionTimeout(IDLE_CONNECTION_TIMEOUT_MS);
setWriteAheadLoggingEnabled(false);
+ try {
+ PhoneFactory.addLocalLog(TAG, 100);
+ } catch (IllegalArgumentException e) {
+ // ignore
+ }
}
private static synchronized MmsSmsDatabaseErrorHandler getDbErrorHandler(Context context) {
@@ -551,10 +557,12 @@
private static void localLog(String logMsg) {
Log.d(TAG, logMsg);
+ PhoneFactory.localLog(TAG, logMsg);
}
private static void localLogWtf(String logMsg) {
Log.wtf(TAG, logMsg);
+ PhoneFactory.localLog(TAG, logMsg);
}
private boolean isInitialCreateDone() {
diff --git a/src/com/android/providers/telephony/TelephonyProvider.java b/src/com/android/providers/telephony/TelephonyProvider.java
index 27930dc..d16e030 100644
--- a/src/com/android/providers/telephony/TelephonyProvider.java
+++ b/src/com/android/providers/telephony/TelephonyProvider.java
@@ -114,6 +114,7 @@
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.telephony.PhoneFactory;
import com.android.internal.util.XmlUtils;
import android.service.carrier.IApnSourceService;
@@ -2642,6 +2643,12 @@
public boolean onCreate() {
mOpenHelper = new DatabaseHelper(getContext());
+ try {
+ PhoneFactory.addLocalLog(TAG, 100);
+ } catch (IllegalArgumentException e) {
+ // ignore
+ }
+
boolean isNewBuild = false;
String newBuildId = SystemProperties.get("ro.build.id", null);
if (!TextUtils.isEmpty(newBuildId)) {
@@ -2708,6 +2715,7 @@
private static void localLog(String logMsg) {
Log.d(TAG, logMsg);
+ PhoneFactory.localLog(TAG, logMsg);
}
private synchronized boolean isManagedApnEnforced() {