Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2ed287b6 authored by Suchi Amalapurapu's avatar Suchi Amalapurapu
Browse files

fix issue with gids not being added for packages with shared user id

Squashed commit of the following:

commit 2bc4c29dab22d8a541dfca0a20320b307ba64cfb
Author: Suchi Amalapurapu <asuchitra@google.com>
Date:   Tue Aug 4 16:24:55 2009 -0700

    fix issue with gids not being added for packages with shared user id
parent d4543c51
Loading
Loading
Loading
Loading
+17 −8
Original line number Diff line number Diff line
@@ -4220,7 +4220,7 @@ class PackageManagerService extends IPackageManager.Stub {
        synchronized (mPackages) {
            if ( (deletedPs != null) && (deletedPs.sharedUser != null)) {
                // remove permissions associated with package
                mSettings.updateSharedUserPerms (deletedPs);
                mSettings.updateSharedUserPermsLP(deletedPs, mGlobalGids);
            }
            // Save settings now
            mSettings.writeLP ();
@@ -6008,7 +6008,15 @@ class PackageManagerService extends IPackageManager.Stub {
            }
        }

        private void updateSharedUserPerms (PackageSetting deletedPs) {
        /*
         * 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.
         */
        private void updateSharedUserPermsLP(PackageSetting deletedPs, int[] globalGids) {
            if ( (deletedPs == null) || (deletedPs.pkg == null)) {
                Log.i(TAG, "Trying to update info for null package. Just ignoring");
                return;
@@ -6037,9 +6045,10 @@ class PackageManagerService extends IPackageManager.Stub {
                }
            }
            // Update gids
            int newGids[] = null;
            for (PackageSetting pkg:sus.packages) {
                newGids = appendInts(newGids, pkg.gids);
            int newGids[] = globalGids;
            for (String eachPerm : sus.grantedPermissions) {
                BasePermission bp = mPermissions.get(eachPerm);
                newGids = appendInts(newGids, bp.gids);
            }
            sus.gids = newGids;
        }