Java Code Examples for android.content.pm.ApplicationInfo#isInstantApp()

The following examples show how to use android.content.pm.ApplicationInfo#isInstantApp() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IconDrawableFactory.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public Drawable getBadgedIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo,
        @UserIdInt int userId) {
    Drawable icon = mPm.loadUnbadgedItemIcon(itemInfo, appInfo);
    if (!mEmbedShadow && !needsBadging(appInfo, userId)) {
        return icon;
    }

    icon = getShadowedIcon(icon);
    if (appInfo.isInstantApp()) {
        int badgeColor = Resources.getSystem().getColor(
                com.android.internal.R.color.instant_app_badge, null);
        icon = mLauncherIcons.getBadgedDrawable(icon,
                com.android.internal.R.drawable.ic_instant_icon_badge_bolt,
                badgeColor);
    }
    if (mUm.isManagedProfile(userId)) {
        icon = mLauncherIcons.getBadgedDrawable(icon,
                com.android.internal.R.drawable.ic_corp_icon_badge_case,
                getUserBadgeColor(mUm, userId));
    }
    return icon;
}
 
Example 2
Source File: SettingsProvider.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
private List<String> getSettingsNamesLocked(int settingsType, int userId) {
    boolean instantApp;
    if (UserHandle.getAppId(Binder.getCallingUid()) < Process.FIRST_APPLICATION_UID) {
        instantApp = false;
    } else {
        ApplicationInfo ai = getCallingApplicationInfoOrThrow();
        instantApp = ai.isInstantApp();
    }
    if (instantApp) {
        return new ArrayList<String>(getInstantAppAccessibleSettings(settingsType));
    } else {
        return mSettingsRegistry.getSettingsNamesLocked(settingsType, userId);
    }
}
 
Example 3
Source File: SettingsProvider.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
private void enforceSettingReadable(String settingName, int settingsType, int userId) {
    if (UserHandle.getAppId(Binder.getCallingUid()) < Process.FIRST_APPLICATION_UID) {
        return;
    }
    ApplicationInfo ai = getCallingApplicationInfoOrThrow();
    if (!ai.isInstantApp()) {
        return;
    }
    if (!getInstantAppAccessibleSettings(settingsType).contains(settingName)
            && !getOverlayInstantAppAccessibleSettings(settingsType).contains(settingName)) {
        throw new SecurityException("Setting " + settingName + " is not accessible from"
                + " ephemeral package " + getCallingPackage());
    }
}
 
Example 4
Source File: ShortcutService.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private static boolean isEphemeralApp(@Nullable ApplicationInfo ai) {
    return (ai != null) && ai.isInstantApp();
}
 
Example 5
Source File: IconDrawableFactory.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
protected boolean needsBadging(ApplicationInfo appInfo, @UserIdInt int userId) {
    return appInfo.isInstantApp() || mUm.isManagedProfile(userId);
}