| 613 | } |
| 614 | |
| 615 | private static int getAppType(@Nullable Context context) { |
| 616 | if (sAppType != AppType.UNSET) { |
| 617 | return sAppType; |
| 618 | } |
| 619 | if (context == null) { |
| 620 | LogUtil.d(TAG, "context is null, fallback to THIRD_PARTY_APP appType"); |
| 621 | return AppType.THIRD_PARTY_APP; |
| 622 | } |
| 623 | |
| 624 | final int type; |
| 625 | final ApplicationInfo appInfo = context.getApplicationInfo(); |
| 626 | |
| 627 | if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) { |
| 628 | type = AppType.THIRD_PARTY_APP; |
| 629 | } else if ((appInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) { |
| 630 | type = AppType.UPDATED_SYSTEM_APP; |
| 631 | } else { |
| 632 | type = AppType.SYSTEM_APP; |
| 633 | } |
| 634 | LogUtil.d(TAG, "ApplicationInfo.flags is: " + appInfo.flags + " appType is: " + type); |
| 635 | return type; |
| 636 | } |
| 637 | |
| 638 | /** Turn shared-library loading into a no-op. Useful in special circumstances. */ |
| 639 | public static void setInTestMode() { |