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

Commit cc89831d authored by Danny Baumann's avatar Danny Baumann
Browse files

Fix theme provider crashing for non-primary user.

PackageManagerService's context is for user 0, so if the theme provider
for other users was invoking the getInstalledThemePackages() method, the
themes provider crashed as it doesn't have the INTERACT_ACROSS_USERS
permission.
Fix that (and simplify code) by making getInstalledThemePackages()
return the installed themes for the current user, which was probably the
intent anyway.

Change-Id: I02002cee005b74128f3b2f7cc7a93b9b8514f1f3
parent c5c33031
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -427,14 +427,17 @@ final class ApplicationPackageManager extends PackageManager {
        }
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<PackageInfo> getInstalledThemePackages() {
        try {
            return mPM.getInstalledThemePackages();
        } catch (RemoteException e) {
            throw new RuntimeException("Package manager has died", e);
        // Returns a list of theme APKs.
        ArrayList<PackageInfo> finalList = new ArrayList<PackageInfo>();
        List<PackageInfo> installedPackagesList = getInstalledPackages(0);
        for (PackageInfo pi : installedPackagesList) {
            if (pi != null && pi.isThemeApk) {
                finalList.add(pi);
            }
        }
        return finalList;
    }

    @SuppressWarnings("unchecked")
+0 −2
Original line number Diff line number Diff line
@@ -130,8 +130,6 @@ interface IPackageManager {
     */
    ParceledListSlice getInstalledPackages(int flags, in String lastRead, in int userId);

    List<PackageInfo> getInstalledThemePackages();

    /**
     * This implements getInstalledApplications via a "last returned row"
     * mechanism that is not exposed in the API. This is to get around the IPC
+0 −14
Original line number Diff line number Diff line
@@ -2958,20 +2958,6 @@ public class PackageManagerService extends IPackageManager.Stub {
        return list;
    }

    public List<PackageInfo> getInstalledThemePackages() {
        // Returns a list of theme APKs.
        ArrayList<PackageInfo> finalList = new ArrayList<PackageInfo>();
        List<PackageInfo> installedPackagesList = mContext.getPackageManager().getInstalledPackages(0);
        Iterator<PackageInfo> i = installedPackagesList.iterator();
        while (i.hasNext()) {
            final PackageInfo pi = i.next();
            if (pi != null && pi.isThemeApk) {
                finalList.add(pi);
            }
        }
        return finalList;
    }

    @Override
    public ParceledListSlice<ApplicationInfo> getInstalledApplications(int flags,
            String lastRead, int userId) {