diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-04-04 01:43:18 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-04-04 01:43:18 +0000 |
commit | d5408c9423f20bef650ca838ff66bb5ecf60f818 (patch) | |
tree | d71a3bf4606c11bcf0ce9f2dc2266b5533561c0b /java/com/android/dialer/database | |
parent | c81fbd75f18621d7ce68c8df65cc468efe6ffe23 (diff) | |
parent | 01b782754418aa17dbb867591642b49e473e92b1 (diff) |
Merge changes I28244a72,Ic984f958,I5dc2bed7,I1be427b3,I0220a342, ...
* changes:
Remove reference to RTT system setting.
Fix the button style of RTT request dialog.
Don't deadlock in DialerDatabaseHelper.
Fix NPE for details number
Per linguists' request, increase CHAR_LIMIT of "Carrier video" from 30 to 31.
Fix permission
Handle missed calls for new call log in old peer.
Separate calls with the video feature from others when coalescing rows in the new call log.
Support placing Duo calls in the new UI's bottom sheet.
Turn off component generating step of RootComponentGenerato and @DialerCompoennt. Delete related tests.
Implement dialog for responding RTT request.
Diffstat (limited to 'java/com/android/dialer/database')
-rw-r--r-- | java/com/android/dialer/database/DialerDatabaseHelper.java | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/java/com/android/dialer/database/DialerDatabaseHelper.java b/java/com/android/dialer/database/DialerDatabaseHelper.java index efff11ecc..b172d7039 100644 --- a/java/com/android/dialer/database/DialerDatabaseHelper.java +++ b/java/com/android/dialer/database/DialerDatabaseHelper.java @@ -32,21 +32,23 @@ import android.provider.ContactsContract.CommonDataKinds.Phone; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Data; import android.provider.ContactsContract.Directory; -import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.support.annotation.WorkerThread; import android.text.TextUtils; import com.android.contacts.common.R; import com.android.contacts.common.util.StopWatch; import com.android.dialer.common.LogUtil; -import com.android.dialer.common.concurrent.DialerExecutor.Worker; +import com.android.dialer.common.concurrent.DefaultFutureCallback; import com.android.dialer.common.concurrent.DialerExecutorComponent; +import com.android.dialer.common.concurrent.DialerFutureSerializer; import com.android.dialer.common.database.Selection; import com.android.dialer.configprovider.ConfigProviderBindings; import com.android.dialer.database.FilteredNumberContract.FilteredNumberColumns; import com.android.dialer.smartdial.util.SmartDialNameMatcher; import com.android.dialer.smartdial.util.SmartDialPrefix; import com.android.dialer.util.PermissionsUtil; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.MoreExecutors; import java.util.ArrayList; import java.util.HashSet; import java.util.Objects; @@ -85,6 +87,8 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper { private static final int MAX_ENTRIES = 20; private final Context context; + private final DialerFutureSerializer dialerFutureSerializer = new DialerFutureSerializer(); + private boolean isTestInstance = false; protected DialerDatabaseHelper(Context context, String databaseName, int dbVersion) { @@ -344,11 +348,19 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper { */ public void startSmartDialUpdateThread(boolean forceUpdate) { if (PermissionsUtil.hasContactsReadPermissions(context)) { - DialerExecutorComponent.get(context) - .dialerExecutorFactory() - .createNonUiTaskBuilder(new UpdateSmartDialWorker()) - .build() - .executeParallel(forceUpdate); + Futures.addCallback( + // Serialize calls to updateSmartDialDatabase. Use FutureSerializer instead of + // synchronizing on the method to prevent deadlocking thread pool. FutureSerializer + // provides the guarantee that the next AsyncCallable won't even be submitted until the + // ListenableFuture returned by the previous one completes. See a bug. + dialerFutureSerializer.submit( + () -> { + updateSmartDialDatabase(forceUpdate); + return null; + }, + DialerExecutorComponent.get(context).backgroundExecutor()), + new DefaultFutureCallback<>(), + MoreExecutors.directExecutor()); } } @@ -657,7 +669,7 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper { * @param forceUpdate If set to true, update the database by reloading all contacts. */ @WorkerThread - public synchronized void updateSmartDialDatabase(boolean forceUpdate) { + public void updateSmartDialDatabase(boolean forceUpdate) { LogUtil.enterBlock("DialerDatabaseHelper.updateSmartDialDatabase"); final SQLiteDatabase db = getWritableDatabase(); @@ -1296,14 +1308,4 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper { return false; } } - - private class UpdateSmartDialWorker implements Worker<Boolean, Void> { - - @Nullable - @Override - public Void doInBackground(Boolean forceUpdate) throws Throwable { - updateSmartDialDatabase(forceUpdate); - return null; - } - } } |