Directly dispatch USER_REMOVED to LockSettingsService

Bug: 18931518
Change-Id: Ibaf875a06868ae3196115d77eed6874daf2fec16
This commit is contained in:
Adrian Roos
2015-01-07 22:19:38 +01:00
parent 230635efe7
commit db0f76e1d8
6 changed files with 7 additions and 45 deletions

View File

@@ -31,5 +31,4 @@ interface ILockSettings {
boolean checkVoldPassword(int userId);
boolean havePattern(int userId);
boolean havePassword(int userId);
void removeUser(int userId);
}

View File

@@ -267,14 +267,6 @@ public class LockPatternUtils {
}
}
public void removeUser(int userId) {
try {
getLockSettings().removeUser(userId);
} catch (RemoteException re) {
Log.e(TAG, "Couldn't remove lock settings for user " + userId);
}
}
private int getCurrentOrCallingUserId() {
if (mMultiUserMode) {
// TODO: This is a little inefficient. See if all users of this are able to

View File

@@ -103,12 +103,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
private static final int MSG_DEVICE_PROVISIONED = 308;
private static final int MSG_DPM_STATE_CHANGED = 309;
private static final int MSG_USER_SWITCHING = 310;
private static final int MSG_USER_REMOVED = 311;
private static final int MSG_KEYGUARD_VISIBILITY_CHANGED = 312;
private static final int MSG_BOOT_COMPLETED = 313;
private static final int MSG_USER_SWITCH_COMPLETE = 314;
private static final int MSG_SET_CURRENT_CLIENT_ID = 315;
private static final int MSG_SET_PLAYBACK_STATE = 316;
private static final int MSG_USER_INFO_CHANGED = 317;
private static final int MSG_REPORT_EMERGENCY_CALL_ACTION = 318;
private static final int MSG_SCREEN_TURNED_ON = 319;
@@ -185,9 +182,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
case MSG_USER_SWITCH_COMPLETE:
handleUserSwitchComplete(msg.arg1);
break;
case MSG_USER_REMOVED:
handleUserRemoved(msg.arg1);
break;
case MSG_KEYGUARD_VISIBILITY_CHANGED:
handleKeyguardVisibilityChanged(msg.arg1);
break;
@@ -449,9 +443,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
} else if (TelephonyManager.ACTION_PHONE_STATE_CHANGED.equals(action)) {
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
mHandler.sendMessage(mHandler.obtainMessage(MSG_PHONE_STATE_CHANGED, state));
} else if (Intent.ACTION_USER_REMOVED.equals(action)) {
mHandler.sendMessage(mHandler.obtainMessage(MSG_USER_REMOVED,
intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0), 0));
} else if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
dispatchBootCompleted();
}
@@ -679,7 +670,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
filter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
filter.addAction(Intent.ACTION_USER_REMOVED);
context.registerReceiver(mBroadcastReceiver, filter);
final IntentFilter bootCompleteFilter = new IntentFilter();
@@ -831,18 +821,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
return mBootCompleted;
}
/**
* Handle {@link #MSG_USER_REMOVED}
*/
protected void handleUserRemoved(int userId) {
for (int i = 0; i < mCallbacks.size(); i++) {
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
if (cb != null) {
cb.onUserRemoved(userId);
}
}
}
/**
* Handle {@link #MSG_DEVICE_PROVISIONED}
*/

View File

@@ -122,11 +122,6 @@ public class KeyguardUpdateMonitorCallback {
*/
public void onSimStateChanged(int subId, int slotId, IccCardConstants.State simState) { }
/**
* Called when a user is removed.
*/
public void onUserRemoved(int userId) { }
/**
* Called when the user's info changed.
*/

View File

@@ -328,11 +328,6 @@ public class KeyguardViewMediator extends SystemUI {
}
}
@Override
public void onUserRemoved(int userId) {
mLockPatternUtils.removeUser(userId);
}
@Override
public void onUserInfoChanged(int userId) {
}

View File

@@ -82,6 +82,7 @@ public class LockSettingsService extends ILockSettings.Stub {
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_USER_ADDED);
filter.addAction(Intent.ACTION_USER_STARTING);
filter.addAction(Intent.ACTION_USER_REMOVED);
mContext.registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, filter, null, null);
mStorage = new LockSettingsStorage(context, new LockSettingsStorage.Callback() {
@@ -118,6 +119,11 @@ public class LockSettingsService extends ILockSettings.Stub {
} else if (Intent.ACTION_USER_STARTING.equals(intent.getAction())) {
final int userHandle = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0);
mStorage.prefetchUser(userHandle);
} else if (Intent.ACTION_USER_REMOVED.equals(intent.getAction())) {
final int userHandle = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0);
if (userHandle > 0) {
removeUser(userHandle);
}
}
}
};
@@ -416,10 +422,7 @@ public class LockSettingsService extends ILockSettings.Stub {
return false;
}
@Override
public void removeUser(int userId) {
checkWritePermission(userId);
private void removeUser(int userId) {
mStorage.removeUser(userId);
final KeyStore ks = KeyStore.getInstance();