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

Commit 5d04c97d authored by Yuting Fang's avatar Yuting Fang Committed by Android (Google) Code Review
Browse files

Merge "Use ParceledListSlice to paginate response from...

Merge "Use ParceledListSlice to paginate response from getPackagesForOpsForDevice binder API" into main
parents dc33f8b1 2c637955
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -8501,13 +8501,13 @@ public class AppOpsManager {
        } else {
            opCodes = null;
        }
        final List<AppOpsManager.PackageOps> result;
        try {
            result = mService.getPackagesForOpsForDevice(opCodes, persistentDeviceId);
            ParceledListSlice<PackageOps> packageOps = mService.getPackagesForOpsForDevice(opCodes,
                    persistentDeviceId);
            return packageOps == null ? Collections.emptyList() : packageOps.getList();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
        return (result != null) ? result : Collections.emptyList();
    }

    /**
@@ -8526,8 +8526,9 @@ public class AppOpsManager {
    @UnsupportedAppUsage
    public List<AppOpsManager.PackageOps> getPackagesForOps(int[] ops) {
        try {
            return mService.getPackagesForOpsForDevice(ops,
            ParceledListSlice<PackageOps> packageOps = mService.getPackagesForOpsForDevice(ops,
                    VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT);
            return packageOps == null ? null : packageOps.getList();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
+2 −2
Original line number Diff line number Diff line
@@ -162,6 +162,6 @@ interface IAppOpsService {
            int attributionFlags, int attributionChainId);
    void finishOperationForDevice(IBinder clientId, int code, int uid, String packageName,
            @nullable String attributionTag, int virtualDeviceId);
   List<AppOpsManager.PackageOps> getPackagesForOpsForDevice(in int[] ops, String persistentDeviceId);
    ParceledListSlice<AppOpsManager.PackageOps> getPackagesForOpsForDevice(in int[] ops, String persistentDeviceId);
    oneway void noteOperationsInBatch(in Map batchedNoteOps);
}
+7 −4
Original line number Diff line number Diff line
@@ -110,6 +110,7 @@ import android.content.IntentFilter;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManagerInternal;
import android.content.pm.ParceledListSlice;
import android.content.pm.PermissionInfo;
import android.content.pm.UserInfo;
import android.database.ContentObserver;
@@ -203,8 +204,8 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.StringWriter;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.Instant;
@@ -1820,11 +1821,13 @@ public class AppOpsService extends IAppOpsService.Stub {

    @Override
    public List<AppOpsManager.PackageOps> getPackagesForOps(int[] ops) {
        return getPackagesForOpsForDevice(ops, PERSISTENT_DEVICE_ID_DEFAULT);
        ParceledListSlice<AppOpsManager.PackageOps> packageOps = getPackagesForOpsForDevice(ops,
                PERSISTENT_DEVICE_ID_DEFAULT);
        return packageOps == null ? null : packageOps.getList();
    }

    @Override
    public List<AppOpsManager.PackageOps> getPackagesForOpsForDevice(int[] ops,
    public ParceledListSlice<AppOpsManager.PackageOps> getPackagesForOpsForDevice(int[] ops,
            @NonNull String persistentDeviceId) {
        final int callingUid = Binder.getCallingUid();
        final boolean hasAllPackageAccess = mContext.checkPermission(
@@ -1861,7 +1864,7 @@ public class AppOpsService extends IAppOpsService.Stub {
                }
            }
        }
        return res;
        return res == null ? null : new ParceledListSlice<>(res);
    }

    @Override