Merge "Add mainline module utils function into AppUtils" into rvc-dev am: a14615426f am: 8c53e8bf48 am: cec34ba6dd

Change-Id: I8ff92d223ab64668493e489aaaa6615bf06b2d3d
This commit is contained in:
Yanting Yang
2020-05-07 08:51:58 +00:00
committed by Automerger Merge Worker

View File

@@ -140,4 +140,15 @@ public class AppUtils {
.isSystemModule(packageName); .isSystemModule(packageName);
} }
/**
* Returns a boolean indicating whether a given package is a mainline module.
*/
public static boolean isMainlineModule(Context context, String packageName) {
final PackageManager pm = context.getPackageManager();
try {
return pm.getModuleInfo(packageName, 0 /* flags */) != null;
} catch (PackageManager.NameNotFoundException e) {
return false;
}
}
} }