PackageManagerService 不再 extends IPackageManager.Stub ——> 改为由抽象类 IPackageManagerBase extends IPackageManager.Stub
不再以pkms为基础类addService "package"服务 ——> 改为以PackageManagerService 的内部类IPackageManagerImpl 为基础类addService"package"服务
而此内部类IPackageManagerImpl实现了抽象类IPackageManagerBase,则app可以通过AIDL将获得的binder转为接口实例来使用调用系统接口。
具体使用:
(可能需要是system_app或者在frameworks/base/core/java/android/content/pm/ApplicationInfo.java中的isAllowedToUseHiddenApis函数中添加调用系统隐藏接口的app_whitelist)
try {标签:PackageManagerService,package,app,Stub,binder,IPackageManager,Android13.0 From: https://www.cnblogs.com/1118zjg/p/16969681.html
Method method = Class.forName("android.os.ServiceManager").getMethod("getService", String.class);
IBinder binder = (IBinder) method.invoke(null, "package");
if (binder != null) {
IPackageManager mIPm = IPackageManager.Stub.asInterface(binder);
res = mIPm.deletePreloadsFileCache();
}
} catch (RemoteException | ClassNotFoundException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
e.printStackTrace();
}