Merge "remove the code that clears the passwords when the sim is replaced with a different one." into gingerbread
This commit is contained in:
committed by
Android (Google) Code Review
commit
661e9b371f
@@ -101,7 +101,6 @@ public class AccountManagerService
|
||||
|
||||
private final AccountAuthenticatorCache mAuthenticatorCache;
|
||||
private final DatabaseHelper mOpenHelper;
|
||||
private final SimWatcher mSimWatcher;
|
||||
|
||||
private static final String TABLE_ACCOUNTS = "accounts";
|
||||
private static final String ACCOUNTS_ID = "_id";
|
||||
@@ -227,7 +226,6 @@ public class AccountManagerService
|
||||
mAuthenticatorCache = new AccountAuthenticatorCache(mContext);
|
||||
mAuthenticatorCache.setListener(this, null /* Handler */);
|
||||
|
||||
mSimWatcher = new SimWatcher(mContext);
|
||||
sThis.set(this);
|
||||
|
||||
validateAccounts();
|
||||
@@ -1691,95 +1689,6 @@ public class AccountManagerService
|
||||
}
|
||||
}
|
||||
|
||||
private class SimWatcher extends BroadcastReceiver {
|
||||
public SimWatcher(Context context) {
|
||||
// Re-scan the SIM card when the SIM state changes, and also if
|
||||
// the disk recovers from a full state (we may have failed to handle
|
||||
// things properly while the disk was full).
|
||||
final IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
|
||||
filter.addAction(Intent.ACTION_DEVICE_STORAGE_OK);
|
||||
context.registerReceiver(this, filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare the IMSI to the one stored in the login service's
|
||||
* database. If they differ, erase all passwords and
|
||||
* authtokens (and store the new IMSI).
|
||||
*/
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
// Check IMSI on every update; nothing happens if the IMSI
|
||||
// is missing or unchanged.
|
||||
TelephonyManager telephonyManager =
|
||||
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
if (telephonyManager == null) {
|
||||
Log.w(TAG, "failed to get TelephonyManager");
|
||||
return;
|
||||
}
|
||||
String imsi = telephonyManager.getSubscriberId();
|
||||
|
||||
// If the subscriber ID is an empty string, don't do anything.
|
||||
if (TextUtils.isEmpty(imsi)) return;
|
||||
|
||||
// If the current IMSI matches what's stored, don't do anything.
|
||||
String storedImsi = getMetaValue("imsi");
|
||||
if (Log.isLoggable(TAG, Log.VERBOSE)) {
|
||||
Log.v(TAG, "current IMSI=" + imsi + "; stored IMSI=" + storedImsi);
|
||||
}
|
||||
if (imsi.equals(storedImsi)) return;
|
||||
|
||||
// If a CDMA phone is unprovisioned, getSubscriberId()
|
||||
// will return a different value, but we *don't* erase the
|
||||
// passwords. We only erase them if it has a different
|
||||
// subscriber ID once it's provisioned.
|
||||
if (telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA) {
|
||||
IBinder service = ServiceManager.checkService(Context.TELEPHONY_SERVICE);
|
||||
if (service == null) {
|
||||
Log.w(TAG, "call to checkService(TELEPHONY_SERVICE) failed");
|
||||
return;
|
||||
}
|
||||
ITelephony telephony = ITelephony.Stub.asInterface(service);
|
||||
if (telephony == null) {
|
||||
Log.w(TAG, "failed to get ITelephony interface");
|
||||
return;
|
||||
}
|
||||
boolean needsProvisioning;
|
||||
try {
|
||||
needsProvisioning = telephony.getCdmaNeedsProvisioning();
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "exception while checking provisioning", e);
|
||||
// default to NOT wiping out the passwords
|
||||
needsProvisioning = true;
|
||||
}
|
||||
if (needsProvisioning) {
|
||||
// if the phone needs re-provisioning, don't do anything.
|
||||
if (Log.isLoggable(TAG, Log.VERBOSE)) {
|
||||
Log.v(TAG, "current IMSI=" + imsi + " (needs provisioning); stored IMSI=" +
|
||||
storedImsi);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!imsi.equals(storedImsi) && !TextUtils.isEmpty(storedImsi)) {
|
||||
Log.w(TAG, "wiping all passwords and authtokens because IMSI changed ("
|
||||
+ "stored=" + storedImsi + ", current=" + imsi + ")");
|
||||
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
|
||||
db.beginTransaction();
|
||||
try {
|
||||
db.execSQL("DELETE from " + TABLE_AUTHTOKENS);
|
||||
db.execSQL("UPDATE " + TABLE_ACCOUNTS + " SET " + ACCOUNTS_PASSWORD + " = ''");
|
||||
sendAccountsChangedBroadcast();
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
}
|
||||
}
|
||||
setMetaValue("imsi", imsi);
|
||||
}
|
||||
}
|
||||
|
||||
public IBinder onBind(Intent intent) {
|
||||
return asBinder();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user