Close idle connections to release RAM
Close idle connections after 30s of inactivity to release RAM.
Savings: ~1MB on marlin, 0.5MB on low-ram devices
Bug: 63398887
Test: reboot and dumpsys meminfo com.android.phone
Change-Id: I38256e224ee090f1be0e26b2c5e8451743ca8c96
diff --git a/src/com/android/providers/telephony/HbpcdLookupDatabaseHelper.java b/src/com/android/providers/telephony/HbpcdLookupDatabaseHelper.java
index ceaed4c..2debc57 100644
--- a/src/com/android/providers/telephony/HbpcdLookupDatabaseHelper.java
+++ b/src/com/android/providers/telephony/HbpcdLookupDatabaseHelper.java
@@ -86,6 +86,7 @@
private static final String DATABASE_NAME = "HbpcdLookup.db";
private static final int DATABASE_VERSION = 1;
+ private static final int IDLE_CONNECTION_TIMEOUT_MS = 30000;
// Context to access resources with
private Context mContext;
@@ -99,6 +100,8 @@
super(context, DATABASE_NAME, null, DATABASE_VERSION);
mContext = context;
+ // Memory optimization - close idle connections after 30s of inactivity
+ setIdleConnectionTimeout(IDLE_CONNECTION_TIMEOUT_MS);
}
@Override
diff --git a/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java b/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java
index 095313f..4b84fe5 100644
--- a/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java
+++ b/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java
@@ -241,14 +241,17 @@
static final String DATABASE_NAME = "mmssms.db";
static final int DATABASE_VERSION = 66;
+ private static final int IDLE_CONNECTION_TIMEOUT_MS = 30000;
+
private final Context mContext;
private LowStorageMonitor mLowStorageMonitor;
private MmsSmsDatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
-
mContext = context;
+ // Memory optimization - close idle connections after 30s of inactivity
+ setIdleConnectionTimeout(IDLE_CONNECTION_TIMEOUT_MS);
}
/**
diff --git a/src/com/android/providers/telephony/TelephonyProvider.java b/src/com/android/providers/telephony/TelephonyProvider.java
index 32e0b55..a74ceb0 100644
--- a/src/com/android/providers/telephony/TelephonyProvider.java
+++ b/src/com/android/providers/telephony/TelephonyProvider.java
@@ -115,6 +115,7 @@
public class TelephonyProvider extends ContentProvider
{
private static final String DATABASE_NAME = "telephony.db";
+ private static final int IDLE_CONNECTION_TIMEOUT_MS = 30000;
private static final boolean DBG = true;
private static final boolean VDBG = false; // STOPSHIP if true
@@ -337,6 +338,8 @@
public DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, getVersion(context));
mContext = context;
+ // Memory optimization - close idle connections after 30s of inactivity
+ setIdleConnectionTimeout(IDLE_CONNECTION_TIMEOUT_MS);
}
private static int getVersion(Context context) {