Dialer: Remove compatibility (1/x)
* Now that we don't expect any more changes we can rip out
all the unused stuff
* Start with all the TargetApi-checks for N, O and P including
version checks in code for those and remove the old number
blocking - we have the provider since 2017 now...
Change-Id: Ib9369476fa660c44d946b0e41b0d23a34ff14e7c
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 6243740..8b4086c 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -20,7 +20,7 @@
android:versionName="23.0">
<uses-sdk
- android:minSdkVersion="24"
+ android:minSdkVersion="27"
android:targetSdkVersion="30"/>
diff --git a/java/com/android/contacts/common/compat/CallCompat.java b/java/com/android/contacts/common/compat/CallCompat.java
index 641f7b1..55a1df3 100644
--- a/java/com/android/contacts/common/compat/CallCompat.java
+++ b/java/com/android/contacts/common/compat/CallCompat.java
@@ -16,8 +16,6 @@
package com.android.contacts.common.compat;
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
import android.support.annotation.NonNull;
import android.telecom.Call;
@@ -25,8 +23,7 @@
public class CallCompat {
public static boolean canPullExternalCall(@NonNull android.telecom.Call call) {
- return VERSION.SDK_INT >= VERSION_CODES.N_MR1
- && ((call.getDetails().getCallCapabilities() & Details.CAPABILITY_CAN_PULL_CALL)
+ return ((call.getDetails().getCallCapabilities() & Details.CAPABILITY_CAN_PULL_CALL)
== Details.CAPABILITY_CAN_PULL_CALL);
}
diff --git a/java/com/android/contacts/common/compat/telecom/TelecomManagerCompat.java b/java/com/android/contacts/common/compat/telecom/TelecomManagerCompat.java
deleted file mode 100644
index a1dc89d..0000000
--- a/java/com/android/contacts/common/compat/telecom/TelecomManagerCompat.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.contacts.common.compat.telecom;
-
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
-import android.support.annotation.Nullable;
-import android.telecom.PhoneAccountHandle;
-import android.telecom.TelecomManager;
-import java.lang.reflect.Field;
-
-/** Compatibility class for {@link android.telecom.TelecomManager}. */
-public class TelecomManagerCompat {
-
- // Constants from http://cs/android/frameworks/base/telecomm/java/android/telecom/Call.java.
- public static final String EVENT_REQUEST_HANDOVER = "android.telecom.event.REQUEST_HANDOVER";
- public static final String EXTRA_HANDOVER_PHONE_ACCOUNT_HANDLE =
- "android.telecom.extra.HANDOVER_PHONE_ACCOUNT_HANDLE";
- public static final String EXTRA_HANDOVER_VIDEO_STATE =
- "android.telecom.extra.HANDOVER_VIDEO_STATE";
-
- // This is a hidden constant in android.telecom.DisconnectCause. Telecom sets this as a disconnect
- // reason if it wants us to prompt the user that the video call is not available.
- // TODO(wangqi): Reference it to constant in android.telecom.DisconnectCause.
- public static final String REASON_IMS_ACCESS_BLOCKED = "REASON_IMS_ACCESS_BLOCKED";
-
- /**
- * Returns the current SIM call manager. Apps must be prepared for this method to return null,
- * indicating that there currently exists no registered SIM call manager.
- *
- * @param telecomManager the {@link TelecomManager} to use to fetch the SIM call manager.
- * @return The phone account handle of the current sim call manager.
- */
- @Nullable
- public static PhoneAccountHandle getSimCallManager(TelecomManager telecomManager) {
- if (telecomManager != null) {
- return telecomManager.getSimCallManager();
- }
- return null;
- }
-
- /** Returns true if the Android version supports Handover. */
- public static boolean supportsHandover() {
- // Starting with Android P, handover is supported via a public API.
- if (VERSION.SDK_INT >= VERSION_CODES.P) {
- return true;
- }
- // Handovers are supported from Android O-DR onward. Since there is no API
- // bump from O to O-DR, we need to use reflection to check the existence
- // of TelecomManager.EXTRA_IS_HANDOVER in
- // http://cs/android/frameworks/base/telecomm/java/android/telecom/TelecomManager.java.
- try {
- Field field = TelecomManager.class.getDeclaredField("EXTRA_IS_HANDOVER");
- return "android.telecom.extra.IS_HANDOVER".equals(field.get(null /* obj (static field) */));
- } catch (Exception e) {
- // Do nothing
- }
- return false;
- }
-}
diff --git a/java/com/android/dialer/app/AndroidManifest.xml b/java/com/android/dialer/app/AndroidManifest.xml
index 93dedb6..8cc8f9e 100644
--- a/java/com/android/dialer/app/AndroidManifest.xml
+++ b/java/com/android/dialer/app/AndroidManifest.xml
@@ -60,18 +60,6 @@
<application>
- <activity
- android:exported="false"
- android:label="@string/manage_blocked_numbers_label"
- android:name="com.android.dialer.app.filterednumber.BlockedNumbersSettingsActivity"
- android:parentActivityName="com.android.dialer.app.settings.DialerSettingsActivity"
- android:theme="@style/ManageBlockedNumbersStyle">
- <intent-filter>
- <action android:name="com.android.dialer.action.BLOCKED_NUMBERS_SETTINGS"/>
- <category android:name="android.intent.category.DEFAULT"/>
- </intent-filter>
- </activity>
-
<activity
android:label="@string/call_log_activity_title"
android:name="com.android.dialer.app.calllog.CallLogActivity"
diff --git a/java/com/android/dialer/app/calllog/BlockReportSpamListener.java b/java/com/android/dialer/app/calllog/BlockReportSpamListener.java
index 865cb81..825bf8c 100644
--- a/java/com/android/dialer/app/calllog/BlockReportSpamListener.java
+++ b/java/com/android/dialer/app/calllog/BlockReportSpamListener.java
@@ -93,8 +93,7 @@
.logImpression(DialerImpression.Type.USER_ACTION_BLOCKED_NUMBER);
adapter.notifyDataSetChanged();
},
- number,
- countryIso);
+ number);
if (isSpamChecked) {
showSpamBlockingPromoDialog();
@@ -134,8 +133,7 @@
.logImpression(DialerImpression.Type.USER_ACTION_BLOCKED_NUMBER);
adapter.notifyDataSetChanged();
},
- number,
- countryIso);
+ number);
showSpamBlockingPromoDialog();
},
null)
diff --git a/java/com/android/dialer/app/calllog/CallLogAdapter.java b/java/com/android/dialer/app/calllog/CallLogAdapter.java
index 485683b..edea8cb 100644
--- a/java/com/android/dialer/app/calllog/CallLogAdapter.java
+++ b/java/com/android/dialer/app/calllog/CallLogAdapter.java
@@ -24,8 +24,6 @@
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.Trace;
import android.provider.CallLog;
@@ -950,10 +948,7 @@
final String viaNumber = cursor.getString(CallLogQuery.VIA_NUMBER);
final int numberPresentation = cursor.getInt(CallLogQuery.NUMBER_PRESENTATION);
final ContactInfo cachedContactInfo = ContactInfoHelper.getContactInfo(cursor);
- final int transcriptionState =
- (VERSION.SDK_INT >= VERSION_CODES.O)
- ? cursor.getInt(CallLogQuery.TRANSCRIPTION_STATE)
- : VoicemailCompat.TRANSCRIPTION_NOT_STARTED;
+ final int transcriptionState = cursor.getInt(CallLogQuery.TRANSCRIPTION_STATE);
final PhoneCallDetails details =
new PhoneCallDetails(number, numberPresentation, postDialDigits);
details.viaNumber = viaNumber;
diff --git a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java
index 07e00f9..e1ffaea 100644
--- a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java
+++ b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java
@@ -66,8 +66,6 @@
import com.android.dialer.app.calllog.calllogcache.CallLogCache;
import com.android.dialer.app.voicemail.VoicemailPlaybackLayout;
import com.android.dialer.app.voicemail.VoicemailPlaybackPresenter;
-import com.android.dialer.blocking.BlockedNumbersMigrator;
-import com.android.dialer.blocking.FilteredNumberCompat;
import com.android.dialer.blocking.FilteredNumbersUtil;
import com.android.dialer.callcomposer.CallComposerActivity;
import com.android.dialer.calldetails.CallDetailsEntries;
@@ -418,24 +416,12 @@
} else if (resId == R.id.context_menu_block_report_spam) {
Logger.get(context)
.logImpression(DialerImpression.Type.CALL_LOG_CONTEXT_MENU_BLOCK_REPORT_SPAM);
- maybeShowBlockNumberMigrationDialog(
- new BlockedNumbersMigrator.Listener() {
- @Override
- public void onComplete() {
- blockReportListener.onBlockReportSpam(
- displayNumber, number, countryIso, callType, info.sourceType);
- }
- });
+ blockReportListener.onBlockReportSpam(
+ displayNumber, number, countryIso, callType, info.sourceType);
} else if (resId == R.id.context_menu_block) {
Logger.get(context).logImpression(DialerImpression.Type.CALL_LOG_CONTEXT_MENU_BLOCK_NUMBER);
- maybeShowBlockNumberMigrationDialog(
- new BlockedNumbersMigrator.Listener() {
- @Override
- public void onComplete() {
- blockReportListener.onBlock(
- displayNumber, number, countryIso, callType, info.sourceType);
- }
- });
+ blockReportListener.onBlock(
+ displayNumber, number, countryIso, callType, info.sourceType);
} else if (resId == R.id.context_menu_unblock) {
Logger.get(context).logImpression(DialerImpression.Type.CALL_LOG_CONTEXT_MENU_UNBLOCK_NUMBER);
blockReportListener.onUnblock(
@@ -1073,27 +1059,15 @@
if (view.getId() == R.id.block_report_action) {
Logger.get(context).logImpression(DialerImpression.Type.CALL_LOG_BLOCK_REPORT_SPAM);
- maybeShowBlockNumberMigrationDialog(
- new BlockedNumbersMigrator.Listener() {
- @Override
- public void onComplete() {
- blockReportListener.onBlockReportSpam(
- displayNumber, number, countryIso, callType, info.sourceType);
- }
- });
+ blockReportListener.onBlockReportSpam(
+ displayNumber, number, countryIso, callType, info.sourceType);
return;
}
if (view.getId() == R.id.block_action) {
Logger.get(context).logImpression(DialerImpression.Type.CALL_LOG_BLOCK_NUMBER);
- maybeShowBlockNumberMigrationDialog(
- new BlockedNumbersMigrator.Listener() {
- @Override
- public void onComplete() {
- blockReportListener.onBlock(
- displayNumber, number, countryIso, callType, info.sourceType);
- }
- });
+ blockReportListener.onBlock(
+ displayNumber, number, countryIso, callType, info.sourceType);
return;
}
@@ -1251,13 +1225,6 @@
}
}
- private void maybeShowBlockNumberMigrationDialog(BlockedNumbersMigrator.Listener listener) {
- if (!FilteredNumberCompat.maybeShowBlockNumberMigrationDialog(
- context, ((Activity) context).getFragmentManager(), listener)) {
- listener.onComplete();
- }
- }
-
private void updateBlockReportActions(boolean canPlaceCallToNumber, boolean isVoicemailNumber) {
// Set block/spam actions.
blockReportView.setVisibility(View.GONE);
@@ -1267,8 +1234,7 @@
String e164Number = PhoneNumberUtils.formatNumberToE164(number, countryIso);
if (!canPlaceCallToNumber
|| isVoicemailNumber
- || !FilteredNumbersUtil.canBlockNumber(context, e164Number, number)
- || !FilteredNumberCompat.canAttemptBlockOperations(context)) {
+ || !FilteredNumbersUtil.canBlockNumber(context, e164Number, number)) {
return;
}
boolean isBlocked = blockId != null;
@@ -1350,8 +1316,7 @@
boolean canPlaceCallToNumber = PhoneNumberHelper.canPlaceCallsTo(number, numberPresentation);
if (canPlaceCallToNumber
&& !isVoicemailNumber
- && FilteredNumbersUtil.canBlockNumber(context, e164Number, number)
- && FilteredNumberCompat.canAttemptBlockOperations(context)) {
+ && FilteredNumbersUtil.canBlockNumber(context, e164Number, number)) {
boolean isBlocked = blockId != null;
if (isBlocked) {
menu.add(
diff --git a/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java b/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java
index 03b824e..126b7a1 100644
--- a/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java
+++ b/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java
@@ -389,7 +389,7 @@
try (Cursor cursor =
contentResolver.query(
Calls.CONTENT_URI_WITH_VOICEMAIL,
- (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) ? PROJECTION_O : PROJECTION,
+ PROJECTION_O,
selection.getSelection(),
selection.getSelectionArgs(),
Calls.DEFAULT_SORT_ORDER)) {
@@ -428,7 +428,7 @@
try (Cursor cursor =
contentResolver.query(
Calls.CONTENT_URI_WITH_VOICEMAIL,
- (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) ? PROJECTION_O : PROJECTION,
+ PROJECTION_O,
selection.getSelection(),
selection.getSelectionArgs(),
null)) {
@@ -459,9 +459,7 @@
cursor.getString(TRANSCRIPTION_COLUMN_INDEX),
cursor.getString(COUNTRY_ISO_COLUMN_INDEX),
cursor.getLong(DATE_COLUMN_INDEX),
- Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
- ? cursor.getInt(TRANSCRIPTION_STATE_COLUMN_INDEX)
- : VoicemailCompat.TRANSCRIPTION_NOT_STARTED);
+ cursor.getInt(TRANSCRIPTION_STATE_COLUMN_INDEX));
}
}
}
diff --git a/java/com/android/dialer/app/calllog/CallLogReceiver.java b/java/com/android/dialer/app/calllog/CallLogReceiver.java
index 654436c..5d8d130 100644
--- a/java/com/android/dialer/app/calllog/CallLogReceiver.java
+++ b/java/com/android/dialer/app/calllog/CallLogReceiver.java
@@ -23,8 +23,6 @@
import android.provider.VoicemailContract;
import com.android.dialer.common.LogUtil;
import com.android.dialer.database.CallLogQueryHandler;
-import com.android.dialer.voicemail.listui.error.VoicemailStatusCorruptionHandler;
-import com.android.dialer.voicemail.listui.error.VoicemailStatusCorruptionHandler.Source;
/**
* Receiver for call log events.
@@ -55,8 +53,7 @@
new CallLogQueryHandler.Listener() {
@Override
public void onVoicemailStatusFetched(Cursor statusCursor) {
- VoicemailStatusCorruptionHandler.maybeFixVoicemailStatus(
- context, statusCursor, Source.Notification);
+ // Do nothing
}
@Override
diff --git a/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java b/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java
index 62ae748..4925c72 100644
--- a/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java
+++ b/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java
@@ -16,14 +16,11 @@
package com.android.dialer.app.calllog;
-import android.annotation.TargetApi;
import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
-import android.os.Build.VERSION_CODES;
import android.os.PersistableBundle;
import android.support.annotation.NonNull;
-import android.support.v4.os.BuildCompat;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
@@ -41,7 +38,6 @@
import com.android.dialer.theme.base.ThemeComponent;
/** Shows a notification in the status bar for legacy vociemail. */
-@TargetApi(VERSION_CODES.O)
public final class LegacyVoicemailNotifier {
private static final String NOTIFICATION_TAG_PREFIX = "LegacyVoicemail_";
private static final String NOTIFICATION_TAG = "LegacyVoicemail";
@@ -62,7 +58,6 @@
boolean isRefresh) {
LogUtil.enterBlock("LegacyVoicemailNotifier.showNotification");
Assert.isNotNull(handle);
- Assert.checkArgument(BuildCompat.isAtLeastO());
TelephonyManager pinnedTelephonyManager =
context.getSystemService(TelephonyManager.class).createForPhoneAccountHandle(handle);
@@ -159,7 +154,6 @@
public static void cancelNotification(
@NonNull Context context, @NonNull PhoneAccountHandle phoneAccountHandle) {
LogUtil.enterBlock("LegacyVoicemailNotifier.cancelNotification");
- Assert.checkArgument(BuildCompat.isAtLeastO());
Assert.isNotNull(phoneAccountHandle);
if ("null".equals(phoneAccountHandle.getId())) {
// while PhoneAccountHandle itself will never be null, telephony may still construct a "null"
diff --git a/java/com/android/dialer/app/calllog/MissedCallNotifier.java b/java/com/android/dialer/app/calllog/MissedCallNotifier.java
index 64536c8..d9d6b40 100644
--- a/java/com/android/dialer/app/calllog/MissedCallNotifier.java
+++ b/java/com/android/dialer/app/calllog/MissedCallNotifier.java
@@ -35,7 +35,6 @@
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.support.annotation.WorkerThread;
-import android.support.v4.os.BuildCompat;
import android.support.v4.os.UserManagerCompat;
import android.support.v4.util.Pair;
import android.telecom.PhoneAccount;
@@ -223,10 +222,8 @@
CallLogNotificationsService.createCancelAllMissedCallsPendingIntent(context))
.setGroupSummary(useCallList)
.setOnlyAlertOnce(useCallList)
- .setPublicVersion(publicSummaryBuilder.build());
- if (BuildCompat.isAtLeastO()) {
- groupSummary.setChannelId(NotificationChannelId.MISSED_CALL);
- }
+ .setPublicVersion(publicSummaryBuilder.build())
+ .setChannelId(NotificationChannelId.MISSED_CALL);
Notification notification = groupSummary.build();
configureLedOnNotification(notification);
@@ -421,10 +418,8 @@
.setDeleteIntent(
CallLogNotificationsService.createCancelSingleMissedCallPendingIntent(
context, call.callsUri))
- .setContentIntent(createCallLogPendingIntent(call.callsUri));
- if (BuildCompat.isAtLeastO()) {
- builder.setChannelId(NotificationChannelId.MISSED_CALL);
- }
+ .setContentIntent(createCallLogPendingIntent(call.callsUri))
+ .setChannelId(NotificationChannelId.MISSED_CALL);
return builder;
}
diff --git a/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java b/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java
index 9d04cb2..e6b94fc 100644
--- a/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java
+++ b/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java
@@ -25,7 +25,6 @@
import android.provider.CallLog.Calls;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.support.v4.content.ContextCompat;
-import android.support.v4.os.BuildCompat;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telephony.PhoneNumberUtils;
@@ -173,9 +172,7 @@
views.callTypeIcons.setShowAssistedDialed(
(details.features & TelephonyManagerCompat.FEATURES_ASSISTED_DIALING)
== TelephonyManagerCompat.FEATURES_ASSISTED_DIALING);
- if (BuildCompat.isAtLeastP()) {
- views.callTypeIcons.setShowRtt((details.features & Calls.FEATURES_RTT) == Calls.FEATURES_RTT);
- }
+ views.callTypeIcons.setShowRtt((details.features & Calls.FEATURES_RTT) == Calls.FEATURES_RTT);
views.callTypeIcons.requestLayout();
views.callTypeIcons.setVisibility(View.VISIBLE);
diff --git a/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java b/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java
index 7fc104b..b0f2670 100644
--- a/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java
+++ b/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java
@@ -23,8 +23,6 @@
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.NotificationCompat;
@@ -90,19 +88,17 @@
.setGroupSummary(true)
.setContentIntent(newVoicemailIntent(context, null));
- if (VERSION.SDK_INT >= VERSION_CODES.O) {
- if (shouldAlert) {
- groupSummary.setOnlyAlertOnce(false);
- // Group summary will alert when posted/updated
- groupSummary.setGroupAlertBehavior(Notification.GROUP_ALERT_ALL);
- } else {
- // Only children will alert. but since all children are set to "only alert summary" it is
- // effectively silenced.
- groupSummary.setGroupAlertBehavior(Notification.GROUP_ALERT_CHILDREN);
- }
- PhoneAccountHandle handle = getAccountForCall(context, newCalls.get(0));
- groupSummary.setChannelId(NotificationChannelManager.getVoicemailChannelId(context, handle));
+ if (shouldAlert) {
+ groupSummary.setOnlyAlertOnce(false);
+ // Group summary will alert when posted/updated
+ groupSummary.setGroupAlertBehavior(Notification.GROUP_ALERT_ALL);
+ } else {
+ // Only children will alert. but since all children are set to "only alert summary" it is
+ // effectively silenced.
+ groupSummary.setGroupAlertBehavior(Notification.GROUP_ALERT_CHILDREN);
}
+ PhoneAccountHandle handle = getAccountForCall(context, newCalls.get(0));
+ groupSummary.setChannelId(NotificationChannelManager.getVoicemailChannelId(context, handle));
DialerNotificationManager.notify(
context, GROUP_SUMMARY_NOTIFICATION_TAG, NOTIFICATION_ID, groupSummary.build());
@@ -214,10 +210,8 @@
context, voicemail.voicemailUri));
}
- if (VERSION.SDK_INT >= VERSION_CODES.O) {
- builder.setChannelId(NotificationChannelManager.getVoicemailChannelId(context, handle));
- builder.setGroupAlertBehavior(Notification.GROUP_ALERT_SUMMARY);
- }
+ builder.setChannelId(NotificationChannelManager.getVoicemailChannelId(context, handle));
+ builder.setGroupAlertBehavior(Notification.GROUP_ALERT_SUMMARY);
ContactPhotoLoader loader = new ContactPhotoLoader(context, contactInfo);
Bitmap photoIcon = loader.loadPhotoIcon();
diff --git a/java/com/android/dialer/app/filterednumber/BlockedNumbersAdapter.java b/java/com/android/dialer/app/filterednumber/BlockedNumbersAdapter.java
deleted file mode 100644
index 603c06f..0000000
--- a/java/com/android/dialer/app/filterednumber/BlockedNumbersAdapter.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.dialer.app.filterednumber;
-
-import android.app.FragmentManager;
-import android.content.Context;
-import android.database.Cursor;
-import android.view.View;
-import com.android.dialer.app.R;
-import com.android.dialer.blocking.BlockNumberDialogFragment;
-import com.android.dialer.contactphoto.ContactPhotoManager;
-import com.android.dialer.database.FilteredNumberContract.FilteredNumberColumns;
-import com.android.dialer.location.GeoUtil;
-import com.android.dialer.logging.InteractionEvent;
-import com.android.dialer.logging.Logger;
-import com.android.dialer.phonenumbercache.ContactInfoHelper;
-import com.android.dialer.phonenumberutil.PhoneNumberHelper;
-
-/** TODO(calderwoodra): documentation */
-public class BlockedNumbersAdapter extends NumbersAdapter {
-
- private BlockedNumbersAdapter(
- Context context,
- FragmentManager fragmentManager,
- ContactInfoHelper contactInfoHelper,
- ContactPhotoManager contactPhotoManager) {
- super(context, fragmentManager, contactInfoHelper, contactPhotoManager);
- }
-
- public static BlockedNumbersAdapter newBlockedNumbersAdapter(
- Context context, FragmentManager fragmentManager) {
- return new BlockedNumbersAdapter(
- context,
- fragmentManager,
- new ContactInfoHelper(context, GeoUtil.getCurrentCountryIso(context)),
- ContactPhotoManager.getInstance(context));
- }
-
- @Override
- public void bindView(View view, final Context context, Cursor cursor) {
- super.bindView(view, context, cursor);
- final Integer id = cursor.getInt(cursor.getColumnIndex(FilteredNumberColumns._ID));
- final String countryIso =
- cursor.getString(cursor.getColumnIndex(FilteredNumberColumns.COUNTRY_ISO));
- final String number = cursor.getString(cursor.getColumnIndex(FilteredNumberColumns.NUMBER));
-
- final View deleteButton = view.findViewById(R.id.delete_button);
- deleteButton.setOnClickListener(
- new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- BlockNumberDialogFragment.show(
- id,
- number,
- countryIso,
- PhoneNumberHelper.formatNumber(getContext(), number, countryIso),
- R.id.blocked_numbers_activity_container,
- getFragmentManager(),
- new BlockNumberDialogFragment.Callback() {
- @Override
- public void onFilterNumberSuccess() {}
-
- @Override
- public void onUnfilterNumberSuccess() {
- Logger.get(context)
- .logInteraction(InteractionEvent.Type.UNBLOCK_NUMBER_MANAGEMENT_SCREEN);
- }
-
- @Override
- public void onChangeFilteredNumberUndo() {}
- });
- }
- });
-
- updateView(view, number, countryIso);
- }
-
- @Override
- public boolean isEmpty() {
- // Always return false, so that the header with blocking-related options always shows.
- return false;
- }
-}
diff --git a/java/com/android/dialer/app/filterednumber/BlockedNumbersFragment.java b/java/com/android/dialer/app/filterednumber/BlockedNumbersFragment.java
deleted file mode 100644
index bf40fdf..0000000
--- a/java/com/android/dialer/app/filterednumber/BlockedNumbersFragment.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.dialer.app.filterednumber;
-
-import android.app.ListFragment;
-import android.app.LoaderManager;
-import android.content.Context;
-import android.content.CursorLoader;
-import android.content.Loader;
-import android.database.Cursor;
-import android.graphics.drawable.ColorDrawable;
-import android.os.Bundle;
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.AppCompatActivity;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-import com.android.dialer.app.R;
-import com.android.dialer.blocking.BlockedNumbersMigrator;
-import com.android.dialer.blocking.BlockedNumbersMigrator.Listener;
-import com.android.dialer.blocking.FilteredNumberCompat;
-import com.android.dialer.blocking.FilteredNumbersUtil;
-import com.android.dialer.blocking.FilteredNumbersUtil.CheckForSendToVoicemailContactListener;
-import com.android.dialer.blocking.FilteredNumbersUtil.ImportSendToVoicemailContactsListener;
-import com.android.dialer.database.FilteredNumberContract;
-import com.android.dialer.lettertile.LetterTileDrawable;
-import com.android.dialer.theme.base.ThemeComponent;
-import com.android.dialer.voicemailstatus.VisualVoicemailEnabledChecker;
-
-/** TODO(calderwoodra): documentation */
-public class BlockedNumbersFragment extends ListFragment
- implements LoaderManager.LoaderCallbacks<Cursor>,
- View.OnClickListener,
- VisualVoicemailEnabledChecker.Callback {
-
- private static final char ADD_BLOCKED_NUMBER_ICON_LETTER = '+';
- protected View migratePromoView;
- private BlockedNumbersMigrator blockedNumbersMigratorForTest;
- private TextView blockedNumbersText;
- private TextView footerText;
- private BlockedNumbersAdapter adapter;
- private VisualVoicemailEnabledChecker voicemailEnabledChecker;
- private View importSettings;
- private View blockedNumbersDisabledForEmergency;
- private View blockedNumberListDivider;
-
- @Override
- public Context getContext() {
- return getActivity();
- }
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
-
- LayoutInflater inflater =
- (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- getListView().addHeaderView(inflater.inflate(R.layout.blocked_number_header, null));
- getListView().addFooterView(inflater.inflate(R.layout.blocked_number_footer, null));
- //replace the icon for add number with LetterTileDrawable(), so it will have identical style
- LetterTileDrawable drawable = new LetterTileDrawable(getResources());
- drawable.setLetter(ADD_BLOCKED_NUMBER_ICON_LETTER);
- drawable.setColor(ThemeComponent.get(getContext()).theme().getColorIcon());
- drawable.setIsCircular(true);
-
- if (adapter == null) {
- adapter =
- BlockedNumbersAdapter.newBlockedNumbersAdapter(
- getContext(), getActivity().getFragmentManager());
- }
- setListAdapter(adapter);
-
- blockedNumbersText = (TextView) getListView().findViewById(R.id.blocked_number_text_view);
- migratePromoView = getListView().findViewById(R.id.migrate_promo);
- getListView().findViewById(R.id.migrate_promo_allow_button).setOnClickListener(this);
- importSettings = getListView().findViewById(R.id.import_settings);
- blockedNumbersDisabledForEmergency =
- getListView().findViewById(R.id.blocked_numbers_disabled_for_emergency);
- blockedNumberListDivider = getActivity().findViewById(R.id.blocked_number_list_divider);
- getListView().findViewById(R.id.import_button).setOnClickListener(this);
- getListView().findViewById(R.id.view_numbers_button).setOnClickListener(this);
-
- footerText = (TextView) getActivity().findViewById(R.id.blocked_number_footer_textview);
- voicemailEnabledChecker = new VisualVoicemailEnabledChecker(getContext(), this);
- voicemailEnabledChecker.asyncUpdate();
- updateActiveVoicemailProvider();
- }
-
- @Override
- public void onDestroy() {
- setListAdapter(null);
- super.onDestroy();
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getLoaderManager().initLoader(0, null, this);
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
- ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
- ColorDrawable backgroundDrawable =
- new ColorDrawable(ThemeComponent.get(getContext()).theme().getColorPrimary());
- actionBar.setBackgroundDrawable(backgroundDrawable);
- actionBar.setDisplayShowCustomEnabled(false);
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- actionBar.setDisplayShowTitleEnabled(true);
- actionBar.setTitle(R.string.manage_blocked_numbers_label);
-
- // If the device can use the framework blocking solution, users should not be able to add
- // new blocked numbers from the Blocked Management UI. They will be shown a promo card
- // asking them to migrate to new blocking instead.
- if (FilteredNumberCompat.canUseNewFiltering()) {
- migratePromoView.setVisibility(View.VISIBLE);
- blockedNumbersText.setVisibility(View.GONE);
- blockedNumberListDivider.setVisibility(View.GONE);
- importSettings.setVisibility(View.GONE);
- getListView().findViewById(R.id.import_button).setOnClickListener(null);
- getListView().findViewById(R.id.view_numbers_button).setOnClickListener(null);
- blockedNumbersDisabledForEmergency.setVisibility(View.GONE);
- footerText.setVisibility(View.GONE);
- } else {
- FilteredNumbersUtil.checkForSendToVoicemailContact(
- getActivity(),
- new CheckForSendToVoicemailContactListener() {
- @Override
- public void onComplete(boolean hasSendToVoicemailContact) {
- final int visibility = hasSendToVoicemailContact ? View.VISIBLE : View.GONE;
- importSettings.setVisibility(visibility);
- }
- });
- }
-
- // All views except migrate and the block list are hidden when new filtering is available
- if (!FilteredNumberCompat.canUseNewFiltering()
- && FilteredNumbersUtil.hasRecentEmergencyCall(getContext())) {
- blockedNumbersDisabledForEmergency.setVisibility(View.VISIBLE);
- } else {
- blockedNumbersDisabledForEmergency.setVisibility(View.GONE);
- }
-
- voicemailEnabledChecker.asyncUpdate();
- }
-
- @Override
- public View onCreateView(
- LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- return inflater.inflate(R.layout.blocked_number_fragment, container, false);
- }
-
- @Override
- public Loader<Cursor> onCreateLoader(int id, Bundle args) {
- final String[] projection = {
- FilteredNumberContract.FilteredNumberColumns._ID,
- FilteredNumberContract.FilteredNumberColumns.COUNTRY_ISO,
- FilteredNumberContract.FilteredNumberColumns.NUMBER,
- FilteredNumberContract.FilteredNumberColumns.NORMALIZED_NUMBER
- };
- final String selection =
- FilteredNumberContract.FilteredNumberColumns.TYPE
- + "="
- + FilteredNumberContract.FilteredNumberTypes.BLOCKED_NUMBER;
- return new CursorLoader(
- getContext(),
- FilteredNumberContract.FilteredNumber.CONTENT_URI,
- projection,
- selection,
- null,
- null);
- }
-
- @Override
- public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
- adapter.swapCursor(data);
- if (FilteredNumberCompat.canUseNewFiltering() || data.getCount() == 0) {
- blockedNumberListDivider.setVisibility(View.INVISIBLE);
- } else {
- blockedNumberListDivider.setVisibility(View.VISIBLE);
- }
- }
-
- @Override
- public void onLoaderReset(Loader<Cursor> loader) {
- adapter.swapCursor(null);
- }
-
- @Override
- public void onClick(final View view) {
- final BlockedNumbersSettingsActivity activity = (BlockedNumbersSettingsActivity) getActivity();
- if (activity == null) {
- return;
- }
-
- int resId = view.getId();
- if (resId == R.id.view_numbers_button) {
- activity.showNumbersToImportPreviewUi();
- } else if (resId == R.id.import_button) {
- FilteredNumbersUtil.importSendToVoicemailContacts(
- activity,
- new ImportSendToVoicemailContactsListener() {
- @Override
- public void onImportComplete() {
- importSettings.setVisibility(View.GONE);
- }
- });
- } else if (resId == R.id.migrate_promo_allow_button) {
- view.setEnabled(false);
- (blockedNumbersMigratorForTest != null
- ? blockedNumbersMigratorForTest
- : new BlockedNumbersMigrator(getContext()))
- .migrate(
- new Listener() {
- @Override
- public void onComplete() {
- getContext()
- .startActivity(
- FilteredNumberCompat.createManageBlockedNumbersIntent(getContext()));
- // Remove this activity from the backstack
- activity.finish();
- }
- });
- }
- }
-
- @Override
- public void onVisualVoicemailEnabledStatusChanged(boolean newStatus) {
- updateActiveVoicemailProvider();
- }
-
- private void updateActiveVoicemailProvider() {
- if (getActivity() == null || getActivity().isFinishing()) {
- return;
- }
- if (voicemailEnabledChecker.isVisualVoicemailEnabled()) {
- footerText.setText(R.string.block_number_footer_message_vvm);
- } else {
- footerText.setText(R.string.block_number_footer_message_no_vvm);
- }
- }
-
- void setBlockedNumbersMigratorForTest(BlockedNumbersMigrator blockedNumbersMigrator) {
- blockedNumbersMigratorForTest = blockedNumbersMigrator;
- }
-}
diff --git a/java/com/android/dialer/app/filterednumber/BlockedNumbersSettingsActivity.java b/java/com/android/dialer/app/filterednumber/BlockedNumbersSettingsActivity.java
deleted file mode 100644
index 5475b4e..0000000
--- a/java/com/android/dialer/app/filterednumber/BlockedNumbersSettingsActivity.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.dialer.app.filterednumber;
-
-import android.os.Bundle;
-import android.support.v7.app.AppCompatActivity;
-import android.view.MenuItem;
-import com.android.dialer.app.R;
-import com.android.dialer.logging.Logger;
-import com.android.dialer.logging.ScreenEvent;
-
-/** TODO(calderwoodra): documentation */
-public class BlockedNumbersSettingsActivity extends AppCompatActivity {
-
- private static final String TAG_BLOCKED_MANAGEMENT_FRAGMENT = "blocked_management";
- private static final String TAG_VIEW_NUMBERS_TO_IMPORT_FRAGMENT = "view_numbers_to_import";
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.blocked_numbers_activity);
-
- // If savedInstanceState != null, the Activity will automatically restore the last fragment.
- if (savedInstanceState == null) {
- showManagementUi();
- }
- }
-
- /** Shows fragment with the list of currently blocked numbers and settings related to blocking. */
- public void showManagementUi() {
- BlockedNumbersFragment fragment =
- (BlockedNumbersFragment)
- getFragmentManager().findFragmentByTag(TAG_BLOCKED_MANAGEMENT_FRAGMENT);
- if (fragment == null) {
- fragment = new BlockedNumbersFragment();
- }
-
- getFragmentManager()
- .beginTransaction()
- .replace(R.id.blocked_numbers_activity_container, fragment, TAG_BLOCKED_MANAGEMENT_FRAGMENT)
- .commit();
-
- Logger.get(this).logScreenView(ScreenEvent.Type.BLOCKED_NUMBER_MANAGEMENT, this);
- }
-
- /**
- * Shows fragment with UI to preview the numbers of contacts currently marked as send-to-voicemail
- * in Contacts. These numbers can be imported into Dialer's blocked number list.
- */
- public void showNumbersToImportPreviewUi() {
- ViewNumbersToImportFragment fragment =
- (ViewNumbersToImportFragment)
- getFragmentManager().findFragmentByTag(TAG_VIEW_NUMBERS_TO_IMPORT_FRAGMENT);
- if (fragment == null) {
- fragment = new ViewNumbersToImportFragment();
- }
-
- getFragmentManager()
- .beginTransaction()
- .replace(
- R.id.blocked_numbers_activity_container, fragment, TAG_VIEW_NUMBERS_TO_IMPORT_FRAGMENT)
- .addToBackStack(null)
- .commit();
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == android.R.id.home) {
- onBackPressed();
- return true;
- }
- return false;
- }
-
- @Override
- public void onBackPressed() {
- // TODO: Achieve back navigation without overriding onBackPressed.
- if (getFragmentManager().getBackStackEntryCount() > 0) {
- getFragmentManager().popBackStack();
- } else {
- super.onBackPressed();
- }
- }
-}
diff --git a/java/com/android/dialer/app/filterednumber/NumbersAdapter.java b/java/com/android/dialer/app/filterednumber/NumbersAdapter.java
deleted file mode 100644
index 2c08558..0000000
--- a/java/com/android/dialer/app/filterednumber/NumbersAdapter.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.dialer.app.filterednumber;
-
-import android.app.FragmentManager;
-import android.content.Context;
-import android.provider.ContactsContract;
-import android.provider.ContactsContract.CommonDataKinds.Phone;
-import android.text.BidiFormatter;
-import android.text.TextDirectionHeuristics;
-import android.text.TextUtils;
-import android.view.View;
-import android.widget.QuickContactBadge;
-import android.widget.SimpleCursorAdapter;
-import android.widget.TextView;
-import com.android.dialer.app.R;
-import com.android.dialer.contactphoto.ContactPhotoManager;
-import com.android.dialer.contactphoto.ContactPhotoManager.DefaultImageRequest;
-import com.android.dialer.lettertile.LetterTileDrawable;
-import com.android.dialer.phonenumbercache.ContactInfo;
-import com.android.dialer.phonenumbercache.ContactInfoHelper;
-import com.android.dialer.phonenumberutil.PhoneNumberHelper;
-import com.android.dialer.util.UriUtils;
-
-/** TODO(calderwoodra): documentation */
-public class NumbersAdapter extends SimpleCursorAdapter {
-
- private final Context context;
- private final FragmentManager fragmentManager;
- private final ContactInfoHelper contactInfoHelper;
- private final BidiFormatter bidiFormatter = BidiFormatter.getInstance();
- private final ContactPhotoManager contactPhotoManager;
-
- public NumbersAdapter(
- Context context,
- FragmentManager fragmentManager,
- ContactInfoHelper contactInfoHelper,
- ContactPhotoManager contactPhotoManager) {
- super(context, R.layout.blocked_number_item, null, new String[] {}, new int[] {}, 0);
- this.context = context;
- this.fragmentManager = fragmentManager;
- this.contactInfoHelper = contactInfoHelper;
- this.contactPhotoManager = contactPhotoManager;
- }
-
- public void updateView(View view, String number, String countryIso) {
- final TextView callerName = (TextView) view.findViewById(R.id.caller_name);
- final TextView callerNumber = (TextView) view.findViewById(R.id.caller_number);
- final QuickContactBadge quickContactBadge =
- (QuickContactBadge) view.findViewById(R.id.quick_contact_photo);
- quickContactBadge.setOverlay(null);
- quickContactBadge.setPrioritizedMimeType(Phone.CONTENT_ITEM_TYPE);
-
- ContactInfo info = contactInfoHelper.lookupNumber(number, countryIso);
- if (info == null) {
- info = new ContactInfo();
- info.number = number;
- }
- final CharSequence locationOrType = getNumberTypeOrLocation(info, countryIso);
- final String displayNumber = getDisplayNumber(info);
- final String displayNumberStr =
- bidiFormatter.unicodeWrap(displayNumber, TextDirectionHeuristics.LTR);
-
- String nameForDefaultImage;
- if (!TextUtils.isEmpty(info.name)) {
- nameForDefaultImage = info.name;
- callerName.setText(info.name);
- callerNumber.setText(locationOrType + " " + displayNumberStr);
- } else {
- nameForDefaultImage = displayNumber;
- callerName.setText(displayNumberStr);
- if (!TextUtils.isEmpty(locationOrType)) {
- callerNumber.setText(locationOrType);
- callerNumber.setVisibility(View.VISIBLE);
- } else {
- callerNumber.setVisibility(View.GONE);
- }
- }
- loadContactPhoto(info, nameForDefaultImage, quickContactBadge);
- }
-
- private void loadContactPhoto(ContactInfo info, String displayName, QuickContactBadge badge) {
- final String lookupKey =
- info.lookupUri == null ? null : UriUtils.getLookupKeyFromUri(info.lookupUri);
- final int contactType =
- contactInfoHelper.isBusiness(info.sourceType)
- ? LetterTileDrawable.TYPE_BUSINESS
- : LetterTileDrawable.TYPE_DEFAULT;
- final DefaultImageRequest request =
- new DefaultImageRequest(displayName, lookupKey, contactType, true /* isCircular */);
- badge.assignContactUri(info.lookupUri);
- badge.setContentDescription(
- context.getResources().getString(R.string.description_contact_details, displayName));
- contactPhotoManager.loadDirectoryPhoto(
- badge, info.photoUri, false /* darkTheme */, true /* isCircular */, request);
- }
-
- private String getDisplayNumber(ContactInfo info) {
- if (!TextUtils.isEmpty(info.formattedNumber)) {
- return info.formattedNumber;
- } else if (!TextUtils.isEmpty(info.number)) {
- return info.number;
- } else {
- return "";
- }
- }
-
- private CharSequence getNumberTypeOrLocation(ContactInfo info, String countryIso) {
- if (!TextUtils.isEmpty(info.name)) {
- return ContactsContract.CommonDataKinds.Phone.getTypeLabel(
- context.getResources(), info.type, info.label);
- } else {
- return PhoneNumberHelper.getGeoDescription(context, info.number, countryIso);
- }
- }
-
- protected Context getContext() {
- return context;
- }
-
- protected FragmentManager getFragmentManager() {
- return fragmentManager;
- }
-}
diff --git a/java/com/android/dialer/app/filterednumber/ViewNumbersToImportAdapter.java b/java/com/android/dialer/app/filterednumber/ViewNumbersToImportAdapter.java
deleted file mode 100644
index 106c4fb..0000000
--- a/java/com/android/dialer/app/filterednumber/ViewNumbersToImportAdapter.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.dialer.app.filterednumber;
-
-import android.app.FragmentManager;
-import android.content.Context;
-import android.database.Cursor;
-import android.view.View;
-import com.android.dialer.app.R;
-import com.android.dialer.blocking.FilteredNumbersUtil;
-import com.android.dialer.contactphoto.ContactPhotoManager;
-import com.android.dialer.location.GeoUtil;
-import com.android.dialer.phonenumbercache.ContactInfoHelper;
-
-/** TODO(calderwoodra): documentation */
-public class ViewNumbersToImportAdapter extends NumbersAdapter {
-
- private ViewNumbersToImportAdapter(
- Context context,
- FragmentManager fragmentManager,
- ContactInfoHelper contactInfoHelper,
- ContactPhotoManager contactPhotoManager) {
- super(context, fragmentManager, contactInfoHelper, contactPhotoManager);
- }
-
- public static ViewNumbersToImportAdapter newViewNumbersToImportAdapter(
- Context context, FragmentManager fragmentManager) {
- return new ViewNumbersToImportAdapter(
- context,
- fragmentManager,
- new ContactInfoHelper(context, GeoUtil.getCurrentCountryIso(context)),
- ContactPhotoManager.getInstance(context));
- }
-
- @Override
- public void bindView(View view, Context context, Cursor cursor) {
- super.bindView(view, context, cursor);
-
- final String number = cursor.getString(FilteredNumbersUtil.PhoneQuery.NUMBER_COLUMN_INDEX);
-
- view.findViewById(R.id.delete_button).setVisibility(View.GONE);
- updateView(view, number, null /* countryIso */);
- }
-}
diff --git a/java/com/android/dialer/app/filterednumber/ViewNumbersToImportFragment.java b/java/com/android/dialer/app/filterednumber/ViewNumbersToImportFragment.java
deleted file mode 100644
index be3ae79..0000000
--- a/java/com/android/dialer/app/filterednumber/ViewNumbersToImportFragment.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.dialer.app.filterednumber;
-
-import android.app.ListFragment;
-import android.app.LoaderManager;
-import android.content.Context;
-import android.content.CursorLoader;
-import android.content.Loader;
-import android.database.Cursor;
-import android.os.Bundle;
-import android.provider.ContactsContract.CommonDataKinds.Phone;
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.AppCompatActivity;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import com.android.dialer.app.R;
-import com.android.dialer.blocking.FilteredNumbersUtil;
-import com.android.dialer.blocking.FilteredNumbersUtil.ImportSendToVoicemailContactsListener;
-
-/** TODO(calderwoodra): documentation */
-public class ViewNumbersToImportFragment extends ListFragment
- implements LoaderManager.LoaderCallbacks<Cursor>, View.OnClickListener {
-
- private ViewNumbersToImportAdapter adapter;
-
- @Override
- public Context getContext() {
- return getActivity();
- }
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
-
- if (adapter == null) {
- adapter =
- ViewNumbersToImportAdapter.newViewNumbersToImportAdapter(
- getContext(), getActivity().getFragmentManager());
- }
- setListAdapter(adapter);
- }
-
- @Override
- public void onDestroy() {
- setListAdapter(null);
- super.onDestroy();
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getLoaderManager().initLoader(0, null, this);
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
- ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
- actionBar.setTitle(R.string.import_send_to_voicemail_numbers_label);
- actionBar.setDisplayShowCustomEnabled(false);
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- actionBar.setDisplayShowTitleEnabled(true);
-
- getActivity().findViewById(R.id.cancel_button).setOnClickListener(this);
- getActivity().findViewById(R.id.import_button).setOnClickListener(this);
- }
-
- @Override
- public View onCreateView(
- LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- return inflater.inflate(R.layout.view_numbers_to_import_fragment, container, false);
- }
-
- @Override
- public Loader<Cursor> onCreateLoader(int id, Bundle args) {
- final CursorLoader cursorLoader =
- new CursorLoader(
- getContext(),
- Phone.CONTENT_URI,
- FilteredNumbersUtil.PhoneQuery.PROJECTION,
- FilteredNumbersUtil.PhoneQuery.SELECT_SEND_TO_VOICEMAIL_TRUE,
- null,
- null);
- return cursorLoader;
- }
-
- @Override
- public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
- adapter.swapCursor(data);
- }
-
- @Override
- public void onLoaderReset(Loader<Cursor> loader) {
- adapter.swapCursor(null);
- }
-
- @Override
- public void onClick(final View view) {
- if (view.getId() == R.id.import_button) {
- FilteredNumbersUtil.importSendToVoicemailContacts(
- getContext(),
- new ImportSendToVoicemailContactsListener() {
- @Override
- public void onImportComplete() {
- if (getActivity() != null) {
- getActivity().onBackPressed();
- }
- }
- });
- } else if (view.getId() == R.id.cancel_button) {
- getActivity().onBackPressed();
- }
- }
-}
diff --git a/java/com/android/dialer/app/list/ListsFragment.java b/java/com/android/dialer/app/list/ListsFragment.java
index 93e8923..4a606bb 100644
--- a/java/com/android/dialer/app/list/ListsFragment.java
+++ b/java/com/android/dialer/app/list/ListsFragment.java
@@ -46,8 +46,6 @@
import com.android.dialer.logging.UiAction;
import com.android.dialer.performancereport.PerformanceReport;
import com.android.dialer.util.PermissionsUtil;
-import com.android.dialer.voicemail.listui.error.VoicemailStatusCorruptionHandler;
-import com.android.dialer.voicemail.listui.error.VoicemailStatusCorruptionHandler.Source;
import com.android.dialer.voicemailstatus.VisualVoicemailEnabledChecker;
import com.android.dialer.voicemailstatus.VoicemailStatusHelper;
import java.util.ArrayList;
@@ -333,9 +331,6 @@
return;
}
- VoicemailStatusCorruptionHandler.maybeFixVoicemailStatus(
- getContext(), statusCursor, Source.Activity);
-
// Update hasActiveVoicemailProvider, which controls the number of tabs displayed.
boolean hasActiveVoicemailProvider =
VoicemailStatusHelper.getNumberActivityVoicemailSources(statusCursor) > 0;
diff --git a/java/com/android/dialer/app/res/layout/blocked_number_footer.xml b/java/com/android/dialer/app/res/layout/blocked_number_footer.xml
deleted file mode 100644
index 2d36860..0000000
--- a/java/com/android/dialer/app/res/layout/blocked_number_footer.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:focusable="false"
- android:orientation="vertical">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:padding="@dimen/blocked_number_container_padding"
- android:background="@android:color/white"
- android:focusable="true"
- android:orientation="vertical">
-
- <TextView
- android:id="@+id/blocked_number_footer_textview"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/block_number_footer_message_vvm"
- style="@style/Dialer.TextAppearance.Secondary"/>
- </LinearLayout>
-</LinearLayout>
diff --git a/java/com/android/dialer/app/res/layout/blocked_number_fragment.xml b/java/com/android/dialer/app/res/layout/blocked_number_fragment.xml
deleted file mode 100644
index 22dcfef..0000000
--- a/java/com/android/dialer/app/res/layout/blocked_number_fragment.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/blocked_number_fragment"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="?android:attr/colorBackground"
- android:orientation="vertical">
-
- <ListView
- android:id="@id/android:list"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:divider="@null"
- android:headerDividersEnabled="false"/>
-
-</LinearLayout>
diff --git a/java/com/android/dialer/app/res/layout/blocked_number_header.xml b/java/com/android/dialer/app/res/layout/blocked_number_header.xml
deleted file mode 100644
index 27b624c..0000000
--- a/java/com/android/dialer/app/res/layout/blocked_number_header.xml
+++ /dev/null
@@ -1,180 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:card_view="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:focusable="false"
- android:orientation="vertical">
-
- <LinearLayout
- android:id="@+id/blocked_numbers_disabled_for_emergency"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingTop="27dp"
- android:paddingBottom="29dp"
- android:paddingStart="@dimen/blocked_number_container_padding"
- android:paddingEnd="44dp"
- android:background="?android:attr/colorBackground"
- android:focusable="true"
- android:orientation="vertical"
- android:visibility="gone">
-
- <TextView
- style="@style/BlockedNumbersDescriptionTextStyle"
- android:textStyle="bold"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/blocked_numbers_disabled_emergency_header_label"/>
-
- <TextView
- style="@style/BlockedNumbersDescriptionTextStyle"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/blocked_numbers_disabled_emergency_desc"/>
-
- </LinearLayout>
-
- <android.support.v7.widget.CardView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- card_view:cardCornerRadius="0dp">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="@android:color/white"
- android:focusable="true"
- android:orientation="vertical">
-
- <TextView
- android:id="@+id/blocked_number_text_view"
- style="@android:style/TextAppearance.Material.Subhead"
- android:layout_width="wrap_content"
- android:layout_height="48dp"
- android:paddingStart="@dimen/blocked_number_container_padding"
- android:gravity="center_vertical"
- android:text="@string/block_list"
- android:textColor="?android:attr/textColorPrimary"/>
-
- <RelativeLayout
- android:id="@+id/import_settings"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:visibility="gone"
- tools:visibility="visible">
-
- <TextView
- android:id="@+id/import_description"
- style="@style/BlockedNumbersDescriptionTextStyle"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingTop="11dp"
- android:paddingBottom="27dp"
- android:paddingStart="@dimen/blocked_number_container_padding"
- android:paddingEnd="@dimen/blocked_number_container_padding"
- android:text="@string/blocked_call_settings_import_description"
- android:textColor="?colorIcon"
- android:textSize="@dimen/blocked_number_settings_description_text_size"/>
-
- <Button
- android:id="@+id/import_button"
- style="@style/DialerFlatButtonStyle"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginEnd="@dimen/blocked_number_container_padding"
- android:layout_alignParentEnd="true"
- android:layout_below="@id/import_description"
- android:text="@string/blocked_call_settings_import_button"/>
-
- <Button
- android:id="@+id/view_numbers_button"
- style="@style/DialerFlatButtonStyle"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginEnd="8dp"
- android:layout_below="@id/import_description"
- android:layout_toStartOf="@id/import_button"
- android:text="@string/blocked_call_settings_view_numbers_button"/>
-
- <View
- android:layout_width="match_parent"
- android:layout_height="1dp"
- android:layout_marginTop="8dp"
- android:layout_below="@id/import_button"
- android:background="@color/dialer_divider_line_color"/>
-
- </RelativeLayout>
-
- <LinearLayout
- android:id="@+id/migrate_promo"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:visibility="gone"
- tools:visibility="visible">
-
- <TextView
- android:id="@+id/migrate_promo_header"
- style="@android:style/TextAppearance.Material.Subhead"
- android:textStyle="bold"
- android:layout_width="match_parent"
- android:layout_height="48dp"
- android:paddingStart="@dimen/blocked_number_container_padding"
- android:paddingEnd="@dimen/blocked_number_container_padding"
- android:gravity="center_vertical"
- android:text="@string/migrate_blocked_numbers_dialog_title"
- android:textColor="?android:attr/textColorPrimary"/>
-
- <TextView
- android:id="@+id/migrate_promo_description"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginBottom="@dimen/blocked_number_container_padding"
- android:layout_marginStart="@dimen/blocked_number_container_padding"
- android:layout_marginEnd="@dimen/blocked_number_container_padding"
- android:text="@string/migrate_blocked_numbers_dialog_message"
- android:textColor="?colorIcon"/>
-
- <Button
- android:id="@+id/migrate_promo_allow_button"
- style="@style/DialerPrimaryFlatButtonStyle"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginBottom="@dimen/blocked_number_container_padding"
- android:layout_marginStart="@dimen/blocked_number_container_padding"
- android:layout_marginEnd="@dimen/blocked_number_container_padding"
- android:layout_gravity="end"
- android:text="@string/migrate_blocked_numbers_dialog_allow_button"/>
-
- <View
- style="@style/FullWidthDivider"/>
-
- </LinearLayout>
-
- <View
- android:id="@+id/blocked_number_list_divider"
- android:layout_width="match_parent"
- android:layout_height="1dp"
- android:layout_marginStart="72dp"
- android:background="@color/dialer_divider_line_color"/>
-
- </LinearLayout>
-
- </android.support.v7.widget.CardView>
-
-</LinearLayout>
diff --git a/java/com/android/dialer/app/res/layout/blocked_number_item.xml b/java/com/android/dialer/app/res/layout/blocked_number_item.xml
deleted file mode 100644
index 921c476..0000000
--- a/java/com/android/dialer/app/res/layout/blocked_number_item.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/caller_information"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingStart="@dimen/blocked_number_horizontal_margin"
- android:background="@android:color/white"
- android:baselineAligned="false"
- android:focusable="true"
- android:gravity="center_vertical"
- android:orientation="horizontal">
-
- <QuickContactBadge
- android:id="@+id/quick_contact_photo"
- android:layout_width="@dimen/contact_photo_size"
- android:layout_height="@dimen/contact_photo_size"
- android:layout_marginTop="@dimen/blocked_number_top_margin"
- android:layout_marginBottom="@dimen/blocked_number_bottom_margin"
- android:focusable="true"/>
- <LinearLayout
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:layout_marginStart="@dimen/blocked_number_horizontal_margin"
- android:gravity="center_vertical"
- android:orientation="vertical">
-
- <TextView
- android:id="@+id/caller_name"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:includeFontPadding="false"
- style="@style/Dialer.TextAppearance.Primary.Ellipsize"/>
-
- <TextView
- android:id="@+id/caller_number"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- style="@style/Dialer.TextAppearance.Secondary.Ellipsize"/>
- </LinearLayout>
-
- <ImageView
- android:id="@+id/delete_button"
- android:layout_width="@dimen/blocked_number_delete_icon_size"
- android:layout_height="@dimen/blocked_number_delete_icon_size"
- android:layout_marginEnd="24dp"
- android:background="?android:attr/selectableItemBackgroundBorderless"
- android:contentDescription="@string/description_blocked_number_list_delete"
- android:scaleType="center"
- android:src="@drawable/ic_remove"
- android:tint="?colorIcon"/>
-</LinearLayout>
diff --git a/java/com/android/dialer/app/res/layout/blocked_numbers_activity.xml b/java/com/android/dialer/app/res/layout/blocked_numbers_activity.xml
deleted file mode 100644
index 0c4874c..0000000
--- a/java/com/android/dialer/app/res/layout/blocked_numbers_activity.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/blocked_numbers_activity_container"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_marginTop="@dimen/action_bar_height">
-</FrameLayout>
diff --git a/java/com/android/dialer/app/res/layout/view_numbers_to_import_fragment.xml b/java/com/android/dialer/app/res/layout/view_numbers_to_import_fragment.xml
deleted file mode 100644
index e821c06..0000000
--- a/java/com/android/dialer/app/res/layout/view_numbers_to_import_fragment.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="?android:attr/colorBackground"
- android:orientation="vertical">
-
- <ListView
- android:id="@id/android:list"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1"
- android:divider="@null"
- android:headerDividersEnabled="false"/>
-
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom"
- android:paddingTop="8dp"
- android:paddingBottom="8dp"
- android:background="@android:color/white">
-
- <Button
- android:id="@+id/import_button"
- style="@style/DialerFlatButtonStyle"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginEnd="@dimen/blocked_number_container_padding"
- android:layout_alignParentEnd="true"
- android:text="@string/blocked_call_settings_import_button"/>
-
- <Button
- android:id="@+id/cancel_button"
- style="@style/DialerFlatButtonStyle"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@id/import_description"
- android:layout_toLeftOf="@id/import_button"
- android:text="@android:string/cancel"/>
-
- </RelativeLayout>
-
-</LinearLayout>
diff --git a/java/com/android/dialer/app/settings/DialerSettingsActivity.java b/java/com/android/dialer/app/settings/DialerSettingsActivity.java
index 6ffa62a..12331ba 100644
--- a/java/com/android/dialer/app/settings/DialerSettingsActivity.java
+++ b/java/com/android/dialer/app/settings/DialerSettingsActivity.java
@@ -19,8 +19,6 @@
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.UserManager;
import android.preference.PreferenceManager;
@@ -34,11 +32,9 @@
import android.widget.Toast;
import com.android.dialer.about.AboutPhoneFragment;
import com.android.dialer.app.R;
-import com.android.dialer.assisteddialing.ConcreteCreator;
-import com.android.dialer.blocking.FilteredNumberCompat;
+import com.android.dialer.blocking.FilteredNumbersUtil;
import com.android.dialer.common.LogUtil;
import com.android.dialer.compat.telephony.TelephonyManagerCompat;
-import com.android.dialer.configprovider.ConfigProviderComponent;
import com.android.dialer.lookup.LookupSettingsFragment;
import com.android.dialer.proguard.UsedByReflection;
import com.android.dialer.util.PermissionsUtil;
@@ -52,7 +48,6 @@
public class DialerSettingsActivity extends AppCompatPreferenceActivity {
protected SharedPreferences preferences;
- private boolean migrationStatusOnBuildHeaders;
private List<Header> headers;
@Override
@@ -80,13 +75,6 @@
@Override
protected void onResume() {
super.onResume();
- /*
- * The blockedCallsHeader need to be recreated if the migration status changed because
- * the intent needs to be updated.
- */
- if (migrationStatusOnBuildHeaders != FilteredNumberCompat.hasMigratedToNewBlocking(this)) {
- invalidateHeaders();
- }
}
@Override
@@ -142,12 +130,12 @@
phoneAccountSettingsHeader.intent = phoneAccountSettingsIntent;
target.add(phoneAccountSettingsHeader);
}
- if (FilteredNumberCompat.canCurrentUserOpenBlockSettings(this)) {
+ if (FilteredNumbersUtil.canCurrentUserOpenBlockSettings(this)) {
Header blockedCallsHeader = new Header();
blockedCallsHeader.titleRes = R.string.manage_blocked_numbers_label;
- blockedCallsHeader.intent = FilteredNumberCompat.createManageBlockedNumbersIntent(this);
+ blockedCallsHeader.intent = getApplicationContext().getSystemService(TelecomManager.class)
+ .createManageBlockedNumbersIntent();
target.add(blockedCallsHeader);
- migrationStatusOnBuildHeaders = FilteredNumberCompat.hasMigratedToNewBlocking(this);
}
addVoicemailSettings(target, isPrimaryUser);
@@ -163,22 +151,6 @@
target.add(accessibilitySettingsHeader);
}
- boolean isAssistedDialingEnabled =
- ConcreteCreator.isAssistedDialingEnabled(
- ConfigProviderComponent.get(getApplicationContext()).getConfigProvider());
- LogUtil.i(
- "DialerSettingsActivity.onBuildHeaders",
- "showing assisted dialing header: " + isAssistedDialingEnabled);
- if (isAssistedDialingEnabled) {
-
- Header assistedDialingSettingsHeader = new Header();
- assistedDialingSettingsHeader.titleRes =
- com.android.dialer.assisteddialing.ui.R.string.assisted_dialing_setting_title;
- assistedDialingSettingsHeader.intent =
- new Intent("com.android.dialer.app.settings.SHOW_ASSISTED_DIALING_SETTINGS");
- target.add(assistedDialingSettingsHeader);
- }
-
if (showAbout()) {
Header aboutPhoneHeader = new Header();
aboutPhoneHeader.titleRes = R.string.about_phone_label;
@@ -192,12 +164,6 @@
LogUtil.i("DialerSettingsActivity.addVoicemailSettings", "user not primary user");
return;
}
- if (VERSION.SDK_INT < VERSION_CODES.O) {
- LogUtil.i(
- "DialerSettingsActivity.addVoicemailSettings",
- "Dialer voicemail settings not supported by system");
- return;
- }
if (!PermissionsUtil.hasReadPhoneStatePermissions(this)) {
LogUtil.i("DialerSettingsActivity.addVoicemailSettings", "Missing READ_PHONE_STATE");
diff --git a/java/com/android/dialer/app/voicemail/LegacyVoicemailNotificationReceiver.java b/java/com/android/dialer/app/voicemail/LegacyVoicemailNotificationReceiver.java
index cf76385..7e71bf4 100644
--- a/java/com/android/dialer/app/voicemail/LegacyVoicemailNotificationReceiver.java
+++ b/java/com/android/dialer/app/voicemail/LegacyVoicemailNotificationReceiver.java
@@ -16,15 +16,11 @@
package com.android.dialer.app.voicemail;
-import android.annotation.TargetApi;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
-import android.os.Build;
-import android.os.Build.VERSION_CODES;
import android.support.annotation.VisibleForTesting;
-import android.support.v4.os.BuildCompat;
import android.support.v4.os.UserManagerCompat;
import android.telecom.PhoneAccountHandle;
import android.telephony.TelephonyManager;
@@ -42,7 +38,6 @@
* LegacyVoicemailNotifier}. Will ignore the notification if the account has visual voicemail.
* Legacy voicemail is the traditional, non-visual, dial-in voicemail.
*/
-@TargetApi(VERSION_CODES.O)
public class LegacyVoicemailNotificationReceiver extends BroadcastReceiver {
@VisibleForTesting static final String LEGACY_VOICEMAIL_DISMISSED = "legacy_voicemail_dismissed";
@@ -57,18 +52,6 @@
LogUtil.i(
"LegacyVoicemailNotificationReceiver.onReceive", "received legacy voicemail notification");
- if (!BuildCompat.isAtLeastO()) {
- LogUtil.e(
- "LegacyVoicemailNotificationReceiver.onReceive",
- "SDK not finalized: SDK_INT="
- + Build.VERSION.SDK_INT
- + ", PREVIEW_SDK_INT="
- + Build.VERSION.PREVIEW_SDK_INT
- + ", RELEASE="
- + Build.VERSION.RELEASE_OR_CODENAME);
- return;
- }
-
PhoneAccountHandle phoneAccountHandle =
Assert.isNotNull(intent.getParcelableExtra(TelephonyManager.EXTRA_PHONE_ACCOUNT_HANDLE));
int count = intent.getIntExtra(TelephonyManager.EXTRA_NOTIFICATION_COUNT, -1);
diff --git a/java/com/android/dialer/assisteddialing/ConcreteCreator.java b/java/com/android/dialer/assisteddialing/ConcreteCreator.java
index b4f926d..6e14516 100644
--- a/java/com/android/dialer/assisteddialing/ConcreteCreator.java
+++ b/java/com/android/dialer/assisteddialing/ConcreteCreator.java
@@ -22,6 +22,8 @@
import android.support.annotation.NonNull;
import android.support.v4.os.UserManagerCompat;
import android.telephony.TelephonyManager;
+
+import com.android.dialer.R;
import com.android.dialer.common.LogUtil;
import com.android.dialer.configprovider.ConfigProvider;
import com.android.dialer.configprovider.ConfigProviderComponent;
@@ -35,10 +37,6 @@
*/
public final class ConcreteCreator {
- // Ceiling set at P (version code 28) because this feature will ship as part of the framework in
- // Q.
- public static final int BUILD_CODE_CEILING = 28;
-
/**
* Creates a new AssistedDialingMediator
*
@@ -49,59 +47,7 @@
*/
public static AssistedDialingMediator createNewAssistedDialingMediator(
@NonNull TelephonyManager telephonyManager, @NonNull Context context) {
-
- ConfigProvider configProvider = ConfigProviderComponent.get(context).getConfigProvider();
-
- if (telephonyManager == null) {
- LogUtil.i(
- "ConcreteCreator.createNewAssistedDialingMediator", "provided TelephonyManager was null");
- throw new NullPointerException("Provided TelephonyManager was null");
- }
- if (context == null) {
- LogUtil.i("ConcreteCreator.createNewAssistedDialingMediator", "provided context was null");
- throw new NullPointerException("Provided context was null");
- }
-
- if (!UserManagerCompat.isUserUnlocked(context)) {
- // To avoid any issues reading preferences, we disable the feature when the user is in a
- // locked state.
- LogUtil.i("ConcreteCreator.createNewAssistedDialingMediator", "user is locked");
- return new AssistedDialingMediatorStub();
- }
-
- if (!isAssistedDialingEnabled(configProvider)) {
- LogUtil.i("ConcreteCreator.createNewAssistedDialingMediator", "feature not enabled");
- return new AssistedDialingMediatorStub();
- }
-
- if (!PreferenceManager.getDefaultSharedPreferences(context)
- .getBoolean(context.getString(R.string.assisted_dialing_setting_toggle_key), true)) {
- LogUtil.i("ConcreteCreator.createNewAssistedDialingMediator", "disabled by local setting");
-
- return new AssistedDialingMediatorStub();
- }
-
- Constraints constraints = new Constraints(context, getCountryCodeProvider(configProvider));
- return new AssistedDialingMediatorImpl(
- new LocationDetector(
- telephonyManager,
- StrictModeUtils.bypass(
- () ->
- PreferenceManager.getDefaultSharedPreferences(context)
- .getString(
- context.getString(R.string.assisted_dialing_setting_cc_key), null))),
- new NumberTransformer(constraints));
- }
-
- /** Returns a boolean indicating whether or not the assisted dialing feature is enabled. */
- public static boolean isAssistedDialingEnabled(@NonNull ConfigProvider configProvider) {
- if (configProvider == null) {
- LogUtil.i("ConcreteCreator.isAssistedDialingEnabled", "provided configProvider was null");
- throw new NullPointerException("Provided configProvider was null");
- }
-
- return Build.VERSION.SDK_INT <= BUILD_CODE_CEILING
- && configProvider.getBoolean("assisted_dialing_enabled", false);
+ return new AssistedDialingMediatorStub();
}
/**
diff --git a/java/com/android/dialer/assisteddialing/ui/AssistedDialingSettingFragment.java b/java/com/android/dialer/assisteddialing/ui/AssistedDialingSettingFragment.java
index 2da2528..76e6127 100644
--- a/java/com/android/dialer/assisteddialing/ui/AssistedDialingSettingFragment.java
+++ b/java/com/android/dialer/assisteddialing/ui/AssistedDialingSettingFragment.java
@@ -23,6 +23,8 @@
import android.preference.PreferenceFragment;
import android.preference.SwitchPreference;
import android.telephony.TelephonyManager;
+
+import com.android.dialer.R;
import com.android.dialer.assisteddialing.AssistedDialingMediator;
import com.android.dialer.assisteddialing.ConcreteCreator;
import com.android.dialer.assisteddialing.CountryCodeProvider;
diff --git a/java/com/android/dialer/binary/common/DialerApplication.java b/java/com/android/dialer/binary/common/DialerApplication.java
index 0f15025..146c252 100644
--- a/java/com/android/dialer/binary/common/DialerApplication.java
+++ b/java/com/android/dialer/binary/common/DialerApplication.java
@@ -19,9 +19,6 @@
import android.app.Application;
import android.os.Trace;
import android.support.annotation.NonNull;
-import android.support.v4.os.BuildCompat;
-import com.android.dialer.blocking.BlockedNumbersAutoMigrator;
-import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler;
import com.android.dialer.calllog.CallLogComponent;
import com.android.dialer.calllog.CallLogFramework;
import com.android.dialer.calllog.config.CallLogConfig;
@@ -44,21 +41,13 @@
Trace.beginSection("DialerApplication.onCreate");
StrictModeComponent.get(this).getDialerStrictMode().onApplicationCreate(this);
super.onCreate();
- new BlockedNumbersAutoMigrator(
- this.getApplicationContext(),
- new FilteredNumberAsyncQueryHandler(this),
- DialerExecutorComponent.get(this).dialerExecutorFactory())
- .asyncAutoMigrate();
new CallRecordingAutoMigrator(
this.getApplicationContext(),
DialerExecutorComponent.get(this).dialerExecutorFactory())
.asyncAutoMigrate();
initializeAnnotatedCallLog();
PersistentLogger.initialize(this);
-
- if (BuildCompat.isAtLeastO()) {
- NotificationChannelManager.initChannels(this);
- }
+ NotificationChannelManager.initChannels(this);
Trace.endSection();
}
diff --git a/java/com/android/dialer/blocking/AndroidManifest.xml b/java/com/android/dialer/blocking/AndroidManifest.xml
index fb811ea..c71c491 100644
--- a/java/com/android/dialer/blocking/AndroidManifest.xml
+++ b/java/com/android/dialer/blocking/AndroidManifest.xml
@@ -15,13 +15,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.dialer.blocking">
- <application>
+ <application />
- <provider
- android:authorities="com.android.dialer.blocking.filterednumberprovider"
- android:exported="false"
- android:multiprocess="false"
- android:name="com.android.dialer.blocking.FilteredNumberProvider"/>
-
- </application>
</manifest>
diff --git a/java/com/android/dialer/blocking/BlockNumberDialogFragment.java b/java/com/android/dialer/blocking/BlockNumberDialogFragment.java
deleted file mode 100644
index de974cb..0000000
--- a/java/com/android/dialer/blocking/BlockNumberDialogFragment.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.dialer.blocking;
-
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.app.DialogFragment;
-import android.app.FragmentManager;
-import android.content.ContentValues;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.net.Uri;
-import android.os.Bundle;
-import android.support.design.widget.Snackbar;
-import android.telephony.PhoneNumberUtils;
-import android.text.TextUtils;
-import android.view.View;
-import android.widget.Toast;
-import com.android.contacts.common.util.ContactDisplayUtils;
-import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler.OnBlockNumberListener;
-import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler.OnUnblockNumberListener;
-import com.android.dialer.logging.InteractionEvent;
-import com.android.dialer.logging.Logger;
-import com.android.dialer.voicemailstatus.VisualVoicemailEnabledChecker;
-
-/**
- * Fragment for confirming and enacting blocking/unblocking a number. Also invokes snackbar
- * providing undo functionality.
- */
-@Deprecated
-public class BlockNumberDialogFragment extends DialogFragment {
-
- private static final String BLOCK_DIALOG_FRAGMENT = "BlockNumberDialog";
- private static final String ARG_BLOCK_ID = "argBlockId";
- private static final String ARG_NUMBER = "argNumber";
- private static final String ARG_COUNTRY_ISO = "argCountryIso";
- private static final String ARG_DISPLAY_NUMBER = "argDisplayNumber";
- private static final String ARG_PARENT_VIEW_ID = "parentViewId";
- private String number;
- private String displayNumber;
- private String countryIso;
- private FilteredNumberAsyncQueryHandler handler;
- private View parentView;
- private VisualVoicemailEnabledChecker voicemailEnabledChecker;
- private Callback callback;
-
- public static BlockNumberDialogFragment show(
- Integer blockId,
- String number,
- String countryIso,
- String displayNumber,
- Integer parentViewId,
- FragmentManager fragmentManager,
- Callback callback) {
- final BlockNumberDialogFragment newFragment =
- BlockNumberDialogFragment.newInstance(
- blockId, number, countryIso, displayNumber, parentViewId);
-
- newFragment.setCallback(callback);
- newFragment.show(fragmentManager, BlockNumberDialogFragment.BLOCK_DIALOG_FRAGMENT);
- return newFragment;
- }
-
- private static BlockNumberDialogFragment newInstance(
- Integer blockId,
- String number,
- String countryIso,
- String displayNumber,
- Integer parentViewId) {
- final BlockNumberDialogFragment fragment = new BlockNumberDialogFragment();
- final Bundle args = new Bundle();
- if (blockId != null) {
- args.putInt(ARG_BLOCK_ID, blockId.intValue());
- }
- if (parentViewId != null) {
- args.putInt(ARG_PARENT_VIEW_ID, parentViewId.intValue());
- }
- args.putString(ARG_NUMBER, number);
- args.putString(ARG_COUNTRY_ISO, countryIso);
- args.putString(ARG_DISPLAY_NUMBER, displayNumber);
- fragment.setArguments(args);
- return fragment;
- }
-
- public void setFilteredNumberAsyncQueryHandlerForTesting(
- FilteredNumberAsyncQueryHandler handler) {
- this.handler = handler;
- }
-
- @Override
- public Context getContext() {
- return getActivity();
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- super.onCreateDialog(savedInstanceState);
- final boolean isBlocked = getArguments().containsKey(ARG_BLOCK_ID);
-
- number = getArguments().getString(ARG_NUMBER);
- displayNumber = getArguments().getString(ARG_DISPLAY_NUMBER);
- countryIso = getArguments().getString(ARG_COUNTRY_ISO);
-
- if (TextUtils.isEmpty(displayNumber)) {
- displayNumber = number;
- }
-
- handler = new FilteredNumberAsyncQueryHandler(getContext());
- voicemailEnabledChecker = new VisualVoicemailEnabledChecker(getActivity(), null);
- // Choose not to update VoicemailEnabledChecker, as checks should already been done in
- // all current use cases.
- parentView = getActivity().findViewById(getArguments().getInt(ARG_PARENT_VIEW_ID));
-
- CharSequence title;
- String okText;
- String message;
- if (isBlocked) {
- title = null;
- okText = getString(R.string.unblock_number_ok);
- message =
- ContactDisplayUtils.getTtsSpannedPhoneNumber(
- getResources(), R.string.unblock_number_confirmation_title, displayNumber)
- .toString();
- } else {
- title =
- ContactDisplayUtils.getTtsSpannedPhoneNumber(
- getResources(), R.string.old_block_number_confirmation_title, displayNumber);
- okText = getString(R.string.block_number_ok);
- if (FilteredNumberCompat.useNewFiltering(getContext())) {
- message = getString(R.string.block_number_confirmation_message_new_filtering);
- } else if (voicemailEnabledChecker.isVisualVoicemailEnabled()) {
- message = getString(R.string.block_number_confirmation_message_vvm);
- } else {
- message = getString(R.string.block_number_confirmation_message_no_vvm);
- }
- }
-
- AlertDialog.Builder builder =
- new AlertDialog.Builder(getActivity())
- .setTitle(title)
- .setMessage(message)
- .setPositiveButton(
- okText,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int id) {
- if (isBlocked) {
- unblockNumber();
- } else {
- blockNumber();
- }
- }
- })
- .setNegativeButton(android.R.string.cancel, null);
- return builder.create();
- }
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
- String e164Number = PhoneNumberUtils.formatNumberToE164(number, countryIso);
- if (!FilteredNumbersUtil.canBlockNumber(getContext(), e164Number, number)) {
- dismiss();
- Toast.makeText(
- getContext(),
- ContactDisplayUtils.getTtsSpannedPhoneNumber(
- getResources(), R.string.invalidNumber, displayNumber),
- Toast.LENGTH_SHORT)
- .show();
- }
- }
-
- @Override
- public void onPause() {
- // Dismiss on rotation.
- dismiss();
- callback = null;
-
- super.onPause();
- }
-
- public void setCallback(Callback callback) {
- this.callback = callback;
- }
-
- private CharSequence getBlockedMessage() {
- return ContactDisplayUtils.getTtsSpannedPhoneNumber(
- getResources(), R.string.snackbar_number_blocked, displayNumber);
- }
-
- private CharSequence getUnblockedMessage() {
- return ContactDisplayUtils.getTtsSpannedPhoneNumber(
- getResources(), R.string.snackbar_number_unblocked, displayNumber);
- }
-
- private int getActionTextColor() {
- return getContext().getResources().getColor(R.color.dialer_snackbar_action_text_color);
- }
-
- private void blockNumber() {
- final CharSequence message = getBlockedMessage();
- final CharSequence undoMessage = getUnblockedMessage();
- final Callback callback = this.callback;
- final int actionTextColor = getActionTextColor();
- final Context applicationContext = getContext().getApplicationContext();
-
- final OnUnblockNumberListener onUndoListener =
- new OnUnblockNumberListener() {
- @Override
- public void onUnblockComplete(int rows, ContentValues values) {
- Snackbar.make(parentView, undoMessage, Snackbar.LENGTH_LONG).show();
- if (callback != null) {
- callback.onChangeFilteredNumberUndo();
- }
- }
- };
-
- final OnBlockNumberListener onBlockNumberListener =
- new OnBlockNumberListener() {
- @Override
- public void onBlockComplete(final Uri uri) {
- final View.OnClickListener undoListener =
- new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- // Delete the newly created row on 'undo'.
- Logger.get(applicationContext)
- .logInteraction(InteractionEvent.Type.UNDO_BLOCK_NUMBER);
- handler.unblock(onUndoListener, uri);
- }
- };
-
- Snackbar.make(parentView, message, Snackbar.LENGTH_LONG)
- .setAction(R.string.snackbar_undo, undoListener)
- .setActionTextColor(actionTextColor)
- .show();
-
- if (callback != null) {
- callback.onFilterNumberSuccess();
- }
-
- if (FilteredNumbersUtil.hasRecentEmergencyCall(applicationContext)) {
- FilteredNumbersUtil.maybeNotifyCallBlockingDisabled(applicationContext);
- }
- }
- };
-
- handler.blockNumber(onBlockNumberListener, number, countryIso);
- }
-
- private void unblockNumber() {
- final CharSequence message = getUnblockedMessage();
- final CharSequence undoMessage = getBlockedMessage();
- final Callback callback = this.callback;
- final int actionTextColor = getActionTextColor();
- final Context applicationContext = getContext().getApplicationContext();
-
- final OnBlockNumberListener onUndoListener =
- new OnBlockNumberListener() {
- @Override
- public void onBlockComplete(final Uri uri) {
- Snackbar.make(parentView, undoMessage, Snackbar.LENGTH_LONG).show();
- if (callback != null) {
- callback.onChangeFilteredNumberUndo();
- }
- }
- };
-
- handler.unblock(
- new OnUnblockNumberListener() {
- @Override
- public void onUnblockComplete(int rows, final ContentValues values) {
- final View.OnClickListener undoListener =
- new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- // Re-insert the row on 'undo', with a new ID.
- Logger.get(applicationContext)
- .logInteraction(InteractionEvent.Type.UNDO_UNBLOCK_NUMBER);
- handler.blockNumber(onUndoListener, values);
- }
- };
-
- Snackbar.make(parentView, message, Snackbar.LENGTH_LONG)
- .setAction(R.string.snackbar_undo, undoListener)
- .setActionTextColor(actionTextColor)
- .show();
-
- if (callback != null) {
- callback.onUnfilterNumberSuccess();
- }
- }
- },
- getArguments().getInt(ARG_BLOCK_ID));
- }
-
- /**
- * Use a callback interface to update UI after success/undo. Favor this approach over other more
- * standard paradigms because of the variety of scenarios in which the DialogFragment can be
- * invoked (by an Activity, by a fragment, by an adapter, by an adapter list item). Because of
- * this, we do NOT support retaining state on rotation, and will dismiss the dialog upon rotation
- * instead.
- */
- public interface Callback {
-
- /** Called when a number is successfully added to the set of filtered numbers */
- void onFilterNumberSuccess();
-
- /** Called when a number is successfully removed from the set of filtered numbers */
- void onUnfilterNumberSuccess();
-
- /** Called when the action of filtering or unfiltering a number is undone */
- void onChangeFilteredNumberUndo();
- }
-}
diff --git a/java/com/android/dialer/blocking/BlockedNumbersAutoMigrator.java b/java/com/android/dialer/blocking/BlockedNumbersAutoMigrator.java
deleted file mode 100644
index 8a57f29..0000000
--- a/java/com/android/dialer/blocking/BlockedNumbersAutoMigrator.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.dialer.blocking;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.preference.PreferenceManager;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v4.os.UserManagerCompat;
-import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler.OnHasBlockedNumbersListener;
-import com.android.dialer.common.Assert;
-import com.android.dialer.common.LogUtil;
-import com.android.dialer.common.concurrent.DialerExecutor.Worker;
-import com.android.dialer.common.concurrent.DialerExecutorFactory;
-
-/**
- * Class responsible for checking if the user can be auto-migrated to {@link
- * android.provider.BlockedNumberContract} blocking. In order for this to happen, the user cannot
- * have any numbers that are blocked in the Dialer solution.
- */
-@Deprecated
-public class BlockedNumbersAutoMigrator {
-
- static final String HAS_CHECKED_AUTO_MIGRATE_KEY = "checkedAutoMigrate";
-
- @NonNull private final Context appContext;
- @NonNull private final FilteredNumberAsyncQueryHandler queryHandler;
- @NonNull private final DialerExecutorFactory dialerExecutorFactory;
-
- /**
- * Constructs the BlockedNumbersAutoMigrator with the given {@link
- * FilteredNumberAsyncQueryHandler}.
- *
- * @param queryHandler The FilteredNumberAsyncQueryHandler used to determine if there are blocked
- * numbers.
- * @throws NullPointerException if sharedPreferences or queryHandler are null.
- */
- public BlockedNumbersAutoMigrator(
- @NonNull Context appContext,
- @NonNull FilteredNumberAsyncQueryHandler queryHandler,
- @NonNull DialerExecutorFactory dialerExecutorFactory) {
- this.appContext = Assert.isNotNull(appContext);
- this.queryHandler = Assert.isNotNull(queryHandler);
- this.dialerExecutorFactory = Assert.isNotNull(dialerExecutorFactory);
- }
-
- public void asyncAutoMigrate() {
- dialerExecutorFactory
- .createNonUiTaskBuilder(new ShouldAttemptAutoMigrate(appContext))
- .onSuccess(this::autoMigrate)
- .build()
- .executeParallel(null);
- }
-
- /**
- * 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 if blocked numbers don't exist.
- */
- private void autoMigrate(boolean shouldAttemptAutoMigrate) {
- if (!shouldAttemptAutoMigrate) {
- return;
- }
-
- LogUtil.i("BlockedNumbersAutoMigrator", "attempting to auto-migrate.");
- queryHandler.hasBlockedNumbers(
- new OnHasBlockedNumbersListener() {
- @Override
- public void onHasBlockedNumbers(boolean hasBlockedNumbers) {
- if (hasBlockedNumbers) {
- LogUtil.i("BlockedNumbersAutoMigrator", "not auto-migrating: blocked numbers exist.");
- return;
- }
- LogUtil.i("BlockedNumbersAutoMigrator", "auto-migrating: no blocked numbers.");
- FilteredNumberCompat.setHasMigratedToNewBlocking(appContext, true);
- }
- });
- }
-
- private static class ShouldAttemptAutoMigrate implements Worker<Void, Boolean> {
- private final Context appContext;
-
- ShouldAttemptAutoMigrate(Context appContext) {
- this.appContext = appContext;
- }
-
- @Nullable
- @Override
- public Boolean doInBackground(@Nullable Void input) {
- if (!UserManagerCompat.isUserUnlocked(appContext)) {
- LogUtil.i("BlockedNumbersAutoMigrator", "not attempting auto-migrate: device is locked");
- return false;
- }
- SharedPreferences sharedPreferences =
- PreferenceManager.getDefaultSharedPreferences(appContext);
-
- if (sharedPreferences.contains(HAS_CHECKED_AUTO_MIGRATE_KEY)) {
- LogUtil.v(
- "BlockedNumbersAutoMigrator", "not attempting auto-migrate: already checked once.");
- return false;
- }
-
- if (!FilteredNumberCompat.canAttemptBlockOperations(appContext)) {
- // This may be the case where the user is on the lock screen, so we shouldn't record that
- // the migration status was checked.
- LogUtil.i(
- "BlockedNumbersAutoMigrator", "not attempting auto-migrate: current user can't block");
- return false;
- }
- LogUtil.i(
- "BlockedNumbersAutoMigrator", "updating state as already checked for auto-migrate.");
- sharedPreferences.edit().putBoolean(HAS_CHECKED_AUTO_MIGRATE_KEY, true).apply();
-
- if (!FilteredNumberCompat.canUseNewFiltering()) {
- LogUtil.i("BlockedNumbersAutoMigrator", "not attempting auto-migrate: not available.");
- return false;
- }
-
- if (FilteredNumberCompat.hasMigratedToNewBlocking(appContext)) {
- LogUtil.i("BlockedNumbersAutoMigrator", "not attempting auto-migrate: already migrated.");
- return false;
- }
- return true;
- }
- }
-}
diff --git a/java/com/android/dialer/blocking/BlockedNumbersMigrator.java b/java/com/android/dialer/blocking/BlockedNumbersMigrator.java
deleted file mode 100644
index ef047a0..0000000
--- a/java/com/android/dialer/blocking/BlockedNumbersMigrator.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.dialer.blocking;
-
-import android.content.ContentResolver;
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.os.AsyncTask;
-import android.provider.BlockedNumberContract.BlockedNumbers;
-import com.android.dialer.common.LogUtil;
-import com.android.dialer.database.FilteredNumberContract;
-import com.android.dialer.database.FilteredNumberContract.FilteredNumber;
-import com.android.dialer.database.FilteredNumberContract.FilteredNumberColumns;
-import java.util.Objects;
-
-/**
- * Class which should be used to migrate numbers from {@link FilteredNumberContract} blocking to
- * {@link android.provider.BlockedNumberContract} blocking.
- */
-@Deprecated
-public class BlockedNumbersMigrator {
-
- private final Context context;
-
- /**
- * Creates a new BlockedNumbersMigrate, using the given {@link ContentResolver} to perform queries
- * against the blocked numbers tables.
- */
- public BlockedNumbersMigrator(Context context) {
- this.context = Objects.requireNonNull(context);
- }
-
- private static boolean migrateToNewBlockingInBackground(ContentResolver resolver) {
- try (Cursor cursor =
- resolver.query(
- FilteredNumber.CONTENT_URI,
- new String[] {FilteredNumberColumns.NUMBER},
- null,
- null,
- null)) {
- if (cursor == null) {
- LogUtil.i(
- "BlockedNumbersMigrator.migrateToNewBlockingInBackground", "migrate - cursor was null");
- return false;
- }
-
- LogUtil.i(
- "BlockedNumbersMigrator.migrateToNewBlockingInBackground",
- "migrate - attempting to migrate " + cursor.getCount() + "numbers");
-
- int numMigrated = 0;
- while (cursor.moveToNext()) {
- String originalNumber =
- cursor.getString(cursor.getColumnIndex(FilteredNumberColumns.NUMBER));
- if (isNumberInNewBlocking(resolver, originalNumber)) {
- LogUtil.i(
- "BlockedNumbersMigrator.migrateToNewBlockingInBackground",
- "migrate - number was already blocked in new blocking");
- continue;
- }
- ContentValues values = new ContentValues();
- values.put(BlockedNumbers.COLUMN_ORIGINAL_NUMBER, originalNumber);
- resolver.insert(BlockedNumbers.CONTENT_URI, values);
- ++numMigrated;
- }
- LogUtil.i(
- "BlockedNumbersMigrator.migrateToNewBlockingInBackground",
- "migrate - migration complete. " + numMigrated + " numbers migrated.");
- return true;
- }
- }
-
- private static boolean isNumberInNewBlocking(ContentResolver resolver, String originalNumber) {
- try (Cursor cursor =
- resolver.query(
- BlockedNumbers.CONTENT_URI,
- new String[] {BlockedNumbers.COLUMN_ID},
- BlockedNumbers.COLUMN_ORIGINAL_NUMBER + " = ?",
- new String[] {originalNumber},
- null)) {
- return cursor != null && cursor.getCount() != 0;
- }
- }
-
- /**
- * Copies all of the numbers in the {@link FilteredNumberContract} block list to the {@link
- * android.provider.BlockedNumberContract} block list.
- *
- * @param listener {@link Listener} called once the migration is complete.
- * @return {@code true} if the migrate can be attempted, {@code false} otherwise.
- * @throws NullPointerException if listener is null
- */
- public boolean migrate(final Listener listener) {
- LogUtil.i("BlockedNumbersMigrator.migrate", "migrate - start");
- if (!FilteredNumberCompat.canUseNewFiltering()) {
- LogUtil.i("BlockedNumbersMigrator.migrate", "migrate - can't use new filtering");
- return false;
- }
- Objects.requireNonNull(listener);
- new MigratorTask(listener).execute();
- return true;
- }
-
- /**
- * Listener for the operation to migrate from {@link FilteredNumberContract} blocking to {@link
- * android.provider.BlockedNumberContract} blocking.
- */
- public interface Listener {
-
- /** Called when the migration operation is finished. */
- void onComplete();
- }
-
- private class MigratorTask extends AsyncTask<Void, Void, Boolean> {
-
- private final Listener listener;
-
- public MigratorTask(Listener listener) {
- this.listener = listener;
- }
-
- @Override
- protected Boolean doInBackground(Void... params) {
- LogUtil.i("BlockedNumbersMigrator.doInBackground", "migrate - start background migration");
- return migrateToNewBlockingInBackground(context.getContentResolver());
- }
-
- @Override
- protected void onPostExecute(Boolean isSuccessful) {
- LogUtil.i("BlockedNumbersMigrator.onPostExecute", "migrate - marking migration complete");
- FilteredNumberCompat.setHasMigratedToNewBlocking(context, isSuccessful);
- LogUtil.i("BlockedNumbersMigrator.onPostExecute", "migrate - calling listener");
- listener.onComplete();
- }
- }
-}
diff --git a/java/com/android/dialer/blocking/FilteredNumberAsyncQueryHandler.java b/java/com/android/dialer/blocking/FilteredNumberAsyncQueryHandler.java
index 08526ef..e7cbbcb 100644
--- a/java/com/android/dialer/blocking/FilteredNumberAsyncQueryHandler.java
+++ b/java/com/android/dialer/blocking/FilteredNumberAsyncQueryHandler.java
@@ -17,12 +17,14 @@
package com.android.dialer.blocking;
import android.content.AsyncQueryHandler;
+import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.DatabaseUtils;
import android.database.sqlite.SQLiteDatabaseCorruptException;
import android.net.Uri;
+import android.provider.BlockedNumberContract.BlockedNumbers;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.support.v4.os.UserManagerCompat;
@@ -30,9 +32,8 @@
import android.text.TextUtils;
import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
-import com.android.dialer.database.FilteredNumberContract.FilteredNumberColumns;
-import com.android.dialer.database.FilteredNumberContract.FilteredNumberTypes;
import java.util.Map;
+import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
/** TODO(calderwoodra): documentation */
@@ -88,28 +89,6 @@
}
}
- void hasBlockedNumbers(final OnHasBlockedNumbersListener listener) {
- if (!FilteredNumberCompat.canAttemptBlockOperations(context)) {
- listener.onHasBlockedNumbers(false);
- return;
- }
- startQuery(
- NO_TOKEN,
- new Listener() {
- @Override
- protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
- listener.onHasBlockedNumbers(cursor != null && cursor.getCount() > 0);
- }
- },
- FilteredNumberCompat.getContentUri(context, null),
- new String[] {FilteredNumberCompat.getIdColumnName(context)},
- FilteredNumberCompat.useNewFiltering(context)
- ? null
- : FilteredNumberColumns.TYPE + "=" + FilteredNumberTypes.BLOCKED_NUMBER,
- null,
- null);
- }
-
/**
* Checks if the given number is blocked, calling the given {@link OnCheckBlockedListener} with
* the id for the blocked number, {@link #INVALID_ID}, or {@code null} based on the result of the
@@ -121,7 +100,7 @@
listener.onCheckComplete(INVALID_ID);
return;
}
- if (!FilteredNumberCompat.canAttemptBlockOperations(context)) {
+ if (!FilteredNumbersUtil.canAttemptBlockOperations(context)) {
listener.onCheckComplete(null);
return;
}
@@ -146,7 +125,7 @@
}
String e164Number = PhoneNumberUtils.formatNumberToE164(number, countryIso);
- String formattedNumber = FilteredNumbersUtil.getBlockableNumber(context, e164Number, number);
+ String formattedNumber = FilteredNumbersUtil.getBlockableNumber(e164Number, number);
if (TextUtils.isEmpty(formattedNumber)) {
listener.onCheckComplete(INVALID_ID);
blockedNumberCache.put(number, INVALID_ID);
@@ -170,25 +149,13 @@
return;
}
cursor.moveToFirst();
- // New filtering doesn't have a concept of type
- if (!FilteredNumberCompat.useNewFiltering(context)
- && cursor.getInt(cursor.getColumnIndex(FilteredNumberColumns.TYPE))
- != FilteredNumberTypes.BLOCKED_NUMBER) {
- blockedNumberCache.put(number, BLOCKED_NUMBER_CACHE_NULL_ID);
- listener.onCheckComplete(null);
- return;
- }
- Integer blockedId = cursor.getInt(cursor.getColumnIndex(FilteredNumberColumns._ID));
+ Integer blockedId = cursor.getInt(cursor.getColumnIndex(BlockedNumbers.COLUMN_ID));
blockedNumberCache.put(number, blockedId);
listener.onCheckComplete(blockedId);
}
},
- FilteredNumberCompat.getContentUri(context, null),
- FilteredNumberCompat.filter(
- new String[] {
- FilteredNumberCompat.getIdColumnName(context),
- FilteredNumberCompat.getTypeColumnName(context)
- }),
+ BlockedNumbers.CONTENT_URI,
+ new String[] {BlockedNumbers.COLUMN_ID},
getIsBlockedNumberSelection(e164Number != null) + " = ?",
new String[] {formattedNumber},
null);
@@ -205,7 +172,7 @@
if (number == null) {
return null;
}
- if (!FilteredNumberCompat.canAttemptBlockOperations(context)) {
+ if (!FilteredNumbersUtil.canAttemptBlockOperations(context)) {
return null;
}
Integer cachedId = blockedNumberCache.get(number);
@@ -217,7 +184,7 @@
}
String e164Number = PhoneNumberUtils.formatNumberToE164(number, countryIso);
- String formattedNumber = FilteredNumbersUtil.getBlockableNumber(context, e164Number, number);
+ String formattedNumber = FilteredNumbersUtil.getBlockableNumber(e164Number, number);
if (TextUtils.isEmpty(formattedNumber)) {
return null;
}
@@ -226,12 +193,8 @@
context
.getContentResolver()
.query(
- FilteredNumberCompat.getContentUri(context, null),
- FilteredNumberCompat.filter(
- new String[] {
- FilteredNumberCompat.getIdColumnName(context),
- FilteredNumberCompat.getTypeColumnName(context)
- }),
+ BlockedNumbers.CONTENT_URI,
+ new String[] {BlockedNumbers.COLUMN_ID},
getIsBlockedNumberSelection(e164Number != null) + " = ?",
new String[] {formattedNumber},
null)) {
@@ -246,7 +209,7 @@
return null;
}
cursor.moveToFirst();
- int blockedId = cursor.getInt(cursor.getColumnIndex(FilteredNumberColumns._ID));
+ int blockedId = cursor.getInt(cursor.getColumnIndex(BlockedNumbers.COLUMN_ID));
blockedNumberCache.put(number, blockedId);
return blockedId;
} catch (SecurityException e) {
@@ -266,27 +229,17 @@
* number is e164 or not.
*/
private String getIsBlockedNumberSelection(boolean isE164Number) {
- if (FilteredNumberCompat.useNewFiltering(context) && !isE164Number) {
- return FilteredNumberCompat.getOriginalNumberColumnName(context);
+ if (!isE164Number) {
+ return BlockedNumbers.COLUMN_ORIGINAL_NUMBER;
}
- return FilteredNumberCompat.getE164NumberColumnName(context);
- }
-
- public void blockNumber(
- final OnBlockNumberListener listener, String number, @Nullable String countryIso) {
- blockNumber(listener, null, number, countryIso);
+ return BlockedNumbers.COLUMN_E164_NUMBER;
}
/** Add a number manually blocked by the user. */
- public void blockNumber(
- final OnBlockNumberListener listener,
- @Nullable String normalizedNumber,
- String number,
- @Nullable String countryIso) {
- blockNumber(
- listener,
- FilteredNumberCompat.newBlockNumberContentValues(
- context, number, normalizedNumber, countryIso));
+ public void blockNumber(final OnBlockNumberListener listener, String number) {
+ ContentValues contentValues = new ContentValues();
+ contentValues.put(BlockedNumbers.COLUMN_ORIGINAL_NUMBER, Objects.requireNonNull(number));
+ blockNumber(listener, contentValues);
}
/**
@@ -295,7 +248,7 @@
*/
public void blockNumber(final OnBlockNumberListener listener, ContentValues values) {
blockedNumberCache.clear();
- if (!FilteredNumberCompat.canAttemptBlockOperations(context)) {
+ if (!FilteredNumbersUtil.canAttemptBlockOperations(context)) {
if (listener != null) {
listener.onBlockComplete(null);
}
@@ -311,7 +264,7 @@
}
}
},
- FilteredNumberCompat.getContentUri(context, null),
+ BlockedNumbers.CONTENT_URI,
values);
}
@@ -326,7 +279,7 @@
if (id == null) {
throw new IllegalArgumentException("Null id passed into unblock");
}
- unblock(listener, FilteredNumberCompat.getContentUri(context, id));
+ unblock(listener, ContentUris.withAppendedId(BlockedNumbers.CONTENT_URI, id));
}
/**
@@ -338,7 +291,7 @@
*/
public void unblock(@Nullable final OnUnblockNumberListener listener, final Uri uri) {
blockedNumberCache.clear();
- if (!FilteredNumberCompat.canAttemptBlockOperations(context)) {
+ if (!FilteredNumbersUtil.canAttemptBlockOperations(context)) {
if (listener != null) {
listener.onUnblockComplete(0, null);
}
@@ -357,7 +310,7 @@
cursor.moveToFirst();
final ContentValues values = new ContentValues();
DatabaseUtils.cursorRowToContentValues(cursor, values);
- values.remove(FilteredNumberCompat.getIdColumnName(context));
+ values.remove(BlockedNumbers.COLUMN_ID);
startDelete(
NO_TOKEN,
@@ -415,16 +368,6 @@
void onUnblockComplete(int rows, ContentValues values);
}
- /** TODO(calderwoodra): documentation */
- interface OnHasBlockedNumbersListener {
-
- /**
- * @param hasBlockedNumbers {@code true} if any blocked numbers are stored. {@code false}
- * otherwise.
- */
- void onHasBlockedNumbers(boolean hasBlockedNumbers);
- }
-
/** Methods for FilteredNumberAsyncQueryHandler result returns. */
private abstract static class Listener {
diff --git a/java/com/android/dialer/blocking/FilteredNumberCompat.java b/java/com/android/dialer/blocking/FilteredNumberCompat.java
deleted file mode 100644
index 71af340..0000000
--- a/java/com/android/dialer/blocking/FilteredNumberCompat.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.dialer.blocking;
-
-import android.app.FragmentManager;
-import android.content.ContentUris;
-import android.content.ContentValues;
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-import android.preference.PreferenceManager;
-import android.provider.BlockedNumberContract;
-import android.provider.BlockedNumberContract.BlockedNumbers;
-import android.support.annotation.Nullable;
-import android.support.annotation.VisibleForTesting;
-import android.telecom.TelecomManager;
-import android.telephony.PhoneNumberUtils;
-import com.android.dialer.common.LogUtil;
-import com.android.dialer.configprovider.ConfigProviderComponent;
-import com.android.dialer.database.FilteredNumberContract.FilteredNumber;
-import com.android.dialer.database.FilteredNumberContract.FilteredNumberColumns;
-import com.android.dialer.database.FilteredNumberContract.FilteredNumberSources;
-import com.android.dialer.database.FilteredNumberContract.FilteredNumberTypes;
-import com.android.dialer.strictmode.StrictModeUtils;
-import com.android.dialer.telecom.TelecomUtil;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-
-/**
- * Compatibility class to encapsulate logic to switch between call blocking using {@link
- * com.android.dialer.database.FilteredNumberContract} and using {@link
- * android.provider.BlockedNumberContract}. This class should be used rather than explicitly
- * referencing columns from either contract class in situations where both blocking solutions may be
- * used.
- */
-@Deprecated
-public class FilteredNumberCompat {
-
- private static Boolean canAttemptBlockOperationsForTest;
-
- @VisibleForTesting
- public static final String HAS_MIGRATED_TO_NEW_BLOCKING_KEY = "migratedToNewBlocking";
-
- /** @return The column name for ID in the filtered number database. */
- public static String getIdColumnName(Context context) {
- return useNewFiltering(context) ? BlockedNumbers.COLUMN_ID : FilteredNumberColumns._ID;
- }
-
- /**
- * @return The column name for type in the filtered number database. Will be {@code null} for the
- * framework blocking implementation.
- */
- @Nullable
- public static String getTypeColumnName(Context context) {
- return useNewFiltering(context) ? null : FilteredNumberColumns.TYPE;
- }
-
- /**
- * @return The column name for source in the filtered number database. Will be {@code null} for
- * the framework blocking implementation
- */
- @Nullable
- public static String getSourceColumnName(Context context) {
- return useNewFiltering(context) ? null : FilteredNumberColumns.SOURCE;
- }
-
- /** @return The column name for the original number in the filtered number database. */
- public static String getOriginalNumberColumnName(Context context) {
- return useNewFiltering(context)
- ? BlockedNumbers.COLUMN_ORIGINAL_NUMBER
- : FilteredNumberColumns.NUMBER;
- }
-
- /**
- * @return The column name for country iso in the filtered number database. Will be {@code null}
- * the framework blocking implementation
- */
- @Nullable
- public static String getCountryIsoColumnName(Context context) {
- return useNewFiltering(context) ? null : FilteredNumberColumns.COUNTRY_ISO;
- }
-
- /** @return The column name for the e164 formatted number in the filtered number database. */
- public static String getE164NumberColumnName(Context context) {
- return useNewFiltering(context)
- ? BlockedNumbers.COLUMN_E164_NUMBER
- : FilteredNumberColumns.NORMALIZED_NUMBER;
- }
-
- /**
- * @return {@code true} if the current SDK version supports using new filtering, {@code false}
- * otherwise.
- */
- public static boolean canUseNewFiltering() {
- return true;
- }
-
- /**
- * @return {@code true} if the new filtering should be used, i.e. it's enabled and any necessary
- * migration has been performed, {@code false} otherwise.
- */
- public static boolean useNewFiltering(Context context) {
- return !ConfigProviderComponent.get(context)
- .getConfigProvider()
- .getBoolean("debug_force_dialer_filtering", false)
- && canUseNewFiltering()
- && hasMigratedToNewBlocking(context);
- }
-
- /**
- * @return {@code true} if the user has migrated to use {@link
- * android.provider.BlockedNumberContract} blocking, {@code false} otherwise.
- */
- public static boolean hasMigratedToNewBlocking(Context context) {
- return StrictModeUtils.bypass(
- () ->
- PreferenceManager.getDefaultSharedPreferences(context)
- .getBoolean(HAS_MIGRATED_TO_NEW_BLOCKING_KEY, false));
- }
-
- /**
- * Called to inform this class whether the user has fully migrated to use {@link
- * android.provider.BlockedNumberContract} blocking or not.
- *
- * @param hasMigrated {@code true} if the user has migrated, {@code false} otherwise.
- */
- public static void setHasMigratedToNewBlocking(Context context, boolean hasMigrated) {
- PreferenceManager.getDefaultSharedPreferences(context)
- .edit()
- .putBoolean(HAS_MIGRATED_TO_NEW_BLOCKING_KEY, hasMigrated)
- .apply();
- }
-
- /**
- * Gets the content {@link Uri} for number filtering.
- *
- * @param id The optional id to append with the base content uri.
- * @return The Uri for number filtering.
- */
- public static Uri getContentUri(Context context, @Nullable Integer id) {
- if (id == null) {
- return getBaseUri(context);
- }
- return ContentUris.withAppendedId(getBaseUri(context), id);
- }
-
- private static Uri getBaseUri(Context context) {
- // Explicit version check to aid static analysis
- return useNewFiltering(context) ? BlockedNumbers.CONTENT_URI : FilteredNumber.CONTENT_URI;
- }
-
- /**
- * Removes any null column names from the given projection array. This method is intended to be
- * used to strip out any column names that aren't available in every version of number blocking.
- * Example: {@literal getContext().getContentResolver().query( someUri, // Filtering ensures that
- * no non-existent columns are queried FilteredNumberCompat.filter(new String[]
- * {FilteredNumberCompat.getIdColumnName(), FilteredNumberCompat.getTypeColumnName()},
- * FilteredNumberCompat.getE164NumberColumnName() + " = ?", new String[] {e164Number}); }
- *
- * @param projection The projection array.
- * @return The filtered projection array.
- */
- @Nullable
- public static String[] filter(@Nullable String[] projection) {
- if (projection == null) {
- return null;
- }
- List<String> filtered = new ArrayList<>();
- for (String column : projection) {
- if (column != null) {
- filtered.add(column);
- }
- }
- return filtered.toArray(new String[filtered.size()]);
- }
-
- /**
- * Creates a new {@link ContentValues} suitable for inserting in the filtered number table.
- *
- * @param number The unformatted number to insert.
- * @param e164Number (optional) The number to insert formatted to E164 standard.
- * @param countryIso (optional) The country iso to use to format the number.
- * @return The ContentValues to insert.
- * @throws NullPointerException If number is null.
- */
- public static ContentValues newBlockNumberContentValues(
- Context context, String number, @Nullable String e164Number, @Nullable String countryIso) {
- ContentValues contentValues = new ContentValues();
- contentValues.put(getOriginalNumberColumnName(context), Objects.requireNonNull(number));
- if (!useNewFiltering(context)) {
- if (e164Number == null) {
- e164Number = PhoneNumberUtils.formatNumberToE164(number, countryIso);
- }
- contentValues.put(getE164NumberColumnName(context), e164Number);
- contentValues.put(getCountryIsoColumnName(context), countryIso);
- contentValues.put(getTypeColumnName(context), FilteredNumberTypes.BLOCKED_NUMBER);
- contentValues.put(getSourceColumnName(context), FilteredNumberSources.USER);
- }
- return contentValues;
- }
-
- /**
- * Shows block number migration dialog if necessary.
- *
- * @param fragmentManager The {@link FragmentManager} used to show fragments.
- * @param listener The {@link BlockedNumbersMigrator.Listener} to call when migration is complete.
- * @return boolean True if migration dialog is shown.
- */
- public static boolean maybeShowBlockNumberMigrationDialog(
- Context context, FragmentManager fragmentManager, BlockedNumbersMigrator.Listener listener) {
- if (shouldShowMigrationDialog(context)) {
- LogUtil.i(
- "FilteredNumberCompat.maybeShowBlockNumberMigrationDialog",
- "maybeShowBlockNumberMigrationDialog - showing migration dialog");
- MigrateBlockedNumbersDialogFragment.newInstance(new BlockedNumbersMigrator(context), listener)
- .show(fragmentManager, "MigrateBlockedNumbers");
- return true;
- }
- return false;
- }
-
- private static boolean shouldShowMigrationDialog(Context context) {
- return canUseNewFiltering() && !hasMigratedToNewBlocking(context);
- }
-
- /**
- * Creates the {@link Intent} which opens the blocked numbers management interface.
- *
- * @param context The {@link Context}.
- * @return The intent.
- */
- public static Intent createManageBlockedNumbersIntent(Context context) {
- // Explicit version check to aid static analysis
- if (canUseNewFiltering() && hasMigratedToNewBlocking(context)) {
- return context.getSystemService(TelecomManager.class).createManageBlockedNumbersIntent();
- }
- Intent intent = new Intent("com.android.dialer.action.BLOCKED_NUMBERS_SETTINGS");
- intent.setPackage(context.getPackageName());
- return intent;
- }
-
- /**
- * Method used to determine if block operations are possible.
- *
- * @param context The {@link Context}.
- * @return {@code true} if the app and user can block numbers, {@code false} otherwise.
- */
- public static boolean canAttemptBlockOperations(Context context) {
- if (canAttemptBlockOperationsForTest != null) {
- return canAttemptBlockOperationsForTest;
- }
-
- // Great Wall blocking, must be primary user and the default or system dialer
- // TODO(maxwelb): check that we're the system Dialer
- return TelecomUtil.isDefaultDialer(context)
- && safeBlockedNumbersContractCanCurrentUserBlockNumbers(context);
- }
-
- @VisibleForTesting(otherwise = VisibleForTesting.NONE)
- public static void setCanAttemptBlockOperationsForTest(boolean canAttempt) {
- canAttemptBlockOperationsForTest = canAttempt;
- }
-
- /**
- * Used to determine if the call blocking settings can be opened.
- *
- * @param context The {@link Context}.
- * @return {@code true} if the current user can open the call blocking settings, {@code false}
- * otherwise.
- */
- public static boolean canCurrentUserOpenBlockSettings(Context context) {
- // BlockedNumberContract blocking, verify through Contract API
- return TelecomUtil.isDefaultDialer(context)
- && safeBlockedNumbersContractCanCurrentUserBlockNumbers(context);
- }
-
- /**
- * Calls {@link BlockedNumberContract#canCurrentUserBlockNumbers(Context)} in such a way that it
- * never throws an exception. While on the CryptKeeper screen, the BlockedNumberContract isn't
- * available, using this method ensures that the Dialer doesn't crash when on that screen.
- *
- * @param context The {@link Context}.
- * @return the result of BlockedNumberContract#canCurrentUserBlockNumbers, or {@code false} if an
- * exception was thrown.
- */
- private static boolean safeBlockedNumbersContractCanCurrentUserBlockNumbers(Context context) {
- try {
- return BlockedNumberContract.canCurrentUserBlockNumbers(context);
- } catch (Exception e) {
- LogUtil.e(
- "FilteredNumberCompat.safeBlockedNumbersContractCanCurrentUserBlockNumbers",
- "Exception while querying BlockedNumberContract",
- e);
- return false;
- }
- }
-}
diff --git a/java/com/android/dialer/blocking/FilteredNumberProvider.java b/java/com/android/dialer/blocking/FilteredNumberProvider.java
deleted file mode 100644
index 547892b..0000000
--- a/java/com/android/dialer/blocking/FilteredNumberProvider.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.dialer.blocking;
-
-import android.content.ContentProvider;
-import android.content.ContentUris;
-import android.content.ContentValues;
-import android.content.UriMatcher;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteQueryBuilder;
-import android.net.Uri;
-import android.support.annotation.VisibleForTesting;
-import android.text.TextUtils;
-import com.android.dialer.common.LogUtil;
-import com.android.dialer.database.Database;
-import com.android.dialer.database.DialerDatabaseHelper;
-import com.android.dialer.database.FilteredNumberContract;
-import com.android.dialer.database.FilteredNumberContract.FilteredNumberColumns;
-import com.android.dialer.location.GeoUtil;
-
-/** Filtered number content provider. */
-@Deprecated
-public class FilteredNumberProvider extends ContentProvider {
-
- private static final int FILTERED_NUMBERS_TABLE = 1;
- private static final int FILTERED_NUMBERS_TABLE_ID = 2;
- private static final UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
- private DialerDatabaseHelper dialerDatabaseHelper;
-
- @Override
- public boolean onCreate() {
- dialerDatabaseHelper = Database.get(getContext()).getDatabaseHelper(getContext());
- if (dialerDatabaseHelper == null) {
- return false;
- }
- uriMatcher.addURI(
- FilteredNumberContract.AUTHORITY,
- FilteredNumberContract.FilteredNumber.FILTERED_NUMBERS_TABLE,
- FILTERED_NUMBERS_TABLE);
- uriMatcher.addURI(
- FilteredNumberContract.AUTHORITY,
- FilteredNumberContract.FilteredNumber.FILTERED_NUMBERS_TABLE + "/#",
- FILTERED_NUMBERS_TABLE_ID);
- return true;
- }
-
- @Override
- public Cursor query(
- Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
- final SQLiteDatabase db = dialerDatabaseHelper.getReadableDatabase();
- SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
- qb.setTables(DialerDatabaseHelper.Tables.FILTERED_NUMBER_TABLE);
- final int match = uriMatcher.match(uri);
- switch (match) {
- case FILTERED_NUMBERS_TABLE:
- break;
- case FILTERED_NUMBERS_TABLE_ID:
- qb.appendWhere(FilteredNumberColumns._ID + "=" + ContentUris.parseId(uri));
- break;
- default:
- throw new IllegalArgumentException("Unknown uri: " + uri);
- }
- final Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, null);
- if (c != null) {
- c.setNotificationUri(
- getContext().getContentResolver(), FilteredNumberContract.FilteredNumber.CONTENT_URI);
- } else {
- LogUtil.d("FilteredNumberProvider.query", "CURSOR WAS NULL");
- }
- return c;
- }
-
- @Override
- public String getType(Uri uri) {
- return FilteredNumberContract.FilteredNumber.CONTENT_ITEM_TYPE;
- }
-
- @Override
- public Uri insert(Uri uri, ContentValues values) {
- SQLiteDatabase db = dialerDatabaseHelper.getWritableDatabase();
- setDefaultValues(values);
- long id = db.insert(DialerDatabaseHelper.Tables.FILTERED_NUMBER_TABLE, null, values);
- if (id < 0) {
- return null;
- }
- notifyChange(uri);
- return ContentUris.withAppendedId(uri, id);
- }
-
- @VisibleForTesting
- protected long getCurrentTimeMs() {
- return System.currentTimeMillis();
- }
-
- private void setDefaultValues(ContentValues values) {
- if (values.getAsString(FilteredNumberColumns.COUNTRY_ISO) == null) {
- values.put(FilteredNumberColumns.COUNTRY_ISO, GeoUtil.getCurrentCountryIso(getContext()));
- }
- if (values.getAsInteger(FilteredNumberColumns.TIMES_FILTERED) == null) {
- values.put(FilteredNumberContract.FilteredNumberColumns.TIMES_FILTERED, 0);
- }
- if (values.getAsLong(FilteredNumberColumns.CREATION_TIME) == null) {
- values.put(FilteredNumberColumns.CREATION_TIME, getCurrentTimeMs());
- }
- }
-
- @Override
- public int delete(Uri uri, String selection, String[] selectionArgs) {
- SQLiteDatabase db = dialerDatabaseHelper.getWritableDatabase();
- final int match = uriMatcher.match(uri);
- switch (match) {
- case FILTERED_NUMBERS_TABLE:
- break;
- case FILTERED_NUMBERS_TABLE_ID:
- selection = getSelectionWithId(selection, ContentUris.parseId(uri));
- break;
- default:
- throw new IllegalArgumentException("Unknown uri: " + uri);
- }
- int rows =
- db.delete(DialerDatabaseHelper.Tables.FILTERED_NUMBER_TABLE, selection, selectionArgs);
- if (rows > 0) {
- notifyChange(uri);
- }
- return rows;
- }
-
- @Override
- public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
- SQLiteDatabase db = dialerDatabaseHelper.getWritableDatabase();
- final int match = uriMatcher.match(uri);
- switch (match) {
- case FILTERED_NUMBERS_TABLE:
- break;
- case FILTERED_NUMBERS_TABLE_ID:
- selection = getSelectionWithId(selection, ContentUris.parseId(uri));
- break;
- default:
- throw new IllegalArgumentException("Unknown uri: " + uri);
- }
- int rows =
- db.update(
- DialerDatabaseHelper.Tables.FILTERED_NUMBER_TABLE, values, selection, selectionArgs);
- if (rows > 0) {
- notifyChange(uri);
- }
- return rows;
- }
-
- private String getSelectionWithId(String selection, long id) {
- if (TextUtils.isEmpty(selection)) {
- return FilteredNumberContract.FilteredNumberColumns._ID + "=" + id;
- } else {
- return selection + "AND " + FilteredNumberContract.FilteredNumberColumns._ID + "=" + id;
- }
- }
-
- private void notifyChange(Uri uri) {
- getContext().getContentResolver().notifyChange(uri, null);
- }
-}
diff --git a/java/com/android/dialer/blocking/FilteredNumbersUtil.java b/java/com/android/dialer/blocking/FilteredNumbersUtil.java
index d839ef5..6d6f339 100644
--- a/java/com/android/dialer/blocking/FilteredNumbersUtil.java
+++ b/java/com/android/dialer/blocking/FilteredNumbersUtil.java
@@ -15,38 +15,24 @@
*/
package com.android.dialer.blocking;
-import android.app.Notification;
-import android.app.PendingIntent;
-import android.content.ContentValues;
import android.content.Context;
-import android.database.Cursor;
-import android.os.AsyncTask;
-import android.provider.ContactsContract.CommonDataKinds.Phone;
-import android.provider.ContactsContract.Contacts;
+import android.provider.BlockedNumberContract;
import android.provider.Settings;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
-import android.support.v4.os.BuildCompat;
-import android.support.v4.os.UserManagerCompat;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
-import android.widget.Toast;
-import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler.OnHasBlockedNumbersListener;
+
import com.android.dialer.common.LogUtil;
import com.android.dialer.logging.InteractionEvent;
-import com.android.dialer.logging.Logger;
-import com.android.dialer.notification.DialerNotificationManager;
-import com.android.dialer.notification.NotificationChannelId;
import com.android.dialer.storage.StorageComponent;
-import com.android.dialer.util.PermissionsUtil;
+import com.android.dialer.telecom.TelecomUtil;
import java.util.concurrent.TimeUnit;
/** Utility to help with tasks related to filtered numbers. */
@Deprecated
public class FilteredNumbersUtil {
- public static final String CALL_BLOCKING_NOTIFICATION_TAG = "call_blocking";
- public static final int CALL_BLOCKING_DISABLED_BY_EMERGENCY_CALL_NOTIFICATION_ID = 10;
// Pref key for storing the time of end of the last emergency call in milliseconds after epoch.\
@VisibleForTesting
public static final String LAST_EMERGENCY_CALL_MS_PREF_KEY = "last_emergency_call_ms";
@@ -67,126 +53,6 @@
private static final String RECENT_EMERGENCY_CALL_THRESHOLD_SETTINGS_KEY =
"dialer_emergency_call_threshold_ms";
- /** Checks if there exists a contact with {@code Contacts.SEND_TO_VOICEMAIL} set to true. */
- public static void checkForSendToVoicemailContact(
- final Context context, final CheckForSendToVoicemailContactListener listener) {
- final AsyncTask task =
- new AsyncTask<Object, Void, Boolean>() {
- @Override
- public Boolean doInBackground(Object... params) {
- if (context == null || !PermissionsUtil.hasContactsReadPermissions(context)) {
- return false;
- }
-
- final Cursor cursor =
- context
- .getContentResolver()
- .query(
- Contacts.CONTENT_URI,
- ContactsQuery.PROJECTION,
- ContactsQuery.SELECT_SEND_TO_VOICEMAIL_TRUE,
- null,
- null);
-
- boolean hasSendToVoicemailContacts = false;
- if (cursor != null) {
- try {
- hasSendToVoicemailContacts = cursor.getCount() > 0;
- } finally {
- cursor.close();
- }
- }
-
- return hasSendToVoicemailContacts;
- }
-
- @Override
- public void onPostExecute(Boolean hasSendToVoicemailContact) {
- if (listener != null) {
- listener.onComplete(hasSendToVoicemailContact);
- }
- }
- };
- task.execute();
- }
-
- /**
- * Blocks all the phone numbers of any contacts marked as SEND_TO_VOICEMAIL, then clears the
- * SEND_TO_VOICEMAIL flag on those contacts.
- */
- public static void importSendToVoicemailContacts(
- final Context context, final ImportSendToVoicemailContactsListener listener) {
- Logger.get(context).logInteraction(InteractionEvent.Type.IMPORT_SEND_TO_VOICEMAIL);
- final FilteredNumberAsyncQueryHandler mFilteredNumberAsyncQueryHandler =
- new FilteredNumberAsyncQueryHandler(context);
-
- final AsyncTask<Object, Void, Boolean> task =
- new AsyncTask<Object, Void, Boolean>() {
- @Override
- public Boolean doInBackground(Object... params) {
- if (context == null) {
- return false;
- }
-
- // Get the phone number of contacts marked as SEND_TO_VOICEMAIL.
- final Cursor phoneCursor =
- context
- .getContentResolver()
- .query(
- Phone.CONTENT_URI,
- PhoneQuery.PROJECTION,
- PhoneQuery.SELECT_SEND_TO_VOICEMAIL_TRUE,
- null,
- null);
-
- if (phoneCursor == null) {
- return false;
- }
-
- try {
- while (phoneCursor.moveToNext()) {
- final String normalizedNumber =
- phoneCursor.getString(PhoneQuery.NORMALIZED_NUMBER_COLUMN_INDEX);
- final String number = phoneCursor.getString(PhoneQuery.NUMBER_COLUMN_INDEX);
- if (normalizedNumber != null) {
- // Block the phone number of the contact.
- mFilteredNumberAsyncQueryHandler.blockNumber(
- null, normalizedNumber, number, null);
- }
- }
- } finally {
- phoneCursor.close();
- }
-
- // Clear SEND_TO_VOICEMAIL on all contacts. The setting has been imported to Dialer.
- ContentValues newValues = new ContentValues();
- newValues.put(Contacts.SEND_TO_VOICEMAIL, 0);
- context
- .getContentResolver()
- .update(
- Contacts.CONTENT_URI,
- newValues,
- ContactsQuery.SELECT_SEND_TO_VOICEMAIL_TRUE,
- null);
-
- return true;
- }
-
- @Override
- public void onPostExecute(Boolean success) {
- if (success) {
- if (listener != null) {
- listener.onImportComplete();
- }
- } else if (context != null) {
- String toastStr = context.getString(R.string.send_to_voicemail_import_failed);
- Toast.makeText(context, toastStr, Toast.LENGTH_SHORT).show();
- }
- }
- };
- task.execute();
- }
-
public static long getLastEmergencyCallTimeMillis(Context context) {
return StorageComponent.get(context)
.unencryptedSharedPrefs()
@@ -218,67 +84,6 @@
.putLong(LAST_EMERGENCY_CALL_MS_PREF_KEY, System.currentTimeMillis())
.putBoolean(NOTIFIED_CALL_BLOCKING_DISABLED_BY_EMERGENCY_CALL_PREF_KEY, false)
.apply();
-
- if (UserManagerCompat.isUserUnlocked(context)) {
- maybeNotifyCallBlockingDisabled(context);
- }
- }
-
- public static void maybeNotifyCallBlockingDisabled(final Context context) {
- // The Dialer is not responsible for this notification after migrating
- if (FilteredNumberCompat.useNewFiltering(context)) {
- return;
- }
- // Skip if the user has already received a notification for the most recent emergency call.
- if (StorageComponent.get(context)
- .unencryptedSharedPrefs()
- .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);
- queryHandler.hasBlockedNumbers(
- new OnHasBlockedNumbersListener() {
- @Override
- public void onHasBlockedNumbers(boolean hasBlockedNumbers) {
- if (context == null || !hasBlockedNumbers) {
- return;
- }
-
- Notification.Builder builder =
- new Notification.Builder(context)
- .setSmallIcon(R.drawable.quantum_ic_block_white_24)
- .setContentTitle(
- context.getString(R.string.call_blocking_disabled_notification_title))
- .setContentText(
- context.getString(R.string.call_blocking_disabled_notification_text))
- .setAutoCancel(true);
-
- if (BuildCompat.isAtLeastO()) {
- builder.setChannelId(NotificationChannelId.DEFAULT);
- }
- builder.setContentIntent(
- PendingIntent.getActivity(
- context,
- 0,
- FilteredNumberCompat.createManageBlockedNumbersIntent(context),
- PendingIntent.FLAG_UPDATE_CURRENT));
-
- DialerNotificationManager.notify(
- context,
- 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.
- StorageComponent.get(context)
- .unencryptedSharedPrefs()
- .edit()
- .putBoolean(NOTIFIED_CALL_BLOCKING_DISABLED_BY_EMERGENCY_CALL_PREF_KEY, true)
- .apply();
- }
- });
}
/**
@@ -288,8 +93,8 @@
* @return {@code true} if the number can be blocked, {@code false} otherwise.
*/
public static boolean canBlockNumber(Context context, String e164Number, String number) {
- String blockableNumber = getBlockableNumber(context, e164Number, number);
- return !TextUtils.isEmpty(blockableNumber)
+ String blockableNumber = getBlockableNumber(e164Number, number);
+ return canAttemptBlockOperations(context) && !TextUtils.isEmpty(blockableNumber)
&& !PhoneNumberUtils.isEmergencyNumber(blockableNumber);
}
@@ -300,11 +105,7 @@
* @return The version of the given number that can be blocked with the current blocking solution.
*/
@Nullable
- public static String getBlockableNumber(
- Context context, @Nullable String e164Number, String number) {
- if (!FilteredNumberCompat.useNewFiltering(context)) {
- return e164Number;
- }
+ public static String getBlockableNumber(@Nullable String e164Number, String number) {
return TextUtils.isEmpty(e164Number) ? number : e164Number;
}
@@ -319,33 +120,50 @@
}
}
- public interface CheckForSendToVoicemailContactListener {
-
- void onComplete(boolean hasSendToVoicemailContact);
+ /**
+ * Method used to determine if block operations are possible.
+ *
+ * @param context The {@link Context}.
+ * @return {@code true} if the app and user can block numbers, {@code false} otherwise.
+ */
+ public static boolean canAttemptBlockOperations(Context context) {
+ // Great Wall blocking, must be primary user and the default or system dialer
+ // TODO(maxwelb): check that we're the system Dialer
+ return TelecomUtil.isDefaultDialer(context)
+ && safeBlockedNumbersContractCanCurrentUserBlockNumbers(context);
}
- public interface ImportSendToVoicemailContactsListener {
-
- void onImportComplete();
+ /**
+ * Used to determine if the call blocking settings can be opened.
+ *
+ * @param context The {@link Context}.
+ * @return {@code true} if the current user can open the call blocking settings, {@code false}
+ * otherwise.
+ */
+ public static boolean canCurrentUserOpenBlockSettings(Context context) {
+ // BlockedNumberContract blocking, verify through Contract API
+ return TelecomUtil.isDefaultDialer(context)
+ && safeBlockedNumbersContractCanCurrentUserBlockNumbers(context);
}
- private static class ContactsQuery {
-
- static final String[] PROJECTION = {Contacts._ID};
-
- static final String SELECT_SEND_TO_VOICEMAIL_TRUE = Contacts.SEND_TO_VOICEMAIL + "=1";
-
- static final int ID_COLUMN_INDEX = 0;
- }
-
- public static class PhoneQuery {
-
- public static final String[] PROJECTION = {Contacts._ID, Phone.NORMALIZED_NUMBER, Phone.NUMBER};
-
- public static final int ID_COLUMN_INDEX = 0;
- public static final int NORMALIZED_NUMBER_COLUMN_INDEX = 1;
- public static final int NUMBER_COLUMN_INDEX = 2;
-
- public static final String SELECT_SEND_TO_VOICEMAIL_TRUE = Contacts.SEND_TO_VOICEMAIL + "=1";
+ /**
+ * Calls {@link BlockedNumberContract#canCurrentUserBlockNumbers(Context)} in such a way that it
+ * never throws an exception. While on the CryptKeeper screen, the BlockedNumberContract isn't
+ * available, using this method ensures that the Dialer doesn't crash when on that screen.
+ *
+ * @param context The {@link Context}.
+ * @return the result of BlockedNumberContract#canCurrentUserBlockNumbers, or {@code false} if an
+ * exception was thrown.
+ */
+ private static boolean safeBlockedNumbersContractCanCurrentUserBlockNumbers(Context context) {
+ try {
+ return BlockedNumberContract.canCurrentUserBlockNumbers(context);
+ } catch (Exception e) {
+ LogUtil.e(
+ "FilteredNumberCompat.safeBlockedNumbersContractCanCurrentUserBlockNumbers",
+ "Exception while querying BlockedNumberContract",
+ e);
+ return false;
+ }
}
}
diff --git a/java/com/android/dialer/blocking/MigrateBlockedNumbersDialogFragment.java b/java/com/android/dialer/blocking/MigrateBlockedNumbersDialogFragment.java
deleted file mode 100644
index 9a3b647..0000000
--- a/java/com/android/dialer/blocking/MigrateBlockedNumbersDialogFragment.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.dialer.blocking;
-
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.app.DialogFragment;
-import android.content.DialogInterface;
-import android.content.DialogInterface.OnShowListener;
-import android.os.Bundle;
-import android.view.View;
-import com.android.dialer.blocking.BlockedNumbersMigrator.Listener;
-import java.util.Objects;
-
-/**
- * Dialog fragment shown to users when they need to migrate to use {@link
- * android.provider.BlockedNumberContract} for blocking.
- */
-@Deprecated
-public class MigrateBlockedNumbersDialogFragment extends DialogFragment {
-
- private BlockedNumbersMigrator blockedNumbersMigrator;
- private BlockedNumbersMigrator.Listener migrationListener;
-
- /**
- * Creates a new MigrateBlockedNumbersDialogFragment.
- *
- * @param blockedNumbersMigrator The {@link BlockedNumbersMigrator} which will be used to migrate
- * the numbers.
- * @param migrationListener The {@link BlockedNumbersMigrator.Listener} to call when the migration
- * is complete.
- * @return The new MigrateBlockedNumbersDialogFragment.
- * @throws NullPointerException if blockedNumbersMigrator or migrationListener are {@code null}.
- */
- public static DialogFragment newInstance(
- BlockedNumbersMigrator blockedNumbersMigrator,
- BlockedNumbersMigrator.Listener migrationListener) {
- MigrateBlockedNumbersDialogFragment fragment = new MigrateBlockedNumbersDialogFragment();
- fragment.blockedNumbersMigrator = Objects.requireNonNull(blockedNumbersMigrator);
- fragment.migrationListener = Objects.requireNonNull(migrationListener);
- return fragment;
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- super.onCreateDialog(savedInstanceState);
- AlertDialog dialog =
- new AlertDialog.Builder(getActivity())
- .setTitle(R.string.migrate_blocked_numbers_dialog_title)
- .setMessage(R.string.migrate_blocked_numbers_dialog_message)
- .setPositiveButton(R.string.migrate_blocked_numbers_dialog_allow_button, null)
- .setNegativeButton(R.string.migrate_blocked_numbers_dialog_cancel_button, null)
- .create();
- // The Dialog's buttons aren't available until show is called, so an OnShowListener
- // is used to set the positive button callback.
- dialog.setOnShowListener(
- new OnShowListener() {
- @Override
- public void onShow(DialogInterface dialog) {
- final AlertDialog alertDialog = (AlertDialog) dialog;
- alertDialog
- .getButton(AlertDialog.BUTTON_POSITIVE)
- .setOnClickListener(newPositiveButtonOnClickListener(alertDialog));
- }
- });
- return dialog;
- }
-
- /*
- * Creates a new View.OnClickListener to be used as the positive button in this dialog. The
- * OnClickListener will grey out the dialog's positive and negative buttons while the migration
- * is underway, and close the dialog once the migrate is complete.
- */
- private View.OnClickListener newPositiveButtonOnClickListener(final AlertDialog alertDialog) {
- return new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
- alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE).setEnabled(false);
- blockedNumbersMigrator.migrate(
- new Listener() {
- @Override
- public void onComplete() {
- alertDialog.dismiss();
- migrationListener.onComplete();
- }
- });
- }
- };
- }
-
- @Override
- public void onPause() {
- // The dialog is dismissed and state is cleaned up onPause, i.e. rotation.
- dismiss();
- blockedNumbersMigrator = null;
- migrationListener = null;
- super.onPause();
- }
-}
diff --git a/java/com/android/dialer/blockreportspam/BlockReportSpamDialogs.java b/java/com/android/dialer/blockreportspam/BlockReportSpamDialogs.java
index ff2a588..9d57c15 100644
--- a/java/com/android/dialer/blockreportspam/BlockReportSpamDialogs.java
+++ b/java/com/android/dialer/blockreportspam/BlockReportSpamDialogs.java
@@ -27,7 +27,8 @@
import android.view.View;
import android.widget.CheckBox;
import android.widget.TextView;
-import com.android.dialer.blocking.FilteredNumberCompat;
+
+import com.android.dialer.R;
/** Creates dialog fragments to block a number and/or report it as spam/not spam. */
public final class BlockReportSpamDialogs {
@@ -58,13 +59,7 @@
}
private static String getBlockMessage(Context context) {
- String message;
- if (FilteredNumberCompat.useNewFiltering(context)) {
- message = context.getString(R.string.block_number_confirmation_message_new_filtering);
- } else {
- message = context.getString(R.string.block_report_number_alert_details);
- }
- return message;
+ return context.getString(R.string.block_number_confirmation_message_new_filtering);
}
/**
diff --git a/java/com/android/dialer/calldetails/CallDetailsEntryViewHolder.java b/java/com/android/dialer/calldetails/CallDetailsEntryViewHolder.java
index a9be544..5b35dcb 100644
--- a/java/com/android/dialer/calldetails/CallDetailsEntryViewHolder.java
+++ b/java/com/android/dialer/calldetails/CallDetailsEntryViewHolder.java
@@ -27,7 +27,6 @@
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.FileProvider;
-import android.support.v4.os.BuildCompat;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.text.TextUtils;
import android.text.format.DateFormat;
@@ -38,6 +37,8 @@
import android.widget.PopupMenu;
import android.widget.TextView;
import android.widget.Toast;
+
+import com.android.dialer.R;
import com.android.dialer.calldetails.CallDetailsEntries.CallDetailsEntry;
import com.android.dialer.calllogutils.CallLogDates;
import com.android.dialer.calllogutils.CallLogDurations;
@@ -129,9 +130,7 @@
(entry.getFeatures() & Calls.FEATURES_PULLED_EXTERNALLY)
== Calls.FEATURES_PULLED_EXTERNALLY;
boolean isDuoCall = entry.getIsDuoCall();
- boolean isRttCall =
- BuildCompat.isAtLeastP()
- && (entry.getFeatures() & Calls.FEATURES_RTT) == Calls.FEATURES_RTT;
+ boolean isRttCall = (entry.getFeatures() & Calls.FEATURES_RTT) == Calls.FEATURES_RTT;
callTime.setTextColor(getColorForCallType(context, callType));
callTypeIcon.clear();
@@ -141,9 +140,7 @@
(entry.getFeatures() & Calls.FEATURES_HD_CALL) == Calls.FEATURES_HD_CALL);
callTypeIcon.setShowWifi(
MotorolaUtils.shouldShowWifiIconInCallLog(context, entry.getFeatures()));
- if (BuildCompat.isAtLeastP()) {
- callTypeIcon.setShowRtt((entry.getFeatures() & Calls.FEATURES_RTT) == Calls.FEATURES_RTT);
- }
+ callTypeIcon.setShowRtt((entry.getFeatures() & Calls.FEATURES_RTT) == Calls.FEATURES_RTT);
callTypeText.setText(
callTypeHelper.getCallTypeText(callType, isVideoCall, isPulledCall, isDuoCall));
diff --git a/java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java b/java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java
index 1fdf38a..21f32b9 100644
--- a/java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java
+++ b/java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java
@@ -177,8 +177,6 @@
/**
* See {@link VoicemailCompat#TRANSCRIPTION_STATE}
*
- * <p>Only populated in {@link Build.VERSION_CODES#O} and above
- *
* <p>TYPE: INTEGER
*/
public static final String TRANSCRIPTION_STATE = "transcription_state";
diff --git a/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java b/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java
index 3e123c9..7b02d0d 100644
--- a/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java
+++ b/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java
@@ -21,19 +21,17 @@
import android.content.Context;
import android.content.SharedPreferences;
import android.database.Cursor;
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
import android.provider.CallLog;
import android.provider.CallLog.Calls;
import android.provider.VoicemailContract;
import android.provider.VoicemailContract.Voicemails;
import android.support.annotation.Nullable;
-import android.support.annotation.RequiresApi;
import android.support.annotation.VisibleForTesting;
import android.support.annotation.WorkerThread;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import android.util.ArraySet;
+
import com.android.dialer.DialerPhoneNumber;
import com.android.dialer.calllog.database.AnnotatedCallLogDatabaseHelper;
import com.android.dialer.calllog.database.contract.AnnotatedCallLogContract.AnnotatedCallLog;
@@ -382,12 +380,10 @@
}
private void setTranscriptionState(Cursor cursor, ContentValues contentValues) {
- if (VERSION.SDK_INT >= VERSION_CODES.O) {
- int transcriptionStateColumn =
- cursor.getColumnIndexOrThrow(VoicemailCompat.TRANSCRIPTION_STATE);
- int transcriptionState = cursor.getInt(transcriptionStateColumn);
- contentValues.put(VoicemailCompat.TRANSCRIPTION_STATE, transcriptionState);
- }
+ int transcriptionStateColumn =
+ cursor.getColumnIndexOrThrow(VoicemailCompat.TRANSCRIPTION_STATE);
+ int transcriptionState = cursor.getInt(transcriptionStateColumn);
+ contentValues.put(VoicemailCompat.TRANSCRIPTION_STATE, transcriptionState);
}
private static final String[] PROJECTION_PRE_O =
@@ -412,7 +408,6 @@
Calls.POST_DIAL_DIGITS
};
- @RequiresApi(VERSION_CODES.O)
private static final String[] PROJECTION_O_AND_LATER;
static {
@@ -422,10 +417,7 @@
}
private String[] getProjection() {
- if (VERSION.SDK_INT >= VERSION_CODES.O) {
return PROJECTION_O_AND_LATER;
- }
- return PROJECTION_PRE_O;
}
private static void handleDeletes(
diff --git a/java/com/android/dialer/calllogutils/PhotoInfoBuilder.java b/java/com/android/dialer/calllogutils/PhotoInfoBuilder.java
index 2e2e4ab..16fb9ac 100644
--- a/java/com/android/dialer/calllogutils/PhotoInfoBuilder.java
+++ b/java/com/android/dialer/calllogutils/PhotoInfoBuilder.java
@@ -18,7 +18,6 @@
import android.content.Context;
import android.provider.CallLog.Calls;
-import android.support.v4.os.BuildCompat;
import com.android.dialer.NumberAttributes;
import com.android.dialer.calllog.model.CoalescedRow;
import com.android.dialer.glidephotomanager.PhotoInfo;
@@ -38,9 +37,7 @@
Spam.shouldShowAsSpam(
coalescedRow.getNumberAttributes().getIsSpam(), coalescedRow.getCallType()))
.setIsVideo((coalescedRow.getFeatures() & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO)
- .setIsRtt(
- BuildCompat.isAtLeastP()
- && (coalescedRow.getFeatures() & Calls.FEATURES_RTT) == Calls.FEATURES_RTT);
+ .setIsRtt((coalescedRow.getFeatures() & Calls.FEATURES_RTT) == Calls.FEATURES_RTT);
}
/** Returns a {@link PhotoInfo.Builder} with info from {@link VoicemailEntry}. */
diff --git a/java/com/android/dialer/callrecord/CallRecordingAutoMigrator.java b/java/com/android/dialer/callrecord/CallRecordingAutoMigrator.java
index 81c1612..456f122 100644
--- a/java/com/android/dialer/callrecord/CallRecordingAutoMigrator.java
+++ b/java/com/android/dialer/callrecord/CallRecordingAutoMigrator.java
@@ -17,12 +17,10 @@
package com.android.dialer.callrecord;
-import android.annotation.TargetApi;
import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.PackageManager;
import android.net.Uri;
-import android.os.Build;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
@@ -65,7 +63,6 @@
.executeParallel(null);
}
- @TargetApi(26)
private void autoMigrate(boolean shouldAttemptAutoMigrate) {
if (!shouldAttemptAutoMigrate) {
return;
@@ -136,9 +133,6 @@
@Nullable
@Override
public Boolean doInBackground(@Nullable Void input) {
- if (Build.VERSION.SDK_INT < 26) {
- return false;
- }
if (appContext.checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
LogUtil.i(TAG, "not attempting auto-migrate: no storage permission");
diff --git a/java/com/android/dialer/compat/telephony/TelephonyManagerCompat.java b/java/com/android/dialer/compat/telephony/TelephonyManagerCompat.java
index 41e5be2..653fc08 100644
--- a/java/com/android/dialer/compat/telephony/TelephonyManagerCompat.java
+++ b/java/com/android/dialer/compat/telephony/TelephonyManagerCompat.java
@@ -17,12 +17,8 @@
package com.android.dialer.compat.telephony;
import android.content.Context;
-import android.content.Intent;
import android.net.Uri;
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
import android.support.annotation.Nullable;
-import android.support.v4.os.BuildCompat;
import android.telecom.PhoneAccountHandle;
import android.telephony.TelephonyManager;
import com.android.dialer.common.LogUtil;
@@ -69,8 +65,7 @@
/** Indicates the Connection/Call used assisted dialing. */
public static final int PROPERTY_ASSISTED_DIALING_USED = 1 << 9;
- public static final String EXTRA_IS_REFRESH =
- BuildCompat.isAtLeastOMR1() ? "android.telephony.extra.IS_REFRESH" : "is_refresh";
+ public static final String EXTRA_IS_REFRESH = "android.telephony.extra.IS_REFRESH";
/**
* Indicates the call underwent Assisted Dialing; typically set as a feature available from the
@@ -189,21 +184,13 @@
* @param secretCode the secret code without the "*#*#" prefix and "#*#*" suffix
*/
public static void handleSecretCode(Context context, String secretCode) {
- // Must use system service on O+ to avoid using broadcasts, which are not allowed on O+.
- if (BuildCompat.isAtLeastO()) {
- if (!TelecomUtil.isDefaultDialer(context)) {
- LogUtil.e(
- "TelephonyManagerCompat.handleSecretCode",
- "not default dialer, cannot send special code");
- return;
- }
- context.getSystemService(TelephonyManager.class).sendDialerSpecialCode(secretCode);
- } else {
- // System service call is not supported pre-O, so must use a broadcast for N-.
- Intent intent =
- new Intent(SECRET_CODE_ACTION, Uri.parse("android_secret_code://" + secretCode));
- context.sendBroadcast(intent);
+ if (!TelecomUtil.isDefaultDialer(context)) {
+ LogUtil.e(
+ "TelephonyManagerCompat.handleSecretCode",
+ "not default dialer, cannot send special code");
+ return;
}
+ context.getSystemService(TelephonyManager.class).sendDialerSpecialCode(secretCode);
}
/**
@@ -226,12 +213,10 @@
if (phoneAccountHandle == null) {
return telephonyManager;
}
- if (VERSION.SDK_INT >= VERSION_CODES.O) {
- TelephonyManager telephonyManagerForPhoneAccount =
- telephonyManager.createForPhoneAccountHandle(phoneAccountHandle);
- if (telephonyManagerForPhoneAccount != null) {
- return telephonyManagerForPhoneAccount;
- }
+ TelephonyManager telephonyManagerForPhoneAccount =
+ telephonyManager.createForPhoneAccountHandle(phoneAccountHandle);
+ if (telephonyManagerForPhoneAccount != null) {
+ return telephonyManagerForPhoneAccount;
}
return telephonyManager;
}
diff --git a/java/com/android/dialer/constants/Constants.java b/java/com/android/dialer/constants/Constants.java
index fb1aa2a..8570192 100644
--- a/java/com/android/dialer/constants/Constants.java
+++ b/java/com/android/dialer/constants/Constants.java
@@ -49,9 +49,6 @@
}
@NonNull
- public abstract String getFilteredNumberProviderAuthority();
-
- @NonNull
public abstract String getFileProviderAuthority();
@NonNull
diff --git a/java/com/android/dialer/constants/aospdialer/ConstantsImpl.java b/java/com/android/dialer/constants/aospdialer/ConstantsImpl.java
index 312b3f5..eb93563 100644
--- a/java/com/android/dialer/constants/aospdialer/ConstantsImpl.java
+++ b/java/com/android/dialer/constants/aospdialer/ConstantsImpl.java
@@ -26,12 +26,6 @@
@Override
@NonNull
- public String getFilteredNumberProviderAuthority() {
- return "com.android.dialer.blocking.filterednumberprovider";
- }
-
- @Override
- @NonNull
public String getFileProviderAuthority() {
return "com.android.dialer.files";
}
diff --git a/java/com/android/dialer/constants/googledialer/ConstantsImpl.java b/java/com/android/dialer/constants/googledialer/ConstantsImpl.java
index e4a96fe..9a6fdd7 100644
--- a/java/com/android/dialer/constants/googledialer/ConstantsImpl.java
+++ b/java/com/android/dialer/constants/googledialer/ConstantsImpl.java
@@ -28,12 +28,6 @@
@Override
@NonNull
- public String getFilteredNumberProviderAuthority() {
- return "com.google.android.dialer.blocking.filterednumberprovider";
- }
-
- @Override
- @NonNull
public String getFileProviderAuthority() {
return "com.google.android.dialer.files";
}
diff --git a/java/com/android/dialer/database/DialerDatabaseHelper.java b/java/com/android/dialer/database/DialerDatabaseHelper.java
index 9d26398..8c1c1cc 100644
--- a/java/com/android/dialer/database/DialerDatabaseHelper.java
+++ b/java/com/android/dialer/database/DialerDatabaseHelper.java
@@ -43,7 +43,6 @@
import com.android.dialer.common.database.Selection;
import com.android.dialer.configprovider.ConfigProviderComponent;
import com.android.dialer.contacts.resources.R;
-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;
@@ -67,7 +66,7 @@
* 0-98 KitKat
* </pre>
*/
- public static final int DATABASE_VERSION = 10;
+ public static final int DATABASE_VERSION = 11;
public static final String DATABASE_NAME = "dialer.db";
@@ -89,17 +88,11 @@
private final Context context;
private final DialerFutureSerializer dialerFutureSerializer = new DialerFutureSerializer();
- private boolean isTestInstance = false;
-
protected DialerDatabaseHelper(Context context, String databaseName, int dbVersion) {
super(context, databaseName, null, dbVersion);
this.context = Objects.requireNonNull(context, "Context must not be null");
}
- public void setIsTestInstance(boolean isTestInstance) {
- this.isTestInstance = isTestInstance;
- }
-
/**
* Creates tables in the database when database is created for the first time.
*
@@ -170,45 +163,16 @@
+ " TEXT "
+ ");");
- // This will need to also be updated in setupTablesForFilteredNumberTest and onUpgrade.
- // Hardcoded so we know on glance what columns are updated in setupTables,
- // and to be able to guarantee the state of the DB at each upgrade step.
- db.execSQL(
- "CREATE TABLE "
- + Tables.FILTERED_NUMBER_TABLE
- + " ("
- + FilteredNumberColumns._ID
- + " INTEGER PRIMARY KEY AUTOINCREMENT,"
- + FilteredNumberColumns.NORMALIZED_NUMBER
- + " TEXT UNIQUE,"
- + FilteredNumberColumns.NUMBER
- + " TEXT,"
- + FilteredNumberColumns.COUNTRY_ISO
- + " TEXT,"
- + FilteredNumberColumns.TIMES_FILTERED
- + " INTEGER,"
- + FilteredNumberColumns.LAST_TIME_FILTERED
- + " LONG,"
- + FilteredNumberColumns.CREATION_TIME
- + " LONG,"
- + FilteredNumberColumns.TYPE
- + " INTEGER,"
- + FilteredNumberColumns.SOURCE
- + " INTEGER"
- + ");");
-
setProperty(db, DATABASE_VERSION_PROPERTY, String.valueOf(DATABASE_VERSION));
- if (!isTestInstance) {
- resetSmartDialLastUpdatedTime();
- }
+ resetSmartDialLastUpdatedTime();
}
public void dropTables(SQLiteDatabase db) {
db.execSQL("DROP TABLE IF EXISTS " + Tables.PREFIX_TABLE);
db.execSQL("DROP TABLE IF EXISTS " + Tables.SMARTDIAL_TABLE);
db.execSQL("DROP TABLE IF EXISTS " + Tables.PROPERTIES);
- db.execSQL("DROP TABLE IF EXISTS " + Tables.FILTERED_NUMBER_TABLE);
db.execSQL("DROP TABLE IF EXISTS " + Tables.VOICEMAIL_ARCHIVE_TABLE);
+ db.execSQL("DROP TABLE IF EXISTS filtered_numbers_table");
}
@Override
@@ -231,30 +195,6 @@
}
if (oldVersion < 7) {
- db.execSQL("DROP TABLE IF EXISTS " + Tables.FILTERED_NUMBER_TABLE);
- db.execSQL(
- "CREATE TABLE "
- + Tables.FILTERED_NUMBER_TABLE
- + " ("
- + FilteredNumberColumns._ID
- + " INTEGER PRIMARY KEY AUTOINCREMENT,"
- + FilteredNumberColumns.NORMALIZED_NUMBER
- + " TEXT UNIQUE,"
- + FilteredNumberColumns.NUMBER
- + " TEXT,"
- + FilteredNumberColumns.COUNTRY_ISO
- + " TEXT,"
- + FilteredNumberColumns.TIMES_FILTERED
- + " INTEGER,"
- + FilteredNumberColumns.LAST_TIME_FILTERED
- + " LONG,"
- + FilteredNumberColumns.CREATION_TIME
- + " LONG,"
- + FilteredNumberColumns.TYPE
- + " INTEGER,"
- + FilteredNumberColumns.SOURCE
- + " INTEGER"
- + ");");
oldVersion = 7;
}
@@ -268,6 +208,11 @@
oldVersion = 10;
}
+ if (oldVersion < 11) {
+ db.execSQL("DROP TABLE IF EXISTS filtered_numbers_table");
+ oldVersion = 11;
+ }
+
if (oldVersion != DATABASE_VERSION) {
throw new IllegalStateException(
"error upgrading the database to version " + DATABASE_VERSION);
@@ -1048,9 +993,6 @@
}
public interface Tables {
-
- /** Saves a list of numbers to be blocked. */
- String FILTERED_NUMBER_TABLE = "filtered_numbers_table";
/** Saves the necessary smart dial information of all contacts. */
String SMARTDIAL_TABLE = "smartdial_table";
/** Saves all possible prefixes to refer to a contacts. */
diff --git a/java/com/android/dialer/database/FilteredNumberContract.java b/java/com/android/dialer/database/FilteredNumberContract.java
deleted file mode 100644
index 5a7153e..0000000
--- a/java/com/android/dialer/database/FilteredNumberContract.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.dialer.database;
-
-import android.net.Uri;
-import android.provider.BaseColumns;
-import com.android.dialer.constants.Constants;
-
-/**
- * The contract between the filtered number provider and applications. Contains definitions for the
- * supported URIs and columns. Currently only accessible within Dialer.
- */
-public final class FilteredNumberContract {
-
- public static final String AUTHORITY = Constants.get().getFilteredNumberProviderAuthority();
-
- public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY);
-
- /** The type of filtering to be applied, e.g. block the number or allow the number. */
- public interface FilteredNumberTypes {
-
- int UNDEFINED = 0;
- /** Dialer will disconnect the call without sending the caller to voicemail. */
- int BLOCKED_NUMBER = 1;
- }
-
- /** The original source of the filtered number, e.g. the user manually added it. */
- public interface FilteredNumberSources {
-
- int UNDEFINED = 0;
- /** The user manually added this number through Dialer (e.g. from the call log or InCallUI). */
- int USER = 1;
- }
-
- public interface FilteredNumberColumns {
-
- // TYPE: INTEGER
- String _ID = "_id";
- /**
- * Represents the number to be filtered, normalized to compare phone numbers for equality.
- *
- * <p>TYPE: TEXT
- */
- String NORMALIZED_NUMBER = "normalized_number";
- /**
- * Represents the number to be filtered, for formatting and used with country iso for contact
- * lookups.
- *
- * <p>TYPE: TEXT
- */
- String NUMBER = "number";
- /**
- * The country code representing the country detected when the phone number was added to the
- * database. Most numbers don't have the country code, so a best guess is provided by the
- * country detector system. The country iso is also needed in order to format phone numbers
- * correctly.
- *
- * <p>TYPE: TEXT
- */
- String COUNTRY_ISO = "country_iso";
- /**
- * The number of times the number has been filtered by Dialer. When this number is incremented,
- * LAST_TIME_FILTERED should also be updated to the current time.
- *
- * <p>TYPE: INTEGER
- */
- String TIMES_FILTERED = "times_filtered";
- /**
- * Set to the current time when the phone number is filtered. When this is updated,
- * TIMES_FILTERED should also be incremented.
- *
- * <p>TYPE: LONG
- */
- String LAST_TIME_FILTERED = "last_time_filtered";
- // TYPE: LONG
- String CREATION_TIME = "creation_time";
- /**
- * Indicates the type of filtering to be applied.
- *
- * <p>TYPE: INTEGER See {@link FilteredNumberTypes}
- */
- String TYPE = "type";
- /**
- * Integer representing the original source of the filtered number.
- *
- * <p>TYPE: INTEGER See {@link FilteredNumberSources}
- */
- String SOURCE = "source";
- }
-
- /**
- * Constants for the table of filtered numbers.
- *
- * <h3>Operations</h3>
- *
- * <dl>
- * <dt><b>Insert</b>
- * <dd>Required fields: NUMBER, NORMALIZED_NUMBER, TYPE, SOURCE. A default value will be used for
- * the other fields if left null.
- * <dt><b>Update</b>
- * <dt><b>Delete</b>
- * <dt><b>Query</b>
- * <dd>{@link #CONTENT_URI} can be used for any query, append an ID to retrieve a specific
- * filtered number entry.
- * </dl>
- */
- public static class FilteredNumber implements BaseColumns {
-
- public static final String FILTERED_NUMBERS_TABLE = "filtered_numbers_table";
-
- /**
- * The MIME type of a {@link android.content.ContentProvider#getType(Uri)} single filtered
- * number.
- */
- public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/filtered_numbers_table";
-
- public static final Uri CONTENT_URI =
- Uri.withAppendedPath(AUTHORITY_URI, FILTERED_NUMBERS_TABLE);
-
- /** This utility class cannot be instantiated. */
- private FilteredNumber() {}
- }
-}
diff --git a/java/com/android/dialer/databasepopulator/VoicemailPopulator.java b/java/com/android/dialer/databasepopulator/VoicemailPopulator.java
index 4465056..4e76484 100644
--- a/java/com/android/dialer/databasepopulator/VoicemailPopulator.java
+++ b/java/com/android/dialer/databasepopulator/VoicemailPopulator.java
@@ -19,8 +19,6 @@
import android.content.ComponentName;
import android.content.ContentValues;
import android.content.Context;
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
import android.provider.VoicemailContract.Status;
import android.provider.VoicemailContract.Voicemails;
import android.support.annotation.NonNull;
@@ -28,6 +26,7 @@
import android.support.annotation.WorkerThread;
import android.telecom.PhoneAccountHandle;
import com.android.dialer.common.Assert;
+import com.android.voicemail.impl.Voicemail;
import com.google.auto.value.AutoValue;
import java.util.ArrayList;
import java.util.Arrays;
@@ -118,9 +117,7 @@
componentName = handle.getComponentName().toString();
ContentValues values = new ContentValues();
values.put(Status.SOURCE_PACKAGE, handle.getComponentName().getPackageName());
- if (VERSION.SDK_INT >= VERSION_CODES.N_MR1) {
- values.put(Status.SOURCE_TYPE, "vvm_type_vvm3"); // mark populated voice mail as vvm3
- }
+ values.put(Status.SOURCE_TYPE, "vvm_type_vvm3"); // mark populated voice mail as vvm3
values.put(Status.PHONE_ACCOUNT_COMPONENT_NAME, handle.getComponentName().flattenToString());
values.put(Status.PHONE_ACCOUNT_ID, handle.getId());
values.put(Status.CONFIGURATION_STATE, Status.CONFIGURATION_STATE_OK);
diff --git a/java/com/android/dialer/dialpadview/DialpadFragment.java b/java/com/android/dialer/dialpadview/DialpadFragment.java
index 234457e..20d75b1 100644
--- a/java/com/android/dialer/dialpadview/DialpadFragment.java
+++ b/java/com/android/dialer/dialpadview/DialpadFragment.java
@@ -16,7 +16,6 @@
package com.android.dialer.dialpadview;
-import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
@@ -35,8 +34,6 @@
import android.media.AudioManager;
import android.media.ToneGenerator;
import android.net.Uri;
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.os.Trace;
@@ -81,6 +78,7 @@
import android.widget.TextView;
import com.android.contacts.common.dialog.CallSubjectDialog;
import com.android.contacts.common.util.StopWatch;
+import com.android.dialer.R;
import com.android.dialer.animation.AnimUtils;
import com.android.dialer.animation.AnimUtils.AnimationCallback;
import com.android.dialer.callintent.CallInitiationType;
@@ -493,15 +491,11 @@
* cannot be inflated in robolectric.
*/
@SuppressWarnings("missingPermission")
- @TargetApi(VERSION_CODES.O)
@VisibleForTesting
static boolean shouldShowEmergencyCallWarning(Context context) {
if (showEmergencyCallWarningForTest != null) {
return showEmergencyCallWarningForTest;
}
- if (VERSION.SDK_INT < VERSION_CODES.O) {
- return false;
- }
if (!PermissionsUtil.hasReadPhoneStatePermissions(context)) {
return false;
}
diff --git a/java/com/android/dialer/main/impl/OldMainActivityPeer.java b/java/com/android/dialer/main/impl/OldMainActivityPeer.java
index 78ed252..a818ef4 100644
--- a/java/com/android/dialer/main/impl/OldMainActivityPeer.java
+++ b/java/com/android/dialer/main/impl/OldMainActivityPeer.java
@@ -55,6 +55,7 @@
import android.widget.ImageView;
import android.widget.TextView;
import com.android.contacts.common.list.OnPhoneNumberPickerActionListener;
+import com.android.dialer.R;
import com.android.dialer.animation.AnimUtils;
import com.android.dialer.app.MainComponent;
import com.android.dialer.app.calllog.CallLogAdapter;
@@ -123,8 +124,6 @@
import com.android.dialer.util.PermissionsUtil;
import com.android.dialer.util.TransactionSafeActivity;
import com.android.dialer.voicemail.listui.NewVoicemailFragment;
-import com.android.dialer.voicemail.listui.error.VoicemailStatusCorruptionHandler;
-import com.android.dialer.voicemail.listui.error.VoicemailStatusCorruptionHandler.Source;
import com.android.dialer.voicemailstatus.VisualVoicemailEnabledChecker;
import com.android.dialer.voicemailstatus.VoicemailStatusHelper;
import com.android.voicemail.VoicemailComponent;
@@ -966,8 +965,6 @@
@Override
public void onVoicemailStatusFetched(Cursor statusCursor) {
LogUtil.i("OldMainActivityPeer.MainCallLogFragmentListener", "onVoicemailStatusFetched");
- VoicemailStatusCorruptionHandler.maybeFixVoicemailStatus(
- context, statusCursor, Source.Activity);
// Update hasActiveVoicemailProvider, which controls the number of tabs displayed.
int numberOfActiveVoicemailSources =
diff --git a/java/com/android/dialer/notification/DialerNotificationManager.java b/java/com/android/dialer/notification/DialerNotificationManager.java
index eb730be..a311124 100644
--- a/java/com/android/dialer/notification/DialerNotificationManager.java
+++ b/java/com/android/dialer/notification/DialerNotificationManager.java
@@ -22,7 +22,6 @@
import android.service.notification.StatusBarNotification;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import android.support.v4.os.BuildCompat;
import android.text.TextUtils;
import android.util.Pair;
import com.android.dialer.common.Assert;
@@ -49,10 +48,7 @@
Assert.isNotNull(context);
Assert.isNotNull(notification);
Assert.checkArgument(!TextUtils.isEmpty(tag));
-
- if (BuildCompat.isAtLeastO()) {
- Assert.checkArgument(!TextUtils.isEmpty(notification.getChannelId()));
- }
+ Assert.checkArgument(!TextUtils.isEmpty(notification.getChannelId()));
getNotificationManager(context).notify(tag, id, notification);
throttledNotificationSet.addAll(NotificationThrottler.throttle(context, notification));
diff --git a/java/com/android/dialer/notification/NotificationChannelManager.java b/java/com/android/dialer/notification/NotificationChannelManager.java
index 790aac3..8f9229d 100644
--- a/java/com/android/dialer/notification/NotificationChannelManager.java
+++ b/java/com/android/dialer/notification/NotificationChannelManager.java
@@ -16,23 +16,21 @@
package com.android.dialer.notification;
-import android.annotation.TargetApi;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.media.AudioAttributes;
-import android.os.Build.VERSION_CODES;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import android.support.v4.os.BuildCompat;
import android.telecom.PhoneAccountHandle;
import android.util.ArraySet;
+
+import com.android.dialer.R;
import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
import java.util.Set;
/** Creates all notification channels for Dialer. */
-@TargetApi(VERSION_CODES.O)
public final class NotificationChannelManager {
/**
@@ -51,7 +49,6 @@
* <ul>
*/
public static void initChannels(@NonNull Context context) {
- Assert.checkArgument(BuildCompat.isAtLeastO());
Assert.isNotNull(context);
NotificationManager notificationManager = context.getSystemService(NotificationManager.class);
@@ -90,7 +87,6 @@
@NonNull
public static String getVoicemailChannelId(
@NonNull Context context, @Nullable PhoneAccountHandle handle) {
- Assert.checkArgument(BuildCompat.isAtLeastO());
Assert.isNotNull(context);
return VoicemailChannelUtils.getChannelId(context, handle);
}
diff --git a/java/com/android/dialer/notification/VoicemailChannelUtils.java b/java/com/android/dialer/notification/VoicemailChannelUtils.java
index ddc0f77..5cf8ee9 100644
--- a/java/com/android/dialer/notification/VoicemailChannelUtils.java
+++ b/java/com/android/dialer/notification/VoicemailChannelUtils.java
@@ -17,24 +17,23 @@
package com.android.dialer.notification;
import android.Manifest.permission;
-import android.annotation.TargetApi;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.media.AudioAttributes;
-import android.os.Build.VERSION_CODES;
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresPermission;
import android.support.annotation.VisibleForTesting;
-import android.support.v4.os.BuildCompat;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.ArraySet;
+
+import com.android.dialer.R;
import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
import com.android.dialer.util.PermissionsUtil;
@@ -43,16 +42,12 @@
import java.util.Set;
/** Utilities for working with voicemail channels. */
-@TargetApi(VERSION_CODES.O)
/* package */ final class VoicemailChannelUtils {
@VisibleForTesting static final String GLOBAL_VOICEMAIL_CHANNEL_ID = "phone_voicemail";
private static final String PER_ACCOUNT_VOICEMAIL_CHANNEL_ID_PREFIX = "phone_voicemail_account_";
@SuppressWarnings("MissingPermission") // isSingleSimDevice() returns true if no permission
static Set<String> getAllChannelIds(@NonNull Context context) {
- Assert.checkArgument(BuildCompat.isAtLeastO());
- Assert.isNotNull(context);
-
Set<String> result = new ArraySet<>();
if (isSingleSimDevice(context)) {
result.add(GLOBAL_VOICEMAIL_CHANNEL_ID);
@@ -66,9 +61,6 @@
@SuppressWarnings("MissingPermission") // isSingleSimDevice() returns true if no permission
static void createAllChannels(@NonNull Context context) {
- Assert.checkArgument(BuildCompat.isAtLeastO());
- Assert.isNotNull(context);
-
if (isSingleSimDevice(context)) {
createGlobalVoicemailChannel(context);
} else {
@@ -80,9 +72,6 @@
@NonNull
static String getChannelId(@NonNull Context context, @Nullable PhoneAccountHandle handle) {
- Assert.checkArgument(BuildCompat.isAtLeastO());
- Assert.isNotNull(context);
-
// Most devices we deal with have a single SIM slot. No need to distinguish between phone
// accounts.
if (isSingleSimDevice(context)) {
diff --git a/java/com/android/dialer/phonelookup/blockednumber/SystemBlockedNumberPhoneLookup.java b/java/com/android/dialer/phonelookup/blockednumber/SystemBlockedNumberPhoneLookup.java
index 4192e79..2d53d2d 100644
--- a/java/com/android/dialer/phonelookup/blockednumber/SystemBlockedNumberPhoneLookup.java
+++ b/java/com/android/dialer/phonelookup/blockednumber/SystemBlockedNumberPhoneLookup.java
@@ -23,7 +23,6 @@
import android.support.annotation.WorkerThread;
import android.util.ArraySet;
import com.android.dialer.DialerPhoneNumber;
-import com.android.dialer.blocking.FilteredNumberCompat;
import com.android.dialer.calllog.observer.MarkDirtyObserver;
import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
@@ -66,9 +65,6 @@
@Override
public ListenableFuture<SystemBlockedNumberInfo> lookup(@NonNull DialerPhoneNumber number) {
- if (!FilteredNumberCompat.useNewFiltering(appContext)) {
- return Futures.immediateFuture(SystemBlockedNumberInfo.getDefaultInstance());
- }
return executorService.submit(() -> queryNumbers(ImmutableSet.of(number)).get(number));
}
@@ -83,9 +79,6 @@
public ListenableFuture<ImmutableMap<DialerPhoneNumber, SystemBlockedNumberInfo>>
getMostRecentInfo(ImmutableMap<DialerPhoneNumber, SystemBlockedNumberInfo> existingInfoMap) {
LogUtil.enterBlock("SystemBlockedNumberPhoneLookup.getMostRecentPhoneLookupInfo");
- if (!FilteredNumberCompat.useNewFiltering(appContext)) {
- return Futures.immediateFuture(existingInfoMap);
- }
return executorService.submit(() -> queryNumbers(existingInfoMap.keySet()));
}
diff --git a/java/com/android/dialer/phonenumbercache/CallLogQuery.java b/java/com/android/dialer/phonenumbercache/CallLogQuery.java
index 2f2758a..c001eaf 100644
--- a/java/com/android/dialer/phonenumbercache/CallLogQuery.java
+++ b/java/com/android/dialer/phonenumbercache/CallLogQuery.java
@@ -16,12 +16,9 @@
package com.android.dialer.phonenumbercache;
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
import android.provider.CallLog;
import android.provider.CallLog.Calls;
import android.support.annotation.NonNull;
-import android.support.annotation.RequiresApi;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -55,8 +52,6 @@
public static final int CACHED_PHOTO_URI = 23;
public static final int POST_DIAL_DIGITS = 24;
public static final int VIA_NUMBER = 25;
-
- @RequiresApi(VERSION_CODES.O)
public static final int TRANSCRIPTION_STATE = 26;
private static final String[] PROJECTION_N =
@@ -86,14 +81,14 @@
Calls.TRANSCRIPTION, // 22
Calls.CACHED_PHOTO_URI, // 23
CallLog.Calls.POST_DIAL_DIGITS, // 24
- CallLog.Calls.VIA_NUMBER // 25
+ CallLog.Calls.VIA_NUMBER, // 25
};
private static final String[] PROJECTION_O;
// TODO(mdooley): remove when this becomes a public api
// Copied from android.provider.CallLog.Calls
- private static final String TRANSCRIPTION_STATE_COLUMN = "transcription_state";
+ public static final String TRANSCRIPTION_STATE_COLUMN = "transcription_state";
static {
List<String> projectionList = new ArrayList<>(Arrays.asList(PROJECTION_N));
@@ -103,6 +98,6 @@
@NonNull
public static String[] getProjection() {
- return VERSION.SDK_INT >= VERSION_CODES.O ? PROJECTION_O : PROJECTION_N;
+ return PROJECTION_O;
}
}
diff --git a/java/com/android/dialer/preferredsim/PreferredAccountUtil.java b/java/com/android/dialer/preferredsim/PreferredAccountUtil.java
index 1cfdbb1..9b7c56b 100644
--- a/java/com/android/dialer/preferredsim/PreferredAccountUtil.java
+++ b/java/com/android/dialer/preferredsim/PreferredAccountUtil.java
@@ -18,15 +18,9 @@
import android.content.ComponentName;
import android.content.Context;
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
-import android.telecom.TelecomManager;
-import android.telephony.SubscriptionInfo;
-import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import com.android.dialer.common.LogUtil;
@@ -66,32 +60,10 @@
public static boolean isPhoneAccountValid(
Context context, PhoneAccountHandle phoneAccountHandle) {
- if (VERSION.SDK_INT >= VERSION_CODES.O) {
return context
.getSystemService(TelephonyManager.class)
.createForPhoneAccountHandle(phoneAccountHandle)
!= null;
- }
-
- PhoneAccount phoneAccount =
- context.getSystemService(TelecomManager.class).getPhoneAccount(phoneAccountHandle);
- if (phoneAccount == null) {
- LogUtil.e("PreferredAccountUtil.isPhoneAccountValid", "invalid phone account");
- return false;
- }
-
- if (!phoneAccount.isEnabled()) {
- LogUtil.e("PreferredAccountUtil.isPhoneAccountValid", "disabled phone account");
- return false;
- }
- for (SubscriptionInfo info :
- SubscriptionManager.from(context).getActiveSubscriptionInfoList()) {
- if (phoneAccountHandle.getId().startsWith(info.getIccId())) {
- LogUtil.i("PreferredAccountUtil.isPhoneAccountValid", "sim found");
- return true;
- }
- }
- return false;
}
/**
diff --git a/java/com/android/dialer/shortcuts/DialerShortcut.java b/java/com/android/dialer/shortcuts/DialerShortcut.java
index a8d4204..5132b95 100644
--- a/java/com/android/dialer/shortcuts/DialerShortcut.java
+++ b/java/com/android/dialer/shortcuts/DialerShortcut.java
@@ -16,10 +16,8 @@
package com.android.dialer.shortcuts;
-import android.annotation.TargetApi;
import android.content.pm.ShortcutInfo;
import android.net.Uri;
-import android.os.Build.VERSION_CODES;
import android.provider.ContactsContract.Contacts;
import android.support.annotation.NonNull;
import com.google.auto.value.AutoValue;
@@ -30,7 +28,6 @@
* <p>This differs from {@link ShortcutInfo} in that it doesn't hold an icon or intent, and provides
* convenience methods for doing things like constructing labels.
*/
-@TargetApi(VERSION_CODES.N_MR1) // Shortcuts introduced in N MR1
@AutoValue
abstract class DialerShortcut {
diff --git a/java/com/android/dialer/shortcuts/DynamicShortcuts.java b/java/com/android/dialer/shortcuts/DynamicShortcuts.java
index e39dc27..e0d6104 100644
--- a/java/com/android/dialer/shortcuts/DynamicShortcuts.java
+++ b/java/com/android/dialer/shortcuts/DynamicShortcuts.java
@@ -17,12 +17,10 @@
package com.android.dialer.shortcuts;
import android.Manifest;
-import android.annotation.TargetApi;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutManager;
-import android.os.Build.VERSION_CODES;
import android.support.annotation.NonNull;
import android.support.annotation.WorkerThread;
import android.support.v4.content.ContextCompat;
@@ -60,7 +58,6 @@
* updated periodically (about once a day).
*
*/
-@TargetApi(VERSION_CODES.N_MR1) // Shortcuts introduced in N MR1
final class DynamicShortcuts {
private static final int MAX_DYNAMIC_SHORTCUTS = 3;
diff --git a/java/com/android/dialer/shortcuts/IconFactory.java b/java/com/android/dialer/shortcuts/IconFactory.java
index 7aad112..711e5a5 100644
--- a/java/com/android/dialer/shortcuts/IconFactory.java
+++ b/java/com/android/dialer/shortcuts/IconFactory.java
@@ -21,18 +21,14 @@
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.AdaptiveIconDrawable;
-import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.net.Uri;
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
import android.provider.ContactsContract;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import android.support.annotation.RequiresApi;
import android.support.annotation.WorkerThread;
-import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
-import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
+
+import com.android.dialer.R;
import com.android.dialer.common.Assert;
import com.android.dialer.lettertile.LetterTileDrawable;
import com.android.dialer.util.DrawableConverter;
@@ -88,12 +84,9 @@
ContactsContract.Contacts.openContactPhotoInputStream(
context.getContentResolver(), lookupUri, false /* preferHighres */);
- return VERSION.SDK_INT >= VERSION_CODES.O
- ? createAdaptiveIcon(displayName, lookupKey, inputStream)
- : createFlatIcon(displayName, lookupKey, inputStream);
+ return createAdaptiveIcon(displayName, lookupKey, inputStream);
}
- @RequiresApi(VERSION_CODES.O)
private Icon createAdaptiveIcon(
@NonNull String displayName, @NonNull String lookupKey, @Nullable InputStream inputStream) {
if (inputStream == null) {
@@ -117,33 +110,4 @@
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
return Icon.createWithAdaptiveBitmap(bitmap);
}
-
- private Icon createFlatIcon(
- @NonNull String displayName, @NonNull String lookupKey, @Nullable InputStream inputStream) {
- Drawable drawable;
- if (inputStream == null) {
- // No photo for contact; use a letter tile.
- LetterTileDrawable letterTileDrawable = new LetterTileDrawable(context.getResources());
- letterTileDrawable.setCanonicalDialerLetterTileDetails(
- displayName, lookupKey, LetterTileDrawable.SHAPE_CIRCLE, LetterTileDrawable.TYPE_DEFAULT);
- drawable = letterTileDrawable;
- } else {
- // There's a photo, create a circular drawable from it.
- Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
- drawable = createCircularDrawable(bitmap);
- }
- int iconSize =
- context.getResources().getDimensionPixelSize(R.dimen.launcher_shortcut_icon_size);
- return Icon.createWithBitmap(
- DrawableConverter.drawableToBitmap(drawable, iconSize /* width */, iconSize /* height */));
- }
-
- @NonNull
- private Drawable createCircularDrawable(@NonNull Bitmap bitmap) {
- RoundedBitmapDrawable roundedBitmapDrawable =
- RoundedBitmapDrawableFactory.create(context.getResources(), bitmap);
- roundedBitmapDrawable.setCircular(true);
- roundedBitmapDrawable.setAntiAlias(true);
- return roundedBitmapDrawable;
- }
}
diff --git a/java/com/android/dialer/shortcuts/PeriodicJobService.java b/java/com/android/dialer/shortcuts/PeriodicJobService.java
index 62c9e37..4a48c74 100644
--- a/java/com/android/dialer/shortcuts/PeriodicJobService.java
+++ b/java/com/android/dialer/shortcuts/PeriodicJobService.java
@@ -16,15 +16,12 @@
package com.android.dialer.shortcuts;
-import android.annotation.TargetApi;
import android.app.job.JobInfo;
import android.app.job.JobParameters;
import android.app.job.JobScheduler;
import android.app.job.JobService;
import android.content.ComponentName;
import android.content.Context;
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
import android.support.annotation.MainThread;
import android.support.annotation.NonNull;
import android.support.v4.os.UserManagerCompat;
@@ -38,7 +35,6 @@
*
* <p>Only {@link #schedulePeriodicJob(Context)} should be used by callers.
*/
-@TargetApi(VERSION_CODES.N_MR1) // Shortcuts introduced in N MR1
public final class PeriodicJobService extends JobService {
private static final long REFRESH_PERIOD_MILLIS = TimeUnit.HOURS.toMillis(24);
@@ -57,7 +53,7 @@
Assert.isMainThread();
LogUtil.enterBlock("PeriodicJobService.schedulePeriodicJob");
- if (VERSION.SDK_INT >= VERSION_CODES.N_MR1 && UserManagerCompat.isUserUnlocked(context)) {
+ if (UserManagerCompat.isUserUnlocked(context)) {
JobScheduler jobScheduler = context.getSystemService(JobScheduler.class);
if (jobScheduler.getPendingJob(ScheduledJobIds.SHORTCUT_PERIODIC_JOB) != null) {
LogUtil.i("PeriodicJobService.schedulePeriodicJob", "job already scheduled.");
@@ -91,16 +87,7 @@
Assert.isMainThread();
LogUtil.enterBlock("PeriodicJobService.onStartJob");
- if (VERSION.SDK_INT >= VERSION_CODES.N_MR1) {
- (refreshShortcutsTask = new RefreshShortcutsTask(this)).execute(params);
- } else {
- // It is possible for the job to have been scheduled on NMR1+ and then the system was
- // downgraded to < NMR1. In this case, shortcuts are no longer supported so we cancel the job
- // which creates them.
- LogUtil.i("PeriodicJobService.onStartJob", "not running on NMR1, cancelling job");
- cancelJob(this);
- return false;
- }
+ (refreshShortcutsTask = new RefreshShortcutsTask(this)).execute(params);
return true;
}
diff --git a/java/com/android/dialer/shortcuts/PinnedShortcuts.java b/java/com/android/dialer/shortcuts/PinnedShortcuts.java
index d5265c2..870abac 100644
--- a/java/com/android/dialer/shortcuts/PinnedShortcuts.java
+++ b/java/com/android/dialer/shortcuts/PinnedShortcuts.java
@@ -17,19 +17,19 @@
package com.android.dialer.shortcuts;
import android.Manifest;
-import android.annotation.TargetApi;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutManager;
import android.database.Cursor;
import android.net.Uri;
-import android.os.Build.VERSION_CODES;
import android.provider.ContactsContract.Contacts;
import android.support.annotation.NonNull;
import android.support.annotation.WorkerThread;
import android.support.v4.content.ContextCompat;
import android.util.ArrayMap;
+
+import com.android.dialer.R;
import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
import java.util.ArrayList;
@@ -47,7 +47,6 @@
* still up to date (e.g. photo and name). We also check to see if the contact has been deleted from
* the user's contacts, and if so, we disable the pinned shortcut.
*/
-@TargetApi(VERSION_CODES.N_MR1) // Shortcuts introduced in N MR1
final class PinnedShortcuts {
private static final String[] PROJECTION =
diff --git a/java/com/android/dialer/shortcuts/RefreshShortcutsTask.java b/java/com/android/dialer/shortcuts/RefreshShortcutsTask.java
index 086d1dc..0bb9ecb 100644
--- a/java/com/android/dialer/shortcuts/RefreshShortcutsTask.java
+++ b/java/com/android/dialer/shortcuts/RefreshShortcutsTask.java
@@ -16,11 +16,9 @@
package com.android.dialer.shortcuts;
-import android.annotation.TargetApi;
import android.app.job.JobParameters;
import android.app.job.JobService;
import android.os.AsyncTask;
-import android.os.Build.VERSION_CODES;
import android.support.annotation.MainThread;
import android.support.annotation.NonNull;
import android.support.annotation.WorkerThread;
@@ -28,7 +26,6 @@
import com.android.dialer.common.LogUtil;
/** {@link AsyncTask} used by the periodic job service to refresh dynamic and pinned shortcuts. */
-@TargetApi(VERSION_CODES.N_MR1) // Shortcuts introduced in N MR1
final class RefreshShortcutsTask extends AsyncTask<JobParameters, Void, JobParameters> {
private final JobService jobService;
diff --git a/java/com/android/dialer/shortcuts/ShortcutInfoFactory.java b/java/com/android/dialer/shortcuts/ShortcutInfoFactory.java
index cf780bb..62dd0e9 100644
--- a/java/com/android/dialer/shortcuts/ShortcutInfoFactory.java
+++ b/java/com/android/dialer/shortcuts/ShortcutInfoFactory.java
@@ -16,11 +16,9 @@
package com.android.dialer.shortcuts;
-import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ShortcutInfo;
-import android.os.Build.VERSION_CODES;
import android.support.annotation.NonNull;
import android.support.annotation.WorkerThread;
import com.android.dialer.common.Assert;
@@ -35,7 +33,6 @@
* <p>The main work this factory does is create shortcut intents. It also delegates to the {@link
* IconFactory} to create icons.
*/
-@TargetApi(VERSION_CODES.N_MR1) // Shortcuts introduced in N MR1
final class ShortcutInfoFactory {
/** Key for the contact ID extra (a long) stored as part of the shortcut intent. */
diff --git a/java/com/android/dialer/shortcuts/ShortcutRefresher.java b/java/com/android/dialer/shortcuts/ShortcutRefresher.java
index 7776aa9..810fd8b 100644
--- a/java/com/android/dialer/shortcuts/ShortcutRefresher.java
+++ b/java/com/android/dialer/shortcuts/ShortcutRefresher.java
@@ -38,10 +38,6 @@
Assert.isMainThread();
Assert.isNotNull(context);
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) {
- return;
- }
-
if (!Shortcuts.areDynamicShortcutsEnabled(context)) {
return;
}
diff --git a/java/com/android/dialer/shortcuts/ShortcutUsageReporter.java b/java/com/android/dialer/shortcuts/ShortcutUsageReporter.java
index 3f0b2a6..49ff51b 100644
--- a/java/com/android/dialer/shortcuts/ShortcutUsageReporter.java
+++ b/java/com/android/dialer/shortcuts/ShortcutUsageReporter.java
@@ -17,15 +17,12 @@
package com.android.dialer.shortcuts;
import android.Manifest;
-import android.annotation.TargetApi;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.ShortcutManager;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
-import android.os.Build;
-import android.os.Build.VERSION_CODES;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.PhoneLookup;
import android.support.annotation.MainThread;
@@ -48,7 +45,6 @@
* <p>This allows launcher applications to provide users with shortcut suggestions, even if the user
* isn't already using shortcuts.
*/
-@TargetApi(VERSION_CODES.N_MR1) // Shortcuts introduced in N_MR1
public class ShortcutUsageReporter {
private static final AsyncTaskExecutor EXECUTOR = AsyncTaskExecutors.createThreadPoolExecutor();
@@ -68,7 +64,7 @@
Assert.isMainThread();
Assert.isNotNull(context);
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1 || TextUtils.isEmpty(phoneNumber)) {
+ if (TextUtils.isEmpty(phoneNumber)) {
return;
}
diff --git a/java/com/android/dialer/simulator/impl/RttChatBot.java b/java/com/android/dialer/simulator/impl/RttChatBot.java
index cd52343..f141130 100644
--- a/java/com/android/dialer/simulator/impl/RttChatBot.java
+++ b/java/com/android/dialer/simulator/impl/RttChatBot.java
@@ -16,7 +16,6 @@
package com.android.dialer.simulator.impl;
-import android.annotation.TargetApi;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
@@ -31,7 +30,6 @@
import java.util.Random;
/** Chat bot to generate remote RTT chat messages. */
-@TargetApi(28)
class RttChatBot {
interface Callback {
diff --git a/java/com/android/dialer/simulator/impl/SimulatorConnection.java b/java/com/android/dialer/simulator/impl/SimulatorConnection.java
index 3aa3296..b04742f 100644
--- a/java/com/android/dialer/simulator/impl/SimulatorConnection.java
+++ b/java/com/android/dialer/simulator/impl/SimulatorConnection.java
@@ -16,10 +16,8 @@
package com.android.dialer.simulator.impl;
-import android.annotation.TargetApi;
import android.content.Context;
import android.support.annotation.NonNull;
-import android.support.v4.os.BuildCompat;
import android.telecom.Connection;
import android.telecom.Connection.RttTextStream;
import android.telecom.ConnectionRequest;
@@ -34,7 +32,6 @@
import java.util.List;
/** Represents a single phone call on the device. */
-@TargetApi(28)
public final class SimulatorConnection extends Connection {
private final List<Listener> listeners = new ArrayList<>();
private final List<Event> events = new ArrayList<>();
@@ -60,9 +57,7 @@
getConnectionCapabilities() | CAPABILITY_SEPARATE_FROM_CONFERENCE);
}
}
- if (BuildCompat.isAtLeastP()) {
- rttTextStream = request.getRttTextStream();
- }
+ rttTextStream = request.getRttTextStream();
setVideoProvider(new SimulatorVideoProvider(context, this));
simulatorConnectionsBank = SimulatorComponent.get(context).getSimulatorConnectionsBank();
}
diff --git a/java/com/android/dialer/spam/promo/SpamBlockingPromoHelper.java b/java/com/android/dialer/spam/promo/SpamBlockingPromoHelper.java
index c270c59..cf67a79 100644
--- a/java/com/android/dialer/spam/promo/SpamBlockingPromoHelper.java
+++ b/java/com/android/dialer/spam/promo/SpamBlockingPromoHelper.java
@@ -25,9 +25,10 @@
import android.graphics.drawable.Icon;
import android.support.design.widget.Snackbar;
import android.support.v4.app.FragmentManager;
-import android.support.v4.os.BuildCompat;
import android.view.View;
import android.widget.Toast;
+
+import com.android.dialer.R;
import com.android.dialer.configprovider.ConfigProviderComponent;
import com.android.dialer.logging.DialerImpression;
import com.android.dialer.logging.Logger;
@@ -196,11 +197,8 @@
context.getString(R.string.spam_blocking_promo_action_filter_spam),
actionIntent)
.build())
- .setContentTitle(context.getString(R.string.spam_blocking_promo_title));
-
- if (BuildCompat.isAtLeastO()) {
- builder.setChannelId(NotificationChannelId.DEFAULT);
- }
+ .setContentTitle(context.getString(R.string.spam_blocking_promo_title))
+ .setChannelId(NotificationChannelId.DEFAULT);
return builder.build();
}
}
diff --git a/java/com/android/dialer/strictmode/impl/SystemDialerStrictMode.java b/java/com/android/dialer/strictmode/impl/SystemDialerStrictMode.java
index f3ce70c..4e527e5 100644
--- a/java/com/android/dialer/strictmode/impl/SystemDialerStrictMode.java
+++ b/java/com/android/dialer/strictmode/impl/SystemDialerStrictMode.java
@@ -17,8 +17,6 @@
package com.android.dialer.strictmode.impl;
import android.app.Application;
-import android.os.Build;
-import android.os.Build.VERSION_CODES;
import android.os.Handler;
import android.os.Looper;
import android.os.StrictMode;
@@ -91,12 +89,10 @@
StrictMode.VmPolicy.Builder vmPolicyBuilder =
new StrictMode.VmPolicy.Builder(vmPenalties)
.detectLeakedClosableObjects()
- .detectLeakedSqlLiteObjects();
- if (Build.VERSION.SDK_INT >= VERSION_CODES.O) {
- vmPolicyBuilder.detectContentUriWithoutPermission();
+ .detectLeakedSqlLiteObjects()
+ .detectContentUriWithoutPermission();
// TODO(azlatin): Enable detecting untagged sockets once: a bug is fixed.
// vmPolicyBuilder.detectUntaggedSockets();
- }
StrictMode.setVmPolicy(vmPolicyBuilder.build());
}
diff --git a/java/com/android/dialer/telecom/TelecomUtil.java b/java/com/android/dialer/telecom/TelecomUtil.java
index 633a53e..2d22314 100644
--- a/java/com/android/dialer/telecom/TelecomUtil.java
+++ b/java/com/android/dialer/telecom/TelecomUtil.java
@@ -23,8 +23,6 @@
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
import android.os.UserHandle;
import android.provider.CallLog.Calls;
import android.support.annotation.NonNull;
@@ -356,11 +354,7 @@
// Dialer is launched.
// Instead, Dialer should use TelecomManager#isInManagedCall, which only returns true if the
// device is in a managed call which Dialer would know about.
- if (VERSION.SDK_INT >= VERSION_CODES.O) {
- return getTelecomManager(context).isInManagedCall();
- } else {
- return getTelecomManager(context).isInCall();
- }
+ return getTelecomManager(context).isInManagedCall();
}
return false;
}
diff --git a/java/com/android/dialer/voicemail/listui/error/VoicemailErrorMessageCreator.java b/java/com/android/dialer/voicemail/listui/error/VoicemailErrorMessageCreator.java
index 43da6af..86cfad7 100644
--- a/java/com/android/dialer/voicemail/listui/error/VoicemailErrorMessageCreator.java
+++ b/java/com/android/dialer/voicemail/listui/error/VoicemailErrorMessageCreator.java
@@ -17,8 +17,6 @@
package com.android.dialer.voicemail.listui.error;
import android.content.Context;
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
import android.support.annotation.Nullable;
import com.android.voicemail.VisualVoicemailTypeExtensions;
@@ -32,10 +30,6 @@
@Nullable
public VoicemailErrorMessage create(
Context context, VoicemailStatus status, VoicemailStatusReader statusReader) {
- // Never return error message before NMR1. Voicemail status is not supported on those.
- if (VERSION.SDK_INT < VERSION_CODES.N_MR1) {
- return null;
- }
switch (status.type) {
case VisualVoicemailTypeExtensions.VVM_TYPE_VVM3:
return Vvm3VoicemailMessageCreator.create(context, status, statusReader);
diff --git a/java/com/android/dialer/voicemail/listui/error/VoicemailStatus.java b/java/com/android/dialer/voicemail/listui/error/VoicemailStatus.java
index ebda0e6..05bb32a 100644
--- a/java/com/android/dialer/voicemail/listui/error/VoicemailStatus.java
+++ b/java/com/android/dialer/voicemail/listui/error/VoicemailStatus.java
@@ -16,18 +16,14 @@
package com.android.dialer.voicemail.listui.error;
-import android.annotation.TargetApi;
import android.content.ComponentName;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
import android.provider.Settings;
import android.provider.Settings.Global;
import android.provider.VoicemailContract.Status;
import android.support.annotation.Nullable;
-import android.support.v4.os.BuildCompat;
import android.telecom.PhoneAccountHandle;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
@@ -67,18 +63,11 @@
settingsUri = getUri(statusCursor, VoicemailStatusQuery.SETTINGS_URI_INDEX);
voicemailAccessUri = getUri(statusCursor, VoicemailStatusQuery.VOICEMAIL_ACCESS_URI_INDEX);
- if (VERSION.SDK_INT >= VERSION_CODES.N_MR1) {
- type =
- getString(
- statusCursor, VoicemailStatusQuery.SOURCE_TYPE_INDEX, TelephonyManager.VVM_TYPE_OMTP);
- phoneAccountComponentName =
- getString(statusCursor, VoicemailStatusQuery.PHONE_ACCOUNT_COMPONENT_NAME, "");
- phoneAccountId = getString(statusCursor, VoicemailStatusQuery.PHONE_ACCOUNT_ID, "");
- } else {
- type = TelephonyManager.VVM_TYPE_OMTP;
- phoneAccountComponentName = "";
- phoneAccountId = "";
- }
+ type = getString(
+ statusCursor, VoicemailStatusQuery.SOURCE_TYPE_INDEX, TelephonyManager.VVM_TYPE_OMTP);
+ phoneAccountComponentName =
+ getString(statusCursor, VoicemailStatusQuery.PHONE_ACCOUNT_COMPONENT_NAME, "");
+ phoneAccountId = getString(statusCursor, VoicemailStatusQuery.PHONE_ACCOUNT_ID, "");
configurationState =
getInt(
@@ -97,7 +86,7 @@
* user. It is much simpler to poll the status on the UI side. The result is injected back to
* the status query result so the handling will be consistent with other voicemail clients.
*/
- if (BuildCompat.isAtLeastO() && sourcePackage.equals(context.getPackageName())) {
+ if (sourcePackage.equals(context.getPackageName())) {
notificationChannelState =
getNotificationChannelStateFormTelephony(context, getPhoneAccountHandle());
} else {
@@ -130,7 +119,6 @@
isAirplaneMode = builder.isAirplaneMode;
}
- @TargetApi(VERSION_CODES.O)
private static int getNotificationChannelStateFormTelephony(
Context context, PhoneAccountHandle phoneAccountHandle) {
TelephonyManager telephonyManager =
diff --git a/java/com/android/dialer/voicemail/listui/error/VoicemailStatusCorruptionHandler.java b/java/com/android/dialer/voicemail/listui/error/VoicemailStatusCorruptionHandler.java
deleted file mode 100644
index 75b21e7..0000000
--- a/java/com/android/dialer/voicemail/listui/error/VoicemailStatusCorruptionHandler.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.dialer.voicemail.listui.error;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.database.Cursor;
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
-import android.provider.VoicemailContract.Status;
-import android.telecom.PhoneAccountHandle;
-import android.telephony.TelephonyManager;
-import com.android.dialer.common.Assert;
-import com.android.dialer.common.LogUtil;
-import com.android.dialer.compat.telephony.TelephonyManagerCompat;
-import com.android.dialer.configprovider.ConfigProviderComponent;
-import com.android.dialer.logging.DialerImpression;
-import com.android.dialer.logging.Logger;
-
-/**
- * This class will detect the corruption in the voicemail status and log it so we can track how many
- * users are affected.
- */
-public class VoicemailStatusCorruptionHandler {
-
- /** Where the check is made so logging can be done. */
- public enum Source {
- Activity,
- Notification
- }
-
- private static final String CONFIG_VVM_STATUS_FIX_DISABLED = "vvm_status_fix_disabled";
-
- public static void maybeFixVoicemailStatus(Context context, Cursor statusCursor, Source source) {
-
- if (ConfigProviderComponent.get(context)
- .getConfigProvider()
- .getBoolean(CONFIG_VVM_STATUS_FIX_DISABLED, false)) {
- return;
- }
-
- if (VERSION.SDK_INT != VERSION_CODES.N_MR1) {
- // This issue is specific to N MR1, it is fixed in future SDK.
- return;
- }
-
- if (statusCursor.getCount() == 0) {
- return;
- }
-
- statusCursor.moveToFirst();
- VoicemailStatus status = new VoicemailStatus(context, statusCursor);
- PhoneAccountHandle phoneAccountHandle =
- new PhoneAccountHandle(
- ComponentName.unflattenFromString(status.phoneAccountComponentName),
- status.phoneAccountId);
-
- TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class);
-
- boolean visualVoicemailEnabled =
- TelephonyManagerCompat.isVisualVoicemailEnabled(telephonyManager, phoneAccountHandle);
- LogUtil.i(
- "VoicemailStatusCorruptionHandler.maybeFixVoicemailStatus",
- "Source="
- + source
- + ", CONFIGURATION_STATE="
- + status.configurationState
- + ", visualVoicemailEnabled="
- + visualVoicemailEnabled);
-
- // If visual voicemail is enabled, the CONFIGURATION_STATE should be either OK, PIN_NOT_SET,
- // or other failure code. CONFIGURATION_STATE_NOT_CONFIGURED means that the client has been
- // shut down improperly (a bug). The client should be reset or the VVM tab will be
- // missing.
- if (Status.CONFIGURATION_STATE_NOT_CONFIGURED == status.configurationState
- && visualVoicemailEnabled) {
- LogUtil.e(
- "VoicemailStatusCorruptionHandler.maybeFixVoicemailStatus",
- "VVM3 voicemail status corrupted");
-
- switch (source) {
- case Activity:
- Logger.get(context)
- .logImpression(
- DialerImpression.Type
- .VOICEMAIL_CONFIGURATION_STATE_CORRUPTION_DETECTED_FROM_ACTIVITY);
- break;
- case Notification:
- Logger.get(context)
- .logImpression(
- DialerImpression.Type
- .VOICEMAIL_CONFIGURATION_STATE_CORRUPTION_DETECTED_FROM_NOTIFICATION);
- break;
- default:
- Assert.fail("this should never happen");
- break;
- }
- // At this point we could attempt to work around the issue by disabling and re-enabling
- // voicemail. Unfortunately this work around is buggy so we'll do nothing for now.
- }
- }
-}
diff --git a/java/com/android/dialer/voicemail/listui/error/Vvm3VoicemailMessageCreator.java b/java/com/android/dialer/voicemail/listui/error/Vvm3VoicemailMessageCreator.java
index 863c586..6106111 100644
--- a/java/com/android/dialer/voicemail/listui/error/Vvm3VoicemailMessageCreator.java
+++ b/java/com/android/dialer/voicemail/listui/error/Vvm3VoicemailMessageCreator.java
@@ -19,14 +19,14 @@
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
-import android.os.Build.VERSION_CODES;
import android.provider.VoicemailContract.Status;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import android.support.annotation.RequiresApi;
import android.view.View;
import android.view.View.OnClickListener;
+
import com.android.contacts.common.util.ContactDisplayUtils;
+import com.android.dialer.R;
import com.android.dialer.logging.DialerImpression;
import com.android.dialer.logging.Logger;
import com.android.dialer.voicemail.listui.error.VoicemailErrorMessage.Action;
@@ -35,7 +35,6 @@
* Create error message from {@link VoicemailStatus} for VVM3 visual voicemail. VVM3 is used only by
* Verizon Wireless.
*/
-@RequiresApi(VERSION_CODES.N_MR1)
public class Vvm3VoicemailMessageCreator {
// Copied from com.android.phone.vvm.omtp.protocol.Vvm3EventHandler
diff --git a/java/com/android/dialer/voicemail/settings/VoicemailChangePinActivity.java b/java/com/android/dialer/voicemail/settings/VoicemailChangePinActivity.java
index ebebdf7..5952e4f 100644
--- a/java/com/android/dialer/voicemail/settings/VoicemailChangePinActivity.java
+++ b/java/com/android/dialer/voicemail/settings/VoicemailChangePinActivity.java
@@ -16,14 +16,12 @@
package com.android.dialer.voicemail.settings;
-import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
-import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -44,6 +42,8 @@
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import android.widget.Toast;
+
+import com.android.dialer.R;
import com.android.dialer.common.LogUtil;
import com.android.dialer.common.concurrent.DialerExecutor;
import com.android.dialer.common.concurrent.DialerExecutor.Worker;
@@ -62,7 +62,6 @@
* traditional voicemail through phone call. The intent to launch this activity must contain {@link
* VoicemailClient#PARAM_PHONE_ACCOUNT_HANDLE}
*/
-@TargetApi(VERSION_CODES.O)
public class VoicemailChangePinActivity extends Activity
implements OnClickListener, OnEditorActionListener, TextWatcher {
diff --git a/java/com/android/dialer/voicemail/settings/VoicemailSettingsFragment.java b/java/com/android/dialer/voicemail/settings/VoicemailSettingsFragment.java
index 1eb831f..00b5901 100644
--- a/java/com/android/dialer/voicemail/settings/VoicemailSettingsFragment.java
+++ b/java/com/android/dialer/voicemail/settings/VoicemailSettingsFragment.java
@@ -13,11 +13,9 @@
*/
package com.android.dialer.voicemail.settings;
-import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
-import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
@@ -33,6 +31,8 @@
import android.telecom.TelecomManager;
import android.telephony.SubscriptionInfo;
import android.telephony.TelephonyManager;
+
+import com.android.dialer.R;
import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
import com.android.dialer.common.preference.SwitchPreferenceWithClickableSummary;
@@ -53,7 +53,6 @@
* Fragment for voicemail settings. Requires {@link VoicemailClient#PARAM_PHONE_ACCOUNT_HANDLE} set
* in arguments.
*/
-@TargetApi(VERSION_CODES.O)
public class VoicemailSettingsFragment extends PreferenceFragment
implements Preference.OnPreferenceChangeListener, ActivationStateListener {
diff --git a/java/com/android/dialer/voicemailstatus/VoicemailStatusQuery.java b/java/com/android/dialer/voicemailstatus/VoicemailStatusQuery.java
index 7264afe..20b073d 100644
--- a/java/com/android/dialer/voicemailstatus/VoicemailStatusQuery.java
+++ b/java/com/android/dialer/voicemailstatus/VoicemailStatusQuery.java
@@ -16,13 +16,7 @@
package com.android.dialer.voicemailstatus;
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
import android.provider.VoicemailContract.Status;
-import android.support.annotation.RequiresApi;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
/** The query for the call voicemail status table. */
public class VoicemailStatusQuery {
@@ -36,19 +30,11 @@
public static final int NOTIFICATION_CHANNEL_STATE_INDEX = 5;
public static final int QUOTA_OCCUPIED_INDEX = 6;
public static final int QUOTA_TOTAL_INDEX = 7;
-
- @RequiresApi(VERSION_CODES.N_MR1)
- // The PHONE_ACCOUNT columns were added in M, but aren't queryable until N MR1
public static final int PHONE_ACCOUNT_COMPONENT_NAME = 8;
-
- @RequiresApi(VERSION_CODES.N_MR1)
public static final int PHONE_ACCOUNT_ID = 9;
-
- @RequiresApi(VERSION_CODES.N_MR1)
public static final int SOURCE_TYPE_INDEX = 10;
- @RequiresApi(VERSION_CODES.N)
- private static final String[] PROJECTION_N =
+ private static final String[] PROJECTION =
new String[] {
Status.SOURCE_PACKAGE, // 0
Status.SETTINGS_URI, // 1
@@ -57,21 +43,14 @@
Status.DATA_CHANNEL_STATE, // 4
Status.NOTIFICATION_CHANNEL_STATE, // 5
Status.QUOTA_OCCUPIED, // 6
- Status.QUOTA_TOTAL // 7
+ Status.QUOTA_TOTAL, // 7
+ Status.PHONE_ACCOUNT_COMPONENT_NAME, // 8
+ Status.PHONE_ACCOUNT_ID, // 9
+ Status.SOURCE_TYPE // 10
};
- @RequiresApi(VERSION_CODES.N_MR1)
- private static final String[] PROJECTION_NMR1;
-
- static {
- List<String> projectionList = new ArrayList<>(Arrays.asList(PROJECTION_N));
- projectionList.add(Status.PHONE_ACCOUNT_COMPONENT_NAME); // 8
- projectionList.add(Status.PHONE_ACCOUNT_ID); // 9
- projectionList.add(Status.SOURCE_TYPE); // 10
- PROJECTION_NMR1 = projectionList.toArray(new String[projectionList.size()]);
- }
public static String[] getProjection() {
- return VERSION.SDK_INT >= VERSION_CODES.N_MR1 ? PROJECTION_NMR1 : PROJECTION_N;
+ return PROJECTION;
}
}
diff --git a/java/com/android/incallui/ExternalCallNotifier.java b/java/com/android/incallui/ExternalCallNotifier.java
index 160e250..53a43a8 100644
--- a/java/com/android/incallui/ExternalCallNotifier.java
+++ b/java/com/android/incallui/ExternalCallNotifier.java
@@ -16,7 +16,6 @@
package com.android.incallui;
-import android.annotation.TargetApi;
import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
@@ -25,10 +24,8 @@
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
-import android.os.Build.VERSION_CODES;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import android.support.v4.os.BuildCompat;
import android.telecom.Call;
import android.telecom.PhoneAccount;
import android.telecom.VideoProfile;
@@ -38,6 +35,7 @@
import android.util.ArrayMap;
import com.android.contacts.common.ContactsUtils;
import com.android.contacts.common.compat.CallCompat;
+import com.android.dialer.R;
import com.android.dialer.common.Assert;
import com.android.dialer.contactphoto.BitmapUtil;
import com.android.dialer.contacts.ContactsComponent;
@@ -128,7 +126,6 @@
* @param notificationId The notification ID associated with the external call which is to be
* pulled.
*/
- @TargetApi(VERSION_CODES.N_MR1)
public void pullExternalCall(int notificationId) {
for (NotificationInfo info : notifications.values()) {
if (info.getNotificationId() == notificationId
@@ -239,9 +236,7 @@
builder.setLargeIcon(info.getLargeIcon());
builder.setColor(ThemeComponent.get(context).theme().getColorPrimary());
builder.addPerson(info.getPersonReference());
- if (BuildCompat.isAtLeastO()) {
- builder.setChannelId(NotificationChannelId.DEFAULT);
- }
+ builder.setChannelId(NotificationChannelId.DEFAULT);
// Where the external call supports being transferred to the local device, add an action
// to the notification to initiate the call pull process.
@@ -274,9 +269,7 @@
Notification.Builder publicBuilder = new Notification.Builder(context);
publicBuilder.setSmallIcon(R.drawable.quantum_ic_call_white_24);
publicBuilder.setColor(ThemeComponent.get(context).theme().getColorPrimary());
- if (BuildCompat.isAtLeastO()) {
- publicBuilder.setChannelId(NotificationChannelId.DEFAULT);
- }
+ publicBuilder.setChannelId(NotificationChannelId.DEFAULT);
builder.setPublicVersion(publicBuilder.build());
Notification notification = builder.build();
@@ -451,9 +444,7 @@
summary.setGroup(GROUP_KEY);
summary.setGroupSummary(true);
summary.setSmallIcon(R.drawable.quantum_ic_call_white_24);
- if (BuildCompat.isAtLeastO()) {
- summary.setChannelId(NotificationChannelId.DEFAULT);
- }
+ summary.setChannelId(NotificationChannelId.DEFAULT);
DialerNotificationManager.notify(
context, GROUP_SUMMARY_NOTIFICATION_TAG, GROUP_SUMMARY_NOTIFICATION_ID, summary.build());
}
diff --git a/java/com/android/incallui/InCallPresenter.java b/java/com/android/incallui/InCallPresenter.java
index 8881029..67bc2a5 100644
--- a/java/com/android/incallui/InCallPresenter.java
+++ b/java/com/android/incallui/InCallPresenter.java
@@ -20,13 +20,12 @@
import android.content.Intent;
import android.graphics.Point;
import android.os.Bundle;
-import android.os.Handler;
import android.os.Trace;
+import android.provider.BlockedNumberContract;
import android.support.annotation.MainThread;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
-import android.support.v4.os.UserManagerCompat;
import android.telecom.Call.Details;
import android.telecom.CallAudioState;
import android.telecom.DisconnectCause;
@@ -43,20 +42,18 @@
import com.android.contacts.common.compat.CallCompat;
import com.android.dialer.CallConfiguration;
import com.android.dialer.Mode;
+import com.android.dialer.R;
import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler;
import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler.OnCheckBlockedListener;
-import com.android.dialer.blocking.FilteredNumberCompat;
import com.android.dialer.blocking.FilteredNumbersUtil;
import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
import com.android.dialer.common.concurrent.DialerExecutorComponent;
import com.android.dialer.enrichedcall.EnrichedCallComponent;
-import com.android.dialer.location.GeoUtil;
import com.android.dialer.logging.DialerImpression;
import com.android.dialer.logging.InteractionEvent;
import com.android.dialer.logging.Logger;
import com.android.dialer.postcall.PostCall;
-import com.android.dialer.telecom.TelecomCallUtil;
import com.android.dialer.telecom.TelecomUtil;
import com.android.dialer.util.TouchPointManager;
import com.android.incallui.InCallOrientationEventListener.ScreenOrientation;
@@ -70,7 +67,6 @@
import com.android.incallui.disconnectdialog.DisconnectMessage;
import com.android.incallui.incalluilock.InCallUiLock;
import com.android.incallui.latencyreport.LatencyReport;
-import com.android.incallui.legacyblocking.BlockedNumberContentObserver;
import com.android.incallui.spam.SpamCallListListener;
import com.android.incallui.speakeasy.SpeakEasyCallManager;
import com.android.incallui.telecomeventui.InternationalCallOnWifiDialogActivity;
@@ -85,7 +81,6 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.atomic.AtomicBoolean;
/**
* Takes updates from the CallList and notifies the InCallActivity (UI) of the changes. Responsible
@@ -95,11 +90,8 @@
* of a state machine at this point. Consider renaming.
*/
public class InCallPresenter implements CallList.Listener, AudioModeProvider.AudioModeListener {
- private static final String PIXEL2017_SYSTEM_FEATURE =
- "com.google.android.feature.PIXEL_2017_EXPERIENCE";
- private static final String CALL_CONFIGURATION_EXTRA = "call_configuration";
- private static final long BLOCK_QUERY_TIMEOUT_MS = 1000;
+ private static final String CALL_CONFIGURATION_EXTRA = "call_configuration";
private static final Bundle EMPTY_EXTRAS = new Bundle();
@@ -201,7 +193,6 @@
private final PseudoScreenState pseudoScreenState = new PseudoScreenState();
private boolean serviceConnected;
private InCallCameraManager inCallCameraManager;
- private FilteredNumberAsyncQueryHandler filteredQueryHandler;
private CallList.Listener spamCallListListener;
private CallList.Listener activeCallsListener;
/** Whether or not we are currently bound and waiting for Telecom to send us a new call. */
@@ -220,9 +211,9 @@
return;
}
// Check if the number is blocked, to silence the ringer.
- String countryIso = GeoUtil.getCurrentCountryIso(context);
- filteredQueryHandler.isBlockedNumber(
- onCheckBlockedListener, incomingNumber, countryIso);
+ if (BlockedNumberContract.isBlocked(context, incomingNumber)) {
+ TelecomUtil.silenceRinger(context);
+ }
}
}
};
@@ -342,7 +333,6 @@
ExternalCallNotifier externalCallNotifier,
ContactInfoCache contactInfoCache,
ProximitySensor proximitySensor,
- FilteredNumberAsyncQueryHandler filteredNumberQueryHandler,
@NonNull SpeakEasyCallManager speakEasyCallManager) {
Trace.beginSection("InCallPresenter.setUp");
if (serviceConnected) {
@@ -401,7 +391,6 @@
VideoPauseController.getInstance().setUp(this);
- filteredQueryHandler = filteredNumberQueryHandler;
this.speakEasyCallManager = speakEasyCallManager;
this.context
.getSystemService(TelephonyManager.class)
@@ -629,15 +618,11 @@
public void onCallAdded(final android.telecom.Call call) {
Trace.beginSection("InCallPresenter.onCallAdded");
LatencyReport latencyReport = new LatencyReport(call);
- if (shouldAttemptBlocking(call)) {
- maybeBlockCall(call, latencyReport);
+ if (call.getDetails().hasProperty(CallCompat.Details.PROPERTY_IS_EXTERNAL_CALL)) {
+ externalCallList.onCallAdded(call);
} else {
- if (call.getDetails().hasProperty(CallCompat.Details.PROPERTY_IS_EXTERNAL_CALL)) {
- externalCallList.onCallAdded(call);
- } else {
- latencyReport.onCallBlockingDone();
- callList.onCallAdded(context, call, latencyReport);
- }
+ latencyReport.onCallBlockingDone();
+ callList.onCallAdded(context, call, latencyReport);
}
// Since a call has been added we are no longer waiting for Telecom to send us a call.
@@ -648,121 +633,6 @@
Trace.endSection();
}
- private boolean shouldAttemptBlocking(android.telecom.Call call) {
- if (call.getState() != android.telecom.Call.STATE_RINGING) {
- return false;
- }
- if (!UserManagerCompat.isUserUnlocked(context)) {
- LogUtil.i(
- "InCallPresenter.shouldAttemptBlocking",
- "not attempting to block incoming call because user is locked");
- return false;
- }
- if (TelecomCallUtil.isEmergencyCall(call)) {
- LogUtil.i(
- "InCallPresenter.shouldAttemptBlocking",
- "Not attempting to block incoming emergency call");
- return false;
- }
- if (FilteredNumbersUtil.hasRecentEmergencyCall(context)) {
- LogUtil.i(
- "InCallPresenter.shouldAttemptBlocking",
- "Not attempting to block incoming call due to recent emergency call");
- return false;
- }
- if (call.getDetails().hasProperty(CallCompat.Details.PROPERTY_IS_EXTERNAL_CALL)) {
- return false;
- }
- if (FilteredNumberCompat.useNewFiltering(context)) {
- LogUtil.i(
- "InCallPresenter.shouldAttemptBlocking",
- "not attempting to block incoming call because framework blocking is in use");
- return false;
- }
- return true;
- }
-
- /**
- * Checks whether a call should be blocked, and blocks it if so. Otherwise, it adds the call to
- * the CallList so it can proceed as normal. There is a timeout, so if the function for checking
- * whether a function is blocked does not return in a reasonable time, we proceed with adding the
- * call anyways.
- */
- private void maybeBlockCall(final android.telecom.Call call, final LatencyReport latencyReport) {
- final String countryIso = GeoUtil.getCurrentCountryIso(context);
- final String number = TelecomCallUtil.getNumber(call);
- final long timeAdded = System.currentTimeMillis();
-
- // Though AtomicBoolean's can be scary, don't fear, as in this case it is only used on the
- // main UI thread. It is needed so we can change its value within different scopes, since
- // that cannot be done with a final boolean.
- final AtomicBoolean hasTimedOut = new AtomicBoolean(false);
-
- final Handler handler = new Handler();
-
- // Proceed if the query is slow; the call may still be blocked after the query returns.
- final Runnable runnable =
- new Runnable() {
- @Override
- public void run() {
- hasTimedOut.set(true);
- latencyReport.onCallBlockingDone();
- callList.onCallAdded(context, call, latencyReport);
- }
- };
- handler.postDelayed(runnable, BLOCK_QUERY_TIMEOUT_MS);
-
- OnCheckBlockedListener onCheckBlockedListener =
- new OnCheckBlockedListener() {
- @Override
- public void onCheckComplete(final Integer id) {
- if (isReadyForTearDown()) {
- LogUtil.i("InCallPresenter.onCheckComplete", "torn down, not adding call");
- return;
- }
- if (!hasTimedOut.get()) {
- handler.removeCallbacks(runnable);
- }
- if (id == null) {
- if (!hasTimedOut.get()) {
- latencyReport.onCallBlockingDone();
- callList.onCallAdded(context, call, latencyReport);
- }
- } else if (id == FilteredNumberAsyncQueryHandler.INVALID_ID) {
- LogUtil.d(
- "InCallPresenter.onCheckComplete", "invalid number, skipping block checking");
- if (!hasTimedOut.get()) {
- handler.removeCallbacks(runnable);
-
- latencyReport.onCallBlockingDone();
- callList.onCallAdded(context, call, latencyReport);
- }
- } else {
- LogUtil.i(
- "InCallPresenter.onCheckComplete", "Rejecting incoming call from blocked number");
- call.reject(false, null);
- Logger.get(context).logInteraction(InteractionEvent.Type.CALL_BLOCKED);
-
- /*
- * If mContext is null, then the InCallPresenter was torn down before the
- * block check had a chance to complete. The context is no longer valid, so
- * don't attempt to remove the call log entry.
- */
- if (context == null) {
- return;
- }
- // Register observer to update the call log.
- // BlockedNumberContentObserver will unregister after successful log or timeout.
- BlockedNumberContentObserver contentObserver =
- new BlockedNumberContentObserver(context, new Handler(), number, timeAdded);
- contentObserver.register();
- }
- }
- };
-
- filteredQueryHandler.isBlockedNumber(onCheckBlockedListener, number, countryIso);
- }
-
public void onCallRemoved(android.telecom.Call call) {
if (call.getDetails().hasProperty(CallCompat.Details.PROPERTY_IS_EXTERNAL_CALL)) {
externalCallList.onCallRemoved(call);
@@ -1892,22 +1762,14 @@
VideoSurfaceTexture getLocalVideoSurfaceTexture() {
if (localVideoSurfaceTexture == null) {
- boolean isPixel2017 = false;
- if (context != null) {
- isPixel2017 = context.getPackageManager().hasSystemFeature(PIXEL2017_SYSTEM_FEATURE);
- }
- localVideoSurfaceTexture = VideoSurfaceBindings.createLocalVideoSurfaceTexture(isPixel2017);
+ localVideoSurfaceTexture = VideoSurfaceBindings.createLocalVideoSurfaceTexture();
}
return localVideoSurfaceTexture;
}
VideoSurfaceTexture getRemoteVideoSurfaceTexture() {
if (remoteVideoSurfaceTexture == null) {
- boolean isPixel2017 = false;
- if (context != null) {
- isPixel2017 = context.getPackageManager().hasSystemFeature(PIXEL2017_SYSTEM_FEATURE);
- }
- remoteVideoSurfaceTexture = VideoSurfaceBindings.createRemoteVideoSurfaceTexture(isPixel2017);
+ remoteVideoSurfaceTexture = VideoSurfaceBindings.createRemoteVideoSurfaceTexture();
}
return remoteVideoSurfaceTexture;
}
diff --git a/java/com/android/incallui/InCallServiceImpl.java b/java/com/android/incallui/InCallServiceImpl.java
index b2d318f..b225d53 100644
--- a/java/com/android/incallui/InCallServiceImpl.java
+++ b/java/com/android/incallui/InCallServiceImpl.java
@@ -108,7 +108,6 @@
contactInfoCache,
new ProximitySensor(
context, AudioModeProvider.getInstance(), new AccelerometerListener(context)),
- new FilteredNumberAsyncQueryHandler(context),
speakEasyCallManager);
InCallPresenter.getInstance().onServiceBind();
InCallPresenter.getInstance().maybeStartRevealAnimation(intent);
diff --git a/java/com/android/incallui/NotificationBroadcastReceiver.java b/java/com/android/incallui/NotificationBroadcastReceiver.java
index 91421ea..5051231 100644
--- a/java/com/android/incallui/NotificationBroadcastReceiver.java
+++ b/java/com/android/incallui/NotificationBroadcastReceiver.java
@@ -20,10 +20,8 @@
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
-import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.support.annotation.NonNull;
-import android.support.annotation.RequiresApi;
import android.telecom.CallAudioState;
import android.telecom.VideoProfile;
@@ -70,7 +68,6 @@
public static final String ACTION_ANSWER_SPEAKEASY_CALL =
"com.android.incallui.ACTION_ANSWER_SPEAKEASY_CALL";
- @RequiresApi(VERSION_CODES.N_MR1)
public static final String ACTION_PULL_EXTERNAL_CALL =
"com.android.incallui.ACTION_PULL_EXTERNAL_CALL";
diff --git a/java/com/android/incallui/RttCallPresenter.java b/java/com/android/incallui/RttCallPresenter.java
index 2114691..4726cd3 100644
--- a/java/com/android/incallui/RttCallPresenter.java
+++ b/java/com/android/incallui/RttCallPresenter.java
@@ -16,7 +16,6 @@
package com.android.incallui;
-import android.annotation.TargetApi;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
@@ -36,7 +35,6 @@
* Logic related to the {@link RttCallScreen} and for managing changes to the RTT calling surfaces
* based on other user interface events and incoming events.
*/
-@TargetApi(28)
public class RttCallPresenter implements RttCallScreenDelegate, InCallStateListener {
private RttCallScreen rttCallScreen;
diff --git a/java/com/android/incallui/StatusBarNotifier.java b/java/com/android/incallui/StatusBarNotifier.java
index 3942851..ed4109e 100644
--- a/java/com/android/incallui/StatusBarNotifier.java
+++ b/java/com/android/incallui/StatusBarNotifier.java
@@ -44,8 +44,6 @@
import android.graphics.drawable.Icon;
import android.media.AudioAttributes;
import android.net.Uri;
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
import android.os.Trace;
import android.support.annotation.ColorRes;
import android.support.annotation.NonNull;
@@ -53,7 +51,6 @@
import android.support.annotation.RequiresPermission;
import android.support.annotation.StringRes;
import android.support.annotation.VisibleForTesting;
-import android.support.v4.os.BuildCompat;
import android.telecom.Call.Details;
import android.telecom.CallAudioState;
import android.telecom.PhoneAccount;
@@ -68,6 +65,7 @@
import android.text.style.ForegroundColorSpan;
import com.android.contacts.common.ContactsUtils;
import com.android.contacts.common.ContactsUtils.UserType;
+import com.android.dialer.R;
import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
import com.android.dialer.configprovider.ConfigProviderComponent;
@@ -356,9 +354,7 @@
LogUtil.i("StatusBarNotifier.buildAndSendNotification", "notificationType=" + notificationType);
switch (notificationType) {
case NOTIFICATION_INCOMING_CALL:
- if (BuildCompat.isAtLeastO()) {
- builder.setChannelId(NotificationChannelId.INCOMING_CALL);
- }
+ builder.setChannelId(NotificationChannelId.INCOMING_CALL);
// Set the intent as a full screen intent as well if a call is incoming
configureFullScreenIntent(builder, createLaunchPendingIntent(true /* isFullScreen */));
// Set the notification category and bump the priority for incoming calls
@@ -375,16 +371,12 @@
}
break;
case NOTIFICATION_INCOMING_CALL_QUIET:
- if (BuildCompat.isAtLeastO()) {
- builder.setChannelId(NotificationChannelId.ONGOING_CALL);
- }
+ builder.setChannelId(NotificationChannelId.ONGOING_CALL);
break;
case NOTIFICATION_IN_CALL:
- if (BuildCompat.isAtLeastO()) {
- publicBuilder.setColorized(true);
- builder.setColorized(true);
- builder.setChannelId(NotificationChannelId.ONGOING_CALL);
- }
+ publicBuilder.setColorized(true);
+ builder.setColorized(true);
+ builder.setChannelId(NotificationChannelId.ONGOING_CALL);
break;
default:
break;
@@ -874,13 +866,11 @@
private Spannable getActionText(@StringRes int stringRes, @ColorRes int colorRes) {
Spannable spannable = new SpannableString(context.getText(stringRes));
- if (VERSION.SDK_INT >= VERSION_CODES.N_MR1) {
- // This will only work for cases where the Notification.Builder has a fullscreen intent set
- // Notification.Builder that does not have a full screen intent will take the color of the
- // app and the following leads to a no-op.
- spannable.setSpan(
- new ForegroundColorSpan(context.getColor(colorRes)), 0, spannable.length(), 0);
- }
+ // This will only work for cases where the Notification.Builder has a fullscreen intent set
+ // Notification.Builder that does not have a full screen intent will take the color of the
+ // app and the following leads to a no-op.
+ spannable.setSpan(
+ new ForegroundColorSpan(context.getColor(colorRes)), 0, spannable.length(), 0);
return spannable;
}
diff --git a/java/com/android/incallui/answer/impl/AnswerFragment.java b/java/com/android/incallui/answer/impl/AnswerFragment.java
index 2405b8e..395faa7 100644
--- a/java/com/android/incallui/answer/impl/AnswerFragment.java
+++ b/java/com/android/incallui/answer/impl/AnswerFragment.java
@@ -22,15 +22,12 @@
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
-import android.annotation.TargetApi;
import android.app.KeyguardManager;
import android.app.KeyguardManager.KeyguardDismissCallback;
import android.content.Context;
import android.content.pm.PackageManager;
import android.location.Location;
import android.net.Uri;
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@@ -55,6 +52,8 @@
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
import android.widget.ImageView;
import android.widget.LinearLayout;
+
+import com.android.dialer.R;
import com.android.dialer.common.Assert;
import com.android.dialer.common.FragmentUtils;
import com.android.dialer.common.LogUtil;
@@ -1057,17 +1056,11 @@
}
@Override
- @TargetApi(VERSION_CODES.O)
public void smsSelected(@Nullable CharSequence text) {
LogUtil.i("AnswerFragment.smsSelected", null);
textResponsesFragment = null;
if (text == null) {
- if (VERSION.SDK_INT < VERSION_CODES.O) {
- LogUtil.i("AnswerFragment.smsSelected", "below O, showing dialog directly");
- showCustomSmsDialog();
- return;
- }
if (!getContext().getSystemService(KeyguardManager.class).isKeyguardLocked()) {
LogUtil.i("AnswerFragment.smsSelected", "not locked, showing dialog directly");
showCustomSmsDialog();
diff --git a/java/com/android/incallui/audioroute/AudioRouteSelectorDialogFragment.java b/java/com/android/incallui/audioroute/AudioRouteSelectorDialogFragment.java
index 846834f..68aa2c1 100644
--- a/java/com/android/incallui/audioroute/AudioRouteSelectorDialogFragment.java
+++ b/java/com/android/incallui/audioroute/AudioRouteSelectorDialogFragment.java
@@ -27,7 +27,6 @@
import android.provider.Settings;
import android.support.annotation.Nullable;
import android.support.design.widget.BottomSheetDialogFragment;
-import android.support.v4.os.BuildCompat;
import android.telecom.CallAudioState;
import android.view.LayoutInflater;
import android.view.View;
@@ -35,6 +34,8 @@
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.TextView;
+
+import com.android.dialer.R;
import com.android.dialer.common.FragmentUtils;
import com.android.dialer.common.LogUtil;
import com.android.dialer.logging.DialerImpression;
@@ -82,10 +83,7 @@
if (Settings.canDrawOverlays(getContext())) {
dialog
.getWindow()
- .setType(
- BuildCompat.isAtLeastO()
- ? WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
- : WindowManager.LayoutParams.TYPE_PHONE);
+ .setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
}
return dialog;
}
@@ -98,27 +96,14 @@
View view = layoutInflater.inflate(R.layout.audioroute_selector, viewGroup, false);
CallAudioState audioState = getArguments().getParcelable(ARG_AUDIO_STATE);
- if (BuildCompat.isAtLeastP()) {
- // Create items for all connected Bluetooth devices
- Collection<BluetoothDevice> bluetoothDeviceSet = audioState.getSupportedBluetoothDevices();
- for (BluetoothDevice device : bluetoothDeviceSet) {
- boolean selected =
- (audioState.getRoute() == CallAudioState.ROUTE_BLUETOOTH)
- && (bluetoothDeviceSet.size() == 1
- || device.equals(audioState.getActiveBluetoothDevice()));
- TextView textView = createBluetoothItem(device, selected);
- ((LinearLayout) view).addView(textView, 0);
- }
- } else {
- // Only create Bluetooth audio route
- TextView textView =
- (TextView) getLayoutInflater().inflate(R.layout.audioroute_item, null, false);
- textView.setText(getString(R.string.audioroute_bluetooth));
- initItem(
- textView,
- CallAudioState.ROUTE_BLUETOOTH,
- audioState,
- DialerImpression.Type.IN_CALL_SWITCH_AUDIO_ROUTE_BLUETOOTH);
+ // Create items for all connected Bluetooth devices
+ Collection<BluetoothDevice> bluetoothDeviceSet = audioState.getSupportedBluetoothDevices();
+ for (BluetoothDevice device : bluetoothDeviceSet) {
+ boolean selected =
+ (audioState.getRoute() == CallAudioState.ROUTE_BLUETOOTH)
+ && (bluetoothDeviceSet.size() == 1
+ || device.equals(audioState.getActiveBluetoothDevice()));
+ TextView textView = createBluetoothItem(device, selected);
((LinearLayout) view).addView(textView, 0);
}
diff --git a/java/com/android/incallui/call/DialerCall.java b/java/com/android/incallui/call/DialerCall.java
index b028946..a8a62f7 100644
--- a/java/com/android/incallui/call/DialerCall.java
+++ b/java/com/android/incallui/call/DialerCall.java
@@ -18,13 +18,9 @@
import android.Manifest.permission;
import android.annotation.SuppressLint;
-import android.annotation.TargetApi;
import android.content.Context;
import android.hardware.camera2.CameraCharacteristics;
import android.net.Uri;
-import android.os.Build;
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.os.SystemClock;
@@ -33,7 +29,6 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
-import android.support.v4.os.BuildCompat;
import android.telecom.Call;
import android.telecom.Call.Details;
import android.telecom.Call.RttCall;
@@ -377,11 +372,8 @@
isMergeInProcess = false;
break;
case TelephonyManagerCompat.EVENT_CALL_FORWARDED:
- // Only handle this event for P+ since it's unreliable pre-P.
- if (BuildCompat.isAtLeastP()) {
- isCallForwarded = true;
- update();
- }
+ isCallForwarded = true;
+ update();
break;
default:
break;
@@ -663,9 +655,6 @@
if (!PermissionsUtil.hasPermission(context, permission.READ_PHONE_STATE)) {
return;
}
- if (VERSION.SDK_INT < VERSION_CODES.O) {
- return;
- }
// TODO(a bug): This may take several seconds to complete, revisit it to move it to worker
// thread.
carrierConfig =
@@ -827,12 +816,6 @@
return true;
}
- // Call.EXTRA_LAST_EMERGENCY_CALLBACK_TIME_MILLIS is available starting in O
- if (VERSION.SDK_INT < VERSION_CODES.O) {
- long timestampMillis = FilteredNumbersUtil.getLastEmergencyCallTimeMillis(context);
- return isInEmergencyCallbackWindow(timestampMillis);
- }
-
// We want to treat any incoming call that arrives a short time after an outgoing emergency call
// as a potential emergency callback.
if (getExtras() != null
@@ -989,7 +972,6 @@
}
/** Checks if the call supports the given set of capabilities supplied as a bit mask. */
- @TargetApi(28)
public boolean can(int capabilities) {
int supportedCapabilities = telecomCall.getDetails().getCallCapabilities();
@@ -998,7 +980,7 @@
// RTT call is not conferenceable, it's a bug (a bug) in Telecom and we work around it
// here before it's fixed in Telecom.
for (Call call : telecomCall.getConferenceableCalls()) {
- if (!(BuildCompat.isAtLeastP() && call.isRttActive())) {
+ if (!call.isRttActive()) {
hasConferenceableCall = true;
break;
}
@@ -1034,7 +1016,6 @@
* the same time that is logged as the start time in the Call Log (see {@link
* android.provider.CallLog.Calls#DATE}).
*/
- @TargetApi(VERSION_CODES.O)
public long getCreationTimeMillis() {
return telecomCall.getDetails().getCreationTimeMillis();
}
@@ -1078,16 +1059,10 @@
return getVideoTech().isTransmittingOrReceiving() || VideoProfile.isVideo(getVideoState());
}
- @TargetApi(28)
public boolean isActiveRttCall() {
- if (BuildCompat.isAtLeastP()) {
- return getTelecomCall().isRttActive();
- } else {
- return false;
- }
+ return getTelecomCall().isRttActive();
}
- @TargetApi(28)
@Nullable
public RttCall getRttCall() {
if (!isActiveRttCall()) {
@@ -1096,7 +1071,6 @@
return getTelecomCall().getRttCall();
}
- @TargetApi(28)
public boolean isPhoneAccountRttCapable() {
PhoneAccount phoneAccount = getPhoneAccount();
if (phoneAccount == null) {
@@ -1108,7 +1082,6 @@
return true;
}
- @TargetApi(28)
public boolean canUpgradeToRttCall() {
if (!isPhoneAccountRttCapable()) {
return false;
@@ -1128,12 +1101,10 @@
return true;
}
- @TargetApi(28)
public void sendRttUpgradeRequest() {
getTelecomCall().sendRttRequest();
}
- @TargetApi(28)
public void respondToRttRequest(boolean accept, int rttRequestId) {
Logger.get(context)
.logCallImpression(
@@ -1145,11 +1116,7 @@
getTelecomCall().respondToRttRequest(rttRequestId, accept);
}
- @TargetApi(28)
private void saveRttTranscript() {
- if (!BuildCompat.isAtLeastP()) {
- return;
- }
if (getRttCall() != null) {
// Save any remaining text in the buffer that's not shown by UI yet.
// This may happen when the call is switched to background before disconnect.
@@ -1353,19 +1320,6 @@
* @return a boolean indicating assisted dialing may have been performed
*/
public boolean isAssistedDialed() {
- if (getIntentExtras() != null) {
- // P and below uses the existence of USE_ASSISTED_DIALING to indicate assisted dialing
- // was used. The Dialer client is responsible for performing assisted dialing before
- // placing the outgoing call.
- //
- // The existence of the assisted dialing extras indicates that assisted dialing took place.
- if (getIntentExtras().getBoolean(TelephonyManagerCompat.USE_ASSISTED_DIALING, false)
- && getAssistedDialingExtras() != null
- && Build.VERSION.SDK_INT <= ConcreteCreator.BUILD_CODE_CEILING) {
- return true;
- }
- }
-
return false;
}
diff --git a/java/com/android/incallui/call/TelecomAdapter.java b/java/com/android/incallui/call/TelecomAdapter.java
index 4ae1bc1..3070fb2 100644
--- a/java/com/android/incallui/call/TelecomAdapter.java
+++ b/java/com/android/incallui/call/TelecomAdapter.java
@@ -16,7 +16,6 @@
package com.android.incallui.call;
-import android.annotation.TargetApi;
import android.app.Notification;
import android.bluetooth.BluetoothDevice;
import android.content.ActivityNotFoundException;
@@ -196,7 +195,6 @@
}
}
- @TargetApi(28)
public void requestBluetoothAudio(BluetoothDevice bluetoothDevice) {
if (inCallService != null) {
inCallService.requestBluetoothAudio(bluetoothDevice);
diff --git a/java/com/android/incallui/disconnectdialog/VideoCallNotAvailablePrompt.java b/java/com/android/incallui/disconnectdialog/VideoCallNotAvailablePrompt.java
index 099450a..f6af4a1 100644
--- a/java/com/android/incallui/disconnectdialog/VideoCallNotAvailablePrompt.java
+++ b/java/com/android/incallui/disconnectdialog/VideoCallNotAvailablePrompt.java
@@ -23,7 +23,7 @@
import android.telecom.DisconnectCause;
import android.telecom.PhoneAccountHandle;
import android.util.Pair;
-import com.android.contacts.common.compat.telecom.TelecomManagerCompat;
+import com.android.dialer.R;
import com.android.dialer.callintent.CallInitiationType;
import com.android.dialer.callintent.CallIntentBuilder;
import com.android.dialer.common.LogUtil;
@@ -36,7 +36,7 @@
@Override
public boolean shouldShow(DisconnectCause disconnectCause) {
if (disconnectCause.getCode() == DisconnectCause.ERROR
- && TelecomManagerCompat.REASON_IMS_ACCESS_BLOCKED.equals(disconnectCause.getReason())) {
+ && DisconnectCause.REASON_IMS_ACCESS_BLOCKED.equals(disconnectCause.getReason())) {
LogUtil.i(
"VideoCallNotAvailablePrompt.shouldShowPrompt",
"showing prompt for disconnect cause: %s",
diff --git a/java/com/android/incallui/legacyblocking/BlockedNumberContentObserver.java b/java/com/android/incallui/legacyblocking/BlockedNumberContentObserver.java
deleted file mode 100644
index d774fc3..0000000
--- a/java/com/android/incallui/legacyblocking/BlockedNumberContentObserver.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.incallui.legacyblocking;
-
-import android.content.Context;
-import android.database.ContentObserver;
-import android.os.Handler;
-import android.provider.CallLog;
-import android.support.annotation.NonNull;
-import com.android.dialer.common.LogUtil;
-import com.android.dialer.common.concurrent.AsyncTaskExecutor;
-import com.android.dialer.common.concurrent.AsyncTaskExecutors;
-import com.android.dialer.util.PermissionsUtil;
-import java.util.Objects;
-
-/**
- * Observes the {@link CallLog} to delete the CallLog entry for a blocked call after it is added.
- * Automatically de-registers itself {@link #TIMEOUT_MS} ms after registration or if the entry is
- * found and deleted.
- */
-public class BlockedNumberContentObserver extends ContentObserver
- implements DeleteBlockedCallTask.Listener {
-
- /**
- * The time after which a {@link BlockedNumberContentObserver} will be automatically unregistered.
- */
- public static final int TIMEOUT_MS = 5000;
-
- @NonNull private final Context context;
- @NonNull private final Handler handler;
- private final String number;
- private final long timeAddedMillis;
- private final Runnable timeoutRunnable =
- new Runnable() {
- @Override
- public void run() {
- unregister();
- }
- };
-
- private final AsyncTaskExecutor asyncTaskExecutor = AsyncTaskExecutors.createThreadPoolExecutor();
-
- /**
- * Creates the BlockedNumberContentObserver to delete the new {@link CallLog} entry from the given
- * blocked number.
- *
- * @param number The blocked number.
- * @param timeAddedMillis The time at which the call from the blocked number was placed.
- */
- public BlockedNumberContentObserver(
- @NonNull Context context, @NonNull Handler handler, String number, long timeAddedMillis) {
- super(handler);
- this.context = Objects.requireNonNull(context, "context").getApplicationContext();
- this.handler = Objects.requireNonNull(handler);
- this.number = number;
- this.timeAddedMillis = timeAddedMillis;
- }
-
- @Override
- public void onChange(boolean selfChange) {
- LogUtil.i(
- "BlockedNumberContentObserver.onChange",
- "attempting to remove call log entry from blocked number");
- asyncTaskExecutor.submit(
- DeleteBlockedCallTask.IDENTIFIER,
- new DeleteBlockedCallTask(context, this, number, timeAddedMillis));
- }
-
- @Override
- public void onDeleteBlockedCallTaskComplete(boolean didFindEntry) {
- if (didFindEntry) {
- unregister();
- }
- }
-
- /**
- * Registers this {@link ContentObserver} to listen for changes to the {@link CallLog}. If the
- * CallLog entry is not found before {@link #TIMEOUT_MS}, this ContentObserver automatically
- * un-registers itself.
- */
- public void register() {
- LogUtil.i("BlockedNumberContentObserver.register", null);
- if (PermissionsUtil.hasCallLogReadPermissions(context)
- && PermissionsUtil.hasCallLogWritePermissions(context)) {
- context.getContentResolver().registerContentObserver(CallLog.CONTENT_URI, true, this);
- handler.postDelayed(timeoutRunnable, TIMEOUT_MS);
- } else {
- LogUtil.w("BlockedNumberContentObserver.register", "no call log read/write permissions.");
- }
- }
-
- private void unregister() {
- LogUtil.i("BlockedNumberContentObserver.unregister", null);
- handler.removeCallbacks(timeoutRunnable);
- context.getContentResolver().unregisterContentObserver(this);
- }
-}
diff --git a/java/com/android/incallui/legacyblocking/DeleteBlockedCallTask.java b/java/com/android/incallui/legacyblocking/DeleteBlockedCallTask.java
deleted file mode 100644
index 309e994..0000000
--- a/java/com/android/incallui/legacyblocking/DeleteBlockedCallTask.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.incallui.legacyblocking;
-
-import android.Manifest.permission;
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.database.Cursor;
-import android.os.AsyncTask;
-import android.provider.CallLog;
-import android.support.v4.content.ContextCompat;
-import com.android.dialer.common.LogUtil;
-import com.android.dialer.telecom.TelecomUtil;
-import java.util.Objects;
-
-/**
- * Deletes a blocked call from the call log. This is only used on Android Marshmallow. On later
- * versions of the OS, call blocking is implemented in the system and there's no need to mess with
- * the call log.
- */
-public class DeleteBlockedCallTask extends AsyncTask<Void, Void, Long> {
-
- public static final String IDENTIFIER = "DeleteBlockedCallTask";
-
- // Try to identify if a call log entry corresponds to a number which was blocked. We match by
- // by comparing its creation time to the time it was added in the InCallUi and seeing if they
- // fall within a certain threshold.
- private static final int MATCH_BLOCKED_CALL_THRESHOLD_MS = 3000;
-
- private final Context context;
- private final Listener listener;
- private final String number;
- private final long timeAddedMillis;
-
- /**
- * Creates the task to delete the new {@link CallLog} entry from the given blocked number.
- *
- * @param number The blocked number.
- * @param timeAddedMillis The time at which the call from the blocked number was placed.
- */
- public DeleteBlockedCallTask(
- Context context, Listener listener, String number, long timeAddedMillis) {
- this.context = Objects.requireNonNull(context);
- this.listener = Objects.requireNonNull(listener);
- this.number = number;
- this.timeAddedMillis = timeAddedMillis;
- }
-
- @Override
- public Long doInBackground(Void... params) {
- if (ContextCompat.checkSelfPermission(context, permission.READ_CALL_LOG)
- != PackageManager.PERMISSION_GRANTED
- || ContextCompat.checkSelfPermission(context, permission.WRITE_CALL_LOG)
- != PackageManager.PERMISSION_GRANTED) {
- LogUtil.i("DeleteBlockedCallTask.doInBackground", "missing call log permissions");
- return -1L;
- }
-
- // First, lookup the call log entry of the most recent call with this number.
- try (Cursor cursor =
- context
- .getContentResolver()
- .query(
- TelecomUtil.getCallLogUri(context),
- CallLogDeleteBlockedCallQuery.PROJECTION,
- CallLog.Calls.NUMBER + "= ?",
- new String[] {number},
- CallLog.Calls.DATE + " DESC LIMIT 1")) {
-
- // If match is found, delete this call log entry and return the call log entry id.
- if (cursor != null && cursor.moveToFirst()) {
- long creationTime = cursor.getLong(CallLogDeleteBlockedCallQuery.DATE_COLUMN_INDEX);
- if (timeAddedMillis > creationTime
- && timeAddedMillis - creationTime < MATCH_BLOCKED_CALL_THRESHOLD_MS) {
- long callLogEntryId = cursor.getLong(CallLogDeleteBlockedCallQuery.ID_COLUMN_INDEX);
- context
- .getContentResolver()
- .delete(
- TelecomUtil.getCallLogUri(context),
- CallLog.Calls._ID + " IN (" + callLogEntryId + ")",
- null);
- return callLogEntryId;
- }
- }
- }
- return -1L;
- }
-
- @Override
- public void onPostExecute(Long callLogEntryId) {
- listener.onDeleteBlockedCallTaskComplete(callLogEntryId >= 0);
- }
-
- /** Callback invoked when delete is complete. */
- public interface Listener {
-
- void onDeleteBlockedCallTaskComplete(boolean didFindEntry);
- }
-
- private static class CallLogDeleteBlockedCallQuery {
-
- static final String[] PROJECTION = new String[] {CallLog.Calls._ID, CallLog.Calls.DATE};
-
- static final int ID_COLUMN_INDEX = 0;
- static final int DATE_COLUMN_INDEX = 1;
- }
-}
diff --git a/java/com/android/incallui/spam/SpamCallListListener.java b/java/com/android/incallui/spam/SpamCallListListener.java
index 7fd41f9..bf48d8b 100644
--- a/java/com/android/incallui/spam/SpamCallListListener.java
+++ b/java/com/android/incallui/spam/SpamCallListListener.java
@@ -28,11 +28,11 @@
import android.provider.CallLog.Calls;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import android.support.v4.os.BuildCompat;
import android.telecom.DisconnectCause;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
-import com.android.dialer.blocking.FilteredNumberCompat;
+
+import com.android.dialer.R;
import com.android.dialer.blocking.FilteredNumbersUtil;
import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
@@ -182,8 +182,7 @@
String e164Number =
PhoneNumberUtils.formatNumberToE164(
call.getNumber(), GeoUtil.getCurrentCountryIso(context));
- if (!FilteredNumbersUtil.canBlockNumber(context, e164Number, call.getNumber())
- || !FilteredNumberCompat.canAttemptBlockOperations(context)) {
+ if (!FilteredNumbersUtil.canBlockNumber(context, e164Number, call.getNumber())) {
return;
}
if (e164Number == null) {
@@ -256,10 +255,8 @@
.setPriority(Notification.PRIORITY_DEFAULT)
.setColor(ThemeComponent.get(context).theme().getColorPrimary())
.setSmallIcon(R.drawable.quantum_ic_call_end_vd_theme_24)
- .setGroup(GROUP_KEY);
- if (BuildCompat.isAtLeastO()) {
- builder.setChannelId(NotificationChannelId.DEFAULT);
- }
+ .setGroup(GROUP_KEY)
+ .setChannelId(NotificationChannelId.DEFAULT);
return builder;
}
diff --git a/java/com/android/incallui/spam/SpamNotificationActivity.java b/java/com/android/incallui/spam/SpamNotificationActivity.java
index 4c0c67c..0299dc3 100644
--- a/java/com/android/incallui/spam/SpamNotificationActivity.java
+++ b/java/com/android/incallui/spam/SpamNotificationActivity.java
@@ -28,9 +28,9 @@
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.AlertDialog;
import android.telephony.PhoneNumberUtils;
-import com.android.dialer.blocking.BlockedNumbersMigrator;
+
+import com.android.dialer.R;
import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler;
-import com.android.dialer.blocking.FilteredNumberCompat;
import com.android.dialer.blockreportspam.BlockReportSpamDialogs;
import com.android.dialer.blockreportspam.BlockReportSpamDialogs.DialogFragmentForBlockingNumberAndOptionallyReportingAsSpam;
import com.android.dialer.blockreportspam.BlockReportSpamDialogs.DialogFragmentForReportingNotSpam;
@@ -241,27 +241,21 @@
final String number, final ContactLookupResult.Type contactLookupResultType) {
if (SpamComponent.get(this).spamSettings().isDialogEnabledForSpamNotification()) {
String displayNumber = getFormattedNumber(number, this);
- maybeShowBlockNumberMigrationDialog(
- new BlockedNumbersMigrator.Listener() {
- @Override
- public void onComplete() {
- DialogFragmentForBlockingNumberAndOptionallyReportingAsSpam.newInstance(
- displayNumber,
- SpamComponent.get(SpamNotificationActivity.this)
- .spamSettings()
- .isDialogReportSpamCheckedByDefault(),
- new BlockReportSpamDialogs.OnSpamDialogClickListener() {
- @Override
- public void onClick(boolean isSpamChecked) {
- blockReportNumber(number, isSpamChecked, contactLookupResultType);
- }
- },
- dismissListener)
- .show(
- getSupportFragmentManager(),
- BlockReportSpamDialogs.BLOCK_REPORT_SPAM_DIALOG_TAG);
- }
- });
+ DialogFragmentForBlockingNumberAndOptionallyReportingAsSpam.newInstance(
+ displayNumber,
+ SpamComponent.get(SpamNotificationActivity.this)
+ .spamSettings()
+ .isDialogReportSpamCheckedByDefault(),
+ new BlockReportSpamDialogs.OnSpamDialogClickListener() {
+ @Override
+ public void onClick(boolean isSpamChecked) {
+ blockReportNumber(number, isSpamChecked, contactLookupResultType);
+ }
+ },
+ dismissListener)
+ .show(
+ getSupportFragmentManager(),
+ BlockReportSpamDialogs.BLOCK_REPORT_SPAM_DIALOG_TAG);
} else {
blockReportNumber(number, true, contactLookupResultType);
}
@@ -286,14 +280,6 @@
.show(getFragmentManager(), FirstTimeSpamCallDialogFragment.TAG);
}
- /** Checks if the user has migrated to the new blocking and display a dialog if necessary. */
- private void maybeShowBlockNumberMigrationDialog(BlockedNumbersMigrator.Listener listener) {
- if (!FilteredNumberCompat.maybeShowBlockNumberMigrationDialog(
- this, getFragmentManager(), listener)) {
- listener.onComplete();
- }
- }
-
/** Block and report the number as spam. */
private void blockReportNumber(
String number, boolean reportAsSpam, ContactLookupResult.Type contactLookupResultType) {
@@ -310,7 +296,7 @@
}
logCallImpression(DialerImpression.Type.SPAM_AFTER_CALL_NOTIFICATION_BLOCK_NUMBER);
- filteredNumberAsyncQueryHandler.blockNumber(null, number, getCountryIso());
+ filteredNumberAsyncQueryHandler.blockNumber(null, number);
}
/** Report the number as not spam. */
diff --git a/java/com/android/incallui/spam/SpamNotificationService.java b/java/com/android/incallui/spam/SpamNotificationService.java
index f7deae1..26aec2f 100644
--- a/java/com/android/incallui/spam/SpamNotificationService.java
+++ b/java/com/android/incallui/spam/SpamNotificationService.java
@@ -128,7 +128,7 @@
CallLog.Calls.INCOMING_TYPE,
ReportingLocation.Type.FEEDBACK_PROMPT,
contactLookupResultType);
- new FilteredNumberAsyncQueryHandler(this).blockNumber(null, number, countryIso);
+ new FilteredNumberAsyncQueryHandler(this).blockNumber(null, number);
if (shouldShowSpamBlockingPromo) {
spamBlockingPromoHelper.showSpamBlockingPromoNotification(
notificationTag,
diff --git a/java/com/android/incallui/videosurface/bindings/VideoSurfaceBindings.java b/java/com/android/incallui/videosurface/bindings/VideoSurfaceBindings.java
index 1cb26bd..96fccb4 100644
--- a/java/com/android/incallui/videosurface/bindings/VideoSurfaceBindings.java
+++ b/java/com/android/incallui/videosurface/bindings/VideoSurfaceBindings.java
@@ -24,12 +24,12 @@
/** Bindings for video surface module. */
public class VideoSurfaceBindings {
- public static VideoSurfaceTexture createLocalVideoSurfaceTexture(boolean isPixel2017) {
- return new VideoSurfaceTextureImpl(isPixel2017, VideoSurfaceTexture.SURFACE_TYPE_LOCAL);
+ public static VideoSurfaceTexture createLocalVideoSurfaceTexture() {
+ return new VideoSurfaceTextureImpl(VideoSurfaceTexture.SURFACE_TYPE_LOCAL);
}
- public static VideoSurfaceTexture createRemoteVideoSurfaceTexture(boolean isPixel2017) {
- return new VideoSurfaceTextureImpl(isPixel2017, VideoSurfaceTexture.SURFACE_TYPE_REMOTE);
+ public static VideoSurfaceTexture createRemoteVideoSurfaceTexture() {
+ return new VideoSurfaceTextureImpl(VideoSurfaceTexture.SURFACE_TYPE_REMOTE);
}
public static void scaleVideoAndFillView(
diff --git a/java/com/android/incallui/videosurface/impl/VideoSurfaceTextureImpl.java b/java/com/android/incallui/videosurface/impl/VideoSurfaceTextureImpl.java
index fa75724..18d09a7 100644
--- a/java/com/android/incallui/videosurface/impl/VideoSurfaceTextureImpl.java
+++ b/java/com/android/incallui/videosurface/impl/VideoSurfaceTextureImpl.java
@@ -18,8 +18,6 @@
import android.graphics.Point;
import android.graphics.SurfaceTexture;
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
import android.view.Surface;
import android.view.TextureView;
import android.view.View;
@@ -35,7 +33,6 @@
*/
public class VideoSurfaceTextureImpl implements VideoSurfaceTexture {
@SurfaceType private final int surfaceType;
- private final boolean isPixel2017;
private VideoSurfaceDelegate delegate;
private TextureView textureView;
@@ -45,8 +42,7 @@
private Point sourceVideoDimensions;
private boolean isDoneWithSurface;
- public VideoSurfaceTextureImpl(boolean isPixel2017, @SurfaceType int surfaceType) {
- this.isPixel2017 = isPixel2017;
+ public VideoSurfaceTextureImpl(@SurfaceType int surfaceType) {
this.surfaceType = surfaceType;
}
@@ -73,13 +69,6 @@
"surfaceDimensions: " + surfaceDimensions + " " + toString());
this.surfaceDimensions = surfaceDimensions;
if (surfaceDimensions != null && savedSurfaceTexture != null) {
- // Only do this on O (not at least O) because we expect this issue to be fixed in OMR1
- if (VERSION.SDK_INT == VERSION_CODES.O && isPixel2017) {
- LogUtil.i(
- "VideoSurfaceTextureImpl.setSurfaceDimensions",
- "skip setting default buffer size on Pixel 2017 ODR");
- return;
- }
savedSurfaceTexture.setDefaultBufferSize(surfaceDimensions.x, surfaceDimensions.y);
}
}
diff --git a/java/com/android/voicemail/impl/ActivationTask.java b/java/com/android/voicemail/impl/ActivationTask.java
index d8ec4e2..4f3c0c4 100644
--- a/java/com/android/voicemail/impl/ActivationTask.java
+++ b/java/com/android/voicemail/impl/ActivationTask.java
@@ -16,10 +16,8 @@
package com.android.voicemail.impl;
-import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
-import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.provider.Settings;
import android.support.annotation.Nullable;
@@ -52,7 +50,6 @@
* boots, the SIM is inserted, signal returned when VVM is not activated yet, and when the carrier
* spontaneously sent a STATUS SMS.
*/
-@TargetApi(VERSION_CODES.O)
@UsedByReflection(value = "Tasks.java")
public class ActivationTask extends BaseTask {
@@ -133,8 +130,6 @@
return;
}
- PreOMigrationHandler.migrate(getContext(), phoneAccountHandle);
-
OmtpVvmCarrierConfigHelper helper;
if (configForTest != null) {
helper = configForTest;
diff --git a/java/com/android/voicemail/impl/CarrierIdentifier.java b/java/com/android/voicemail/impl/CarrierIdentifier.java
index 7788b7d..8b0b693 100644
--- a/java/com/android/voicemail/impl/CarrierIdentifier.java
+++ b/java/com/android/voicemail/impl/CarrierIdentifier.java
@@ -16,9 +16,7 @@
package com.android.voicemail.impl;
-import android.annotation.TargetApi;
import android.content.Context;
-import android.os.Build.VERSION_CODES;
import android.support.annotation.Nullable;
import android.telecom.PhoneAccountHandle;
import android.telephony.TelephonyManager;
@@ -27,7 +25,6 @@
/** Identifies a carrier. */
@AutoValue
-@TargetApi(VERSION_CODES.O)
@SuppressWarnings({"missingpermission"})
public abstract class CarrierIdentifier {
diff --git a/java/com/android/voicemail/impl/DeviceProvisionedJobService.java b/java/com/android/voicemail/impl/DeviceProvisionedJobService.java
index 20993d0..39ac1e1 100644
--- a/java/com/android/voicemail/impl/DeviceProvisionedJobService.java
+++ b/java/com/android/voicemail/impl/DeviceProvisionedJobService.java
@@ -16,7 +16,6 @@
package com.android.voicemail.impl;
-import android.annotation.TargetApi;
import android.app.job.JobInfo;
import android.app.job.JobInfo.TriggerContentUri;
import android.app.job.JobParameters;
@@ -26,7 +25,6 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
-import android.os.Build.VERSION_CODES;
import android.provider.Settings;
import android.provider.Settings.Global;
import android.support.annotation.VisibleForTesting;
@@ -37,7 +35,6 @@
* JobService triggered when the setup wizard is completed, and rerun all {@link ActivationTask}
* scheduled during the setup.
*/
-@TargetApi(VERSION_CODES.O)
public class DeviceProvisionedJobService extends JobService {
@VisibleForTesting static final String EXTRA_PHONE_ACCOUNT_HANDLE = "EXTRA_PHONE_ACCOUNT_HANDLE";
diff --git a/java/com/android/voicemail/impl/OmtpService.java b/java/com/android/voicemail/impl/OmtpService.java
index e10a275..f96666a 100644
--- a/java/com/android/voicemail/impl/OmtpService.java
+++ b/java/com/android/voicemail/impl/OmtpService.java
@@ -16,10 +16,8 @@
package com.android.voicemail.impl;
-import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
-import android.os.Build.VERSION_CODES;
import android.os.UserManager;
import android.preference.PreferenceManager;
import android.support.annotation.MainThread;
@@ -36,7 +34,6 @@
import com.android.voicemail.impl.sync.VvmAccountManager;
/** Implements {@link VisualVoicemailService} to receive visual voicemail events */
-@TargetApi(VERSION_CODES.O)
public class OmtpService extends VisualVoicemailService {
private static final String TAG = "VvmOmtpService";
diff --git a/java/com/android/voicemail/impl/OmtpVvmCarrierConfigHelper.java b/java/com/android/voicemail/impl/OmtpVvmCarrierConfigHelper.java
index e5263f4..31841fd 100644
--- a/java/com/android/voicemail/impl/OmtpVvmCarrierConfigHelper.java
+++ b/java/com/android/voicemail/impl/OmtpVvmCarrierConfigHelper.java
@@ -15,12 +15,10 @@
*/
package com.android.voicemail.impl;
-import android.annotation.TargetApi;
import android.app.PendingIntent;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager.NameNotFoundException;
-import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.annotation.NonNull;
@@ -55,7 +53,6 @@
*
* <p>TODO(twyen): refactor this to an interface.
*/
-@TargetApi(VERSION_CODES.O)
@SuppressWarnings({"missingpermission"})
public class OmtpVvmCarrierConfigHelper {
diff --git a/java/com/android/voicemail/impl/PinChangerImpl.java b/java/com/android/voicemail/impl/PinChangerImpl.java
index 8735a26..a2df22d 100644
--- a/java/com/android/voicemail/impl/PinChangerImpl.java
+++ b/java/com/android/voicemail/impl/PinChangerImpl.java
@@ -16,10 +16,8 @@
package com.android.voicemail.impl;
-import android.annotation.TargetApi;
import android.content.Context;
import android.net.Network;
-import android.os.Build.VERSION_CODES;
import android.support.annotation.WorkerThread;
import android.telecom.PhoneAccountHandle;
import com.android.dialer.common.Assert;
@@ -31,7 +29,6 @@
import com.android.voicemail.impl.sync.VvmNetworkRequest.NetworkWrapper;
import com.android.voicemail.impl.sync.VvmNetworkRequest.RequestFailedException;
-@TargetApi(VERSION_CODES.O)
class PinChangerImpl implements PinChanger {
private final Context context;
diff --git a/java/com/android/voicemail/impl/PreOMigrationHandler.java b/java/com/android/voicemail/impl/PreOMigrationHandler.java
deleted file mode 100644
index 2c45471..0000000
--- a/java/com/android/voicemail/impl/PreOMigrationHandler.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.voicemail.impl;
-
-import android.content.Context;
-import android.os.Bundle;
-import android.support.annotation.VisibleForTesting;
-import android.support.annotation.WorkerThread;
-import android.telecom.PhoneAccountHandle;
-import android.telephony.TelephonyManager;
-import android.text.TextUtils;
-import com.android.voicemail.VoicemailComponent;
-import com.android.voicemail.impl.settings.VisualVoicemailSettingsUtil;
-import java.lang.reflect.Method;
-
-/** Handles migration of data from the visual voicemail client in telephony before O. */
-public final class PreOMigrationHandler {
-
- // Hidden system APIs to access pre O VVM data
- // Bundle getVisualVoicemailSettings()
- private static final String METHOD_GET_VISUAL_VOICEMAIL_SETTINGS = "getVisualVoicemailSettings";
-
- /**
- * Key in bundle returned by {@link #METHOD_GET_VISUAL_VOICEMAIL_SETTINGS}, indicating whether
- * visual voicemail was enabled or disabled by the user. If the user never explicitly changed this
- * setting, this key will not exist.
- */
- private static final String EXTRA_VISUAL_VOICEMAIL_ENABLED_BY_USER_BOOL =
- "android.telephony.extra.VISUAL_VOICEMAIL_ENABLED_BY_USER_BOOL";
-
- /**
- * Key in bundle returned by {@link #METHOD_GET_VISUAL_VOICEMAIL_SETTINGS}, indicating the
- * voicemail access PIN scrambled during the auto provisioning process. The user is expected to
- * reset their PIN if this value is not {@code null}.
- */
- private static final String EXTRA_VOICEMAIL_SCRAMBLED_PIN_STRING =
- "android.telephony.extra.VOICEMAIL_SCRAMBLED_PIN_STRING";
-
- @VisibleForTesting static final String PRE_O_MIGRATION_FINISHED = "pre_o_migration_finished";
-
- @WorkerThread
- public static void migrate(Context context, PhoneAccountHandle phoneAccountHandle) {
- Assert.isNotMainThread();
- VisualVoicemailPreferences preferences =
- new VisualVoicemailPreferences(context, phoneAccountHandle);
- if (preferences.getBoolean(PRE_O_MIGRATION_FINISHED, false)) {
- VvmLog.i("PreOMigrationHandler", phoneAccountHandle + " already migrated");
- return;
- }
- VvmLog.i("PreOMigrationHandler", "migrating " + phoneAccountHandle);
- migrateSettings(context, phoneAccountHandle);
-
- preferences.edit().putBoolean(PRE_O_MIGRATION_FINISHED, true).apply();
- }
-
- private static void migrateSettings(Context context, PhoneAccountHandle phoneAccountHandle) {
- VvmLog.i("PreOMigrationHandler.migrateSettings", "migrating settings");
- TelephonyManager telephonyManager =
- context
- .getSystemService(TelephonyManager.class)
- .createForPhoneAccountHandle(phoneAccountHandle);
- if (telephonyManager == null) {
- VvmLog.e("PreOMigrationHandler.migrateSettings", "invalid PhoneAccountHandle");
- return;
- }
- Bundle legacySettings;
- try {
- Method method = TelephonyManager.class.getMethod(METHOD_GET_VISUAL_VOICEMAIL_SETTINGS);
- legacySettings = (Bundle) method.invoke(telephonyManager);
- } catch (ReflectiveOperationException | ClassCastException e) {
- VvmLog.i("PreOMigrationHandler.migrateSettings", "unable to retrieve settings from system");
- return;
- }
-
- if (legacySettings.containsKey(EXTRA_VISUAL_VOICEMAIL_ENABLED_BY_USER_BOOL)) {
- boolean enabled = legacySettings.getBoolean(EXTRA_VISUAL_VOICEMAIL_ENABLED_BY_USER_BOOL);
- VvmLog.i("PreOMigrationHandler.migrateSettings", "setting VVM enabled to " + enabled);
- VisualVoicemailSettingsUtil.setEnabled(context, phoneAccountHandle, enabled);
- }
-
- if (legacySettings.containsKey(EXTRA_VOICEMAIL_SCRAMBLED_PIN_STRING)) {
- String scrambledPin = legacySettings.getString(EXTRA_VOICEMAIL_SCRAMBLED_PIN_STRING);
- if (!TextUtils.isEmpty(scrambledPin)) {
- VvmLog.i("PreOMigrationHandler.migrateSettings", "migrating scrambled PIN");
- VoicemailComponent.get(context)
- .getVoicemailClient()
- .createPinChanger(context, phoneAccountHandle)
- .setScrambledPin(scrambledPin);
- }
- }
- }
-}
diff --git a/java/com/android/voicemail/impl/StatusCheckJobService.java b/java/com/android/voicemail/impl/StatusCheckJobService.java
index 870c5b4..fb2016b 100644
--- a/java/com/android/voicemail/impl/StatusCheckJobService.java
+++ b/java/com/android/voicemail/impl/StatusCheckJobService.java
@@ -13,14 +13,12 @@
*/
package com.android.voicemail.impl;
-import android.annotation.TargetApi;
import android.app.job.JobInfo;
import android.app.job.JobParameters;
import android.app.job.JobScheduler;
import android.app.job.JobService;
import android.content.ComponentName;
import android.content.Context;
-import android.os.Build.VERSION_CODES;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import com.android.dialer.constants.ScheduledJobIds;
@@ -33,7 +31,6 @@
* scheduled for each active voicemail account. The status is expected to be always in sync, the
* check is a failsafe to mimic the previous status check on signal return behavior.
*/
-@TargetApi(VERSION_CODES.O)
public class StatusCheckJobService extends JobService {
public static void schedule(Context context) {
diff --git a/java/com/android/voicemail/impl/StatusCheckTask.java b/java/com/android/voicemail/impl/StatusCheckTask.java
index e59eb3b..973d00d 100644
--- a/java/com/android/voicemail/impl/StatusCheckTask.java
+++ b/java/com/android/voicemail/impl/StatusCheckTask.java
@@ -13,10 +13,8 @@
*/
package com.android.voicemail.impl;
-import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
-import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.telecom.PhoneAccountHandle;
import android.telephony.ServiceState;
@@ -41,7 +39,6 @@
* com.android.voicemail.impl.sms.OmtpMessageReceiver}). If the provisioning status is not ready an
* {@link ActivationTask} will be launched to attempt to correct it.
*/
-@TargetApi(VERSION_CODES.O)
@UsedByReflection(value = "Tasks.java")
public class StatusCheckTask extends BaseTask {
diff --git a/java/com/android/voicemail/impl/VoicemailClientImpl.java b/java/com/android/voicemail/impl/VoicemailClientImpl.java
index 36e5a6c..2a112e8 100644
--- a/java/com/android/voicemail/impl/VoicemailClientImpl.java
+++ b/java/com/android/voicemail/impl/VoicemailClientImpl.java
@@ -13,11 +13,9 @@
*/
package com.android.voicemail.impl;
-import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
-import android.os.Build.VERSION_CODES;
import android.os.PersistableBundle;
import android.preference.PreferenceManager;
import android.provider.VoicemailContract.Status;
@@ -25,9 +23,9 @@
import android.support.annotation.MainThread;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import android.support.v4.os.BuildCompat;
import android.telecom.PhoneAccountHandle;
import android.telephony.TelephonyManager;
+
import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
import com.android.dialer.configprovider.ConfigProviderComponent;
@@ -67,9 +65,7 @@
};
@Inject
- public VoicemailClientImpl() {
- Assert.checkArgument(BuildCompat.isAtLeastO());
- }
+ public VoicemailClientImpl() { }
@Override
public boolean isVoicemailModuleEnabled() {
@@ -100,11 +96,6 @@
@Override
public boolean isVoicemailArchiveAvailable(Context context) {
- if (!BuildCompat.isAtLeastO()) {
- LogUtil.i("VoicemailClientImpl.isVoicemailArchiveAllowed", "not running on O or later");
- return false;
- }
-
if (!ConfigProviderComponent.get(context)
.getConfigProvider()
.getBoolean(ALLOW_VOICEMAIL_ARCHIVE, false)) {
@@ -132,12 +123,6 @@
"VoicemailClientImpl.isVoicemailTranscriptionAvailable", "phone account handle is null");
}
- if (!BuildCompat.isAtLeastO()) {
- LogUtil.i(
- "VoicemailClientImpl.isVoicemailTranscriptionAvailable", "not running on O or later");
- return false;
- }
-
if (!isVoicemailEnabled(context, phoneAccountHandle)) {
LogUtil.i(
"VoicemailClientImpl.isVoicemailTranscriptionAvailable",
@@ -271,7 +256,6 @@
return new PinChangerImpl(context, phoneAccountHandle);
}
- @TargetApi(VERSION_CODES.O)
@Override
public void appendOmtpVoicemailSelectionClause(
Context context, StringBuilder where, List<String> selectionArgs) {
@@ -303,7 +287,6 @@
}
}
- @TargetApi(VERSION_CODES.O)
@Override
public void appendOmtpVoicemailStatusSelectionClause(
Context context, StringBuilder where, List<String> selectionArgs) {
diff --git a/java/com/android/voicemail/impl/VoicemailModule.java b/java/com/android/voicemail/impl/VoicemailModule.java
index c4c72d3..07968d8 100644
--- a/java/com/android/voicemail/impl/VoicemailModule.java
+++ b/java/com/android/voicemail/impl/VoicemailModule.java
@@ -17,7 +17,6 @@
package com.android.voicemail.impl;
import android.content.Context;
-import android.support.v4.os.BuildCompat;
import com.android.dialer.inject.ApplicationContext;
import com.android.dialer.inject.DialerVariant;
import com.android.dialer.inject.InstallIn;
@@ -36,11 +35,6 @@
@Provides
@Singleton
static VoicemailClient provideVoicemailClient(@ApplicationContext Context context) {
- if (!BuildCompat.isAtLeastO()) {
- VvmLog.i("VoicemailModule.provideVoicemailClient", "SDK below O");
- return new StubVoicemailClient();
- }
-
if (!VoicemailPermissionHelper.hasPermissions(context)) {
VvmLog.i(
"VoicemailModule.provideVoicemailClient",
diff --git a/java/com/android/voicemail/impl/VvmPackageInstallHandler.java b/java/com/android/voicemail/impl/VvmPackageInstallHandler.java
index ee8b722..d6d5b77 100644
--- a/java/com/android/voicemail/impl/VvmPackageInstallHandler.java
+++ b/java/com/android/voicemail/impl/VvmPackageInstallHandler.java
@@ -16,9 +16,7 @@
package com.android.voicemail.impl;
-import android.annotation.TargetApi;
import android.content.Context;
-import android.os.Build.VERSION_CODES;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import com.android.voicemail.impl.settings.VisualVoicemailSettingsUtil;
@@ -33,7 +31,6 @@
* when a VVM SMS is received instead, as it can be a result of the carrier VVM app trying to run
* activation.
*/
-@TargetApi(VERSION_CODES.O)
public final class VvmPackageInstallHandler {
/**
diff --git a/java/com/android/voicemail/impl/fetch/FetchVoicemailReceiver.java b/java/com/android/voicemail/impl/fetch/FetchVoicemailReceiver.java
index 7be22e4..0fae679 100644
--- a/java/com/android/voicemail/impl/fetch/FetchVoicemailReceiver.java
+++ b/java/com/android/voicemail/impl/fetch/FetchVoicemailReceiver.java
@@ -15,7 +15,6 @@
*/
package com.android.voicemail.impl.fetch;
-import android.annotation.TargetApi;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentResolver;
@@ -24,12 +23,10 @@
import android.database.Cursor;
import android.net.Network;
import android.net.Uri;
-import android.os.Build.VERSION_CODES;
import android.provider.VoicemailContract;
import android.provider.VoicemailContract.Voicemails;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import android.support.v4.os.BuildCompat;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.telephony.TelephonyManager;
@@ -45,7 +42,6 @@
import java.util.concurrent.Executors;
/** handles {@link VoicemailContract#ACTION_FETCH_VOICEMAIL} */
-@TargetApi(VERSION_CODES.O)
public class FetchVoicemailReceiver extends BroadcastReceiver {
private static final String TAG = "FetchVoicemailReceiver";
@@ -157,9 +153,6 @@
@Nullable
private static PhoneAccountHandle getAccountFromMarshmallowAccount(
Context context, PhoneAccountHandle oldAccount) {
- if (!BuildCompat.isAtLeastN()) {
- return null;
- }
for (PhoneAccountHandle handle :
context.getSystemService(TelecomManager.class).getCallCapablePhoneAccounts()) {
if (getIccSerialNumberFromFullIccSerialNumber(handle.getId()).equals(oldAccount.getId())) {
diff --git a/java/com/android/voicemail/impl/mail/store/imap/DigestMd5Utils.java b/java/com/android/voicemail/impl/mail/store/imap/DigestMd5Utils.java
index 6607160..ab835dc 100644
--- a/java/com/android/voicemail/impl/mail/store/imap/DigestMd5Utils.java
+++ b/java/com/android/voicemail/impl/mail/store/imap/DigestMd5Utils.java
@@ -16,8 +16,6 @@
package com.android.voicemail.impl.mail.store.imap;
-import android.annotation.TargetApi;
-import android.os.Build.VERSION_CODES;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.util.ArrayMap;
@@ -33,7 +31,6 @@
import java.util.Map;
/** Utilities for DIGEST-MD5. */
-@TargetApi(VERSION_CODES.O)
public class DigestMd5Utils {
private static final String TAG = "DigestMd5Utils";
diff --git a/java/com/android/voicemail/impl/protocol/Vvm3Protocol.java b/java/com/android/voicemail/impl/protocol/Vvm3Protocol.java
index 5e7b592..0d14bcb 100644
--- a/java/com/android/voicemail/impl/protocol/Vvm3Protocol.java
+++ b/java/com/android/voicemail/impl/protocol/Vvm3Protocol.java
@@ -16,11 +16,9 @@
package com.android.voicemail.impl.protocol;
-import android.annotation.TargetApi;
import android.app.PendingIntent;
import android.content.Context;
import android.net.Network;
-import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.telecom.PhoneAccountHandle;
@@ -55,7 +53,6 @@
*
* <p>Used by carriers such as Verizon Wireless
*/
-@TargetApi(VERSION_CODES.O)
public class Vvm3Protocol extends VisualVoicemailProtocol {
private static final String TAG = "Vvm3Protocol";
diff --git a/java/com/android/voicemail/impl/protocol/Vvm3Subscriber.java b/java/com/android/voicemail/impl/protocol/Vvm3Subscriber.java
index 41598e0..c478a93 100644
--- a/java/com/android/voicemail/impl/protocol/Vvm3Subscriber.java
+++ b/java/com/android/voicemail/impl/protocol/Vvm3Subscriber.java
@@ -16,11 +16,9 @@
package com.android.voicemail.impl.protocol;
-import android.annotation.TargetApi;
import android.content.Context;
import android.net.Network;
import android.os.Build;
-import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.VisibleForTesting;
@@ -81,7 +79,6 @@
* <p>After the process is completed, the carrier should send us another STATUS SMS with a new or
* ready user.
*/
-@TargetApi(VERSION_CODES.O)
public class Vvm3Subscriber {
private static final String TAG = "Vvm3Subscriber";
diff --git a/java/com/android/voicemail/impl/scheduling/TaskExecutor.java b/java/com/android/voicemail/impl/scheduling/TaskExecutor.java
index afa77c5..d2ddea7 100644
--- a/java/com/android/voicemail/impl/scheduling/TaskExecutor.java
+++ b/java/com/android/voicemail/impl/scheduling/TaskExecutor.java
@@ -16,10 +16,8 @@
package com.android.voicemail.impl.scheduling;
-import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
-import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
@@ -69,7 +67,6 @@
* <li>A job cannot be mutated to store information such as retry count.
* </ul>
*/
-@TargetApi(VERSION_CODES.O)
final class TaskExecutor {
/**
diff --git a/java/com/android/voicemail/impl/scheduling/TaskReceiver.java b/java/com/android/voicemail/impl/scheduling/TaskReceiver.java
index b9fd272..d838b9e 100644
--- a/java/com/android/voicemail/impl/scheduling/TaskReceiver.java
+++ b/java/com/android/voicemail/impl/scheduling/TaskReceiver.java
@@ -16,11 +16,9 @@
package com.android.voicemail.impl.scheduling;
-import android.annotation.TargetApi;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
-import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import com.android.voicemail.impl.VvmLog;
import com.android.voicemail.impl.scheduling.Tasks.TaskCreationException;
@@ -34,7 +32,6 @@
* Tasks#createIntent(Context, Class)}). The task will be queued directly in {@link TaskExecutor} if
* it is already running, or in {@link TaskSchedulerJobService} if not.
*/
-@TargetApi(VERSION_CODES.O)
public class TaskReceiver extends BroadcastReceiver {
private static final String TAG = "VvmTaskReceiver";
diff --git a/java/com/android/voicemail/impl/scheduling/TaskSchedulerJobService.java b/java/com/android/voicemail/impl/scheduling/TaskSchedulerJobService.java
index 77a0d25..2daf3a1 100644
--- a/java/com/android/voicemail/impl/scheduling/TaskSchedulerJobService.java
+++ b/java/com/android/voicemail/impl/scheduling/TaskSchedulerJobService.java
@@ -16,7 +16,6 @@
package com.android.voicemail.impl.scheduling;
-import android.annotation.TargetApi;
import android.app.job.JobInfo;
import android.app.job.JobParameters;
import android.app.job.JobScheduler;
@@ -24,7 +23,6 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.SharedPreferences;
-import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.Parcelable;
import android.preference.PreferenceManager;
@@ -38,7 +36,6 @@
import java.util.List;
/** A {@link JobService} that will trigger the background execution of {@link TaskExecutor}. */
-@TargetApi(VERSION_CODES.O)
public class TaskSchedulerJobService extends JobService implements TaskExecutor.Job {
private static final String TAG = "TaskSchedulerJobService";
diff --git a/java/com/android/voicemail/impl/sms/LegacyModeSmsHandler.java b/java/com/android/voicemail/impl/sms/LegacyModeSmsHandler.java
index 5a16f86..f75e23b 100644
--- a/java/com/android/voicemail/impl/sms/LegacyModeSmsHandler.java
+++ b/java/com/android/voicemail/impl/sms/LegacyModeSmsHandler.java
@@ -16,11 +16,9 @@
package com.android.voicemail.impl.sms;
-import android.annotation.TargetApi;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
-import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.telecom.PhoneAccountHandle;
@@ -39,7 +37,6 @@
*
* @see OmtpVvmCarrierConfigHelper#isLegacyModeEnabled()
*/
-@TargetApi(VERSION_CODES.O)
public class LegacyModeSmsHandler {
private static final String TAG = "LegacyModeSmsHandler";
diff --git a/java/com/android/voicemail/impl/sms/OmtpMessageReceiver.java b/java/com/android/voicemail/impl/sms/OmtpMessageReceiver.java
index 0f22c3d..e71dca0 100644
--- a/java/com/android/voicemail/impl/sms/OmtpMessageReceiver.java
+++ b/java/com/android/voicemail/impl/sms/OmtpMessageReceiver.java
@@ -15,13 +15,11 @@
*/
package com.android.voicemail.impl.sms;
-import android.annotation.TargetApi;
import android.content.BroadcastReceiver;
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
-import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.UserManager;
import android.telecom.PhoneAccountHandle;
@@ -42,7 +40,6 @@
import com.android.voicemail.impl.utils.VoicemailDatabaseUtil;
/** Receive SMS messages and send for processing by the OMTP visual voicemail source. */
-@TargetApi(VERSION_CODES.O)
public class OmtpMessageReceiver extends BroadcastReceiver {
private static final String TAG = "OmtpMessageReceiver";
diff --git a/java/com/android/voicemail/impl/sms/OmtpMessageSender.java b/java/com/android/voicemail/impl/sms/OmtpMessageSender.java
index 8b9e049..b10b18f 100644
--- a/java/com/android/voicemail/impl/sms/OmtpMessageSender.java
+++ b/java/com/android/voicemail/impl/sms/OmtpMessageSender.java
@@ -15,10 +15,8 @@
*/
package com.android.voicemail.impl.sms;
-import android.annotation.TargetApi;
import android.app.PendingIntent;
import android.content.Context;
-import android.os.Build.VERSION_CODES;
import android.support.annotation.Nullable;
import android.telecom.PhoneAccountHandle;
import android.telephony.SmsManager;
@@ -35,7 +33,6 @@
*
* <p>Provides simple APIs to send different types of mobile originated OMTP SMS to the VVM server.
*/
-@TargetApi(VERSION_CODES.O)
public abstract class OmtpMessageSender {
protected static final String TAG = "OmtpMessageSender";
protected final Context context;
diff --git a/java/com/android/voicemail/impl/sms/StatusSmsFetcher.java b/java/com/android/voicemail/impl/sms/StatusSmsFetcher.java
index dd945e9..2684abb 100644
--- a/java/com/android/voicemail/impl/sms/StatusSmsFetcher.java
+++ b/java/com/android/voicemail/impl/sms/StatusSmsFetcher.java
@@ -16,14 +16,12 @@
package com.android.voicemail.impl.sms;
-import android.annotation.TargetApi;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
-import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.support.annotation.MainThread;
import android.support.annotation.Nullable;
@@ -46,7 +44,6 @@
import java.util.concurrent.TimeoutException;
/** Intercepts a incoming STATUS SMS with a blocking call. */
-@TargetApi(VERSION_CODES.O)
public class StatusSmsFetcher extends BroadcastReceiver implements Closeable {
private static final String TAG = "VvmStatusSmsFetcher";
diff --git a/java/com/android/voicemail/impl/sync/OmtpVvmSyncService.java b/java/com/android/voicemail/impl/sync/OmtpVvmSyncService.java
index cf2763b..957572e 100644
--- a/java/com/android/voicemail/impl/sync/OmtpVvmSyncService.java
+++ b/java/com/android/voicemail/impl/sync/OmtpVvmSyncService.java
@@ -15,12 +15,9 @@
*/
package com.android.voicemail.impl.sync;
-import android.annotation.TargetApi;
import android.content.Context;
import android.net.Network;
import android.net.Uri;
-import android.os.Build.VERSION_CODES;
-import android.support.v4.os.BuildCompat;
import android.telecom.PhoneAccountHandle;
import android.text.TextUtils;
import android.util.ArrayMap;
@@ -48,7 +45,6 @@
import java.util.Map;
/** Sync OMTP visual voicemail. */
-@TargetApi(VERSION_CODES.O)
public class OmtpVvmSyncService {
private static final String TAG = "OmtpVvmSyncService";
@@ -188,9 +184,6 @@
}
private void deleteAndArchiveVM(ImapHelper imapHelper, Quota quotaOnServer) {
- // Archive column should only be used for 0 and above
- Assert.isTrue(BuildCompat.isAtLeastO());
-
// The number of voicemails that exceed our threshold and should be deleted from the server
int numVoicemails =
quotaOnServer.occupied - (int) (AUTO_DELETE_ARCHIVE_VM_THRESHOLD * quotaOnServer.total);
diff --git a/java/com/android/voicemail/impl/sync/VvmAccountManager.java b/java/com/android/voicemail/impl/sync/VvmAccountManager.java
index e7f2eef..795e207 100644
--- a/java/com/android/voicemail/impl/sync/VvmAccountManager.java
+++ b/java/com/android/voicemail/impl/sync/VvmAccountManager.java
@@ -15,9 +15,7 @@
*/
package com.android.voicemail.impl.sync;
-import android.annotation.TargetApi;
import android.content.Context;
-import android.os.Build.VERSION_CODES;
import android.os.UserManager;
import android.support.annotation.MainThread;
import android.support.annotation.NonNull;
@@ -47,7 +45,6 @@
* #removeAccount(Context, PhoneAccountHandle)} should be called to clear the connection information
* and allow reactivation.
*/
-@TargetApi(VERSION_CODES.O)
public class VvmAccountManager {
public static final String TAG = "VvmAccountManager";
diff --git a/java/com/android/voicemail/impl/sync/VvmNetworkRequest.java b/java/com/android/voicemail/impl/sync/VvmNetworkRequest.java
index a7d578d..92456ca 100644
--- a/java/com/android/voicemail/impl/sync/VvmNetworkRequest.java
+++ b/java/com/android/voicemail/impl/sync/VvmNetworkRequest.java
@@ -16,9 +16,7 @@
package com.android.voicemail.impl.sync;
-import android.annotation.TargetApi;
import android.net.Network;
-import android.os.Build.VERSION_CODES;
import android.support.annotation.NonNull;
import android.telecom.PhoneAccountHandle;
import com.android.voicemail.impl.OmtpVvmCarrierConfigHelper;
@@ -33,7 +31,6 @@
* Class to retrieve a {@link Network} synchronously. {@link #getNetwork(OmtpVvmCarrierConfigHelper,
* PhoneAccountHandle)} will block until a suitable network is retrieved or it has failed.
*/
-@TargetApi(VERSION_CODES.O)
public class VvmNetworkRequest {
private static final String TAG = "VvmNetworkRequest";
diff --git a/java/com/android/voicemail/impl/sync/VvmNetworkRequestCallback.java b/java/com/android/voicemail/impl/sync/VvmNetworkRequestCallback.java
index 5762a09..84c3cb5 100644
--- a/java/com/android/voicemail/impl/sync/VvmNetworkRequestCallback.java
+++ b/java/com/android/voicemail/impl/sync/VvmNetworkRequestCallback.java
@@ -15,7 +15,6 @@
*/
package com.android.voicemail.impl.sync;
-import android.annotation.TargetApi;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.InetAddresses;
@@ -24,7 +23,6 @@
import android.net.NetworkCapabilities;
import android.net.NetworkRequest;
import android.os.ConditionVariable;
-import android.os.Build.VERSION_CODES;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.CallSuper;
@@ -40,7 +38,6 @@
* Base class for network request call backs for visual voicemail syncing with the Imap server. This
* handles retries and network requests.
*/
-@TargetApi(VERSION_CODES.O)
public abstract class VvmNetworkRequestCallback extends ConnectivityManager.NetworkCallback {
private static final String TAG = "VvmNetworkRequest";
diff --git a/java/com/android/voicemail/impl/transcribe/TranscriptionBackfillService.java b/java/com/android/voicemail/impl/transcribe/TranscriptionBackfillService.java
index 8fc40ee..4e79d18 100644
--- a/java/com/android/voicemail/impl/transcribe/TranscriptionBackfillService.java
+++ b/java/com/android/voicemail/impl/transcribe/TranscriptionBackfillService.java
@@ -25,7 +25,6 @@
import android.os.Bundle;
import android.support.annotation.WorkerThread;
import android.support.v4.app.JobIntentService;
-import android.support.v4.os.BuildCompat;
import android.telecom.PhoneAccountHandle;
import com.android.dialer.common.LogUtil;
import com.android.dialer.common.concurrent.ThreadUtil;
@@ -41,19 +40,14 @@
/** Schedule a task to scan the database for untranscribed voicemails */
public static boolean scheduleTask(Context context, PhoneAccountHandle account) {
- if (BuildCompat.isAtLeastO()) {
- LogUtil.enterBlock("TranscriptionBackfillService.transcribeOldVoicemails");
- ComponentName componentName = new ComponentName(context, TranscriptionBackfillService.class);
- JobInfo.Builder builder =
- new JobInfo.Builder(ScheduledJobIds.VVM_TRANSCRIPTION_BACKFILL_JOB, componentName)
- .setRequiredNetworkType(JobInfo.NETWORK_TYPE_UNMETERED);
- JobScheduler scheduler = context.getSystemService(JobScheduler.class);
- return scheduler.enqueue(builder.build(), makeWorkItem(account))
- == JobScheduler.RESULT_SUCCESS;
- } else {
- LogUtil.i("TranscriptionBackfillService.transcribeOldVoicemails", "not supported");
- return false;
- }
+ LogUtil.enterBlock("TranscriptionBackfillService.transcribeOldVoicemails");
+ ComponentName componentName = new ComponentName(context, TranscriptionBackfillService.class);
+ JobInfo.Builder builder =
+ new JobInfo.Builder(ScheduledJobIds.VVM_TRANSCRIPTION_BACKFILL_JOB, componentName)
+ .setRequiredNetworkType(JobInfo.NETWORK_TYPE_UNMETERED);
+ JobScheduler scheduler = context.getSystemService(JobScheduler.class);
+ return scheduler.enqueue(builder.build(), makeWorkItem(account))
+ == JobScheduler.RESULT_SUCCESS;
}
private static JobWorkItem makeWorkItem(PhoneAccountHandle account) {
diff --git a/java/com/android/voicemail/impl/transcribe/TranscriptionConfigProvider.java b/java/com/android/voicemail/impl/transcribe/TranscriptionConfigProvider.java
index 66bf16c..ee10685 100644
--- a/java/com/android/voicemail/impl/transcribe/TranscriptionConfigProvider.java
+++ b/java/com/android/voicemail/impl/transcribe/TranscriptionConfigProvider.java
@@ -16,7 +16,6 @@
package com.android.voicemail.impl.transcribe;
import android.content.Context;
-import android.os.Build;
import com.android.dialer.configprovider.ConfigProviderComponent;
import java.util.concurrent.TimeUnit;
@@ -29,8 +28,7 @@
}
public boolean isVoicemailTranscriptionAvailable() {
- return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
- && ConfigProviderComponent.get(context)
+ return ConfigProviderComponent.get(context)
.getConfigProvider()
.getBoolean("voicemail_transcription_available", false);
}
diff --git a/java/com/android/voicemail/impl/transcribe/TranscriptionDbHelper.java b/java/com/android/voicemail/impl/transcribe/TranscriptionDbHelper.java
index 6ffb848..4dc54b1 100644
--- a/java/com/android/voicemail/impl/transcribe/TranscriptionDbHelper.java
+++ b/java/com/android/voicemail/impl/transcribe/TranscriptionDbHelper.java
@@ -15,14 +15,12 @@
*/
package com.android.voicemail.impl.transcribe;
-import android.annotation.TargetApi;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
-import android.os.Build;
import android.provider.VoicemailContract.Voicemails;
import android.support.annotation.VisibleForTesting;
import android.support.annotation.WorkerThread;
@@ -34,7 +32,6 @@
import java.util.List;
/** Helper class for reading and writing transcription data in the database */
-@TargetApi(Build.VERSION_CODES.O)
public class TranscriptionDbHelper {
@VisibleForTesting
static final String[] PROJECTION =
@@ -63,7 +60,6 @@
@WorkerThread
Pair<String, Integer> getTranscriptionAndState() {
- Assert.checkState(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O);
Assert.isWorkerThread();
try (Cursor cursor = contentResolver.query(uri, PROJECTION, null, null, null)) {
if (cursor == null) {
@@ -83,7 +79,6 @@
@WorkerThread
List<Uri> getUntranscribedVoicemails() {
- Assert.checkState(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O);
Assert.isWorkerThread();
List<Uri> untranscribed = new ArrayList<>();
String whereClause =
@@ -110,7 +105,6 @@
@WorkerThread
List<Uri> getTranscribingVoicemails() {
- Assert.checkState(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O);
Assert.isWorkerThread();
List<Uri> inProgress = new ArrayList<>();
String whereClause = VoicemailCompat.TRANSCRIPTION_STATE + "=?";
diff --git a/java/com/android/voicemail/impl/transcribe/TranscriptionRatingService.java b/java/com/android/voicemail/impl/transcribe/TranscriptionRatingService.java
index cff2c6d..51fe3b1 100644
--- a/java/com/android/voicemail/impl/transcribe/TranscriptionRatingService.java
+++ b/java/com/android/voicemail/impl/transcribe/TranscriptionRatingService.java
@@ -21,7 +21,6 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
-import android.os.Build;
import android.support.annotation.WorkerThread;
import android.support.v4.app.JobIntentService;
import com.android.dialer.common.LogUtil;
@@ -39,7 +38,6 @@
/** Schedule a task to upload transcription rating feedback */
public static boolean scheduleTask(Context context, SendTranscriptionFeedbackRequest request) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
LogUtil.enterBlock("TranscriptionRatingService.scheduleTask");
ComponentName componentName = new ComponentName(context, TranscriptionRatingService.class);
JobInfo.Builder builder =
@@ -48,10 +46,6 @@
JobScheduler scheduler = context.getSystemService(JobScheduler.class);
return scheduler.enqueue(builder.build(), makeWorkItem(request))
== JobScheduler.RESULT_SUCCESS;
- } else {
- LogUtil.i("TranscriptionRatingService.scheduleTask", "not supported");
- return false;
- }
}
public TranscriptionRatingService() {}
diff --git a/java/com/android/voicemail/impl/transcribe/TranscriptionService.java b/java/com/android/voicemail/impl/transcribe/TranscriptionService.java
index 781e347..b93c2e5 100644
--- a/java/com/android/voicemail/impl/transcribe/TranscriptionService.java
+++ b/java/com/android/voicemail/impl/transcribe/TranscriptionService.java
@@ -93,10 +93,6 @@
}
private static boolean canTranscribeVoicemail(Context context, PhoneAccountHandle account) {
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
- LogUtil.i("TranscriptionService.canTranscribeVoicemail", "not supported by sdk");
- return false;
- }
VoicemailClient client = VoicemailComponent.get(context).getVoicemailClient();
if (!client.isVoicemailTranscriptionEnabled(context, account)) {
LogUtil.i("TranscriptionService.canTranscribeVoicemail", "transcription is not enabled");
diff --git a/java/com/android/voicemail/impl/transcribe/TranscriptionUtils.java b/java/com/android/voicemail/impl/transcribe/TranscriptionUtils.java
index 8611e80..f1d89d8 100644
--- a/java/com/android/voicemail/impl/transcribe/TranscriptionUtils.java
+++ b/java/com/android/voicemail/impl/transcribe/TranscriptionUtils.java
@@ -15,10 +15,8 @@
*/
package com.android.voicemail.impl.transcribe;
-import android.annotation.TargetApi;
import android.content.Context;
import android.net.Uri;
-import android.os.Build.VERSION_CODES;
import android.support.annotation.Nullable;
import android.util.Base64;
import com.android.dialer.common.Assert;
@@ -47,7 +45,6 @@
: AudioFormat.AUDIO_FORMAT_UNSPECIFIED;
}
- @TargetApi(VERSION_CODES.O)
static String getFingerprintFor(ByteString data, @Nullable String salt) {
Assert.checkArgument(data != null);
try {