urbanairship-core/src/main/java/com/urbanairship/iam/AudienceChecks.java
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
    static boolean checkAudienceForScheduling(Context context, @Nullable Audience audience, boolean isNewUser) {
        if (audience == null) {
            return true;
        }

        // New user
        if (audience.getNewUser() != null && audience.getNewUser() != isNewUser) {
            return false;
        }

        // Test devices
        if (!audience.getTestDevices().isEmpty()) {
            byte[] digest = UAStringUtil.sha256Digest(UAirship.shared().getPushManager().getChannelId());
            if (digest == null || digest.length < 16) {
                return false;
            }

            digest = Arrays.copyOf(digest, 16);

            for (String testDevice : audience.getTestDevices()) {
                byte[] decoded = UAStringUtil.base64Decode(testDevice);
                if (Arrays.equals(digest, decoded)) {
                    return true;
                }
            }

            return false;
        }

        return true;
    }
/**
     * Checks the audience and new user.
     *
     * @param context The application context.
     * @param audience The audience.
     * @param isNewUser If the user is new.
     * @return {@code true} if the audience conditions are met, otherwise {@code false}.
     * @hide
     */
Checks the audience and new user.
@param context The application context.
@param audience The audience.
@param isNewUser If the user is new.
@return  true if the audience conditions are met, otherwise  false.
@hide
Checks the audience and new user . @param context The application context . @param audience The audience . @param isNewUser If the user is new . @return true if the audience conditions are met otherwise false . @hide
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
    static boolean checkAudienceForScheduling(Context context, @Nullable Audience audience, boolean isNewUser) {
        if (audience == null) {
            return true;
        }
        if (audience.getNewUser() != null && audience.getNewUser() != isNewUser) {
            return false;
        }
        if (!audience.getTestDevices().isEmpty()) {
            byte[] digest = UAStringUtil.sha256Digest(UAirship.shared().getPushManager().getChannelId());
            if (digest == null || digest.length < 16) {
                return false;
            }
            digest = Arrays.copyOf(digest, 16);
            for (String testDevice : audience.getTestDevices()) {
                byte[] decoded = UAStringUtil.base64Decode(testDevice);
                if (Arrays.equals(digest, decoded)) {
                    return true;
                }
            }
            return false;
        }
        return true;
    }
@ RestrictTo ( RestrictTo . Scope . LIBRARY_GROUP ) static boolean checkAudienceForScheduling ( Context context , @ Nullable Audience audience , boolean isNewUser ) { if ( audience == null ) { return true ; } if ( audience . getNewUser ( ) != null && audience . getNewUser ( ) != isNewUser ) { return false ; } if ( ! audience . getTestDevices ( ) . isEmpty ( ) ) { byte [ ] digest = UAStringUtil . sha256Digest ( UAirship . shared ( ) . getPushManager ( ) . getChannelId ( ) ) ; if ( digest == null || digest . length < 16 ) { return false ; } digest = Arrays . copyOf ( digest , 16 ) ; for ( String testDevice : audience . getTestDevices ( ) ) { byte [ ] decoded = UAStringUtil . base64Decode ( testDevice ) ; if ( Arrays . equals ( digest , decoded ) ) { return true ; } } return false ; } return true ; }
Checks the audience and new user.
Checks the audience and new user .
// New user // Test devices