Merge Android U (ab/10368041)

Bug: 291102124
Merged-In: I05262c2aea17de84e1265a829c5265af8e1fbbbe
Change-Id: I4df529094ef4fce8185f6574a3c9ed870bcff80b
diff --git a/src/com/android/providers/tv/TransientRowHelper.java b/src/com/android/providers/tv/TransientRowHelper.java
index 7054a0c..c289633 100644
--- a/src/com/android/providers/tv/TransientRowHelper.java
+++ b/src/com/android/providers/tv/TransientRowHelper.java
@@ -71,11 +71,13 @@
     /**
      * Ensures that transient rows, inserted previously before current boot, are deleted.
      */
-    public synchronized void ensureOldTransientRowsDeleted() {
-        if (mTransientRowsDeleted) {
-            return;
+    public void ensureOldTransientRowsDeleted() {
+        synchronized (this) {
+            if (mTransientRowsDeleted) {
+                return;
+            }
+            mTransientRowsDeleted = true;
         }
-        mTransientRowsDeleted = true;
         if (getLastDeletionBootCount() >= getBootCount()) {
             // This can be the second execution of TvProvider after boot since system kills
             // TvProvider in low memory conditions. If this is the case, we shouldn't delete
diff --git a/src/com/android/providers/tv/TvProvider.java b/src/com/android/providers/tv/TvProvider.java
index e1d6c88..ea7bc18 100644
--- a/src/com/android/providers/tv/TvProvider.java
+++ b/src/com/android/providers/tv/TvProvider.java
@@ -818,7 +818,8 @@
 
         @VisibleForTesting
         DatabaseHelper(Context context, String databaseName, int databaseVersion) {
-            super(context, databaseName, null, databaseVersion);
+            super(context, databaseName, databaseVersion,
+                new SQLiteDatabase.OpenParams.Builder().setSynchronousMode("FULL").build());
             mContext = context;
             setWriteAheadLoggingEnabled(true);
         }