Hi All.

  We found a system crash when overwrite install (or re-install) some
packages.

  This issue have also been found by Brian Smith, see this link:
http://groups.google.com/group/android-developers/browse_thread/thread/ac572af11f6d87b6/02ee83ac28df2181?lnk=gst&q=re+install+crash#
http://code.google.com/p/android/issues/detail?can=1&q=4165&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&id=4165

 I am now analysis this issue, below is the solution:

Inside file: PackageManagerService.java, about line 6311, or class
Settings's member method updateSharedUserPermsLP:

The comments for this method is:

        /*
         * Update the shared user setting when a package using
         * specifying the shared user id is removed. The gids
         * associated with each permission of the deleted package
         * are removed from the shared user's gid list only if its
         * not in use by other permissions of packages in the
         * shared user setting.
         */

And the code listed:

1            SharedUserSetting sus = deletedPs.sharedUser;
2            // Update permissions
3            for (String eachPerm: deletedPs.pkg.requestedPermissions)
{
4                boolean used = false;
5                if (!sus.grantedPermissions.contains (eachPerm)) {
6                    continue;
7                }
8                for (PackageSetting pkg:sus.packages) {
9                      //PackageParser.Package pkg;
My fix >>10                   if (pkg.pkg.packageName !=
deletedPs.name)
11                   if (pkg.pkg.requestedPermissions.contains
(eachPerm)) {
12                       used = true;
13                       break;
14                   }
15               }
16               if (!used) {
17                   // can safely delete this permission from list
18                   sus.grantedPermissions.remove(eachPerm);
19                   sus.loadedPermissions.remove(eachPerm);
20               }
21           }

21            int newGids[] = globalGids;
22            for (String eachPerm : sus.grantedPermissions) {
23                BasePermission bp = mPermissions.get(eachPerm);
My fix >>24                if(null != bp)
25                    newGids = appendInts(newGids, bp.gids);
26            }
27            sus.gids = newGids;


Line 25: the crash happens here when reference gids, hence the bp is
null.
Line 10: this is my initial fix.

This issue looks like member HashMap mPermissions have removed some
permission object, but sus.grantedPermissions does not.

For this clues, I found in the same function just ahead about line 18,
it checks all requested permission by the package (which will be
deleted), and trying to find out if this permission still been used by
other packages which have shared user id. After added some logs, I
found this package which will be deleted (deletedPs) also insided
inside su.packages, that is mean it will check it equals to itself,
and this condition will always return true, this makes all the
permissions will be tagged as used (as line 12, variable used will
always be true). No requested permissions will be removed from
sus.grantedPermissions. This may explain why there are some
permissions have been removed from mPermissions, but still exist
inside sus.grantedPermissions.

After apply this fix, the issue disappeared. But I'm not sure if this
fix will affect some other cases. I need Google's confirmation.

Thanks.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to