diff options
author | Nicolas Prevot <nprevot@google.com> | 2014-07-08 15:47:17 +0100 |
---|---|---|
committer | Nicolas Prévot <nprevot@google.com> | 2014-07-17 13:44:56 +0000 |
commit | e702404c5a9d46765acb76f63ea6338d0a42b030 (patch) | |
tree | 54228c40a18c5349ad11beee53f391277cc89b34 /services | |
parent | 31a37dc0a1ad977157d0a0c79fb4c82e6bdd72ce (diff) | |
download | frameworks_base-e702404c5a9d46765acb76f63ea6338d0a42b030.zip frameworks_base-e702404c5a9d46765acb76f63ea6338d0a42b030.tar.gz frameworks_base-e702404c5a9d46765acb76f63ea6338d0a42b030.tar.bz2 |
DO NOT MERGE
Remove cross-profile intent filters when removing a user.
When a user is being removed: removing cross-profile intent filters that have
this user as their source.
This makes sure that if the user id gets reassigned without restarting the phone,
we do not have old information from the preexisting profile.
Change-Id: Ie3a2aa0cbbe6c9eb9e945e650fd907e5cc012409
(cherry picked from commit d44e2d7340c70406d8b5eb8b3d6c6c0daaa8705f)
Diffstat (limited to 'services')
-rw-r--r-- | services/core/java/com/android/server/pm/Settings.java | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/services/core/java/com/android/server/pm/Settings.java b/services/core/java/com/android/server/pm/Settings.java index a3fd1df..e16894e 100644 --- a/services/core/java/com/android/server/pm/Settings.java +++ b/services/core/java/com/android/server/pm/Settings.java @@ -3171,25 +3171,34 @@ final class Settings { file.delete(); file = getUserPackagesStateBackupFile(userId); file.delete(); - removeCrossProfileIntentFiltersToUserLPr(userId); + removeCrossProfileIntentFiltersLPw(userId); removeCrossProfilePackagesLPw(userId); } - void removeCrossProfileIntentFiltersToUserLPr(int targetUserId) { - for (int i = 0; i < mCrossProfileIntentResolvers.size(); i++) { - int sourceUserId = mCrossProfileIntentResolvers.keyAt(i); - CrossProfileIntentResolver cpir = mCrossProfileIntentResolvers.get(sourceUserId); - boolean needsWriting = false; - HashSet<CrossProfileIntentFilter> cpifs = - new HashSet<CrossProfileIntentFilter>(cpir.filterSet()); - for (CrossProfileIntentFilter cpif : cpifs) { - if (cpif.getTargetUserId() == targetUserId) { - needsWriting = true; - cpir.removeFilter(cpif); - } + void removeCrossProfileIntentFiltersLPw(int userId) { + synchronized (mCrossProfileIntentResolvers) { + // userId is the source user + if (mCrossProfileIntentResolvers.get(userId) != null) { + mCrossProfileIntentResolvers.remove(userId); + writePackageRestrictionsLPr(userId); } - if (needsWriting) { - writePackageRestrictionsLPr(sourceUserId); + // userId is the target user + int count = mCrossProfileIntentResolvers.size(); + for (int i = 0; i < count; i++) { + int sourceUserId = mCrossProfileIntentResolvers.keyAt(i); + CrossProfileIntentResolver cpir = mCrossProfileIntentResolvers.get(sourceUserId); + boolean needsWriting = false; + HashSet<CrossProfileIntentFilter> cpifs = + new HashSet<CrossProfileIntentFilter>(cpir.filterSet()); + for (CrossProfileIntentFilter cpif : cpifs) { + if (cpif.getTargetUserId() == userId) { + needsWriting = true; + cpir.removeFilter(cpif); + } + } + if (needsWriting) { + writePackageRestrictionsLPr(sourceUserId); + } } } } |