• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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;
18 
19 import android.content.BroadcastReceiver;
20 import android.content.Context;
21 import android.content.Intent;
22 import android.telecom.PhoneAccountHandle;
23 import android.telecom.TelecomManager;
24 import android.telephony.SubscriptionManager;
25 import com.android.phone.vvm.omtp.utils.PhoneAccountHandleConverter;
26 
27 /**
28  * Upon boot iterate through all callable phone account to activate visual voicemail. This happens
29  * after the device has been unlocked. {@link android.telephony.CarrierConfigManager#
30  * ACTION_CARRIER_CONFIG_CHANGED} can also trigger activation upon boot but it can happen before the
31  * device is unlocked and visual voicemail will not be activated.
32  *
33  * <p>TODO: An additional duplicated activation request will be sent as a result of this receiver,
34  * but similar issues is already covered in b/28730056 and a scheduling system should be used to
35  * resolve this.
36  */
37 public class VvmBootCompletedReceiver extends BroadcastReceiver {
38 
39     private static final String TAG = "VvmBootCompletedRcvr";
40 
41     @Override
onReceive(Context context, Intent intent)42     public void onReceive(Context context, Intent intent) {
43         // Listens to android.intent.action.BOOT_COMPLETED
44         if (!intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
45             return;
46         }
47 
48         VvmLog.v(TAG, "processing subId list");
49         for (PhoneAccountHandle handle : TelecomManager.from(context)
50                 .getCallCapablePhoneAccounts()) {
51             int subId = PhoneAccountHandleConverter.toSubId(handle);
52             if (!SubscriptionManager.isValidSubscriptionId(subId)) {
53                 // getCallCapablePhoneAccounts() might return a PhoneAccountHandle with invalid
54                 // subId if no SIM is inserted. This is intended as it is for emergency calls.
55                 VvmLog.e(TAG, "phone account " + handle + " has invalid subId " + subId);
56                 continue;
57             }
58             VvmLog.v(TAG, "processing subId " + subId);
59             SimChangeReceiver.processSubId(context, subId);
60         }
61     }
62 }
63