diff options
Diffstat (limited to 'java/com')
4 files changed, 40 insertions, 31 deletions
diff --git a/java/com/android/dialer/app/dialpad/SmartDialCursorLoader.java b/java/com/android/dialer/app/dialpad/SmartDialCursorLoader.java index 2e3b0cf92..175360c2d 100644 --- a/java/com/android/dialer/app/dialpad/SmartDialCursorLoader.java +++ b/java/com/android/dialer/app/dialpad/SmartDialCursorLoader.java @@ -17,10 +17,7 @@ package com.android.dialer.app.dialpad; import android.content.AsyncTaskLoader; -import android.content.BroadcastReceiver; import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; import android.database.Cursor; import android.database.MatrixCursor; import com.android.contacts.common.list.PhoneNumberListAdapter.PhoneQuery; @@ -46,8 +43,6 @@ public class SmartDialCursorLoader extends AsyncTaskLoader<Cursor> { private String mQuery; private SmartDialNameMatcher mNameMatcher; - private BroadcastReceiver mSmartDialUpdatedReceiver; - private boolean mShowEmptyListForNullQuery = true; public SmartDialCursorLoader(Context context) { @@ -124,19 +119,6 @@ public class SmartDialCursorLoader extends AsyncTaskLoader<Cursor> { Cursor oldCursor = mCursor; mCursor = cursor; - if (mSmartDialUpdatedReceiver == null) { - mSmartDialUpdatedReceiver = - new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - onContentChanged(); - } - }; - mContext.registerReceiver( - mSmartDialUpdatedReceiver, - new IntentFilter(DialerDatabaseHelper.ACTION_SMART_DIAL_UPDATED)); - } - if (isStarted()) { /** If the Loader is in a started state, deliver the results to the client. */ super.deliverResult(cursor); @@ -171,11 +153,6 @@ public class SmartDialCursorLoader extends AsyncTaskLoader<Cursor> { /** Ensure the loader has been stopped. */ onStopLoading(); - if (mSmartDialUpdatedReceiver != null) { - mContext.unregisterReceiver(mSmartDialUpdatedReceiver); - mSmartDialUpdatedReceiver = null; - } - /** Release all previously saved query results. */ if (mCursor != null) { releaseResources(mCursor); @@ -187,11 +164,6 @@ public class SmartDialCursorLoader extends AsyncTaskLoader<Cursor> { public void onCanceled(Cursor cursor) { super.onCanceled(cursor); - if (mSmartDialUpdatedReceiver != null) { - mContext.unregisterReceiver(mSmartDialUpdatedReceiver); - mSmartDialUpdatedReceiver = null; - } - /** The load has been canceled, so we should release the resources associated with 'data'. */ releaseResources(cursor); } diff --git a/java/com/android/dialer/app/list/SmartDialSearchFragment.java b/java/com/android/dialer/app/list/SmartDialSearchFragment.java index 5d72ee615..eb1508c72 100644 --- a/java/com/android/dialer/app/list/SmartDialSearchFragment.java +++ b/java/com/android/dialer/app/list/SmartDialSearchFragment.java @@ -18,6 +18,10 @@ package com.android.dialer.app.list; import static android.Manifest.permission.CALL_PHONE; import android.app.Activity; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; import android.content.Loader; import android.database.Cursor; import android.os.Bundle; @@ -27,6 +31,8 @@ import com.android.dialer.app.R; import com.android.dialer.app.dialpad.SmartDialCursorLoader; import com.android.dialer.app.widget.EmptyContentView; import com.android.dialer.callintent.CallInitiationType; +import com.android.dialer.common.LogUtil; +import com.android.dialer.database.DialerDatabaseHelper; import com.android.dialer.util.PermissionsUtil; /** Implements a fragment to load and display SmartDial search results. */ @@ -34,10 +40,17 @@ public class SmartDialSearchFragment extends SearchFragment implements EmptyContentView.OnEmptyViewActionButtonClickedListener, FragmentCompat.OnRequestPermissionsResultCallback { - private static final String TAG = SmartDialSearchFragment.class.getSimpleName(); - private static final int CALL_PHONE_PERMISSION_REQUEST_CODE = 1; + private final BroadcastReceiver mSmartDialUpdatedReceiver = + new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + LogUtil.i("SmartDialSearchFragment.onReceive", "smart dial update broadcast received"); + reloadData(); + } + }; + /** Creates a SmartDialListAdapter to display and operate on search results. */ @Override protected ContactEntryListAdapter createListAdapter() { @@ -83,6 +96,27 @@ public class SmartDialSearchFragment extends SearchFragment } @Override + public void onStart() { + super.onStart(); + + LogUtil.i("SmartDialSearchFragment.onStart", "registering smart dial update receiver"); + + getActivity() + .registerReceiver( + mSmartDialUpdatedReceiver, + new IntentFilter(DialerDatabaseHelper.ACTION_SMART_DIAL_UPDATED)); + } + + @Override + public void onStop() { + super.onStop(); + + LogUtil.i("SmartDialSearchFragment.onStop", "unregistering smart dial update receiver"); + + getActivity().unregisterReceiver(mSmartDialUpdatedReceiver); + } + + @Override public void onEmptyViewActionButtonClicked() { final Activity activity = getActivity(); if (activity == null) { diff --git a/java/com/android/dialer/database/DialerDatabaseHelper.java b/java/com/android/dialer/database/DialerDatabaseHelper.java index 1984b9abc..7b6033b65 100644 --- a/java/com/android/dialer/database/DialerDatabaseHelper.java +++ b/java/com/android/dialer/database/DialerDatabaseHelper.java @@ -597,6 +597,8 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper { * since last update. */ public void updateSmartDialDatabase() { + LogUtil.enterBlock("DialerDatabaseHelper.updateSmartDialDatabase"); + final SQLiteDatabase db = getWritableDatabase(); synchronized (mLock) { @@ -799,6 +801,8 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper { editor.putLong(LAST_UPDATED_MILLIS, currentMillis); editor.apply(); + LogUtil.i("DialerDatabaseHelper.updateSmartDialDatabase", "broadcasting smart dial update"); + // Notify content observers that smart dial database has been updated. Intent intent = new Intent(ACTION_SMART_DIAL_UPDATED); intent.setPackage(mContext.getPackageName()); diff --git a/java/com/android/dialer/logging/contact_lookup_result.proto b/java/com/android/dialer/logging/contact_lookup_result.proto index c9624aff1..835d7d7dc 100644 --- a/java/com/android/dialer/logging/contact_lookup_result.proto +++ b/java/com/android/dialer/logging/contact_lookup_result.proto @@ -5,7 +5,6 @@ option java_package = "com.android.dialer.logging"; option java_multiple_files = true; option optimize_for = LITE_RUNTIME; - message ContactLookupResult { // The different results of a contact lookup done using a phone number. enum Type { |