Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License |
| 15 | */ |
| 16 | |
| 17 | package com.android.voicemailomtp; |
| 18 | |
| 19 | import android.content.Intent; |
| 20 | import android.telecom.PhoneAccountHandle; |
| 21 | import android.telephony.VisualVoicemailService; |
| 22 | import android.telephony.VisualVoicemailSms; |
| 23 | |
| 24 | import com.android.voicemailomtp.sync.OmtpVvmSourceManager; |
| 25 | |
| 26 | public class OmtpService extends VisualVoicemailService { |
| 27 | |
| 28 | private static String TAG = "VvmOmtpService"; |
| 29 | |
| 30 | public static final String ACTION_SMS_RECEIVED = "com.android.vociemailomtp.sms.sms_received"; |
| 31 | |
| 32 | public static final String EXTRA_VOICEMAIL_SMS = "extra_voicemail_sms"; |
| 33 | |
| 34 | @Override |
| 35 | public void onCellServiceConnected(VisualVoicemailTask task, |
| 36 | final PhoneAccountHandle phoneAccountHandle) { |
| 37 | VvmLog.i(TAG, "onCellServiceConnected"); |
| 38 | ActivationTask |
| 39 | .start(OmtpService.this, phoneAccountHandle, null); |
| 40 | task.finish(); |
| 41 | } |
| 42 | |
| 43 | @Override |
| 44 | public void onSmsReceived(VisualVoicemailTask task, final VisualVoicemailSms sms) { |
| 45 | VvmLog.i(TAG, "onSmsReceived"); |
| 46 | Intent intent = new Intent(ACTION_SMS_RECEIVED); |
| 47 | intent.setPackage(getPackageName()); |
| 48 | intent.putExtra(EXTRA_VOICEMAIL_SMS, sms); |
| 49 | sendBroadcast(intent); |
| 50 | task.finish(); |
| 51 | } |
| 52 | |
| 53 | @Override |
| 54 | public void onSimRemoved(final VisualVoicemailTask task, |
| 55 | final PhoneAccountHandle phoneAccountHandle) { |
| 56 | VvmLog.i(TAG, "onSimRemoved"); |
| 57 | OmtpVvmSourceManager.getInstance(OmtpService.this).removeSource(phoneAccountHandle); |
| 58 | task.finish(); |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | public void onStopped(VisualVoicemailTask task) { |
| 63 | VvmLog.i(TAG, "onStopped"); |
| 64 | } |
| 65 | } |