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.phone.vvm.omtp.sms; 18 19 import android.app.IntentService; 20 import android.content.Context; 21 import android.content.Intent; 22 import android.os.Bundle; 23 import android.provider.VoicemailContract; 24 import android.telecom.PhoneAccountHandle; 25 26 import com.android.phone.PhoneUtils; 27 import com.android.phone.vvm.omtp.OmtpVvmCarrierConfigHelper; 28 import com.android.phone.vvm.omtp.utils.PhoneAccountHandleConverter; 29 30 /** 31 * Performs visual voicemail provisioning in background thread. Not exported. 32 */ 33 public class OmtpProvisioningService extends IntentService { 34 OmtpProvisioningService()35 public OmtpProvisioningService() { 36 super("OmtpProvisioningService"); 37 } 38 39 /** 40 * Create an intent to start OmtpProvisioningService from a {@link 41 * VoicemailContract.ACTION_VOICEMAIL_SMS_RECEIVED} intent. 42 */ getProvisionIntent(Context context, Intent messageIntent)43 public static Intent getProvisionIntent(Context context, Intent messageIntent) { 44 Intent serviceIntent = new Intent(context, OmtpProvisioningService.class); 45 46 serviceIntent.putExtra(VoicemailContract.EXTRA_VOICEMAIL_SMS_SUBID, 47 messageIntent.getExtras().getInt(VoicemailContract.EXTRA_VOICEMAIL_SMS_SUBID)); 48 serviceIntent.putExtra(VoicemailContract.EXTRA_VOICEMAIL_SMS_FIELDS, 49 messageIntent.getExtras().getBundle(VoicemailContract.EXTRA_VOICEMAIL_SMS_FIELDS)); 50 51 return serviceIntent; 52 } 53 54 @Override onHandleIntent(Intent intent)55 public void onHandleIntent(Intent intent) { 56 int subId = intent.getExtras().getInt(VoicemailContract.EXTRA_VOICEMAIL_SMS_SUBID); 57 PhoneAccountHandle phone = PhoneAccountHandleConverter.fromSubId(subId); 58 59 Bundle data = intent.getExtras().getBundle(VoicemailContract.EXTRA_VOICEMAIL_SMS_FIELDS); 60 61 StatusMessage message = new StatusMessage(data); 62 startProvisioning(phone, message, data); 63 } 64 startProvisioning(PhoneAccountHandle phone, StatusMessage message, Bundle data)65 private void startProvisioning(PhoneAccountHandle phone, StatusMessage message, Bundle data) { 66 OmtpVvmCarrierConfigHelper helper = new OmtpVvmCarrierConfigHelper(this, 67 PhoneUtils.getSubIdForPhoneAccountHandle(phone)); 68 69 } 70 } 71