Loading Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -157,6 +157,7 @@ LOCAL_SRC_FILES += \ core/java/android/content/ISyncServiceAdapter.aidl \ core/java/android/content/ISyncStatusObserver.aidl \ core/java/android/content/om/IOverlayManager.aidl \ core/java/android/content/pm/IDexModuleRegisterCallback.aidl \ core/java/android/content/pm/ILauncherApps.aidl \ core/java/android/content/pm/IOnAppsChangedListener.aidl \ core/java/android/content/pm/IOnPermissionsChangeListener.aidl \ Loading api/system-current.txt +7 −0 Original line number Diff line number Diff line Loading @@ -11340,6 +11340,7 @@ package android.content.pm { method public abstract java.util.List<android.content.pm.ResolveInfo> queryIntentContentProviders(android.content.Intent, int); method public abstract java.util.List<android.content.pm.ResolveInfo> queryIntentServices(android.content.Intent, int); method public abstract java.util.List<android.content.pm.PermissionInfo> queryPermissionsByGroup(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException; method public abstract void registerDexModule(java.lang.String, android.content.pm.PackageManager.DexModuleRegisterCallback); method public abstract void removeOnPermissionsChangeListener(android.content.pm.PackageManager.OnPermissionsChangedListener); method public abstract deprecated void removePackageFromPreferred(java.lang.String); method public abstract void removePermission(java.lang.String); Loading Loading @@ -11560,6 +11561,11 @@ package android.content.pm { field public static final int VERSION_CODE_HIGHEST = -1; // 0xffffffff } public static abstract class PackageManager.DexModuleRegisterCallback { ctor public PackageManager.DexModuleRegisterCallback(); method public abstract void onDexModuleRegistered(java.lang.String, boolean, java.lang.String); } public static class PackageManager.NameNotFoundException extends android.util.AndroidException { ctor public PackageManager.NameNotFoundException(); ctor public PackageManager.NameNotFoundException(java.lang.String); Loading Loading @@ -44527,6 +44533,7 @@ package android.test.mock { method public java.util.List<android.content.pm.ResolveInfo> queryIntentContentProviders(android.content.Intent, int); method public java.util.List<android.content.pm.ResolveInfo> queryIntentServices(android.content.Intent, int); method public java.util.List<android.content.pm.PermissionInfo> queryPermissionsByGroup(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException; method public void registerDexModule(java.lang.String, android.content.pm.PackageManager.DexModuleRegisterCallback); method public void removeOnPermissionsChangeListener(android.content.pm.PackageManager.OnPermissionsChangedListener); method public void removePackageFromPreferred(java.lang.String); method public void removePermission(java.lang.String); core/java/android/app/ApplicationPackageManager.java +78 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,10 @@ import android.os.UserManager; import android.os.storage.StorageManager; import android.os.storage.VolumeInfo; import android.provider.Settings; import android.system.ErrnoException; import android.system.Os; import android.system.OsConstants; import android.system.StructStat; import android.util.ArrayMap; import android.util.IconDrawableFactory; import android.util.LauncherIcons; Loading Loading @@ -2662,4 +2666,78 @@ public class ApplicationPackageManager extends PackageManager { throw e.rethrowAsRuntimeException(); } } private static class DexModuleRegisterResult { final String dexModulePath; final boolean success; final String message; private DexModuleRegisterResult(String dexModulePath, boolean success, String message) { this.dexModulePath = dexModulePath; this.success = success; this.message = message; } } private static class DexModuleRegisterCallbackDelegate extends android.content.pm.IDexModuleRegisterCallback.Stub implements Handler.Callback { private static final int MSG_DEX_MODULE_REGISTERED = 1; private final DexModuleRegisterCallback callback; private final Handler mHandler; DexModuleRegisterCallbackDelegate(@NonNull DexModuleRegisterCallback callback) { this.callback = callback; mHandler = new Handler(Looper.getMainLooper(), this); } @Override public void onDexModuleRegistered(@NonNull String dexModulePath, boolean success, @Nullable String message)throws RemoteException { mHandler.obtainMessage(MSG_DEX_MODULE_REGISTERED, new DexModuleRegisterResult(dexModulePath, success, message)).sendToTarget(); } @Override public boolean handleMessage(Message msg) { if (msg.what != MSG_DEX_MODULE_REGISTERED) { return false; } DexModuleRegisterResult result = (DexModuleRegisterResult)msg.obj; callback.onDexModuleRegistered(result.dexModulePath, result.success, result.message); return true; } } @Override public void registerDexModule(@NonNull String dexModule, @Nullable DexModuleRegisterCallback callback) { // Check if this is a shared module by looking if the others can read it. boolean isSharedModule = false; try { StructStat stat = Os.stat(dexModule); if ((OsConstants.S_IROTH & stat.st_mode) != 0) { isSharedModule = true; } } catch (ErrnoException e) { callback.onDexModuleRegistered(dexModule, false, "Could not get stat the module file: " + e.getMessage()); return; } // Module path is ok. // Create the callback delegate to be passed to package manager service. DexModuleRegisterCallbackDelegate callbackDelegate = null; if (callback != null) { callbackDelegate = new DexModuleRegisterCallbackDelegate(callback); } // Invoke the package manager service. try { mPM.registerDexModule(mContext.getPackageName(), dexModule, isSharedModule, callbackDelegate); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } } } core/java/android/content/pm/IDexModuleRegisterCallback.aidl 0 → 100644 +28 −0 Original line number Diff line number Diff line /* ** Copyright 2017, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ package android.content.pm; import android.os.Bundle; /** * Callback for registering a dex module with the Package Manager. * * @hide */ oneway interface IDexModuleRegisterCallback { void onDexModuleRegistered(in String dexModulePath, in boolean success, in String message); } core/java/android/content/pm/IPackageManager.aidl +33 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.content.pm.ApplicationInfo; import android.content.pm.ChangedPackages; import android.content.pm.InstantAppInfo; import android.content.pm.FeatureInfo; import android.content.pm.IDexModuleRegisterCallback; import android.content.pm.IPackageInstallObserver2; import android.content.pm.IPackageInstaller; import android.content.pm.IPackageDeleteObserver; Loading Loading @@ -473,6 +474,38 @@ interface IPackageManager { */ void notifyDexLoad(String loadingPackageName, in List<String> dexPaths, String loaderIsa); /** * Register an application dex module with the package manager. * The package manager will keep track of the given module for future optimizations. * * Dex module optimizations will disable the classpath checking at runtime. The client bares * the responsibility to ensure that the static assumptions on classes in the optimized code * hold at runtime (e.g. there's no duplicate classes in the classpath). * * Note that the package manager already keeps track of dex modules loaded with * {@link dalvik.system.DexClassLoader} and {@link dalvik.system.PathClassLoader}. * This can be called for an eager registration. * * The call might take a while and the results will be posted on the main thread, using * the given callback. * * If the module is intended to be shared with other apps, make sure that the file * permissions allow for it. * If at registration time the permissions allow for others to read it, the module would * be marked as a shared module which might undergo a different optimization strategy. * (usually shared modules will generated larger optimizations artifacts, * taking more disk space). * * @param packageName the package name to which the dex module belongs * @param dexModulePath the absolute path of the dex module. * @param isSharedModule whether or not the module is intended to be used by other apps. * @param callback if not null, * {@link android.content.pm.IDexModuleRegisterCallback.IDexModuleRegisterCallback#onDexModuleRegistered} * will be called once the registration finishes. */ void registerDexModule(in String packageName, in String dexModulePath, in boolean isSharedModule, IDexModuleRegisterCallback callback); /** * Ask the package manager to perform a dex-opt for the given reason. The package * manager will map the reason to a compiler filter according to the current system Loading Loading
Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -157,6 +157,7 @@ LOCAL_SRC_FILES += \ core/java/android/content/ISyncServiceAdapter.aidl \ core/java/android/content/ISyncStatusObserver.aidl \ core/java/android/content/om/IOverlayManager.aidl \ core/java/android/content/pm/IDexModuleRegisterCallback.aidl \ core/java/android/content/pm/ILauncherApps.aidl \ core/java/android/content/pm/IOnAppsChangedListener.aidl \ core/java/android/content/pm/IOnPermissionsChangeListener.aidl \ Loading
api/system-current.txt +7 −0 Original line number Diff line number Diff line Loading @@ -11340,6 +11340,7 @@ package android.content.pm { method public abstract java.util.List<android.content.pm.ResolveInfo> queryIntentContentProviders(android.content.Intent, int); method public abstract java.util.List<android.content.pm.ResolveInfo> queryIntentServices(android.content.Intent, int); method public abstract java.util.List<android.content.pm.PermissionInfo> queryPermissionsByGroup(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException; method public abstract void registerDexModule(java.lang.String, android.content.pm.PackageManager.DexModuleRegisterCallback); method public abstract void removeOnPermissionsChangeListener(android.content.pm.PackageManager.OnPermissionsChangedListener); method public abstract deprecated void removePackageFromPreferred(java.lang.String); method public abstract void removePermission(java.lang.String); Loading Loading @@ -11560,6 +11561,11 @@ package android.content.pm { field public static final int VERSION_CODE_HIGHEST = -1; // 0xffffffff } public static abstract class PackageManager.DexModuleRegisterCallback { ctor public PackageManager.DexModuleRegisterCallback(); method public abstract void onDexModuleRegistered(java.lang.String, boolean, java.lang.String); } public static class PackageManager.NameNotFoundException extends android.util.AndroidException { ctor public PackageManager.NameNotFoundException(); ctor public PackageManager.NameNotFoundException(java.lang.String); Loading Loading @@ -44527,6 +44533,7 @@ package android.test.mock { method public java.util.List<android.content.pm.ResolveInfo> queryIntentContentProviders(android.content.Intent, int); method public java.util.List<android.content.pm.ResolveInfo> queryIntentServices(android.content.Intent, int); method public java.util.List<android.content.pm.PermissionInfo> queryPermissionsByGroup(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException; method public void registerDexModule(java.lang.String, android.content.pm.PackageManager.DexModuleRegisterCallback); method public void removeOnPermissionsChangeListener(android.content.pm.PackageManager.OnPermissionsChangedListener); method public void removePackageFromPreferred(java.lang.String); method public void removePermission(java.lang.String);
core/java/android/app/ApplicationPackageManager.java +78 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,10 @@ import android.os.UserManager; import android.os.storage.StorageManager; import android.os.storage.VolumeInfo; import android.provider.Settings; import android.system.ErrnoException; import android.system.Os; import android.system.OsConstants; import android.system.StructStat; import android.util.ArrayMap; import android.util.IconDrawableFactory; import android.util.LauncherIcons; Loading Loading @@ -2662,4 +2666,78 @@ public class ApplicationPackageManager extends PackageManager { throw e.rethrowAsRuntimeException(); } } private static class DexModuleRegisterResult { final String dexModulePath; final boolean success; final String message; private DexModuleRegisterResult(String dexModulePath, boolean success, String message) { this.dexModulePath = dexModulePath; this.success = success; this.message = message; } } private static class DexModuleRegisterCallbackDelegate extends android.content.pm.IDexModuleRegisterCallback.Stub implements Handler.Callback { private static final int MSG_DEX_MODULE_REGISTERED = 1; private final DexModuleRegisterCallback callback; private final Handler mHandler; DexModuleRegisterCallbackDelegate(@NonNull DexModuleRegisterCallback callback) { this.callback = callback; mHandler = new Handler(Looper.getMainLooper(), this); } @Override public void onDexModuleRegistered(@NonNull String dexModulePath, boolean success, @Nullable String message)throws RemoteException { mHandler.obtainMessage(MSG_DEX_MODULE_REGISTERED, new DexModuleRegisterResult(dexModulePath, success, message)).sendToTarget(); } @Override public boolean handleMessage(Message msg) { if (msg.what != MSG_DEX_MODULE_REGISTERED) { return false; } DexModuleRegisterResult result = (DexModuleRegisterResult)msg.obj; callback.onDexModuleRegistered(result.dexModulePath, result.success, result.message); return true; } } @Override public void registerDexModule(@NonNull String dexModule, @Nullable DexModuleRegisterCallback callback) { // Check if this is a shared module by looking if the others can read it. boolean isSharedModule = false; try { StructStat stat = Os.stat(dexModule); if ((OsConstants.S_IROTH & stat.st_mode) != 0) { isSharedModule = true; } } catch (ErrnoException e) { callback.onDexModuleRegistered(dexModule, false, "Could not get stat the module file: " + e.getMessage()); return; } // Module path is ok. // Create the callback delegate to be passed to package manager service. DexModuleRegisterCallbackDelegate callbackDelegate = null; if (callback != null) { callbackDelegate = new DexModuleRegisterCallbackDelegate(callback); } // Invoke the package manager service. try { mPM.registerDexModule(mContext.getPackageName(), dexModule, isSharedModule, callbackDelegate); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } } }
core/java/android/content/pm/IDexModuleRegisterCallback.aidl 0 → 100644 +28 −0 Original line number Diff line number Diff line /* ** Copyright 2017, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ package android.content.pm; import android.os.Bundle; /** * Callback for registering a dex module with the Package Manager. * * @hide */ oneway interface IDexModuleRegisterCallback { void onDexModuleRegistered(in String dexModulePath, in boolean success, in String message); }
core/java/android/content/pm/IPackageManager.aidl +33 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.content.pm.ApplicationInfo; import android.content.pm.ChangedPackages; import android.content.pm.InstantAppInfo; import android.content.pm.FeatureInfo; import android.content.pm.IDexModuleRegisterCallback; import android.content.pm.IPackageInstallObserver2; import android.content.pm.IPackageInstaller; import android.content.pm.IPackageDeleteObserver; Loading Loading @@ -473,6 +474,38 @@ interface IPackageManager { */ void notifyDexLoad(String loadingPackageName, in List<String> dexPaths, String loaderIsa); /** * Register an application dex module with the package manager. * The package manager will keep track of the given module for future optimizations. * * Dex module optimizations will disable the classpath checking at runtime. The client bares * the responsibility to ensure that the static assumptions on classes in the optimized code * hold at runtime (e.g. there's no duplicate classes in the classpath). * * Note that the package manager already keeps track of dex modules loaded with * {@link dalvik.system.DexClassLoader} and {@link dalvik.system.PathClassLoader}. * This can be called for an eager registration. * * The call might take a while and the results will be posted on the main thread, using * the given callback. * * If the module is intended to be shared with other apps, make sure that the file * permissions allow for it. * If at registration time the permissions allow for others to read it, the module would * be marked as a shared module which might undergo a different optimization strategy. * (usually shared modules will generated larger optimizations artifacts, * taking more disk space). * * @param packageName the package name to which the dex module belongs * @param dexModulePath the absolute path of the dex module. * @param isSharedModule whether or not the module is intended to be used by other apps. * @param callback if not null, * {@link android.content.pm.IDexModuleRegisterCallback.IDexModuleRegisterCallback#onDexModuleRegistered} * will be called once the registration finishes. */ void registerDexModule(in String packageName, in String dexModulePath, in boolean isSharedModule, IDexModuleRegisterCallback callback); /** * Ask the package manager to perform a dex-opt for the given reason. The package * manager will map the reason to a compiler filter according to the current system Loading