1/* 2** Copyright 2007, 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 17package com.android.internal.telephony.cdma; 18 19import android.content.pm.PackageManager; 20import android.os.AsyncResult; 21import android.os.Handler; 22import android.os.Looper; 23import android.os.Message; 24import android.os.ServiceManager; 25import android.telephony.PhoneNumberUtils; 26import android.util.Log; 27 28import com.android.internal.telephony.AdnRecord; 29import com.android.internal.telephony.AdnRecordCache; 30import com.android.internal.telephony.IccPhoneBookInterfaceManager; 31import com.android.internal.telephony.PhoneProxy; 32 33import java.util.ArrayList; 34import java.util.List; 35 36/** 37 * RuimPhoneBookInterfaceManager to provide an inter-process communication to 38 * access ADN-like SIM records. 39 */ 40 41 42public class RuimPhoneBookInterfaceManager extends IccPhoneBookInterfaceManager { 43 static final String LOG_TAG = "CDMA"; 44 45 46 Handler mHandler = new Handler() { 47 @Override 48 public void handleMessage(Message msg) { 49 AsyncResult ar; 50 51 switch(msg.what) { 52 default: 53 mBaseHandler.handleMessage(msg); 54 break; 55 } 56 } 57 }; 58 59 public RuimPhoneBookInterfaceManager(CDMAPhone phone) { 60 super(phone); 61 adnCache = phone.mRuimRecords.getAdnCache(); 62 //NOTE service "simphonebook" added by IccSmsInterfaceManagerProxy 63 } 64 65 public void dispose() { 66 super.dispose(); 67 } 68 69 protected void finalize() { 70 if(DBG) Log.d(LOG_TAG, "RuimPhoneBookInterfaceManager finalized"); 71 } 72 73 public int[] getAdnRecordsSize(int efid) { 74 if (DBG) logd("getAdnRecordsSize: efid=" + efid); 75 synchronized(mLock) { 76 checkThread(); 77 recordSize = new int[3]; 78 79 //Using mBaseHandler, no difference in EVENT_GET_SIZE_DONE handling 80 Message response = mBaseHandler.obtainMessage(EVENT_GET_SIZE_DONE); 81 82 phone.getIccFileHandler().getEFLinearRecordSize(efid, response); 83 try { 84 mLock.wait(); 85 } catch (InterruptedException e) { 86 logd("interrupted while trying to load from the RUIM"); 87 } 88 } 89 90 return recordSize; 91 } 92 93 protected void logd(String msg) { 94 Log.d(LOG_TAG, "[RuimPbInterfaceManager] " + msg); 95 } 96 97 protected void loge(String msg) { 98 Log.e(LOG_TAG, "[RuimPbInterfaceManager] " + msg); 99 } 100} 101 102