diff options
11 files changed, 213 insertions, 19 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index b16689520..52c2ee221 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -16,8 +16,8 @@ <manifest xmlns:android="http://schemas.android.com/apk/res/android" coreApp="true" package="com.android.dialer" - android:versionCode="2700000" - android:versionName="21.0"> + android:versionCode="2800000" + android:versionName="22.0"> <uses-sdk android:minSdkVersion="24" diff --git a/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java b/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java index ce6e5baf4..d13702931 100644 --- a/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java +++ b/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java @@ -111,7 +111,14 @@ public class CallLogNotificationsQueryHelper { return; } if (!PermissionsUtil.hasPhonePermissions(context)) { - LogUtil.e("CallLogNotificationsQueryHelper.markMissedCallsInCallLogAsRead", "no permission"); + LogUtil.e( + "CallLogNotificationsQueryHelper.markMissedCallsInCallLogAsRead", "no phone permission"); + return; + } + if (!PermissionsUtil.hasCallLogWritePermissions(context)) { + LogUtil.e( + "CallLogNotificationsQueryHelper.markMissedCallsInCallLogAsRead", + "no call log write permission"); return; } diff --git a/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java b/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java index dba43a2f7..5b6eb0387 100644 --- a/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java +++ b/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java @@ -182,10 +182,10 @@ public class VisualVoicemailCallLogFragment extends CallLogFragment { } @VisibleForTesting - static boolean shouldAutoSync( + boolean shouldAutoSync( VoicemailErrorMessageCreator errorMessageCreator, List<VoicemailStatus> statuses) { for (VoicemailStatus status : statuses) { - if (!status.isActive()) { + if (!status.isActive(getContext())) { continue; } if (errorMessageCreator.isSyncBlockingError(status)) { diff --git a/java/com/android/dialer/app/voicemail/VoicemailErrorManager.java b/java/com/android/dialer/app/voicemail/VoicemailErrorManager.java index ffaf16d18..a441e7986 100644 --- a/java/com/android/dialer/app/voicemail/VoicemailErrorManager.java +++ b/java/com/android/dialer/app/voicemail/VoicemailErrorManager.java @@ -86,9 +86,11 @@ public class VoicemailErrorManager implements CallLogQueryHandler.Listener, Voic List<VoicemailStatus> statuses = new ArrayList<>(); while (statusCursor.moveToNext()) { VoicemailStatus status = new VoicemailStatus(context, statusCursor); - if (status.isActive()) { + if (status.isActive(context)) { statuses.add(status); addServiceStateListener(status); + } else { + LogUtil.i("VisualVoicemailCallLogFragment.shouldAutoSync", "inactive source ignored"); } } alertItem.updateStatus(statuses, this); diff --git a/java/com/android/dialer/binary/google/AndroidManifest.xml b/java/com/android/dialer/binary/google/AndroidManifest.xml index 1e12245b4..e750cd06f 100644 --- a/java/com/android/dialer/binary/google/AndroidManifest.xml +++ b/java/com/android/dialer/binary/google/AndroidManifest.xml @@ -16,8 +16,8 @@ <manifest xmlns:android="http://schemas.android.com/apk/res/android" coreApp="true" package="com.google.android.google_stub_dialer" - android:versionCode="2700000" - android:versionName="21.0"> + android:versionCode="2800000" + android:versionName="22.0"> <uses-sdk android:minSdkVersion="24" diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailFragment.java b/java/com/android/dialer/voicemail/listui/NewVoicemailFragment.java index b2052c61e..243dc6a86 100644 --- a/java/com/android/dialer/voicemail/listui/NewVoicemailFragment.java +++ b/java/com/android/dialer/voicemail/listui/NewVoicemailFragment.java @@ -280,7 +280,9 @@ public final class NewVoicemailFragment extends Fragment implements LoaderCallba while (cursor.moveToNext()) { VoicemailStatus status = new VoicemailStatus(context, cursor); - if (status.isActive()) { + if (status.isActive(context)) { + LogUtil.i( + "NewVoicemailFragment.queryVoicemailStatus", "inactive source ignored"); statuses.add(status); // TODO(a bug): Handle Service State Listeners } diff --git a/java/com/android/dialer/voicemail/listui/error/VoicemailStatus.java b/java/com/android/dialer/voicemail/listui/error/VoicemailStatus.java index 4f4dbbbe8..ebda0e658 100644 --- a/java/com/android/dialer/voicemail/listui/error/VoicemailStatus.java +++ b/java/com/android/dialer/voicemail/listui/error/VoicemailStatus.java @@ -34,6 +34,8 @@ import android.telephony.TelephonyManager; import android.text.TextUtils; import com.android.dialer.common.LogUtil; import com.android.dialer.voicemailstatus.VoicemailStatusQuery; +import com.android.voicemail.VoicemailClient; +import com.android.voicemail.VoicemailComponent; /** Structured data from {@link android.provider.VoicemailContract.Status} */ public class VoicemailStatus { @@ -232,7 +234,22 @@ public class VoicemailStatus { } } - public boolean isActive() { + public boolean isActive(Context context) { + VoicemailClient voicemailClient = VoicemailComponent.get(context).getVoicemailClient(); + if (context.getPackageName().equals(sourcePackage)) { + if (!voicemailClient.isVoicemailModuleEnabled()) { + LogUtil.i("VoicemailStatus.isActive", "module disabled"); + return false; + } + if (!voicemailClient.hasCarrierSupport(context, getPhoneAccountHandle())) { + LogUtil.i("VoicemailStatus.isActive", "carrier not supported"); + return false; + } + if (!voicemailClient.isVoicemailEnabled(context, getPhoneAccountHandle())) { + LogUtil.i("VoicemailStatus.isActive", "VVM disabled"); + return false; + } + } switch (configurationState) { case Status.CONFIGURATION_STATE_NOT_CONFIGURED: case Status.CONFIGURATION_STATE_DISABLED: diff --git a/java/com/android/incallui/spam/SpamAlternativeExperimentUtil.java b/java/com/android/incallui/spam/SpamAlternativeExperimentUtil.java new file mode 100644 index 000000000..52eadcff3 --- /dev/null +++ b/java/com/android/incallui/spam/SpamAlternativeExperimentUtil.java @@ -0,0 +1,52 @@ +/* + * 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.spam; + +import android.content.Context; +import com.android.dialer.common.LogUtil; +import com.android.dialer.configprovider.ConfigProviderBindings; + +/** Returns resource id based on experiment number. */ +public final class SpamAlternativeExperimentUtil { + + /** + * Returns the resource id using a resource name for an experiment where we want to use + * alternative words for the keyword spam. + */ + public static int getResourceIdByName(String resourceName, Context context) { + long experiment = + ConfigProviderBindings.get(context).getLong("experiment_for_alternative_spam_word", 230150); + LogUtil.i( + "SpamAlternativeExperimentUtil.getResourceIdByName", "using experiment %d", experiment); + String modifiedResourceName = resourceName; + if (experiment != 230150) { + modifiedResourceName = resourceName + "_" + experiment; + } + int resourceId = + context + .getResources() + .getIdentifier(modifiedResourceName, "string", context.getPackageName()); + if (resourceId == 0) { + LogUtil.i( + "SpamAlternativeExperimentUtil.getResourceIdByName", + "not found experiment %d", + experiment); + return context.getResources().getIdentifier(resourceName, "string", context.getPackageName()); + } + return resourceId; + } +} diff --git a/java/com/android/incallui/spam/SpamCallListListener.java b/java/com/android/incallui/spam/SpamCallListListener.java index 350dd60fc..d03055568 100644 --- a/java/com/android/incallui/spam/SpamCallListListener.java +++ b/java/com/android/incallui/spam/SpamCallListListener.java @@ -277,11 +277,15 @@ public class SpamCallListListener implements CallList.Listener { Notification.Builder notificationBuilder = createAfterCallNotificationBuilder(call) .setContentText( - context.getString(R.string.spam_notification_non_spam_call_collapsed_text)) + context.getString( + SpamAlternativeExperimentUtil.getResourceIdByName( + "spam_notification_non_spam_call_collapsed_text", context))) .setStyle( new Notification.BigTextStyle() .bigText( - context.getString(R.string.spam_notification_non_spam_call_expanded_text))) + context.getString( + SpamAlternativeExperimentUtil.getResourceIdByName( + "spam_notification_non_spam_call_expanded_text", context)))) // Add contact .addAction( new Notification.Action.Builder( @@ -392,12 +396,17 @@ public class SpamCallListListener implements CallList.Listener { Notification.Builder notificationBuilder = createAfterCallNotificationBuilder(call) .setLargeIcon(Icon.createWithResource(context, R.drawable.spam_notification_icon)) - .setContentText(context.getString(R.string.spam_notification_spam_call_collapsed_text)) + .setContentText( + context.getString( + SpamAlternativeExperimentUtil.getResourceIdByName( + "spam_notification_spam_call_collapsed_text", context))) // Not spam .addAction( new Notification.Action.Builder( R.drawable.quantum_ic_close_vd_theme_24, - context.getString(R.string.spam_notification_was_not_spam_action_text), + context.getString( + SpamAlternativeExperimentUtil.getResourceIdByName( + "spam_notification_was_not_spam_action_text", context)), createNotSpamPendingIntent(call)) .build()) // Block/report spam @@ -408,11 +417,16 @@ public class SpamCallListListener implements CallList.Listener { createBlockReportSpamPendingIntent(call)) .build()) .setContentTitle( - context.getString(R.string.spam_notification_title, getDisplayNumber(call))); + context.getString( + SpamAlternativeExperimentUtil.getResourceIdByName( + "spam_notification_title", context), + getDisplayNumber(call))); DialerNotificationManager.notify( context, getNotificationTagForCall(call), NOTIFICATION_ID, notificationBuilder.build()); } + + /** * Creates a pending intent for block/report spam action. If enabled, this intent is forwarded to * the {@link SpamNotificationActivity}, otherwise to the {@link SpamNotificationService}. diff --git a/java/com/android/incallui/spam/SpamNotificationActivity.java b/java/com/android/incallui/spam/SpamNotificationActivity.java index 37755fc53..4c0c67c92 100644 --- a/java/com/android/incallui/spam/SpamNotificationActivity.java +++ b/java/com/android/incallui/spam/SpamNotificationActivity.java @@ -406,7 +406,9 @@ public class SpamNotificationActivity extends FragmentActivity { .setCancelable(false) .setTitle( getString( - R.string.spam_notification_title, getFormattedNumber(number, applicationContext))) + SpamAlternativeExperimentUtil.getResourceIdByName( + "spam_notification_title", applicationContext), + getFormattedNumber(number, applicationContext))) .setNeutralButton( getString(R.string.spam_notification_action_dismiss), new DialogInterface.OnClickListener() { @@ -428,7 +430,9 @@ public class SpamNotificationActivity extends FragmentActivity { } }) .setNegativeButton( - getString(R.string.spam_notification_was_not_spam_action_text), + getString( + SpamAlternativeExperimentUtil.getResourceIdByName( + "spam_notification_was_not_spam_action_text", applicationContext)), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { @@ -494,7 +498,10 @@ public class SpamNotificationActivity extends FragmentActivity { .setTitle( getString(R.string.non_spam_notification_title, getFormattedNumber(number, context))) .setCancelable(false) - .setMessage(getString(R.string.spam_notification_non_spam_call_expanded_text)) + .setMessage( + getString( + SpamAlternativeExperimentUtil.getResourceIdByName( + "spam_notification_non_spam_call_expanded_text", context))) .setNeutralButton( getString(R.string.spam_notification_action_dismiss), new DialogInterface.OnClickListener() { @@ -514,7 +521,9 @@ public class SpamNotificationActivity extends FragmentActivity { } }) .setNegativeButton( - getString(R.string.spam_notification_dialog_block_report_spam_action_text), + getString( + SpamAlternativeExperimentUtil.getResourceIdByName( + "spam_notification_dialog_block_report_spam_action_text", context)), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { diff --git a/java/com/android/incallui/spam/res/values/strings.xml b/java/com/android/incallui/spam/res/values/strings.xml index e893f2afc..7626754e3 100644 --- a/java/com/android/incallui/spam/res/values/strings.xml +++ b/java/com/android/incallui/spam/res/values/strings.xml @@ -44,6 +44,97 @@ <!-- Text for the blocking spam action in the after call prompt. [CHAR LIMIT=40] --> <string name="spam_notification_block_spam_action_text">Yes, block number</string> + <!-- Strings for 'junk' spam word alternative--> + <!-- Title for the notification to the user after a call from an spammer ends. [CHAR LIMIT=100] --> + <string translatable="false" name="spam_notification_title_230151">Was <xliff:g id="number">%1$s</xliff:g> a junk caller?</string> + <!-- Text for the toast shown after the user presses block/report spam. [CHAR LIMIT=100] --> + <string translatable="false" name="spam_notification_block_report_toast_text_230151"><xliff:g id="number">%1$s</xliff:g> blocked and call was reported as junk.</string> + <!-- Text for the toast shown after the user presses not spam. [CHAR LIMIT=100] --> + <string translatable="false" name="spam_notification_not_spam_toast_text_230151">Call from <xliff:g id="number">%1$s</xliff:g> reported as not junk.</string> + <!-- Text displayed in the collapsed notification to the user after a non-spam call ends. [CHAR LIMIT=100] --> + <string translatable="false" name="spam_notification_non_spam_call_collapsed_text_230151">Tap to add to contacts or block junk number.</string> + <!-- Text displayed in the expanded notification to the user after a non-spam call ends. [CHAR LIMIT=NONE] --> + <string translatable="false" name="spam_notification_non_spam_call_expanded_text_230151">This is the first time this number called you. If this call was junk, you can block this number and report it.</string> + <!-- Text displayed in the collapsed notification to the user after a spam call ends. [CHAR LIMIT=100] --> + <string translatable="false" name="spam_notification_spam_call_collapsed_text_230151">Tap to report as not junk or block it</string> + <!-- Text for the blocking and reporting spam action in the after call dialog. [CHAR LIMIT=40] --> + <string translatable="false" name="spam_notification_dialog_block_report_spam_action_text_230151">Block & report junk</string> + <!-- Text for the marking a call as not spam in the after call prompt. [CHAR LIMIT=40] --> + <string translatable="false" name="spam_notification_was_not_spam_action_text_230151">No, not junk</string> + + <!-- Strings for 'junk/spam' spam word alternative--> + <!-- Title for the notification to the user after a call from an spammer ends. [CHAR LIMIT=100] --> + <string translatable="false" name="spam_notification_title_230152">Was <xliff:g id="number">%1$s</xliff:g> a junk/spam caller?</string> + <!-- Text for the toast shown after the user presses block/report spam. [CHAR LIMIT=100] --> + <string translatable="false" name="spam_notification_block_report_toast_text_230152"><xliff:g id="number">%1$s</xliff:g> blocked and call was reported as junk/spam.</string> + <!-- Text for the toast shown after the user presses not spam. [CHAR LIMIT=100] --> + <string translatable="false" name="spam_notification_not_spam_toast_text_230152">Call from <xliff:g id="number">%1$s</xliff:g> reported as not junk/spam.</string> + <!-- Text displayed in the collapsed notification to the user after a non-spam call ends. [CHAR LIMIT=100] --> + <string translatable="false" name="spam_notification_non_spam_call_collapsed_text_230152">Tap to add to contacts or block junk/spam number.</string> + <!-- Text displayed in the expanded notification to the user after a non-spam call ends. [CHAR LIMIT=NONE] --> + <string translatable="false" name="spam_notification_non_spam_call_expanded_text_230152">This is the first time this number called you. If this call was junk/spam, you can block this number and report it.</string> + <!-- Text displayed in the collapsed notification to the user after a spam call ends. [CHAR LIMIT=100] --> + <string translatable="false" name="spam_notification_spam_call_collapsed_text_230152">Tap to report as not junk/spam or block it</string> + <!-- Text for the blocking and reporting spam action in the after call dialog. [CHAR LIMIT=40] --> + <string translatable="false" name="spam_notification_dialog_block_report_spam_action_text_230152">Block & report junk/spam</string> + <!-- Text for the marking a call as not spam in the after call prompt. [CHAR LIMIT=40] --> + <string translatable="false" name="spam_notification_was_not_spam_action_text_230152">No, not junk/spam</string> + + <!-- Strings for 'unwanted' spam word alternative--> + <!-- Title for the notification to the user after a call from an spammer ends. [CHAR LIMIT=100] --> + <string translatable="false" name="spam_notification_title_230153">Was <xliff:g id="number">%1$s</xliff:g> an unwanted caller?</string> + <!-- Text for the toast shown after the user presses block/report spam. [CHAR LIMIT=100] --> + <string translatable="false" name="spam_notification_block_report_toast_text_230153"><xliff:g id="number">%1$s</xliff:g> blocked and call was reported as unwanted.</string> + <!-- Text for the toast shown after the user presses not spam. [CHAR LIMIT=100] --> + <string translatable="false" name="spam_notification_not_spam_toast_text_230153">Call from <xliff:g id="number">%1$s</xliff:g> reported as useful.</string> + <!-- Text displayed in the collapsed notification to the user after a non-spam call ends. [CHAR LIMIT=100] --> + <string translatable="false" name="spam_notification_non_spam_call_collapsed_text_230153">Tap to add to contacts or block unwanted number.</string> + <!-- Text displayed in the expanded notification to the user after a non-spam call ends. [CHAR LIMIT=NONE] --> + <string translatable="false" name="spam_notification_non_spam_call_expanded_text_230153">This is the first time this number called you. If this call was unwanted, you can block this number and report it.</string> + <!-- Text displayed in the collapsed notification to the user after a spam call ends. [CHAR LIMIT=100] --> + <string translatable="false" name="spam_notification_spam_call_collapsed_text_230153">Tap to report as useful or block it</string> + <!-- Text for the blocking and reporting spam action in the after call dialog. [CHAR LIMIT=40] --> + <string translatable="false" name="spam_notification_dialog_block_report_spam_action_text_230153">Block & report unwanted</string> + <!-- Text for the marking a call as not spam in the after call prompt. [CHAR LIMIT=40] --> + <string translatable="false" name="spam_notification_was_not_spam_action_text_230153">No, not unwanted</string> + + <!-- Strings for 'spam/unwanted' spam word alternative--> + <!-- Title for the notification to the user after a call from an spammer ends. [CHAR LIMIT=100] --> + <string translatable="false" name="spam_notification_title_230154">Was <xliff:g id="number">%1$s</xliff:g> a spam/unwanted caller?</string> + <!-- Text for the toast shown after the user presses block/report spam. [CHAR LIMIT=100] --> + <string translatable="false" name="spam_notification_block_report_toast_text_230154"><xliff:g id="number">%1$s</xliff:g> blocked and call was reported as spam/unwanted.</string> + <!-- Text for the toast shown after the user presses not spam. [CHAR LIMIT=100] --> + <string translatable="false" name="spam_notification_not_spam_toast_text_230154">Call from <xliff:g id="number">%1$s</xliff:g> reported as not spam/unwanted.</string> + <!-- Text displayed in the collapsed notification to the user after a non-spam call ends. [CHAR LIMIT=100] --> + <string translatable="false" name="spam_notification_non_spam_call_collapsed_text_230154">Tap to add to contacts or block spam/unwanted number.</string> + <!-- Text displayed in the expanded notification to the user after a non-spam call ends. [CHAR LIMIT=NONE] --> + <string translatable="false" name="spam_notification_non_spam_call_expanded_text_230154">This is the first time this number called you. If this call was spam/unwanted, you can block this number and report it.</string> + <!-- Text displayed in the collapsed notification to the user after a spam call ends. [CHAR LIMIT=100] --> + <string translatable="false" name="spam_notification_spam_call_collapsed_text_230154">Tap to report as not spam/unwanted or block it</string> + <!-- Text for the blocking and reporting spam action in the after call dialog. [CHAR LIMIT=40] --> + <string translatable="false" name="spam_notification_dialog_block_report_spam_action_text_230154">Block & report spam/unwanted</string> + <!-- Text for the marking a call as not spam in the after call prompt. [CHAR LIMIT=40] --> + <string translatable="false" name="spam_notification_was_not_spam_action_text_230154">No, not spam/unwanted</string> + + <!-- Strings for 'junk/unwanted' spam word alternative--> + <!-- Title for the notification to the user after a call from an spammer ends. [CHAR LIMIT=100] --> + <string translatable="false" name="spam_notification_title_230155">Was <xliff:g id="number">%1$s</xliff:g> a junk/unwanted caller?</string> + <!-- Text for the toast shown after the user presses block/report spam. [CHAR LIMIT=100] --> + <string translatable="false" name="spam_notification_block_report_toast_text_230155"><xliff:g id="number">%1$s</xliff:g> blocked and call was reported as junk/unwanted.</string> + <!-- Text for the toast shown after the user presses not spam. [CHAR LIMIT=100] --> + <string translatable="false" name="spam_notification_not_spam_toast_text_230155">Call from <xliff:g id="number">%1$s</xliff:g> reported as not junk/unwanted.</string> + <!-- Text displayed in the collapsed notification to the user after a non-spam call ends. [CHAR LIMIT=100] --> + <string translatable="false" name="spam_notification_non_spam_call_collapsed_text_230155">Tap to add to contacts or block junk/unwanted number.</string> + <!-- Text displayed in the expanded notification to the user after a non-spam call ends. [CHAR LIMIT=NONE] --> + <string translatable="false" name="spam_notification_non_spam_call_expanded_text_230155">This is the first time this number called you. If this call was junk/unwanted, you can block this number and report it.</string> + <!-- Text displayed in the collapsed notification to the user after a spam call ends. [CHAR LIMIT=100] --> + <string translatable="false" name="spam_notification_spam_call_collapsed_text_230155">Tap to report as not junk/unwanted or block it</string> + <!-- Text for the blocking and reporting spam action in the after call dialog. [CHAR LIMIT=40] --> + <string translatable="false" name="spam_notification_dialog_block_report_spam_action_text_230155">Block & report junk/unwanted</string> + <!-- Text for the marking a call as not spam in the after call prompt. [CHAR LIMIT=40] --> + <string translatable="false" name="spam_notification_was_not_spam_action_text_230155">No, not junk/unwanted</string> + + <!-- Label for "Dismiss" dialog action. [CHAR LIMIT=12] --> <string name="spam_notification_action_dismiss">Dismiss</string> |