Validate the ProvidedServiceInstance.

@param serviceInstance
the ServiceInstance.
@return
OK if all ServiceInstance fields are valid.
188810
public static ErrorCode validateProvidedServiceInstance(ProvidedServiceInstance serviceInstance) {

        ErrorCode retstr = isIdValid(serviceInstance.getProviderId());
        if (retstr != ErrorCode.OK) {
            return retstr;
        }

        retstr = isNameValid(serviceInstance.getServiceName());
        if (retstr != ErrorCode.OK) {
            return retstr;
        }

        retstr = isUriValid(serviceInstance.getUri());
        if (retstr != ErrorCode.OK) {
            return retstr;
        }

        retstr = isPortValid(serviceInstance.getPort());
        if (retstr != ErrorCode.OK) {
            return retstr;
        }

        /**
        * Skip the ip validation.
        retstr = isAddressValid(serviceInstance.getAddress());
        if (retstr != ErrorCode.OK) {
            return retstr;
        }
        **/

        Map<String, String> metadata = serviceInstance.getMetadata();
        if (metadata != null && metadata.size() > 0) {
            Iterator<Entry<String, String>> itor = metadata.entrySet().iterator();
            while (itor.hasNext()) {
                Map.Entry<String, String> entry = (Map.Entry<String, String>) itor
                        .next();
                if (!isOptionalFieldValid(entry.getKey(), metaKeyRegEx)) {
                    return ErrorCode.SERVICE_INSTANCE_METAKEY_FORMAT_ERROR;
                }
            }
        }
        return ErrorCode.OK;
    }
1158292
@Override
    public void validate() throws OpsGenieClientValidationException {
        super.validate();
        if (getAlias() == null)
            throw OpsGenieClientValidationException.missingMandatoryProperty(OpsGenieClientConstants.API.ALIAS);
    }
829525
protected void validate(String operationType) throws Exception
	{
		super.validate(operationType);

		MPSString id_validator = new MPSString();
		id_validator.setConstraintIsReq(MPSConstants.DELETE_CONSTRAINT, true);
		id_validator.setConstraintIsReq(MPSConstants.MODIFY_CONSTRAINT, true);
		id_validator.validate(operationType, id, "\"id\"");
		
		MPSInternetHost server_name_validator = new MPSInternetHost();
		server_name_validator.setConstraintIsReq(MPSConstants.ADD_CONSTRAINT, true);
		server_name_validator.validate(operationType, server_name, "\"server_name\"");
		
		MPSString username_validator = new MPSString();
		username_validator.setConstraintCharSetRegEx(MPSConstants.GENERIC_CONSTRAINT,"[ a-zA-Z0-9_#.:@=-]+");
		username_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 128);
		username_validator.validate(operationType, username, "\"username\"");
		
		MPSString profile_name_validator = new MPSString();
		profile_name_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 128);
		profile_name_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		profile_name_validator.setConstraintIsReq(MPSConstants.ADD_CONSTRAINT, true);
		profile_name_validator.validate(operationType, profile_name, "\"profile_name\"");
		
		MPSString to_list_validator = new MPSString();
		to_list_validator.validate(operationType, to_list, "\"to_list\"");
		
		MPSString url_validator = new MPSString();
		url_validator.validate(operationType, url, "\"url\"");
		
		MPSString message_validator = new MPSString();
		message_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 20000);
		message_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		message_validator.validate(operationType, message, "\"message\"");
		
		MPSBoolean is_sent_validator = new MPSBoolean();
		is_sent_validator.validate(operationType, is_sent, "\"is_sent\"");
		
		MPSLong timestamp_validator = new MPSLong();
		timestamp_validator.validate(operationType, timestamp, "\"timestamp\"");
		
		MPSString failed_message_validator = new MPSString();
		failed_message_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 2000);
		failed_message_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		failed_message_validator.validate(operationType, failed_message, "\"failed_message\"");
		
		MPSBoolean is_ssl_validator = new MPSBoolean();
		is_ssl_validator.validate(operationType, is_ssl, "\"is_ssl\"");
		
	}
1044787
public static ErrorCode isNameValid(String name) {
        if (!isMustFieldValid(name, nameRegEx)) {
            return ErrorCode.SERVICE_INSTANCE_NAME_FORMAT_ERROR;
        }
        return ErrorCode.OK;
    }
1156779
protected void validate(String operationType) throws Exception
	{
		super.validate(operationType);

		MPSString id_validator = new MPSString();
		id_validator.setConstraintIsReq(MPSConstants.DELETE_CONSTRAINT, true);
		id_validator.setConstraintIsReq(MPSConstants.MODIFY_CONSTRAINT, true);
		id_validator.validate(operationType, id, "\"id\"");
		
		MPSInternetHost server_name_validator = new MPSInternetHost();
		server_name_validator.setConstraintIsReq(MPSConstants.ADD_CONSTRAINT, true);
		server_name_validator.validate(operationType, server_name, "\"server_name\"");
		
		MPSInt port_validator = new MPSInt();
		port_validator.setConstraintMinValue(MPSConstants.GENERIC_CONSTRAINT, 0);
		port_validator.setConstraintMaxValue(MPSConstants.GENERIC_CONSTRAINT, 65534);
		port_validator.validate(operationType, port, "\"port\"");
		
		MPSString username_validator = new MPSString();
		username_validator.setConstraintCharSetRegEx(MPSConstants.GENERIC_CONSTRAINT,"[ a-zA-Z0-9_#.:@=-]+");
		username_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 128);
		username_validator.validate(operationType, username, "\"username\"");
		
		MPSBoolean is_auth_validator = new MPSBoolean();
		is_auth_validator.validate(operationType, is_auth, "\"is_auth\"");
		
		MPSBoolean is_ssl_validator = new MPSBoolean();
		is_ssl_validator.validate(operationType, is_ssl, "\"is_ssl\"");
		
		MPSString profile_name_validator = new MPSString();
		profile_name_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 128);
		profile_name_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		profile_name_validator.setConstraintIsReq(MPSConstants.ADD_CONSTRAINT, true);
		profile_name_validator.validate(operationType, profile_name, "\"profile_name\"");
		
		MPSString to_list_validator = new MPSString();
		to_list_validator.validate(operationType, to_list, "\"to_list\"");
		
		MPSString cc_list_validator = new MPSString();
		cc_list_validator.validate(operationType, cc_list, "\"cc_list\"");
		
		MPSString bcc_list_validator = new MPSString();
		bcc_list_validator.validate(operationType, bcc_list, "\"bcc_list\"");
		
		MPSString subject_validator = new MPSString();
		subject_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 2000);
		subject_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		subject_validator.validate(operationType, subject, "\"subject\"");
		
		MPSString message_validator = new MPSString();
		message_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 20000);
		message_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		message_validator.validate(operationType, message, "\"message\"");
		
		MPSBoolean is_sent_validator = new MPSBoolean();
		is_sent_validator.validate(operationType, is_sent, "\"is_sent\"");
		
		MPSLong timestamp_validator = new MPSLong();
		timestamp_validator.validate(operationType, timestamp, "\"timestamp\"");
		
		MPSString failed_message_validator = new MPSString();
		failed_message_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 2000);
		failed_message_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		failed_message_validator.validate(operationType, failed_message, "\"failed_message\"");
		
	}
609927
private boolean validateServiceIntent(Context context, Intent intent) {
        ResolveInfo resolveInfo = context.getPackageManager().resolveService(intent, 0);
        if (resolveInfo == null) {
            return false;
        }

        return validateAppSignatureForPackage(context, resolveInfo.serviceInfo.packageName);
    }
887643
protected void validate(String operationType) throws Exception
	{
		super.validate(operationType);

		MPSString port_name_validator = new MPSString();
		port_name_validator.setConstraintIsReq(MPSConstants.GENERIC_CONSTRAINT, true);
		port_name_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 128);
		port_name_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		port_name_validator.validate(operationType, port_name, "\"port_name\"");
		
		MPSString managed_device_id_validator = new MPSString();
		managed_device_id_validator.validate(operationType, managed_device_id, "\"managed_device_id\"");
		
		MPSIPAddress ip_address_validator = new MPSIPAddress();
		ip_address_validator.validate(operationType, ip_address, "\"ip_address\"");
		
		MPSIPAddress netmask_validator = new MPSIPAddress();
		netmask_validator.validate(operationType, netmask, "\"netmask\"");
		
		MPSIPAddress gateway_validator = new MPSIPAddress();
		gateway_validator.validate(operationType, gateway, "\"gateway\"");
		
		MPSInt vlan_validator = new MPSInt();
		vlan_validator.setConstraintMinValue(MPSConstants.GENERIC_CONSTRAINT, 0);
		vlan_validator.setConstraintMaxValue(MPSConstants.GENERIC_CONSTRAINT, 4095);
		vlan_validator.validate(operationType, vlan, "\"vlan\"");
		
		MPSString name_server_validator = new MPSString();
		name_server_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 64);
		name_server_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		name_server_validator.validate(operationType, name_server, "\"name_server\"");
		
		MPSString mac_address_validator = new MPSString();
		mac_address_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 32);
		mac_address_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		mac_address_validator.validate(operationType, mac_address, "\"mac_address\"");
		
		MPSBoolean is_mgmt_ifc_validator = new MPSBoolean();
		is_mgmt_ifc_validator.validate(operationType, is_mgmt_ifc, "\"is_mgmt_ifc\"");
		
		MPSString mac_mode_validator = new MPSString();
		mac_mode_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		mac_mode_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		mac_mode_validator.validate(operationType, mac_mode, "\"mac_mode\"");
		
		MPSString device_channel_name_validator = new MPSString();
		device_channel_name_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 32);
		device_channel_name_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		device_channel_name_validator.validate(operationType, device_channel_name, "\"device_channel_name\"");
		
		MPSBoolean is_member_ifc_validator = new MPSBoolean();
		is_member_ifc_validator.validate(operationType, is_member_ifc, "\"is_member_ifc\"");
		
		MPSString vrid_list_ipv6_validator = new MPSString();
		vrid_list_ipv6_validator.validate(operationType, vrid_list_ipv6, "\"vrid_list_ipv6\"");
		
		MPSString vrid_list_ipv4_validator = new MPSString();
		vrid_list_ipv4_validator.validate(operationType, vrid_list_ipv4, "\"vrid_list_ipv4\"");
		
		MPSString vlan_whitelist_validator = new MPSString();
		vlan_whitelist_validator.validate(operationType, vlan_whitelist, "\"vlan_whitelist\"");
		
		MPSBoolean receiveuntagged_validator = new MPSBoolean();
		receiveuntagged_validator.validate(operationType, receiveuntagged, "\"receiveuntagged\"");
		
		MPSBoolean l2_enabled_validator = new MPSBoolean();
		l2_enabled_validator.validate(operationType, l2_enabled, "\"l2_enabled\"");
		
		MPSInt vf_index_validator = new MPSInt();
		vf_index_validator.validate(operationType, vf_index, "\"vf_index\"");
		
		MPSString vrid_list_ipv4_array_validator = new MPSString();
		if(vrid_list_ipv4_array != null)
		{
			for(int i=0; i<vrid_list_ipv4_array.length; i++)
			{
				vrid_list_ipv4_array_validator.validate(operationType, vrid_list_ipv4_array[i], "vrid_list_ipv4_array["+i+"]");
			}
		}
		
		MPSString vrid_list_ipv6_array_validator = new MPSString();
		if(vrid_list_ipv6_array != null)
		{
			for(int i=0; i<vrid_list_ipv6_array.length; i++)
			{
				vrid_list_ipv6_array_validator.validate(operationType, vrid_list_ipv6_array[i], "vrid_list_ipv6_array["+i+"]");
			}
		}
		
		MPSString vlan_whitelist_array_validator = new MPSString();
		if(vlan_whitelist_array != null)
		{
			for(int i=0; i<vlan_whitelist_array.length; i++)
			{
				vlan_whitelist_array_validator.validate(operationType, vlan_whitelist_array[i], "vlan_whitelist_array["+i+"]");
			}
		}
		
		MPSBoolean is_vlan_applied_validator = new MPSBoolean();
		is_vlan_applied_validator.validate(operationType, is_vlan_applied, "\"is_vlan_applied\"");
		
	}
155449
private ServiceReference checkService(ServiceReference serviceReference, String interfaceClassName)
    {
        if (serviceReference != null)
        {
            Object service = bundleContext.getService(serviceReference);
            if (service != null)
            {
                try {
                    if (interfaceClassName != null)
                        if (!service.getClass().isAssignableFrom(Class.forName(interfaceClassName)))
                            serviceReference = null;
                } catch (ClassNotFoundException e) {
                    // Ignore this error
                }
            }
        }
        return serviceReference;
    }
737720
public synchronized boolean hasService(Class serviceClass) {

        // todo: for multithreaded usage this block needs to be synchronized
        ServiceProvider sp = _serviceProviders.get(serviceClass);
        if (sp != null && !sp.isRevoked()) {
            return true;
        }

        // if service not found locally check in nested context
        BeanContext bc = getBeanContext();
        if (bc instanceof BeanContextServices) {
            return ((BeanContextServices) bc).hasService(serviceClass);
        }
        return false;
        // end synchronized
    }
1112628
protected void validateCredentials(final UsernamePasswordCredentials credentials,
                                       final OAuthRegisteredService registeredService,
                                       final WebContext context) {
        if (!OAuth20Utils.checkClientSecret(registeredService, credentials.getPassword())) {
            throw new CredentialsException("Bad secret for client identifier: " + credentials.getPassword());
        }
    }
806610
protected Assertion validateServiceTicket(final WebApplicationService service, final String serviceTicketId) {
        return serviceValidateConfigurationContext.getCentralAuthenticationService().validateServiceTicket(serviceTicketId, service);
    }
92716
protected void validate(String operationType) throws Exception
	{
		super.validate(operationType);

		MPSBoolean authentication_validator = new MPSBoolean();
		authentication_validator.validate(operationType, authentication, "\"authentication\"");
		
		MPSInt trusted_key_list_validator = new MPSInt();
		trusted_key_list_validator.setConstraintIsReq(MPSConstants.GENERIC_CONSTRAINT, true);
		trusted_key_list_validator.setConstraintMinValue(MPSConstants.GENERIC_CONSTRAINT, 1);
		trusted_key_list_validator.setConstraintMaxValue(MPSConstants.GENERIC_CONSTRAINT, 65534);
		if(trusted_key_list != null)
		{
			for(int i=0; i<trusted_key_list.length; i++)
			{
				trusted_key_list_validator.validate(operationType, trusted_key_list[i], "trusted_key_list["+i+"]");
			}
		}
		
		MPSInt revoke_logsec_validator = new MPSInt();
		revoke_logsec_validator.setConstraintMinValue(MPSConstants.GENERIC_CONSTRAINT, 0);
		revoke_logsec_validator.validate(operationType, revoke_logsec, "\"revoke_logsec\"");
		
		MPSInt automax_logsec_validator = new MPSInt();
		automax_logsec_validator.setConstraintMinValue(MPSConstants.GENERIC_CONSTRAINT, 0);
		automax_logsec_validator.validate(operationType, automax_logsec, "\"automax_logsec\"");
		
	}
194577
public static void validateURI(String uri) throws ServiceException {
        if (uri == null || uri.isEmpty() || !validateRequiredField(uri, urlRegEx) || !isValidBrace(uri)) {
            throw new ServiceException(ErrorCode.SERVICE_INSTANCE_URI_FORMAT_ERROR);
        }
    }
816346
private void validateAndSetMemberLevelWebServiceRef(WebServiceRef webServiceRef, Member member, WebServiceRefInfo wsrInfo) throws InjectionException {

        // Save off these annotation attributes for use later.
        Class<?> typeClass = webServiceRef.type();
        Class<?> valueClass = webServiceRef.value();

        // If the @WebServiceRef's lookup is specified, then no other attributes should be present. Only name can be specified with lookup.
        if (webServiceRef.lookup() != null && !webServiceRef.lookup().isEmpty()) {
            if (!typeClass.getName().equals(Object.class.getName())
                || !valueClass.getName().equals(Service.class.getName())
                || !webServiceRef.wsdlLocation().isEmpty()
                || !webServiceRef.mappedName().isEmpty()) {
                Tr.error(tc, "error.service.ref.annotation.lookup.redundant.attributes");
                throw new InjectionException(Tr.formatMessage(tc, "error.service.ref.annotation.lookup.redundant.attributes"));
            }

        } else { // Otherwise, no 'lookup' attribute is present, then do our normal validations.

            // get the effective type from the member type and WebServiceRef.type
            Class<?> memberType = InjectionHelper.getTypeFromMember(member);
            Class<?> effectiveType;
            if (memberType.getName().equals(Object.class.getName())) { //memberType is Object.class
                effectiveType = typeClass;
                // effectiveType could be Object here
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled() && typeClass.getName().equals(Object.class.getName())) {
                    Tr.debug(tc, "The member type and the @WebServiceRef.type on the " + member.getName() + " in " + member.getDeclaringClass().getName()
                                 + "are all Object.class, so can not infer one. Will try service type injection if the @WebServiceRef.value is a subclass of Service.class.");
                }

            } else { //memberType is not Object.class
                //we prefer subclass
                if (memberType.isAssignableFrom(typeClass)) {
                    effectiveType = typeClass;
                } else if (typeClass.isAssignableFrom(memberType)) {
                    effectiveType = memberType;
                } else {
                    Tr.error(tc, "error.service.ref.member.level.annotation.type.not.compatible",
                             member.getName(), member.getDeclaringClass().getName(), typeClass.getName(), memberType.getName());
                    throw new InjectionException(Tr.formatMessage(tc, "error.service.ref.member.level.annotation.type.not.compatible",
                                                                  member.getName(), member.getDeclaringClass().getName(), typeClass.getName(), memberType.getName()));
                }
            }

            // validate and set value and type in WebServiceRefInfo
            if (effectiveType.getName().equals(Object.class.getName())) { // effectiveType can not be determined above, so try service type injection
                // in this case the 'value' attribute MUST specify a subclass of javax.xml.ws.Service
                if (!Service.class.isAssignableFrom(valueClass) || valueClass.getName().equals(Service.class.getName())) {
                    Tr.error(tc, "error.service.ref.member.level.annotation.type.not.inferred",
                             member.getName(), member.getDeclaringClass().getName());
                    throw new InjectionException(Tr.formatMessage(tc, "error.service.ref.member.level.annotation.type.not.inferred",
                                                                  member.getName(), member.getDeclaringClass().getName()));
                }

                wsrInfo.setServiceRefTypeClassName(valueClass.getName());
                wsrInfo.setServiceInterfaceClassName(valueClass.getName());

            } else if (Service.class.isAssignableFrom(effectiveType)) { // service type injection case
                if (effectiveType.getName().equals(Service.class.getName())) { // effectiveType is javax.xml.ws.Service
                    // in this case the 'value' attribute MUST specify a subclass of javax.xml.ws.Service
                    if (!Service.class.isAssignableFrom(valueClass) || valueClass.getName().equals(Service.class.getName())) {
                        Tr.error(tc, "error.service.ref.member.level.annotation.wrong.value",
                                 member.getName(), member.getDeclaringClass(), valueClass.getName());
                        throw new InjectionException(Tr.formatMessage(tc, "error.service.ref.member.level.annotation.wrong.value",
                                                                      member.getName(), member.getDeclaringClass(), valueClass.getName()));
                    }
                    wsrInfo.setServiceInterfaceClassName(valueClass.getName());
                    wsrInfo.setServiceRefTypeClassName(valueClass.getName());

                } else { //effectiveType is a subclass of javax.xml.ws.Service
                    // in this case the 'value' attribute MUST be the same as 'type' or use default javax.xml.ws.Service
                    if (!valueClass.getName().equals(effectiveType.getName()) && !valueClass.getName().equals(Service.class.getName())) {
                        Tr.error(tc, "error.service.ref.member.level.annotation.value.and.type.not.same",
                                 member.getName(), member.getDeclaringClass().getName());
                        throw new InjectionException(Tr.formatMessage(tc, "error.service.ref.member.level.annotation.value.and.type.not.same",
                                                                      member.getName(), member.getDeclaringClass().getName()));
                    }

                    wsrInfo.setServiceInterfaceClassName(effectiveType.getName());
                    wsrInfo.setServiceRefTypeClassName(effectiveType.getName());
                }

            } else { // port type injection case
                // in this case the 'value' attribute MUST specify a subclass of javax.xml.ws.Service
                if (!Service.class.isAssignableFrom(valueClass) || valueClass.getName().equals(Service.class.getName())) {
                    Tr.error(tc, "error.service.ref.member.level.annotation.wrong.value",
                             member.getName(), member.getDeclaringClass(), valueClass.getName());
                    throw new InjectionException(Tr.formatMessage(tc, "error.service.ref.member.level.annotation.wrong.value",
                                                                  member.getName(), member.getDeclaringClass(), valueClass.getName()));
                }

                wsrInfo.setServiceRefTypeClassName(effectiveType.getName());
                wsrInfo.setServiceInterfaceClassName(valueClass.getName());
            }

        }

    }
705910
protected void validate(String operationType) throws Exception
	{
		super.validate(operationType);

		MPSString name_validator = new MPSString();
		name_validator.validate(operationType, name, "\"name\"");
		
		MPSIPAddress host_ip_address_validator = new MPSIPAddress();
		host_ip_address_validator.validate(operationType, host_ip_address, "\"host_ip_address\"");
		
		MPSString current_value_validator = new MPSString();
		current_value_validator.validate(operationType, current_value, "\"current_value\"");
		
		MPSString expected_value_validator = new MPSString();
		expected_value_validator.validate(operationType, expected_value, "\"expected_value\"");
		
		MPSString unit_validator = new MPSString();
		unit_validator.validate(operationType, unit, "\"unit\"");
		
		MPSString status_validator = new MPSString();
		status_validator.validate(operationType, status, "\"status\"");
		
	}
797565
@Override
    public void removeInstanceChangeListener(String serviceName, ServiceInstanceChangeListener listener) throws ServiceException {
        ServiceInstanceUtils.validateManagerIsStarted(isStarted.get());
        ServiceInstanceUtils.validateServiceName(serviceName);
        if (listener == null) {
            throw new ServiceException(ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR,
                    ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR.getMessageTemplate(),
                    "ServiceInstanceChangeListener");
        }

        getLookupService().removeServiceInstanceChangeListener(serviceName, listener);
    }
49943
public static boolean isServiceRunning(Class<? extends Service> service) {
        ActivityManager manager = (ActivityManager) QuickUtils.getContext().getSystemService(Context.ACTIVITY_SERVICE);
        for (ActivityManager.RunningServiceInfo runningServiceInfo : manager.getRunningServices(Integer.MAX_VALUE)) {
            if (service.getName().equals(runningServiceInfo.service.getClassName())) {
                return true;
            }
        }
        return false;
    }