use of com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnHasBlockedNumbersListener in project android_packages_apps_Dialer by MoKee.
the class BlockedNumbersAutoMigrator method autoMigrate.
/**
* Attempts to perform the auto-migration. Auto-migration will only be attempted once and can be
* performed only when the user has no blocked numbers. As a result of this method, the user
* will be migrated to the framework blocking solution, as determined by {@link
* FilteredNumberCompat#hasMigratedToNewBlocking()}.
*/
public void autoMigrate() {
if (!shouldAttemptAutoMigrate()) {
return;
}
Log.i(TAG, "Attempting to auto-migrate.");
queryHandler.hasBlockedNumbers(new OnHasBlockedNumbersListener() {
@Override
public void onHasBlockedNumbers(boolean hasBlockedNumbers) {
if (hasBlockedNumbers) {
Log.i(TAG, "Not auto-migrating: blocked numbers exist.");
return;
}
Log.i(TAG, "Auto-migrating: no blocked numbers.");
FilteredNumberCompat.setHasMigratedToNewBlocking(true);
}
});
}
use of com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnHasBlockedNumbersListener in project android_packages_apps_Dialer by MoKee.
the class FilteredNumbersUtil method maybeNotifyCallBlockingDisabled.
public static void maybeNotifyCallBlockingDisabled(final Context context) {
// The Dialer is not responsible for this notification after migrating
if (FilteredNumberCompat.useNewFiltering()) {
return;
}
// Skip if the user has already received a notification for the most recent emergency call.
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean(NOTIFIED_CALL_BLOCKING_DISABLED_BY_EMERGENCY_CALL_PREF_KEY, false)) {
return;
}
// If the user has blocked numbers, notify that call blocking is temporarily disabled.
FilteredNumberAsyncQueryHandler queryHandler = new FilteredNumberAsyncQueryHandler(context.getContentResolver());
queryHandler.hasBlockedNumbers(new OnHasBlockedNumbersListener() {
@Override
public void onHasBlockedNumbers(boolean hasBlockedNumbers) {
if (context == null || !hasBlockedNumbers) {
return;
}
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification.Builder builder = new Notification.Builder(context).setSmallIcon(R.drawable.ic_block_24dp).setContentTitle(context.getString(R.string.call_blocking_disabled_notification_title)).setContentText(context.getString(R.string.call_blocking_disabled_notification_text)).setAutoCancel(true);
final Intent contentIntent = new Intent(context, BlockedNumbersSettingsActivity.class);
builder.setContentIntent(PendingIntent.getActivity(context, 0, contentIntent, PendingIntent.FLAG_UPDATE_CURRENT));
notificationManager.notify(CALL_BLOCKING_NOTIFICATION_TAG, CALL_BLOCKING_DISABLED_BY_EMERGENCY_CALL_NOTIFICATION_ID, builder.build());
// Record that the user has been notified for this emergency call.
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean(NOTIFIED_CALL_BLOCKING_DISABLED_BY_EMERGENCY_CALL_PREF_KEY, true).apply();
}
});
}
Aggregations