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

Commit a4a631ea authored by Przemyslaw Szczepaniak's avatar Przemyslaw Szczepaniak
Browse files

Add getLocationFlags getter to PackageManagerNative.

This information is required for enforcing NNAPI Vendor Extensions
restrictions in libneuralnetworks.so library.

What it does is already possible using ApplicationInfo, but in native code
there's no equivalent to platform private (non-exposed public), because of
that I had to create getLocationFlags as an explicit API.

Bug: 120483623
Test: CtsNNAPITestCases

Change-Id: I0b3a5a4f3559b2d1d44088c8fa1d5bb5605c83cb
parent f81337ad
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -23260,6 +23260,23 @@ public class PackageManagerService extends IPackageManager.Stub
            }
            return results;
        }
        @Override
        public int getLocationFlags(String packageName) throws RemoteException {
            int callingUser = UserHandle.getUserId(Binder.getCallingUid());
            ApplicationInfo appInfo = getApplicationInfo(packageName,
                    /*flags*/ 0,
                    /*userId*/ callingUser);
            if (appInfo == null) {
                throw new RemoteException(
                        "Couldn't get ApplicationInfo for package " + packageName);
            }
            return ((appInfo.isSystemApp() ? IPackageManagerNative.LOCATION_SYSTEM : 0)
                    | (appInfo.isVendor() ? IPackageManagerNative.LOCATION_VENDOR : 0)
                    | (appInfo.isProduct() ? IPackageManagerNative.LOCATION_PRODUCT : 0)
                    | (appInfo.isProductServices()
                            ? IPackageManagerNative.LOCATION_PRODUCT_SERVICES : 0));
        }
    }
    private class PackageManagerInternalImpl extends PackageManagerInternal {