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

Commit 7a84f1a9 authored by Yanting Yang's avatar Yanting Yang
Browse files

Add mainline module utils function into AppUtils

Bug: 152718521
Test: make RunSettingsLibRoboTests
Change-Id: I258a6272bb596f7d6d2697d9e46a8624fb296442
parent c6025a7f
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -140,4 +140,15 @@ public class AppUtils {
                .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;
        }
    }
}