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

Commit 8fea4e72 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Rework ParceledListSlice to be much easier to use."

parents 21af9258 d8e1dbb6
Loading
Loading
Loading
Loading
+2 −11
Original line number Diff line number Diff line
@@ -321,17 +321,8 @@ public final class Pm {
    @SuppressWarnings("unchecked")
    private List<PackageInfo> getInstalledPackages(IPackageManager pm, int flags, int userId)
            throws RemoteException {
        final List<PackageInfo> packageInfos = new ArrayList<PackageInfo>();
        PackageInfo lastItem = null;
        ParceledListSlice<PackageInfo> slice;

        do {
            final String lastKey = lastItem != null ? lastItem.packageName : null;
            slice = pm.getInstalledPackages(flags, lastKey, userId);
            lastItem = slice.populateList(packageInfos, PackageInfo.CREATOR);
        } while (!slice.isLastSlice());

        return packageInfos;
        ParceledListSlice<PackageInfo> slice = pm.getInstalledPackages(flags, userId);
        return slice.getList();
    }

    /**
+3 −3
Original line number Diff line number Diff line
@@ -228,7 +228,7 @@ public class AppOpsManager {
    }

    public int noteOp(int op) {
        return noteOp(op, Process.myUid(), mContext.getPackageName());
        return noteOp(op, Process.myUid(), mContext.getBasePackageName());
    }

    public int startOp(int op, int uid, String packageName) {
@@ -252,7 +252,7 @@ public class AppOpsManager {
    }

    public int startOp(int op) {
        return startOp(op, Process.myUid(), mContext.getPackageName());
        return startOp(op, Process.myUid(), mContext.getBasePackageName());
    }

    public void finishOp(int op, int uid, String packageName) {
@@ -263,6 +263,6 @@ public class AppOpsManager {
    }

    public void finishOp(int op) {
        finishOp(op, Process.myUid(), mContext.getPackageName());
        finishOp(op, Process.myUid(), mContext.getBasePackageName());
    }
}
+7 −33
Original line number Diff line number Diff line
@@ -426,17 +426,8 @@ final class ApplicationPackageManager extends PackageManager {
    @Override
    public List<PackageInfo> getInstalledPackages(int flags, int userId) {
        try {
            final List<PackageInfo> packageInfos = new ArrayList<PackageInfo>();
            PackageInfo lastItem = null;
            ParceledListSlice<PackageInfo> slice;

            do {
                final String lastKey = lastItem != null ? lastItem.packageName : null;
                slice = mPM.getInstalledPackages(flags, lastKey, userId);
                lastItem = slice.populateList(packageInfos, PackageInfo.CREATOR);
            } while (!slice.isLastSlice());

            return packageInfos;
            ParceledListSlice<PackageInfo> slice = mPM.getInstalledPackages(flags, userId);
            return slice.getList();
        } catch (RemoteException e) {
            throw new RuntimeException("Package manager has died", e);
        }
@@ -448,17 +439,9 @@ final class ApplicationPackageManager extends PackageManager {
            String[] permissions, int flags) {
        final int userId = mContext.getUserId();
        try {
            final List<PackageInfo> packageInfos = new ArrayList<PackageInfo>();
            PackageInfo lastItem = null;
            ParceledListSlice<PackageInfo> slice;

            do {
                final String lastKey = lastItem != null ? lastItem.packageName : null;
                slice = mPM.getPackagesHoldingPermissions(permissions, flags, lastKey, userId);
                lastItem = slice.populateList(packageInfos, PackageInfo.CREATOR);
            } while (!slice.isLastSlice());

            return packageInfos;
            ParceledListSlice<PackageInfo> slice = mPM.getPackagesHoldingPermissions(
                    permissions, flags, userId);
            return slice.getList();
        } catch (RemoteException e) {
            throw new RuntimeException("Package manager has died", e);
        }
@@ -469,17 +452,8 @@ final class ApplicationPackageManager extends PackageManager {
    public List<ApplicationInfo> getInstalledApplications(int flags) {
        final int userId = mContext.getUserId();
        try {
            final List<ApplicationInfo> applicationInfos = new ArrayList<ApplicationInfo>();
            ApplicationInfo lastItem = null;
            ParceledListSlice<ApplicationInfo> slice;

            do {
                final String lastKey = lastItem != null ? lastItem.packageName : null;
                slice = mPM.getInstalledApplications(flags, lastKey, userId);
                lastItem = slice.populateList(applicationInfos, ApplicationInfo.CREATOR);
            } while (!slice.isLastSlice());

            return applicationInfos;
            ParceledListSlice<ApplicationInfo> slice = mPM.getInstalledApplications(flags, userId);
            return slice.getList();
        } catch (RemoteException e) {
            throw new RuntimeException("Package manager has died", e);
        }
+6 −0
Original line number Diff line number Diff line
@@ -628,6 +628,12 @@ class ContextImpl extends Context {
        return "android";
    }

    /** @hide */
    @Override
    public String getBasePackageName() {
        return mBasePackageName != null ? mBasePackageName : getPackageName();
    }

    @Override
    public ApplicationInfo getApplicationInfo() {
        if (mPackageInfo != null) {
+1 −1
Original line number Diff line number Diff line
@@ -208,7 +208,7 @@ public abstract class ContentResolver {

    public ContentResolver(Context context) {
        mContext = context != null ? context : ActivityThread.currentApplication();
        mPackageName = mContext.getPackageName();
        mPackageName = context.getBasePackageName();
    }

    /** @hide */
Loading