From 938468da6f5c225ebb161a68bd949c9cf3261892 Mon Sep 17 00:00:00 2001 From: Eric Erfanian Date: Tue, 24 Oct 2017 14:05:52 -0700 Subject: Rename the new bubble package name from "bubble" to "newbubble". It fixes AOSP for package name conflict. Test: manual PiperOrigin-RevId: 173298696 Change-Id: Id10ebe0bcf029e61f65cf6580c7198abd8395081 --- Android.mk | 5 +- .../drawable/quantum_ic_fullscreen_vd_theme_24.xml | 10 + .../android/contacts/common/MoreContactUtils.java | 4 +- .../compat/telecom/TelecomManagerCompat.java | 2 +- .../contacts/common/list/AutoScrollListView.java | 2 +- .../common/list/ContactEntryListFragment.java | 2 +- .../contacts/common/res/drawable/back_arrow.xml | 26 + .../common/res/layout-ldrtl/unread_count_tab.xml | 2 +- .../common/res/layout/search_bar_expanded.xml | 2 +- .../about/res/raw/third_party_license_metadata | 20 +- .../dialer/about/res/raw/third_party_licenses | 22 +- java/com/android/dialer/app/DialtactsActivity.java | 2 +- .../android/dialer/app/calllog/CallLogAdapter.java | 2 +- .../dialer/app/calllog/CallLogAsyncTaskUtil.java | 2 +- .../app/calllog/CallLogListItemViewHolder.java | 5 +- .../dialer/app/calllog/MissedCallNotifier.java | 2 +- .../app/calllog/VisualVoicemailNotifier.java | 2 +- java/com/android/dialer/app/list/RemoveView.java | 2 +- .../app/manifests/activities/AndroidManifest.xml | 9 +- .../dialer/app/res/layout/call_log_list_item.xml | 4 + .../app/settings/DialerSettingsActivity.java | 21 + .../app/voicemail/VoicemailErrorManager.java | 2 +- .../dialer/app/voicemail/error/AndroidManifest.xml | 24 + .../error/OmtpVoicemailMessageCreator.java | 2 +- .../voicemail/error/PackageReplacedReceiver.java | 109 +++ .../error/VoicemailStatusCorruptionHandler.java | 2 +- .../error/VoicemailTosMessageCreator.java | 221 +++++- .../error/Vvm3VoicemailMessageCreator.java | 2 +- .../error/res/layout/voicemail_tos_fragment.xml | 3 +- .../app/voicemail/error/res/values/strings.xml | 21 +- .../app/voicemail/error/res/values/styles.xml | 10 +- .../dialer/app/widget/SearchEditTextLayout.java | 6 - .../dialer/assisteddialing/ConcreteCreator.java | 2 +- .../dialer/assisteddialing/Constraints.java | 8 + .../ui/res/xml/assisted_dialing_setting.xml | 4 +- .../blocking/FilteredNumberAsyncQueryHandler.java | 2 +- .../buildtype/bugfood/BuildTypeAccessorImpl.java | 30 - .../buildtype/dogfood/BuildTypeAccessorImpl.java | 30 - .../buildtype/fishfood/BuildTypeAccessorImpl.java | 30 - .../buildtype/test/BuildTypeAccessorImpl.java | 30 - .../dialer/callcomposer/CallComposerActivity.java | 2 +- .../callcomposer/GalleryComposerFragment.java | 4 +- .../dialer/callcomposer/camera/CameraPreview.java | 2 +- .../calldetails/CallDetailsEntryViewHolder.java | 2 +- .../database/AnnotatedCallLogContentProvider.java | 4 +- .../database/AnnotatedCallLogDatabaseHelper.java | 5 +- .../contract/AnnotatedCallLogContract.java | 14 + .../systemcalllog/SystemCallLogDataSource.java | 8 + .../compat/telephony/TelephonyManagerCompat.java | 6 +- java/com/android/dialer/constants/Constants.java | 3 + .../dialer/constants/aospdialer/ConstantsImpl.java | 6 + .../constants/googledialer/ConstantsImpl.java | 6 + .../contactphoto/ContactPhotoManagerImpl.java | 2 +- .../dialer/database/DialerDatabaseHelper.java | 2 +- .../dialer/enrichedcall/EnrichedCallManager.java | 2 +- .../interactions/PhoneNumberInteraction.java | 12 +- .../android/dialer/logging/contact_source.proto | 2 +- .../android/dialer/logging/dialer_impression.proto | 150 ++-- .../android/dialer/main/impl/AndroidManifest.xml | 4 +- .../notification/NotificationChannelManager.java | 2 +- .../dialer/notification/VoicemailChannelUtils.java | 37 +- .../android/dialer/oem/CequintCallerIdManager.java | 2 +- java/com/android/dialer/oem/MotorolaUtils.java | 2 +- .../dialer/phonenumbercache/ContactInfoHelper.java | 2 +- .../phonenumberproto/dialer_phone_number.proto | 3 +- .../dialer/phonenumberutil/PhoneNumberHelper.java | 125 ++- .../android/dialer/proguard/proguard_base.flags | 1 - .../android/dialer/proguard/proguard_release.flags | 1 - .../dialer/searchfragment/common/Projections.java | 18 +- .../searchfragment/cp2/ContactFilterCursor.java | 16 +- .../dialer/searchfragment/cp2/Cp2Contact.java | 2 +- .../cp2/SearchContactsCursorLoader.java | 2 +- .../searchfragment/list/NewSearchFragment.java | 2 +- .../remote/RemoteContactsCursorLoader.java | 5 +- .../searchfragment/testing/TestCursorSchema.java | 2 +- java/com/android/dialer/simulator/Simulator.java | 2 +- .../strictmode/impl/SystemDialerStrictMode.java | 4 +- .../com/android/dialer/theme/res/values/colors.xml | 4 + java/com/android/dialer/util/PermissionsUtil.java | 4 + java/com/android/dialer/util/ViewUtil.java | 44 ++ .../voicemail/listui/NewVoicemailAdapter.java | 7 +- .../voicemail/listui/NewVoicemailFragment.java | 2 +- .../voicemail/listui/NewVoicemailViewHolder.java | 25 +- .../voicemail/listui/VoicemailCursorLoader.java | 12 +- .../voicemail/listui/VoicemailEntryText.java | 66 ++ .../listui/res/layout/new_voicemail_entry.xml | 1 + .../dialer/voicemail/listui/res/values/strings.xml | 5 +- .../dialer/voicemail/model/VoicemailEntry.java | 10 + java/com/android/incallui/CallButtonPresenter.java | 4 +- java/com/android/incallui/CallerInfo.java | 2 +- .../com/android/incallui/CallerInfoAsyncQuery.java | 4 +- java/com/android/incallui/InCallActivity.java | 8 + .../com/android/incallui/InCallActivityCommon.java | 15 +- java/com/android/incallui/InCallPresenter.java | 5 +- java/com/android/incallui/InCallServiceImpl.java | 8 + .../incallui/NewReturnToCallController.java | 283 +++++++ java/com/android/incallui/StatusBarNotifier.java | 12 +- java/com/android/incallui/VideoCallPresenter.java | 4 +- .../impl/answermethod/FlingUpDownMethod.java | 4 +- .../impl/res/layout/fragment_incoming_call.xml | 2 +- .../AnswerProximitySensor.java | 4 +- .../answerproximitysensor/PseudoScreenState.java | 2 +- .../incallui/audiomode/AudioModeProvider.java | 2 +- .../AudioRouteSelectorDialogFragment.java | 2 +- .../autoresizetext/AutoResizeTextView.java | 2 +- java/com/android/incallui/call/CallList.java | 4 +- java/com/android/incallui/call/DialerCall.java | 22 +- .../impl/GoogleLocationSettingHelper.java | 2 +- .../incallui/calllocation/impl/HttpFetcher.java | 2 +- .../incallui/incall/impl/InCallFragment.java | 4 + .../incall/impl/res/color/incall_button_icon.xml | 18 +- .../incall/impl/res/layout/frag_incall_voice.xml | 147 ++-- .../incallui/incall/protocol/PrimaryCallState.java | 2 +- .../incallui/incall/protocol/PrimaryInfo.java | 2 +- .../incallui/sessiondata/MultimediaFragment.java | 2 +- .../incallui/spam/SpamNotificationActivity.java | 4 +- .../incallui/spam/SpamNotificationService.java | 2 +- .../incallui/video/impl/VideoCallFragment.java | 4 +- .../video/impl/res/layout/video_contact_grid.xml | 2 +- java/com/android/newbubble/AndroidManifest.xml | 22 + java/com/android/newbubble/NewBubble.java | 837 +++++++++++++++++++++ java/com/android/newbubble/NewBubbleInfo.java | 117 +++ .../android/newbubble/NewChangeOnScreenBounds.java | 191 +++++ java/com/android/newbubble/NewCheckableButton.java | 87 +++ java/com/android/newbubble/NewMoveHandler.java | 279 +++++++ java/com/android/newbubble/NewWindowRoot.java | 74 ++ .../res/drawable/bubble_background_with_radius.xml | 25 + .../res/drawable/bubble_ripple_circle.xml | 26 + .../newbubble/res/layout/new_bubble_base.xml | 137 ++++ java/com/android/newbubble/res/values/colors.xml | 25 + java/com/android/newbubble/res/values/values.xml | 32 + java/com/android/voicemail/impl/OmtpService.java | 13 + .../voicemail/impl/OmtpVvmCarrierConfigHelper.java | 31 +- .../voicemail/impl/VvmPhoneStateListener.java | 4 +- .../voicemail/impl/protocol/Vvm3EventHandler.java | 2 +- .../voicemail/impl/protocol/Vvm3Protocol.java | 2 +- .../android/voicemail/impl/res/xml/vvm_config.xml | 6 +- .../voicemail/impl/sync/OmtpVvmSyncService.java | 2 +- .../voicemail/impl/sync/VoicemailsQueryHelper.java | 2 +- .../impl/sync/VvmNetworkRequestCallback.java | 2 +- .../transcribe/grpc/voicemail_transcription.proto | 5 +- 141 files changed, 3326 insertions(+), 505 deletions(-) create mode 100644 assets/quantum/res/drawable/quantum_ic_fullscreen_vd_theme_24.xml create mode 100644 java/com/android/contacts/common/res/drawable/back_arrow.xml create mode 100644 java/com/android/dialer/app/voicemail/error/PackageReplacedReceiver.java delete mode 100644 java/com/android/dialer/buildtype/bugfood/BuildTypeAccessorImpl.java delete mode 100644 java/com/android/dialer/buildtype/dogfood/BuildTypeAccessorImpl.java delete mode 100644 java/com/android/dialer/buildtype/fishfood/BuildTypeAccessorImpl.java delete mode 100644 java/com/android/dialer/buildtype/test/BuildTypeAccessorImpl.java create mode 100644 java/com/android/incallui/NewReturnToCallController.java create mode 100644 java/com/android/newbubble/AndroidManifest.xml create mode 100644 java/com/android/newbubble/NewBubble.java create mode 100644 java/com/android/newbubble/NewBubbleInfo.java create mode 100644 java/com/android/newbubble/NewChangeOnScreenBounds.java create mode 100644 java/com/android/newbubble/NewCheckableButton.java create mode 100644 java/com/android/newbubble/NewMoveHandler.java create mode 100644 java/com/android/newbubble/NewWindowRoot.java create mode 100644 java/com/android/newbubble/res/drawable/bubble_background_with_radius.xml create mode 100644 java/com/android/newbubble/res/drawable/bubble_ripple_circle.xml create mode 100644 java/com/android/newbubble/res/layout/new_bubble_base.xml create mode 100644 java/com/android/newbubble/res/values/colors.xml create mode 100644 java/com/android/newbubble/res/values/values.xml diff --git a/Android.mk b/Android.mk index 82f745f61..f47452baf 100644 --- a/Android.mk +++ b/Android.mk @@ -39,10 +39,6 @@ EXCLUDE_FILES += \ # Exclude build variants for now EXCLUDE_FILES += \ - $(BASE_DIR)/dialer/buildtype/bugfood/BuildTypeAccessorImpl.java \ - $(BASE_DIR)/dialer/buildtype/dogfood/BuildTypeAccessorImpl.java \ - $(BASE_DIR)/dialer/buildtype/fishfood/BuildTypeAccessorImpl.java \ - $(BASE_DIR)/dialer/buildtype/test/BuildTypeAccessorImpl.java \ $(BASE_DIR)/dialer/constants/googledialer/ConstantsImpl.java \ $(BASE_DIR)/dialer/binary/google/GoogleStubDialerRootComponent.java \ $(BASE_DIR)/dialer/binary/google/GoogleStubDialerApplication.java \ @@ -156,6 +152,7 @@ LOCAL_AAPT_FLAGS := \ com.android.incallui.telecomeventui \ com.android.incallui.video.impl \ com.android.incallui.video.protocol \ + com.android.newbubble \ com.android.voicemail \ com.android.voicemail.impl \ com.android.voicemail.impl.configui \ diff --git a/assets/quantum/res/drawable/quantum_ic_fullscreen_vd_theme_24.xml b/assets/quantum/res/drawable/quantum_ic_fullscreen_vd_theme_24.xml new file mode 100644 index 000000000..48e3c3104 --- /dev/null +++ b/assets/quantum/res/drawable/quantum_ic_fullscreen_vd_theme_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/java/com/android/contacts/common/MoreContactUtils.java b/java/com/android/contacts/common/MoreContactUtils.java index 26241b34f..9749cabfd 100644 --- a/java/com/android/contacts/common/MoreContactUtils.java +++ b/java/com/android/contacts/common/MoreContactUtils.java @@ -65,7 +65,7 @@ public class MoreContactUtils { // TODO: Move this to PhoneDataItem.shouldCollapse override private static boolean shouldCollapsePhoneNumbers(String number1, String number2) { - // Work around to address b/20724444. We want to distinguish between #555, *555 and 555. + // Work around to address a bug. We want to distinguish between #555, *555 and 555. // This makes no attempt to distinguish between 555 and 55*5, since 55*5 is an improbable // number. PhoneNumberUtil already distinguishes between 555 and 55#5. if (number1.contains("#") != number2.contains("#") @@ -119,7 +119,7 @@ public class MoreContactUtils { // +14155551212 // 4155551212 // - // From b/7519057, case 2 needs to be equal. But also that bug, case 3 + // From a bug, case 2 needs to be equal. But also that bug, case 3 // below should not be equal. // // case 3) diff --git a/java/com/android/contacts/common/compat/telecom/TelecomManagerCompat.java b/java/com/android/contacts/common/compat/telecom/TelecomManagerCompat.java index 172fb11e3..bb0d3c625 100644 --- a/java/com/android/contacts/common/compat/telecom/TelecomManagerCompat.java +++ b/java/com/android/contacts/common/compat/telecom/TelecomManagerCompat.java @@ -24,7 +24,7 @@ import java.lang.reflect.Field; public class TelecomManagerCompat { // TODO(mdooley): remove once this is available in android.telecom.Call - // b/33779976 + // a bug public static final String EXTRA_LAST_EMERGENCY_CALLBACK_TIME_MILLIS = "android.telecom.extra.LAST_EMERGENCY_CALLBACK_TIME_MILLIS"; diff --git a/java/com/android/contacts/common/list/AutoScrollListView.java b/java/com/android/contacts/common/list/AutoScrollListView.java index 601abf528..8d6455f7f 100644 --- a/java/com/android/contacts/common/list/AutoScrollListView.java +++ b/java/com/android/contacts/common/list/AutoScrollListView.java @@ -116,7 +116,7 @@ public class AutoScrollListView extends ListView { protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); - // Workaround for b/31160338 and b/32778636. + // Workaround for a bug and a bug. if (android.os.Build.VERSION.SDK_INT == Build.VERSION_CODES.N || android.os.Build.VERSION.SDK_INT == Build.VERSION_CODES.N_MR1) { layoutChildren(); diff --git a/java/com/android/contacts/common/list/ContactEntryListFragment.java b/java/com/android/contacts/common/list/ContactEntryListFragment.java index 94551a8c8..c807ea815 100644 --- a/java/com/android/contacts/common/list/ContactEntryListFragment.java +++ b/java/com/android/contacts/common/list/ContactEntryListFragment.java @@ -825,7 +825,7 @@ public abstract class ContactEntryListFragment + + + + diff --git a/java/com/android/contacts/common/res/layout-ldrtl/unread_count_tab.xml b/java/com/android/contacts/common/res/layout-ldrtl/unread_count_tab.xml index 2aa97722d..9e9be95e3 100644 --- a/java/com/android/contacts/common/res/layout-ldrtl/unread_count_tab.xml +++ b/java/com/android/contacts/common/res/layout-ldrtl/unread_count_tab.xml @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. --> - , Void> { private PendingIntent createCallLogPendingIntent(@Nullable Uri callUri) { Intent contentIntent = DialtactsActivity.getShowTabIntent(context, DialtactsPagerAdapter.TAB_INDEX_HISTORY); - // TODO (b/35486204): scroll to call + // TODO (a bug): scroll to call contentIntent.setData(callUri); return PendingIntent.getActivity(context, 0, contentIntent, PendingIntent.FLAG_UPDATE_CURRENT); } diff --git a/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java b/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java index 4fc956fa8..f9cb4bf6c 100644 --- a/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java +++ b/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java @@ -274,7 +274,7 @@ final class VisualVoicemailNotifier { @NonNull Context context, @Nullable NewCall voicemail) { Intent intent = DialtactsActivity.getShowTabIntent(context, DialtactsPagerAdapter.TAB_INDEX_VOICEMAIL); - // TODO (b/35486204): scroll to this voicemail + // TODO (a bug): scroll to this voicemail if (voicemail != null) { intent.setData(voicemail.voicemailUri); } diff --git a/java/com/android/dialer/app/list/RemoveView.java b/java/com/android/dialer/app/list/RemoveView.java index 1d566c5a0..244f2da24 100644 --- a/java/com/android/dialer/app/list/RemoveView.java +++ b/java/com/android/dialer/app/list/RemoveView.java @@ -68,7 +68,7 @@ public class RemoveView extends FrameLayout { switch (action) { case DragEvent.ACTION_DRAG_ENTERED: // TODO: This is temporary solution and should be removed once accessibility for - // drag and drop is supported by framework(b/26871588). + // drag and drop is supported by framework(a bug). sendAccessibilityEvent(AccessibilityEvent.TYPE_ANNOUNCEMENT); setAppearanceHighlighted(); break; diff --git a/java/com/android/dialer/app/manifests/activities/AndroidManifest.xml b/java/com/android/dialer/app/manifests/activities/AndroidManifest.xml index 0729d7293..9e08f5f5d 100644 --- a/java/com/android/dialer/app/manifests/activities/AndroidManifest.xml +++ b/java/com/android/dialer/app/manifests/activities/AndroidManifest.xml @@ -27,6 +27,11 @@ android:name="com.android.dialer.app.settings.DialerSettingsActivity" android:parentActivityName="com.android.dialer.app.DialtactsActivity" android:theme="@style/SettingsStyle"> + + + + + + @@ -107,7 +112,7 @@ - + diff --git a/java/com/android/dialer/app/settings/DialerSettingsActivity.java b/java/com/android/dialer/app/settings/DialerSettingsActivity.java index 706f0985a..89c69ca45 100644 --- a/java/com/android/dialer/app/settings/DialerSettingsActivity.java +++ b/java/com/android/dialer/app/settings/DialerSettingsActivity.java @@ -18,6 +18,7 @@ package com.android.dialer.app.settings; import android.content.Context; 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; @@ -51,11 +52,28 @@ public class DialerSettingsActivity extends AppCompatPreferenceActivity { protected SharedPreferences mPreferences; private boolean migrationStatusOnBuildHeaders; + private List
headers; @Override protected void onCreate(Bundle savedInstanceState) { + LogUtil.enterBlock("DialerSettingsActivity.onCreate"); super.onCreate(savedInstanceState); mPreferences = PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext()); + + Intent intent = getIntent(); + Uri data = intent.getData(); + if (data != null) { + String headerToOpen = data.getSchemeSpecificPart(); + if (headerToOpen != null && headers != null) { + for (Header header : headers) { + if (headerToOpen.equals(header.fragment)) { + LogUtil.i("DialerSettingsActivity.onCreate", "switching to header: " + headerToOpen); + switchToHeader(header); + break; + } + } + } + } } @Override @@ -72,6 +90,9 @@ public class DialerSettingsActivity extends AppCompatPreferenceActivity { @Override public void onBuildHeaders(List
target) { + // Keep a reference to the list of headers (since PreferenceActivity.getHeaders() is @Hide) + headers = target; + if (showDisplayOptions()) { Header displayOptionsHeader = new Header(); displayOptionsHeader.titleRes = R.string.display_options_title; diff --git a/java/com/android/dialer/app/voicemail/VoicemailErrorManager.java b/java/com/android/dialer/app/voicemail/VoicemailErrorManager.java index bc6ffb5a7..39ef3fab8 100644 --- a/java/com/android/dialer/app/voicemail/VoicemailErrorManager.java +++ b/java/com/android/dialer/app/voicemail/VoicemailErrorManager.java @@ -92,7 +92,7 @@ public class VoicemailErrorManager implements CallLogQueryHandler.Listener, Voic } } alertItem.updateStatus(statuses, this); - // TODO(twyen): b/30668323 support error from multiple sources. + // TODO(twyen): a bug support error from multiple sources. return; } diff --git a/java/com/android/dialer/app/voicemail/error/AndroidManifest.xml b/java/com/android/dialer/app/voicemail/error/AndroidManifest.xml index 65d043034..bb6c55f5c 100644 --- a/java/com/android/dialer/app/voicemail/error/AndroidManifest.xml +++ b/java/com/android/dialer/app/voicemail/error/AndroidManifest.xml @@ -1,5 +1,29 @@ + + + + + + + + + + + diff --git a/java/com/android/dialer/app/voicemail/error/OmtpVoicemailMessageCreator.java b/java/com/android/dialer/app/voicemail/error/OmtpVoicemailMessageCreator.java index 79e038332..9c8b1469e 100644 --- a/java/com/android/dialer/app/voicemail/error/OmtpVoicemailMessageCreator.java +++ b/java/com/android/dialer/app/voicemail/error/OmtpVoicemailMessageCreator.java @@ -129,7 +129,7 @@ public class OmtpVoicemailMessageCreator { VoicemailErrorMessage.createRetryAction(context, status)); } - // This should be an assertion error, but there's a bug in NYC-DR (b/31069259) that will + // This should be an assertion error, but there's a bug in NYC-DR (a bug) that will // sometimes give status mixed from multiple SIMs. There's no meaningful message to be displayed // from it, so just suppress the message. LogUtil.e("OmtpVoicemailMessageCreator.create", "Unhandled status: " + status); diff --git a/java/com/android/dialer/app/voicemail/error/PackageReplacedReceiver.java b/java/com/android/dialer/app/voicemail/error/PackageReplacedReceiver.java new file mode 100644 index 000000000..64d72b18f --- /dev/null +++ b/java/com/android/dialer/app/voicemail/error/PackageReplacedReceiver.java @@ -0,0 +1,109 @@ +/* + * 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.dialer.app.voicemail.error; + +import android.annotation.TargetApi; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.database.Cursor; +import android.net.Uri; +import android.preference.PreferenceManager; +import android.provider.CallLog.Calls; +import android.provider.VoicemailContract.Voicemails; +import com.android.dialer.common.LogUtil; +import com.android.dialer.common.concurrent.DialerExecutor.Worker; +import com.android.dialer.common.concurrent.DialerExecutorComponent; + +/** Receives MY_PACKAGE_REPLACED to check for legacy voicemail users. */ +public class PackageReplacedReceiver extends BroadcastReceiver { + + @Override + public void onReceive(Context context, Intent intent) { + LogUtil.enterBlock("PackageReplacedReceiver.onReceive"); + + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + if (!prefs.contains(VoicemailTosMessageCreator.PREF_DIALER_FEATURE_VERSION_ACKNOWLEDGED_KEY)) { + setVoicemailFeatureVersionAsync(context); + } + } + + private void setVoicemailFeatureVersionAsync(Context context) { + LogUtil.enterBlock("PackageReplacedReceiver.setVoicemailFeatureVersionAsync"); + + // Check if user is already using voicemail (ie do they have any voicemails), and set the + // acknowledged feature value accordingly. + PendingResult pendingResult = goAsync(); + DialerExecutorComponent.get(context) + .dialerExecutorFactory() + .createNonUiTaskBuilder(new ExistingVoicemailCheck(context)) + .onSuccess( + output -> { + LogUtil.i("PackageReplacedReceiver.setVoicemailFeatureVersionAsync", "success"); + pendingResult.finish(); + }) + .onFailure( + throwable -> { + LogUtil.i("PackageReplacedReceiver.setVoicemailFeatureVersionAsync", "failure"); + pendingResult.finish(); + }) + .build() + .executeParallel(null); + } + + private static class ExistingVoicemailCheck implements Worker { + private static final String[] PROJECTION = new String[] {Voicemails._ID}; + + private final Context context; + + ExistingVoicemailCheck(Context context) { + this.context = context; + } + + @TargetApi(android.os.Build.VERSION_CODES.M) // used for try with resources + @Override + public Void doInBackground(Void arg) throws Throwable { + LogUtil.i("PackageReplacedReceiver.ExistingVoicemailCheck.doInBackground", ""); + + // Check the database for existing voicemails. + boolean hasVoicemails = false; + Uri uri = Voicemails.buildSourceUri(context.getPackageName()); + String whereClause = Calls.TYPE + " = " + Calls.VOICEMAIL_TYPE; + try (Cursor cursor = + context.getContentResolver().query(uri, PROJECTION, whereClause, null, null)) { + if (cursor == null) { + LogUtil.e( + "PackageReplacedReceiver.ExistingVoicemailCheck.doInBackground", + "failed to check for existing voicemails"); + } else if (cursor.moveToNext()) { + hasVoicemails = true; + } + } + + LogUtil.i( + "PackageReplacedReceiver.ExistingVoicemailCheck.doInBackground", + "has voicemails: " + hasVoicemails); + int version = hasVoicemails ? VoicemailTosMessageCreator.LEGACY_VOICEMAIL_FEATURE_VERSION : 0; + PreferenceManager.getDefaultSharedPreferences(context) + .edit() + .putInt(VoicemailTosMessageCreator.PREF_DIALER_FEATURE_VERSION_ACKNOWLEDGED_KEY, version) + .apply(); + return null; + } + } +} diff --git a/java/com/android/dialer/app/voicemail/error/VoicemailStatusCorruptionHandler.java b/java/com/android/dialer/app/voicemail/error/VoicemailStatusCorruptionHandler.java index bbba7ac76..b357f9a4d 100644 --- a/java/com/android/dialer/app/voicemail/error/VoicemailStatusCorruptionHandler.java +++ b/java/com/android/dialer/app/voicemail/error/VoicemailStatusCorruptionHandler.java @@ -82,7 +82,7 @@ public class VoicemailStatusCorruptionHandler { // 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 (b/32371710). The client should be reset or the VVM tab will be + // 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) { diff --git a/java/com/android/dialer/app/voicemail/error/VoicemailTosMessageCreator.java b/java/com/android/dialer/app/voicemail/error/VoicemailTosMessageCreator.java index 63ebd1959..96850ad02 100644 --- a/java/com/android/dialer/app/voicemail/error/VoicemailTosMessageCreator.java +++ b/java/com/android/dialer/app/voicemail/error/VoicemailTosMessageCreator.java @@ -22,6 +22,7 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; +import android.net.Uri; import android.os.Build; import android.preference.PreferenceManager; import android.support.annotation.Nullable; @@ -40,6 +41,7 @@ import com.android.dialer.app.voicemail.error.VoicemailErrorMessage.Action; import com.android.dialer.common.LogUtil; import com.android.dialer.compat.telephony.TelephonyManagerCompat; import com.android.dialer.configprovider.ConfigProviderBindings; +import com.android.dialer.constants.Constants; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; import com.android.voicemail.VisualVoicemailTypeExtensions; @@ -52,14 +54,21 @@ import java.util.Locale; * terms of service for Verizon and for other carriers. */ public class VoicemailTosMessageCreator { - // Flag to check which version of the Verizon ToS that the user has accepted. - public static final String VVM3_TOS_VERSION_ACCEPTED_KEY = "vvm3_tos_version_accepted"; + // Preference key to check which version of the Verizon ToS that the user has accepted. + static final String PREF_VVM3_TOS_VERSION_ACCEPTED_KEY = "vvm3_tos_version_accepted"; - // Flag to check which version of the Google Dialer ToS that the user has accepted. - public static final String DIALER_TOS_VERSION_ACCEPTED_KEY = "dialer_tos_version_accepted"; + // Preference key to check which version of the Google Dialer ToS that the user has accepted. + static final String PREF_DIALER_TOS_VERSION_ACCEPTED_KEY = "dialer_tos_version_accepted"; - public static final int CURRENT_VVM3_TOS_VERSION = 2; - public static final int CURRENT_DIALER_TOS_VERSION = 1; + // Preference key to check which feature version the user has acknowledged + static final String PREF_DIALER_FEATURE_VERSION_ACKNOWLEDGED_KEY = + "dialer_feature_version_acknowledged"; + + static final int CURRENT_VVM3_TOS_VERSION = 2; + static final int CURRENT_DIALER_TOS_VERSION = 1; + static final int LEGACY_VOICEMAIL_FEATURE_VERSION = 1; // original visual voicemail + static final int TRANSCRIPTION_VOICEMAIL_FEATURE_VERSION = 2; // adds voicemail transcription + static final int CURRENT_VOICEMAIL_FEATURE_VERSION = TRANSCRIPTION_VOICEMAIL_FEATURE_VERSION; private static final String ISO639_SPANISH = "es"; @@ -81,25 +90,28 @@ public class VoicemailTosMessageCreator { @Nullable VoicemailErrorMessage maybeCreateTosMessage() { - if (hasAcceptedTos()) { + if (!canShowTos()) { return null; - } - - if (!shouldShowTos()) { + } else if (shouldShowTos()) { + logTosCreatedImpression(); + return getTosMessage(); + } else if (shouldShowPromo()) { + return getPromoMessage(); + } else { return null; } + } - logTosCreatedImpression(); - + private VoicemailErrorMessage getTosMessage() { return new VoicemailTosMessage( - getTosTitle(), - getTosMessage(), + getNewUserTosTitle(), + getNewUserTosMessageText(), new Action( getDeclineText(), new OnClickListener() { @Override public void onClick(View v) { - LogUtil.i("VoicemailTosMessageCreator.maybeShowTosMessage", "decline clicked"); + LogUtil.i("VoicemailTosMessageCreator.getTosMessage", "decline clicked"); PhoneAccountHandle handle = new PhoneAccountHandle( ComponentName.unflattenFromString(status.phoneAccountComponentName), @@ -113,8 +125,10 @@ public class VoicemailTosMessageCreator { new OnClickListener() { @Override public void onClick(View v) { - LogUtil.i("VoicemailTosMessageCreator.maybeShowTosMessage", "accept clicked"); + LogUtil.i("VoicemailTosMessageCreator.getTosMessage", "accept clicked"); recordTosAcceptance(); + // Accepting the TOS also acknowledges the latest features + recordFeatureAcknowledgement(); logTosAcceptedImpression(); statusReader.refresh(); } @@ -124,15 +138,65 @@ public class VoicemailTosMessageCreator { .setImageResourceId(R.drawable.voicemail_tos_image); } - private boolean shouldShowTos() { + private VoicemailErrorMessage getPromoMessage() { + return new VoicemailTosMessage( + getExistingUserTosTitle(), + getExistingUserTosMessageText(), + new Action( + context.getString(R.string.dialer_terms_and_conditions_existing_user_setings), + new OnClickListener() { + @Override + public void onClick(View v) { + LogUtil.i("VoicemailTosMessageCreator.getPromoMessage", "open settings"); + Intent intent = + new Intent(Intent.ACTION_VIEW) + .setComponent( + new ComponentName(context, Constants.get().getSettingsActivity())) + .setData( + Uri.fromParts( + "header", + VoicemailComponent.get(context) + .getVoicemailClient() + .getSettingsFragment(), + null)); + context.startActivity(intent); + } + }), + new Action( + context.getString(R.string.dialer_terms_and_conditions_existing_user_ack), + new OnClickListener() { + @Override + public void onClick(View v) { + LogUtil.i("VoicemailTosMessageCreator.getPromoMessage", "acknowledge clicked"); + // Feature acknowledgement also means accepting TOS + recordTosAcceptance(); + recordFeatureAcknowledgement(); + statusReader.refresh(); + } + }, + true /* raised */)) + .setModal(true) + .setImageResourceId(R.drawable.voicemail_tos_image); + } + + private boolean canShowTos() { if (!isValidVoicemailType(status.type)) { - LogUtil.i("VoicemailTosMessageCreator.shouldShowTos", "unsupported type: " + status.type); + LogUtil.i("VoicemailTosMessageCreator.canShowTos", "unsupported type: " + status.type); return false; } if (status.getPhoneAccountHandle() == null || status.getPhoneAccountHandle().getComponentName() == null) { - LogUtil.i("VoicemailTosMessageCreator.shouldShowTos", "invalid phone account"); + LogUtil.i("VoicemailTosMessageCreator.canShowTos", "invalid phone account"); + return false; + } + + return true; + } + + private boolean shouldShowTos() { + if (hasAcceptedTos()) { + LogUtil.i("VoicemailTosMessageCreator.shouldShowTos", "already accepted TOS"); return false; } @@ -141,7 +205,7 @@ public class VoicemailTosMessageCreator { return true; } - if (isVoicemailTranscriptionEnabled()) { + if (isVoicemailTranscriptionEnabled() && !isLegacyVoicemailUser()) { LogUtil.i( "VoicemailTosMessageCreator.shouldShowTos", "showing TOS for Google transcription users"); return true; @@ -150,6 +214,23 @@ public class VoicemailTosMessageCreator { return false; } + private boolean shouldShowPromo() { + if (hasAcknowledgedFeatures()) { + LogUtil.i( + "VoicemailTosMessageCreator.shouldShowPromo", "already acknowledeged latest features"); + return false; + } + + if (isVoicemailTranscriptionEnabled()) { + LogUtil.i( + "VoicemailTosMessageCreator.shouldShowPromo", + "showing promo for Google transcription users"); + return true; + } + + return false; + } + private static boolean isValidVoicemailType(String type) { if (type == null) { return false; @@ -181,6 +262,7 @@ public class VoicemailTosMessageCreator { "showing decline ToS dialog, status=" + status); final TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class); AlertDialog.Builder builder = new AlertDialog.Builder(context); + builder.setTitle(R.string.terms_and_conditions_decline_dialog_title); builder.setMessage(getTosDeclinedDialogMessageId()); builder.setPositiveButton( getTosDeclinedDialogDowngradeId(), @@ -249,24 +331,49 @@ public class VoicemailTosMessageCreator { private boolean hasAcceptedTos() { if (isVvm3()) { - return preferences.getInt(VVM3_TOS_VERSION_ACCEPTED_KEY, 0) >= CURRENT_VVM3_TOS_VERSION; + return preferences.getInt(PREF_VVM3_TOS_VERSION_ACCEPTED_KEY, 0) >= CURRENT_VVM3_TOS_VERSION; } else { - return preferences.getInt(DIALER_TOS_VERSION_ACCEPTED_KEY, 0) >= CURRENT_DIALER_TOS_VERSION; + return preferences.getInt(PREF_DIALER_TOS_VERSION_ACCEPTED_KEY, 0) + >= CURRENT_DIALER_TOS_VERSION; } } private void recordTosAcceptance() { if (isVvm3()) { - preferences.edit().putInt(VVM3_TOS_VERSION_ACCEPTED_KEY, CURRENT_VVM3_TOS_VERSION).apply(); + preferences + .edit() + .putInt(PREF_VVM3_TOS_VERSION_ACCEPTED_KEY, CURRENT_VVM3_TOS_VERSION) + .apply(); } else { preferences .edit() - .putInt(DIALER_TOS_VERSION_ACCEPTED_KEY, CURRENT_DIALER_TOS_VERSION) + .putInt(PREF_DIALER_TOS_VERSION_ACCEPTED_KEY, CURRENT_DIALER_TOS_VERSION) .apply(); } VoicemailComponent.get(context).getVoicemailClient().onTosAccepted(context); } + private boolean hasAcknowledgedFeatures() { + if (isVvm3()) { + return true; + } + + return preferences.getInt(PREF_DIALER_FEATURE_VERSION_ACKNOWLEDGED_KEY, 0) + >= CURRENT_VOICEMAIL_FEATURE_VERSION; + } + + private void recordFeatureAcknowledgement() { + preferences + .edit() + .putInt(PREF_DIALER_FEATURE_VERSION_ACKNOWLEDGED_KEY, CURRENT_VOICEMAIL_FEATURE_VERSION) + .apply(); + } + + private boolean isLegacyVoicemailUser() { + return preferences.getInt(PREF_DIALER_FEATURE_VERSION_ACKNOWLEDGED_KEY, 0) + == LEGACY_VOICEMAIL_FEATURE_VERSION; + } + private void logTosCreatedImpression() { if (isVvm3()) { Logger.get(context).logImpression(DialerImpression.Type.VOICEMAIL_VVM3_TOS_V2_CREATED); @@ -299,17 +406,30 @@ public class VoicemailTosMessageCreator { : context.getString(R.string.verizon_terms_and_conditions_1_1_english, policyUrl); } - private CharSequence getDialerTos() { + private CharSequence getVvmDialerTos() { if (!isVoicemailTranscriptionEnabled()) { return ""; } - if (isVvm3()) { - return context.getString(R.string.dialer_terms_and_conditions_for_verizon_1_0); - } else { - String learnMoreText = context.getString(R.string.dialer_terms_and_conditions_learn_more); - return context.getString(R.string.dialer_terms_and_conditions_1_0, learnMoreText); + return context.getString(R.string.dialer_terms_and_conditions_for_verizon_1_0); + } + + private CharSequence getNewUserDialerTos() { + if (!isVoicemailTranscriptionEnabled()) { + return ""; + } + + String learnMoreText = context.getString(R.string.dialer_terms_and_conditions_learn_more); + return context.getString(R.string.dialer_terms_and_conditions_1_0, learnMoreText); + } + + private CharSequence getExistingUserDialerTos() { + if (!isVoicemailTranscriptionEnabled()) { + return ""; } + + String learnMoreText = context.getString(R.string.dialer_terms_and_conditions_learn_more); + return context.getString(R.string.dialer_terms_and_conditions_existing_user, learnMoreText); } private CharSequence getAcceptText() { @@ -336,13 +456,19 @@ public class VoicemailTosMessageCreator { } } - private CharSequence getTosTitle() { + private CharSequence getNewUserTosTitle() { return isVvm3() ? context.getString(R.string.verizon_terms_and_conditions_title) : context.getString(R.string.dialer_terms_and_conditions_title); } - private CharSequence getTosMessage() { + private CharSequence getExistingUserTosTitle() { + return isVvm3() + ? context.getString(R.string.verizon_terms_and_conditions_title) + : context.getString(R.string.dialer_terms_and_conditions_existing_user_title); + } + + private CharSequence getNewUserTosMessageText() { SpannableString spannableTos; if (isVvm3()) { // For verizon the TOS consist of three pieces: google dialer TOS, Verizon TOS message and @@ -350,7 +476,7 @@ public class VoicemailTosMessageCreator { CharSequence vvm3Details = getVvm3Tos(); CharSequence tos = context.getString( - R.string.verizon_terms_and_conditions_message, getDialerTos(), vvm3Details); + R.string.verizon_terms_and_conditions_message, getVvmDialerTos(), vvm3Details); spannableTos = new SpannableString(tos); // Set the text style for the details part of the TOS int start = spannableTos.length() - vvm3Details.length(); @@ -365,7 +491,7 @@ public class VoicemailTosMessageCreator { } else { // The TOS for everyone else, there are no details, but change to center alignment. CharSequence tos = - context.getString(R.string.dialer_terms_and_conditions_message, getDialerTos()); + context.getString(R.string.dialer_terms_and_conditions_message, getNewUserDialerTos()); spannableTos = new SpannableString(tos); spannableTos.setSpan( new AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER), @@ -375,11 +501,27 @@ public class VoicemailTosMessageCreator { // Add 'Learn more' link for dialer TOS String learnMore = context.getString(R.string.dialer_terms_and_conditions_learn_more); - String linkUrl = context.getString(R.string.dialer_terms_and_conditions_learn_more_url); - return addLink(spannableTos, learnMore, linkUrl); + return addLink(spannableTos, learnMore, getLearnMoreUrl()); } } + private CharSequence getExistingUserTosMessageText() { + SpannableString spannableTos; + // Change to center alignment. + CharSequence tos = + context.getString(R.string.dialer_terms_and_conditions_message, getExistingUserDialerTos()); + spannableTos = new SpannableString(tos); + spannableTos.setSpan( + new AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER), + 0, + tos.length(), + Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + + // Add 'Learn more' link for dialer TOS + String learnMore = context.getString(R.string.dialer_terms_and_conditions_learn_more); + return addLink(spannableTos, learnMore, getLearnMoreUrl()); + } + private SpannableString addLink(SpannableString spannable, String linkText, String linkUrl) { if (TextUtils.isEmpty(linkUrl) || TextUtils.isEmpty(linkText)) { return spannable; @@ -398,6 +540,13 @@ public class VoicemailTosMessageCreator { return spannable; } + private String getLearnMoreUrl() { + return ConfigProviderBindings.get(context) + .getString( + "voicemail_transcription_learn_more_url", + context.getString(R.string.dialer_terms_and_conditions_learn_more_url)); + } + private int getTosDeclinedDialogMessageId() { return isVvm3() ? R.string.verizon_terms_and_conditions_decline_dialog_message diff --git a/java/com/android/dialer/app/voicemail/error/Vvm3VoicemailMessageCreator.java b/java/com/android/dialer/app/voicemail/error/Vvm3VoicemailMessageCreator.java index 8e8106b44..748b8142a 100644 --- a/java/com/android/dialer/app/voicemail/error/Vvm3VoicemailMessageCreator.java +++ b/java/com/android/dialer/app/voicemail/error/Vvm3VoicemailMessageCreator.java @@ -39,7 +39,7 @@ import com.android.dialer.logging.Logger; public class Vvm3VoicemailMessageCreator { // Copied from com.android.phone.vvm.omtp.protocol.Vvm3EventHandler - // TODO(b/28380841): unbundle VVM client so we can access these values directly + // TODO(a bug): unbundle VVM client so we can access these values directly public static final int VMS_DNS_FAILURE = -9001; public static final int VMG_DNS_FAILURE = -9002; public static final int SPG_DNS_FAILURE = -9003; diff --git a/java/com/android/dialer/app/voicemail/error/res/layout/voicemail_tos_fragment.xml b/java/com/android/dialer/app/voicemail/error/res/layout/voicemail_tos_fragment.xml index 184a81fec..4e143a59a 100644 --- a/java/com/android/dialer/app/voicemail/error/res/layout/voicemail_tos_fragment.xml +++ b/java/com/android/dialer/app/voicemail/error/res/layout/voicemail_tos_fragment.xml @@ -73,6 +73,7 @@ android:paddingEnd="16dp" android:paddingTop="10dp" android:paddingBottom="10dp" + android:background="#ffffffff" android:orientation="horizontal"> %1$s By turning on visual voicemail you agree to the Verizon Wireless terms and conditions:\n\n%2$s Turn on visual voicemail + + New! Read your voicemail %s @@ -173,14 +175,16 @@ Si no acepta todos estos términos y condiciones, no use el buzón de voz visual See and listen to your messages, without having to call voicemail. Transcripts of your voicemail are provided by Google’s free transcription service. %s + + Transcripts of your voicemail are now provided by Google’s free transcription service. %s + + See and listen to your messages, without having to call voicemail. Learn more - - - https://www.google.com + https://support.google.com/phoneapp/answer/2811844?hl=en%26ref_topic=7539039 http://www.verizon.com/about/privacy/policy/ @@ -194,11 +198,16 @@ Si no acepta todos estos términos y condiciones, no use el buzón de voz visual No Thanks Rechazar + Ok, got it + Settings + + Disable visual voicemail? + Visual voicemail will be disabled if the terms and conditions are declined. - Disable visual voicemail + Disable - Visual voicemail will be disabled if the terms and conditions are declined. - Disable visual voicemail + Visual voicemail will be disabled if you turn off visual voicemail. + Disable Voicemail will only be accessible by calling *86. Set a new voicemail PIN to proceed. Set PIN diff --git a/java/com/android/dialer/app/voicemail/error/res/values/styles.xml b/java/com/android/dialer/app/voicemail/error/res/values/styles.xml index 938c77a01..bf70240b6 100644 --- a/java/com/android/dialer/app/voicemail/error/res/values/styles.xml +++ b/java/com/android/dialer/app/voicemail/error/res/values/styles.xml @@ -20,32 +20,32 @@ wrap_content 48dp end|center_vertical - 8dp - 8dp 8dp 8dp + 8dp @color/dialer_theme_color "sans-serif-medium" true true true 14sp + 48dp