SimPhoneBookInterfaceManagerpublic class SimPhoneBookInterfaceManager extends ISimPhoneBook.Stub SimPhoneBookInterfaceManager to provide an inter-process communication to
access ADN-like SIM records. |
Fields Summary |
---|
static final String | LOG_TAG | static final boolean | DBG | private GSMPhone | phone | private AdnRecordCache | adnCache | private final Object | mLock | private int[] | recordSize | private boolean | success | private List | records | private static final boolean | ALLOW_SIM_OP_IN_UI_THREAD | private static final int | EVENT_GET_SIZE_DONE | private static final int | EVENT_LOAD_DONE | private static final int | EVENT_UPDATE_DONE | android.os.Handler | mHandler |
Constructors Summary |
---|
public SimPhoneBookInterfaceManager(GSMPhone phone)
this.phone = phone;
adnCache = phone.mSIMRecords.getAdnCache();
publish();
|
Methods Summary |
---|
private void | checkThread()
if (!ALLOW_SIM_OP_IN_UI_THREAD) {
// Make sure this isn't the UI thread, since it will block
if (mHandler.getLooper().equals(Looper.myLooper())) {
Log.e(LOG_TAG, "query() called on the main UI thread!");
throw new IllegalStateException("You cannot call query on this provder from the main UI thread.");
}
}
| public java.util.List | getAdnRecordsInEf(int efid)Loads the AdnRecords in efid and returns them as a
List of AdnRecords
throws SecurityException if no READ_CONTACTS permission
if (phone.getContext().checkCallingOrSelfPermission(
android.Manifest.permission.READ_CONTACTS)
!= PackageManager.PERMISSION_GRANTED) {
throw new SecurityException(
"Requires android.permission.READ_CONTACTS permission");
}
if (DBG) log("getAdnRecordsInEF: efid=" + efid);
synchronized(mLock) {
checkThread();
Message response = mHandler.obtainMessage(EVENT_LOAD_DONE);
adnCache.requestLoadAllAdnLike(efid, response);
try {
mLock.wait();
} catch (InterruptedException e) {
log("interrupted while trying to load from the SIM");
}
}
return records;
| public int[] | getAdnRecordsSize(int efid)Get the capacity of records in efid
if (DBG) log("getAdnRecordsSize: efid=" + efid);
synchronized(mLock) {
checkThread();
recordSize = new int[3];
Message response = mHandler.obtainMessage(EVENT_GET_SIZE_DONE);
phone.mSIMFileHandler.getEFLinearRecordSize(efid, response);
try {
mLock.wait();
} catch (InterruptedException e) {
log("interrupted while trying to load from the SIM");
}
}
return recordSize;
| private void | log(java.lang.String msg)
Log.d(LOG_TAG, "[SpbInterfaceManager] " + msg);
| private void | publish()
ServiceManager.addService("simphonebook", this);
| public boolean | updateAdnRecordsInEfByIndex(int efid, java.lang.String newTag, java.lang.String newPhoneNumber, int index, java.lang.String pin2)Update an ADN-like EF record by record index
This is useful for iteration the whole ADN file, such as write the whole
phone book or erase/format the whole phonebook
throws SecurityException if no WRITE_CONTACTS permission
if (phone.getContext().checkCallingOrSelfPermission(
android.Manifest.permission.WRITE_CONTACTS)
!= PackageManager.PERMISSION_GRANTED) {
throw new SecurityException(
"Requires android.permission.WRITE_CONTACTS permission");
}
if (DBG) log("updateAdnRecordsInEfByIndex: efid=" + efid +
" Index=" + index + " ==> " +
"("+ newTag + "," + newPhoneNumber + ")"+ " pin2=" + pin2);
synchronized(mLock) {
checkThread();
success = false;
Message response = mHandler.obtainMessage(EVENT_UPDATE_DONE);
AdnRecord newAdn = new AdnRecord(newTag, newPhoneNumber);
adnCache.updateAdnByIndex(efid, newAdn, index, pin2, response);
try {
mLock.wait();
} catch (InterruptedException e) {
log("interrupted while trying to update by index");
}
}
return success;
| public boolean | updateAdnRecordsInEfBySearch(int efid, java.lang.String oldTag, java.lang.String oldPhoneNumber, java.lang.String newTag, java.lang.String newPhoneNumber, java.lang.String pin2)Replace oldAdn with newAdn in ADN-like record in EF
getAdnRecordsInEf must be called at least once before this function,
otherwise an error will be returned
throws SecurityException if no WRITE_CONTACTS permission
if (phone.getContext().checkCallingOrSelfPermission(
android.Manifest.permission.WRITE_CONTACTS)
!= PackageManager.PERMISSION_GRANTED) {
throw new SecurityException(
"Requires android.permission.WRITE_CONTACTS permission");
}
if (DBG) log("updateAdnRecordsInEfBySearch: efid=" + efid +
" ("+ oldTag + "," + oldPhoneNumber + ")"+ "==>" +
" ("+ newTag + "," + newPhoneNumber + ")"+ " pin2=" + pin2);
synchronized(mLock) {
checkThread();
success = false;
Message response = mHandler.obtainMessage(EVENT_UPDATE_DONE);
AdnRecord oldAdn = new AdnRecord(oldTag, oldPhoneNumber);
AdnRecord newAdn = new AdnRecord(newTag, newPhoneNumber);
adnCache.updateAdnBySearch(efid, oldAdn, newAdn, pin2, response);
try {
mLock.wait();
} catch (InterruptedException e) {
log("interrupted while trying to update by search");
}
}
return success;
|
|