Loading core/java/android/accounts/AccountManagerService.java +30 −0 Original line number Diff line number Diff line Loading @@ -231,6 +231,14 @@ public class AccountManagerService } }, intentFilter); IntentFilter userFilter = new IntentFilter(); userFilter.addAction(Intent.ACTION_USER_REMOVED); mContext.registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { onUserRemoved(intent); } }, userFilter); } private UserAccounts initUser(int userId) { Loading Loading @@ -347,6 +355,28 @@ public class AccountManagerService } } private void onUserRemoved(Intent intent) { int userId = intent.getIntExtra(Intent.EXTRA_USERID, -1); if (userId < 1) return; UserAccounts accounts; synchronized (mUsers) { accounts = mUsers.get(userId); mUsers.remove(userId); } if (accounts == null) { File dbFile = new File(getDatabaseName(userId)); dbFile.delete(); return; } synchronized (accounts.cacheLock) { accounts.openHelper.close(); File dbFile = new File(getDatabaseName(userId)); dbFile.delete(); } } private List<UserInfo> getAllUsers() { try { return AppGlobals.getPackageManager().getUsers(); Loading core/java/android/app/ApplicationPackageManager.java +16 −1 Original line number Diff line number Diff line Loading @@ -1211,6 +1211,18 @@ final class ApplicationPackageManager extends PackageManager { } } /** * @hide */ @Override public UserInfo getUser(int userId) { try { return mPM.getUser(userId); } catch (RemoteException re) { return null; } } /** * @hide */ Loading @@ -1228,7 +1240,10 @@ final class ApplicationPackageManager extends PackageManager { */ @Override public void updateUserName(int id, String name) { // TODO: try { mPM.updateUserName(id, name); } catch (RemoteException re) { } } /** Loading core/java/android/content/Intent.java +31 −0 Original line number Diff line number Diff line Loading @@ -2141,6 +2141,30 @@ public class Intent implements Parcelable, Cloneable { public static final String ACTION_PRE_BOOT_COMPLETED = "android.intent.action.PRE_BOOT_COMPLETED"; /** * Broadcast sent to the system when a user is added. Carries an extra EXTRA_USERID that has the * userid of the new user. * @hide */ public static final String ACTION_USER_ADDED = "android.intent.action.USER_ADDED"; /** * Broadcast sent to the system when a user is removed. Carries an extra EXTRA_USERID that has * the userid of the user. * @hide */ public static final String ACTION_USER_REMOVED = "android.intent.action.USER_REMOVED"; /** * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USERID that has * the userid of the user to become the current one. * @hide */ public static final String ACTION_USER_SWITCHED = "android.intent.action.USER_SWITCHED"; // --------------------------------------------------------------------- // --------------------------------------------------------------------- // Standard intent categories (see addCategory()). Loading Loading @@ -2682,6 +2706,13 @@ public class Intent implements Parcelable, Cloneable { public static final String EXTRA_LOCAL_ONLY = "android.intent.extra.LOCAL_ONLY"; /** * The userid carried with broadcast intents related to addition, removal and switching of users * - {@link #ACTION_USER_ADDED}, {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}. * @hide */ public static final String EXTRA_USERID = "android.intent.extra.user_id"; // --------------------------------------------------------------------- // --------------------------------------------------------------------- // Intent flags (see mFlags variable). Loading core/java/android/content/SyncManager.java +23 −0 Original line number Diff line number Diff line Loading @@ -326,6 +326,13 @@ public class SyncManager implements OnAccountsUpdateListener { } }; private BroadcastReceiver mUserIntentReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { onUserRemoved(intent); } }; private static final String ACTION_SYNC_ALARM = "android.content.syncmanager.SYNC_ALARM"; private final SyncHandler mSyncHandler; Loading Loading @@ -420,6 +427,10 @@ public class SyncManager implements OnAccountsUpdateListener { intentFilter.setPriority(100); context.registerReceiver(mShutdownIntentReceiver, intentFilter); intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_USER_REMOVED); mContext.registerReceiver(mUserIntentReceiver, intentFilter); if (!factoryTest) { mNotificationMgr = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); Loading Loading @@ -905,6 +916,18 @@ public class SyncManager implements OnAccountsUpdateListener { } } private void onUserRemoved(Intent intent) { int userId = intent.getIntExtra(Intent.EXTRA_USERID, -1); if (userId == -1) return; // Clean up the storage engine database mSyncStorageEngine.doDatabaseCleanup(new Account[0], userId); onAccountsUpdated(null); synchronized (mSyncQueue) { mSyncQueue.removeUser(userId); } } /** * @hide */ Loading core/java/android/content/SyncQueue.java +13 −0 Original line number Diff line number Diff line Loading @@ -117,6 +117,19 @@ public class SyncQueue { return true; } public void removeUser(int userId) { ArrayList<SyncOperation> opsToRemove = new ArrayList<SyncOperation>(); for (SyncOperation op : mOperationsMap.values()) { if (op.userId == userId) { opsToRemove.add(op); } } for (SyncOperation op : opsToRemove) { remove(op); } } /** * Remove the specified operation if it is in the queue. * @param operation the operation to remove Loading Loading
core/java/android/accounts/AccountManagerService.java +30 −0 Original line number Diff line number Diff line Loading @@ -231,6 +231,14 @@ public class AccountManagerService } }, intentFilter); IntentFilter userFilter = new IntentFilter(); userFilter.addAction(Intent.ACTION_USER_REMOVED); mContext.registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { onUserRemoved(intent); } }, userFilter); } private UserAccounts initUser(int userId) { Loading Loading @@ -347,6 +355,28 @@ public class AccountManagerService } } private void onUserRemoved(Intent intent) { int userId = intent.getIntExtra(Intent.EXTRA_USERID, -1); if (userId < 1) return; UserAccounts accounts; synchronized (mUsers) { accounts = mUsers.get(userId); mUsers.remove(userId); } if (accounts == null) { File dbFile = new File(getDatabaseName(userId)); dbFile.delete(); return; } synchronized (accounts.cacheLock) { accounts.openHelper.close(); File dbFile = new File(getDatabaseName(userId)); dbFile.delete(); } } private List<UserInfo> getAllUsers() { try { return AppGlobals.getPackageManager().getUsers(); Loading
core/java/android/app/ApplicationPackageManager.java +16 −1 Original line number Diff line number Diff line Loading @@ -1211,6 +1211,18 @@ final class ApplicationPackageManager extends PackageManager { } } /** * @hide */ @Override public UserInfo getUser(int userId) { try { return mPM.getUser(userId); } catch (RemoteException re) { return null; } } /** * @hide */ Loading @@ -1228,7 +1240,10 @@ final class ApplicationPackageManager extends PackageManager { */ @Override public void updateUserName(int id, String name) { // TODO: try { mPM.updateUserName(id, name); } catch (RemoteException re) { } } /** Loading
core/java/android/content/Intent.java +31 −0 Original line number Diff line number Diff line Loading @@ -2141,6 +2141,30 @@ public class Intent implements Parcelable, Cloneable { public static final String ACTION_PRE_BOOT_COMPLETED = "android.intent.action.PRE_BOOT_COMPLETED"; /** * Broadcast sent to the system when a user is added. Carries an extra EXTRA_USERID that has the * userid of the new user. * @hide */ public static final String ACTION_USER_ADDED = "android.intent.action.USER_ADDED"; /** * Broadcast sent to the system when a user is removed. Carries an extra EXTRA_USERID that has * the userid of the user. * @hide */ public static final String ACTION_USER_REMOVED = "android.intent.action.USER_REMOVED"; /** * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USERID that has * the userid of the user to become the current one. * @hide */ public static final String ACTION_USER_SWITCHED = "android.intent.action.USER_SWITCHED"; // --------------------------------------------------------------------- // --------------------------------------------------------------------- // Standard intent categories (see addCategory()). Loading Loading @@ -2682,6 +2706,13 @@ public class Intent implements Parcelable, Cloneable { public static final String EXTRA_LOCAL_ONLY = "android.intent.extra.LOCAL_ONLY"; /** * The userid carried with broadcast intents related to addition, removal and switching of users * - {@link #ACTION_USER_ADDED}, {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}. * @hide */ public static final String EXTRA_USERID = "android.intent.extra.user_id"; // --------------------------------------------------------------------- // --------------------------------------------------------------------- // Intent flags (see mFlags variable). Loading
core/java/android/content/SyncManager.java +23 −0 Original line number Diff line number Diff line Loading @@ -326,6 +326,13 @@ public class SyncManager implements OnAccountsUpdateListener { } }; private BroadcastReceiver mUserIntentReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { onUserRemoved(intent); } }; private static final String ACTION_SYNC_ALARM = "android.content.syncmanager.SYNC_ALARM"; private final SyncHandler mSyncHandler; Loading Loading @@ -420,6 +427,10 @@ public class SyncManager implements OnAccountsUpdateListener { intentFilter.setPriority(100); context.registerReceiver(mShutdownIntentReceiver, intentFilter); intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_USER_REMOVED); mContext.registerReceiver(mUserIntentReceiver, intentFilter); if (!factoryTest) { mNotificationMgr = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); Loading Loading @@ -905,6 +916,18 @@ public class SyncManager implements OnAccountsUpdateListener { } } private void onUserRemoved(Intent intent) { int userId = intent.getIntExtra(Intent.EXTRA_USERID, -1); if (userId == -1) return; // Clean up the storage engine database mSyncStorageEngine.doDatabaseCleanup(new Account[0], userId); onAccountsUpdated(null); synchronized (mSyncQueue) { mSyncQueue.removeUser(userId); } } /** * @hide */ Loading
core/java/android/content/SyncQueue.java +13 −0 Original line number Diff line number Diff line Loading @@ -117,6 +117,19 @@ public class SyncQueue { return true; } public void removeUser(int userId) { ArrayList<SyncOperation> opsToRemove = new ArrayList<SyncOperation>(); for (SyncOperation op : mOperationsMap.values()) { if (op.userId == userId) { opsToRemove.add(op); } } for (SyncOperation op : opsToRemove) { remove(op); } } /** * Remove the specified operation if it is in the queue. * @param operation the operation to remove Loading