UiccPhoneBookController.java revision 6a5ef38e6ae3d3a3ad90ae180388fe85de0495a2
1a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville/* 2a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville * Copyright (C) 2008 The Android Open Source Project 3a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville * Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. 4a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville * Not a Contribution. 5a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville * 6a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville * Licensed under the Apache License, Version 2.0 (the "License"); 7a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville * you may not use this file except in compliance with the License. 8a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville * You may obtain a copy of the License at 9a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville * 10a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville * http://www.apache.org/licenses/LICENSE-2.0 11a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville * 12a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville * Unless required by applicable law or agreed to in writing, software 13a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville * distributed under the License is distributed on an "AS IS" BASIS, 14a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville * See the License for the specific language governing permissions and 16a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville * limitations under the License. 17a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville */ 18a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville 19a8467dd0c524787104b1ccdddc5e8af10ba729edWink Savillepackage com.android.internal.telephony; 20a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville 21a8467dd0c524787104b1ccdddc5e8af10ba729edWink Savilleimport android.os.ServiceManager; 22a8467dd0c524787104b1ccdddc5e8af10ba729edWink Savilleimport android.os.RemoteException; 23a8467dd0c524787104b1ccdddc5e8af10ba729edWink Savilleimport android.telephony.Rlog; 24a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville 25a8467dd0c524787104b1ccdddc5e8af10ba729edWink Savilleimport com.android.internal.telephony.IccPhoneBookInterfaceManagerProxy; 26a8467dd0c524787104b1ccdddc5e8af10ba729edWink Savilleimport com.android.internal.telephony.IIccPhoneBook; 27a8467dd0c524787104b1ccdddc5e8af10ba729edWink Savilleimport com.android.internal.telephony.Phone; 28a8467dd0c524787104b1ccdddc5e8af10ba729edWink Savilleimport com.android.internal.telephony.uicc.AdnRecord; 29a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville 30a8467dd0c524787104b1ccdddc5e8af10ba729edWink Savilleimport java.lang.ArrayIndexOutOfBoundsException; 31a8467dd0c524787104b1ccdddc5e8af10ba729edWink Savilleimport java.lang.NullPointerException; 32a8467dd0c524787104b1ccdddc5e8af10ba729edWink Savilleimport java.util.List; 33a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville 34a8467dd0c524787104b1ccdddc5e8af10ba729edWink Savillepublic class UiccPhoneBookController extends IIccPhoneBook.Stub { 35a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville private static final String TAG = "UiccPhoneBookController"; 36a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville private Phone[] mPhone; 37a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville 38a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville /* only one UiccPhoneBookController exists */ 39a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville public UiccPhoneBookController(Phone[] phone) { 40a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville if (ServiceManager.getService("simphonebook") == null) { 41a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville ServiceManager.addService("simphonebook", this); 42a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville } 43a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville mPhone = phone; 44a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville } 45a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville 46a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville public boolean 47a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville updateAdnRecordsInEfBySearch (int efid, String oldTag, String oldPhoneNumber, 48a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville String newTag, String newPhoneNumber, String pin2) throws android.os.RemoteException { 496a5ef38e6ae3d3a3ad90ae180388fe85de0495a2Wink Saville return updateAdnRecordsInEfBySearchForSubscriber(getDefaultSubscription(), efid, oldTag, 50a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville oldPhoneNumber, newTag, newPhoneNumber, pin2); 51a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville } 52a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville 53a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville public boolean 546a5ef38e6ae3d3a3ad90ae180388fe85de0495a2Wink Saville updateAdnRecordsInEfBySearchForSubscriber(long subId, int efid, String oldTag, 55a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville String oldPhoneNumber, String newTag, String newPhoneNumber, 56a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville String pin2) throws android.os.RemoteException { 57a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville IccPhoneBookInterfaceManagerProxy iccPbkIntMgrProxy = 58a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville getIccPhoneBookInterfaceManagerProxy(subId); 59a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville if (iccPbkIntMgrProxy != null) { 60a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville return iccPbkIntMgrProxy.updateAdnRecordsInEfBySearch(efid, oldTag, 61a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville oldPhoneNumber, newTag, newPhoneNumber, pin2); 62a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville } else { 63a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville Rlog.e(TAG,"updateAdnRecordsInEfBySearch iccPbkIntMgrProxy is" + 64a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville " null for Subscription:"+subId); 65a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville return false; 66a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville } 67a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville } 68a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville 69a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville public boolean 70a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville updateAdnRecordsInEfByIndex(int efid, String newTag, 71a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville String newPhoneNumber, int index, String pin2) throws android.os.RemoteException { 726a5ef38e6ae3d3a3ad90ae180388fe85de0495a2Wink Saville return updateAdnRecordsInEfByIndexForSubscriber(getDefaultSubscription(), efid, newTag, 73a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville newPhoneNumber, index, pin2); 74a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville } 75a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville 76a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville public boolean 776a5ef38e6ae3d3a3ad90ae180388fe85de0495a2Wink Saville updateAdnRecordsInEfByIndexForSubscriber(long subId, int efid, String newTag, 78a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville String newPhoneNumber, int index, String pin2) throws android.os.RemoteException { 79a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville IccPhoneBookInterfaceManagerProxy iccPbkIntMgrProxy = 80a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville getIccPhoneBookInterfaceManagerProxy(subId); 81a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville if (iccPbkIntMgrProxy != null) { 82a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville return iccPbkIntMgrProxy.updateAdnRecordsInEfByIndex(efid, newTag, 83a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville newPhoneNumber, index, pin2); 84a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville } else { 85a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville Rlog.e(TAG,"updateAdnRecordsInEfByIndex iccPbkIntMgrProxy is" + 86a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville " null for Subscription:"+subId); 87a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville return false; 88a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville } 89a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville } 90a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville 91a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville public int[] getAdnRecordsSize(int efid) throws android.os.RemoteException { 926a5ef38e6ae3d3a3ad90ae180388fe85de0495a2Wink Saville return getAdnRecordsSizeForSubscriber(getDefaultSubscription(), efid); 93a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville } 94a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville 95a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville public int[] 966a5ef38e6ae3d3a3ad90ae180388fe85de0495a2Wink Saville getAdnRecordsSizeForSubscriber(long subId, int efid) throws android.os.RemoteException { 97a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville IccPhoneBookInterfaceManagerProxy iccPbkIntMgrProxy = 98a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville getIccPhoneBookInterfaceManagerProxy(subId); 99a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville if (iccPbkIntMgrProxy != null) { 100a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville return iccPbkIntMgrProxy.getAdnRecordsSize(efid); 101a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville } else { 102a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville Rlog.e(TAG,"getAdnRecordsSize iccPbkIntMgrProxy is" + 103a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville " null for Subscription:"+subId); 104a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville return null; 105a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville } 106a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville } 107a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville 108a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville public List<AdnRecord> getAdnRecordsInEf(int efid) throws android.os.RemoteException { 1096a5ef38e6ae3d3a3ad90ae180388fe85de0495a2Wink Saville return getAdnRecordsInEfForSubscriber(getDefaultSubscription(), efid); 110a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville } 111a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville 1126a5ef38e6ae3d3a3ad90ae180388fe85de0495a2Wink Saville public List<AdnRecord> getAdnRecordsInEfForSubscriber(long subId, int efid) 113a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville throws android.os.RemoteException { 114a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville IccPhoneBookInterfaceManagerProxy iccPbkIntMgrProxy = 115a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville getIccPhoneBookInterfaceManagerProxy(subId); 116a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville if (iccPbkIntMgrProxy != null) { 117a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville return iccPbkIntMgrProxy.getAdnRecordsInEf(efid); 118a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville } else { 119a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville Rlog.e(TAG,"getAdnRecordsInEf iccPbkIntMgrProxy is" + 120a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville "null for Subscription:"+subId); 121a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville return null; 122a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville } 123a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville } 124a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville 125a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville /** 126a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville * get phone book interface manager proxy object based on subscription. 127a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville **/ 128a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville private IccPhoneBookInterfaceManagerProxy 129a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville getIccPhoneBookInterfaceManagerProxy(long subId) { 130a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville 131a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville long phoneId = SubscriptionController.getInstance().getPhoneId(subId); 132a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville try { 133a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville return ((PhoneProxy)mPhone[(int)phoneId]).getIccPhoneBookInterfaceManagerProxy(); 134a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville } catch (NullPointerException e) { 135a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville Rlog.e(TAG, "Exception is :"+e.toString()+" For subscription :"+subId ); 136a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville e.printStackTrace(); //To print stack trace 137a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville return null; 138a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville } catch (ArrayIndexOutOfBoundsException e) { 139a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville Rlog.e(TAG, "Exception is :"+e.toString()+" For subscription :"+subId ); 140a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville e.printStackTrace(); 141a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville return null; 142a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville } 143a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville } 144a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville 145a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville private long getDefaultSubscription() { 146a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville return PhoneFactory.getDefaultSubscription(); 147a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville } 148a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville} 149