From fc37b02f5d3381a7882770941e461b13b679b6ef Mon Sep 17 00:00:00 2001 From: Eric Erfanian Date: Tue, 21 Mar 2017 10:11:17 -0700 Subject: Update AOSP Dialer source from internal google3 repository at cl/150756069 Test: make, treehugger This CL updates the AOSP Dialer source with all the changes that have gone into the private google3 repository. This includes all the changes from cl/150392808 (3/16/2017) to cl/150756069 (3/21/2017). This goal of these drops is to keep the AOSP source in sync with the internal google3 repository. Currently these sync are done by hand with very minor modifications to the internal source code. See the Android.mk file for list of modifications. Our current goal is to do frequent drops (daily if possible) and eventually switched to an automated process. Change-Id: I0888b5db52efb28eb8194600e0c7804592f975f3 --- java/com/android/voicemail/impl/OmtpReceiver.java | 87 +++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 java/com/android/voicemail/impl/OmtpReceiver.java (limited to 'java/com/android/voicemail/impl/OmtpReceiver.java') diff --git a/java/com/android/voicemail/impl/OmtpReceiver.java b/java/com/android/voicemail/impl/OmtpReceiver.java new file mode 100644 index 000000000..0b871c478 --- /dev/null +++ b/java/com/android/voicemail/impl/OmtpReceiver.java @@ -0,0 +1,87 @@ +/* + * 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.annotation.TargetApi; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.os.Build.VERSION_CODES; +import android.telecom.PhoneAccountHandle; +import android.telephony.VisualVoicemailSms; +import com.android.dialer.common.Assert; +import com.android.dialer.logging.Logger; +import com.android.dialer.logging.nano.DialerImpression; +import com.android.voicemail.impl.sync.VvmAccountManager; + +/** Listens to com.android.phone.vvm.ACTION_TEMP_VISUAL_VOICEMAIL_SERVICE_EVENT */ +@TargetApi(VERSION_CODES.O) +public class OmtpReceiver extends BroadcastReceiver { + + private static final String TAG = "VvmOmtpReceiver"; + + public static final String ACTION_SMS_RECEIVED = "com.android.vociemailomtp.sms.sms_received"; + + public static final String EXTRA_VOICEMAIL_SMS = "extra_voicemail_sms"; + + private static final String EXTRA_WHAT = "what"; + + private static final int MSG_ON_CELL_SERVICE_CONNECTED = 1; + + private static final int MSG_ON_SMS_RECEIVED = 2; + + private static final int MSG_ON_SIM_REMOVED = 3; + + private static final int MSG_TASK_STOPPED = 5; + + private static final String DATA_PHONE_ACCOUNT_HANDLE = "data_phone_account_handle"; + + private static final String DATA_SMS = "data_sms"; + + @Override + public void onReceive(Context context, Intent intent) { + int what = intent.getIntExtra(EXTRA_WHAT, -1); + PhoneAccountHandle phoneAccountHandle = intent.getParcelableExtra(DATA_PHONE_ACCOUNT_HANDLE); + switch (what) { + case MSG_ON_CELL_SERVICE_CONNECTED: + VvmLog.i(TAG, "onCellServiceConnected"); + Logger.get(context).logImpression(DialerImpression.Type.VVM_UNBUNDLED_EVENT_RECEIVED); + ActivationTask.start(context, phoneAccountHandle, null); + break; + case MSG_ON_SMS_RECEIVED: + VvmLog.i(TAG, "onSmsReceived"); + Logger.get(context).logImpression(DialerImpression.Type.VVM_UNBUNDLED_EVENT_RECEIVED); + VisualVoicemailSms sms = intent.getParcelableExtra(DATA_SMS); + Intent receivedIntent = new Intent(ACTION_SMS_RECEIVED); + receivedIntent.setPackage(context.getPackageName()); + receivedIntent.putExtra(EXTRA_VOICEMAIL_SMS, sms); + context.sendBroadcast(receivedIntent); + break; + case MSG_ON_SIM_REMOVED: + VvmLog.i(TAG, "onSimRemoved"); + Logger.get(context).logImpression(DialerImpression.Type.VVM_UNBUNDLED_EVENT_RECEIVED); + VvmAccountManager.removeAccount(context, phoneAccountHandle); + break; + case MSG_TASK_STOPPED: + VvmLog.i(TAG, "onStopped"); + Logger.get(context).logImpression(DialerImpression.Type.VVM_UNBUNDLED_EVENT_RECEIVED); + break; + default: + throw Assert.createIllegalStateFailException("unexpected what: " + what); + } + } +} -- cgit v1.2.3