当前位置: 首页>>代码示例>>Java>>正文


Java DeviceService类代码示例

本文整理汇总了Java中com.connectsdk.service.DeviceService的典型用法代码示例。如果您正苦于以下问题:Java DeviceService类的具体用法?Java DeviceService怎么用?Java DeviceService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DeviceService类属于com.connectsdk.service包,在下文中一共展示了DeviceService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getServiceConfig

import com.connectsdk.service.DeviceService; //导入依赖的package包/类
@Override
public ServiceConfig getServiceConfig(ServiceDescription serviceDescription) {
    if (serviceDescription == null) {
        return null;            
    }
    String uuid = serviceDescription.getUUID();
    if (uuid == null || uuid.length() == 0) {
        return null;
    }

    JSONObject device = getStoredDevice(uuid);
    if (device != null) {
        JSONObject services = device.optJSONObject(ConnectableDevice.KEY_SERVICES);
        if (services != null) {
            JSONObject service = services.optJSONObject(uuid);
            if (service != null) {
                JSONObject serviceConfigInfo = service.optJSONObject(DeviceService.KEY_CONFIG);
                if (serviceConfigInfo != null) {
                    return ServiceConfig.getConfig(serviceConfigInfo);
                }
            }
        }
    }

    return null;
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:27,代码来源:DefaultConnectableDeviceStore.java

示例2: addService

import com.connectsdk.service.DeviceService; //导入依赖的package包/类
/**
 * Adds a DeviceService to the ConnectableDevice instance. Only one instance of each DeviceService type (webOS, Netcast, etc) may be attached to a single ConnectableDevice instance. If a device contains your service type already, your service will not be added.
 * 
 * @param service DeviceService to be added
 */
public void addService(DeviceService service) {
    final List<String> added = getMismatchCapabilities(service.getCapabilities(), getCapabilities());

    service.setListener(this);

    Util.runOnUI(new Runnable() {

        @Override
        public void run() {
            for (ConnectableDeviceListener listener : listeners)
                listener.onCapabilityUpdated(ConnectableDevice.this, added, new ArrayList<String>());
        }
    });

    services.put(service.getServiceName(), service);
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:22,代码来源:ConnectableDevice.java

示例3: removeServiceWithId

import com.connectsdk.service.DeviceService; //导入依赖的package包/类
/**
 * Removes a DeviceService from the ConnectableDevice instance.
 * 
 * @param serviceId ID of the DeviceService to be removed (DLNA, webOS TV, etc)
 */
public void removeServiceWithId(String serviceId) {
    DeviceService service = services.get(serviceId);

    if (service == null)
        return;

    service.disconnect();

    services.remove(serviceId);

    final List<String> removed = getMismatchCapabilities(service.getCapabilities(), getCapabilities());

    Util.runOnUI(new Runnable() {

        @Override
        public void run() {
            for (ConnectableDeviceListener listener : listeners)
                listener.onCapabilityUpdated(ConnectableDevice.this, new ArrayList<String>(), removed);
        }
    });
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:27,代码来源:ConnectableDevice.java

示例4: isConnected

import com.connectsdk.service.DeviceService; //导入依赖的package包/类
public boolean isConnected() {
    int connectedCount = 0;

    Iterator<DeviceService> iterator = services.values().iterator();

    while (iterator.hasNext()) {
        DeviceService service = iterator.next();

        if (!service.isConnectable()) {
            connectedCount++;
        } else {
            if (service.isConnected())
                connectedCount++;
        }
    }

    return connectedCount >= services.size();
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:19,代码来源:ConnectableDevice.java

示例5: toJSONObject

import com.connectsdk.service.DeviceService; //导入依赖的package包/类
public JSONObject toJSONObject() {
    JSONObject deviceObject = new JSONObject();

    try {
        deviceObject.put(KEY_ID, getId());
        deviceObject.put(KEY_LAST_IP, getIpAddress());
        deviceObject.put(KEY_FRIENDLY, getFriendlyName());
        deviceObject.put(KEY_MODEL_NAME, getModelName());
        deviceObject.put(KEY_MODEL_NUMBER, getModelNumber());
        deviceObject.put(KEY_LAST_SEEN, getLastSeenOnWifi());
        deviceObject.put(KEY_LAST_CONNECTED, getLastConnected());
        deviceObject.put(KEY_LAST_DETECTED, getLastDetection());

        JSONObject jsonServices = new JSONObject();
        for (DeviceService service: services.values()) {
            JSONObject serviceObject = service.toJSONObject();

            jsonServices.put(service.getServiceConfig().getServiceUUID(), serviceObject);
        }
        deviceObject.put(KEY_SERVICES, jsonServices);
    } catch (JSONException e) {
        e.printStackTrace();
    }

    return deviceObject;
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:27,代码来源:ConnectableDevice.java

示例6: onConnectionSuccess

import com.connectsdk.service.DeviceService; //导入依赖的package包/类
@Override
public void onConnectionSuccess(DeviceService service) {
    //  TODO: iOS is passing to a function for when each service is ready on a device.  This is not implemented on Android.

    if (isConnected()) {
        ConnectableDeviceStore deviceStore = DiscoveryManager.getInstance().getConnectableDeviceStore();
        if (deviceStore != null) {
            deviceStore.addDevice(this);
        }

        Util.runOnUI(new Runnable() {

            @Override
            public void run() {
                for (ConnectableDeviceListener listener : listeners)
                    listener.onDeviceReady(ConnectableDevice.this);
            }
        });

        setLastConnected(Util.getTime());
    }
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:23,代码来源:ConnectableDevice.java

示例7: testSetPromptPairingType

import com.connectsdk.service.DeviceService; //导入依赖的package包/类
@Test
public void testSetPromptPairingType() throws IOException {
    // given
    addAllCoreServicesToDevice();

    // when
    device.setPairingType(DeviceService.PairingType.FIRST_SCREEN);

    // then
    Assert.assertEquals(DeviceService.PairingType.FIRST_SCREEN, device.getServiceByName(WebOSTVService.ID).getPairingType());
    Assert.assertEquals(DeviceService.PairingType.PIN_CODE, device.getServiceByName(NetcastTVService.ID).getPairingType());
    Assert.assertEquals(DeviceService.PairingType.NONE, device.getServiceByName(DLNAService.ID).getPairingType());
    Assert.assertEquals(DeviceService.PairingType.NONE, device.getServiceByName(DIALService.ID).getPairingType());
    Assert.assertEquals(DeviceService.PairingType.NONE, device.getServiceByName(RokuService.ID).getPairingType());
    Assert.assertEquals(DeviceService.PairingType.PIN_CODE, device.getServiceByName(AirPlayService.ID).getPairingType());
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:17,代码来源:ConnectableDeviceTest.java

示例8: testSetPinPairingType

import com.connectsdk.service.DeviceService; //导入依赖的package包/类
@Test
public void testSetPinPairingType() throws IOException {
    // given
    addAllCoreServicesToDevice();

    // when
    device.setPairingType(DeviceService.PairingType.PIN_CODE);

    // then
    Assert.assertEquals(DeviceService.PairingType.PIN_CODE, device.getServiceByName(WebOSTVService.ID).getPairingType());
    Assert.assertEquals(DeviceService.PairingType.PIN_CODE, device.getServiceByName(NetcastTVService.ID).getPairingType());
    Assert.assertEquals(DeviceService.PairingType.NONE, device.getServiceByName(DLNAService.ID).getPairingType());
    Assert.assertEquals(DeviceService.PairingType.NONE, device.getServiceByName(DIALService.ID).getPairingType());
    Assert.assertEquals(DeviceService.PairingType.NONE, device.getServiceByName(RokuService.ID).getPairingType());
    Assert.assertEquals(DeviceService.PairingType.PIN_CODE, device.getServiceByName(AirPlayService.ID).getPairingType());
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:17,代码来源:ConnectableDeviceTest.java

示例9: testNonePairingType

import com.connectsdk.service.DeviceService; //导入依赖的package包/类
@Test
public void testNonePairingType() throws IOException {
    // given
    addAllCoreServicesToDevice();

    // when
    device.setPairingType(DeviceService.PairingType.NONE);

    // then
    Assert.assertEquals(DeviceService.PairingType.NONE, device.getServiceByName(WebOSTVService.ID).getPairingType());
    Assert.assertEquals(DeviceService.PairingType.PIN_CODE, device.getServiceByName(NetcastTVService.ID).getPairingType());
    Assert.assertEquals(DeviceService.PairingType.NONE, device.getServiceByName(DLNAService.ID).getPairingType());
    Assert.assertEquals(DeviceService.PairingType.NONE, device.getServiceByName(DIALService.ID).getPairingType());
    Assert.assertEquals(DeviceService.PairingType.NONE, device.getServiceByName(RokuService.ID).getPairingType());
    Assert.assertEquals(DeviceService.PairingType.PIN_CODE, device.getServiceByName(AirPlayService.ID).getPairingType());
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:17,代码来源:ConnectableDeviceTest.java

示例10: onPairingRequired

import com.connectsdk.service.DeviceService; //导入依赖的package包/类
@Override
public void onPairingRequired(ConnectableDevice device, DeviceService service, DeviceService.PairingType pairingType) {
    switch (pairingType) {
        case FIRST_SCREEN:
            mPairingAlertDialog.show();
            break;
        case PIN_CODE:
            mPairingCodeDialog.show();
            break;
        case NONE:
        default:
            break;
    }

    for(ConnectableDeviceListener listener : mDeviceListeners)
        listener.onPairingRequired(device, service, pairingType);
}
 
开发者ID:PTCE,项目名称:popcorn-android,代码行数:18,代码来源:BeamManager.java

示例11: updateDevice

import com.connectsdk.service.DeviceService; //导入依赖的package包/类
@Override
public void updateDevice(ConnectableDevice device) {
    if (device == null || device.getServices().size() == 0)
        return;

    JSONObject storedDevice = getStoredDevice(device.getId());

    if (storedDevice == null)
        return;

    try {
        storedDevice.put(ConnectableDevice.KEY_LAST_IP, device.getLastKnownIPAddress());
        storedDevice.put(ConnectableDevice.KEY_LAST_SEEN, device.getLastSeenOnWifi());
        storedDevice.put(ConnectableDevice.KEY_LAST_CONNECTED, device.getLastConnected());
        storedDevice.put(ConnectableDevice.KEY_LAST_DETECTED, device.getLastDetection());

        JSONObject services = storedDevice.optJSONObject(ConnectableDevice.KEY_SERVICES);

        if (services == null)
            services = new JSONObject();

        for (DeviceService service : device.getServices()) {
            JSONObject serviceInfo = service.toJSONObject();

            if (serviceInfo != null)
                services.put(service.getServiceDescription().getUUID(), serviceInfo);
        }

        storedDevice.put(ConnectableDevice.KEY_SERVICES, services);

        storedDevices.put(device.getId(), storedDevice);
        activeDevices.put(device.getId(), device);

        store();
    } catch (JSONException e) {
        e.printStackTrace();
    }
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:39,代码来源:DefaultConnectableDeviceStore.java

示例12: getActiveDevice

import com.connectsdk.service.DeviceService; //导入依赖的package包/类
private ConnectableDevice getActiveDevice(String uuid) {
    ConnectableDevice foundDevice = activeDevices.get(uuid);

    if (foundDevice == null) {
        for (ConnectableDevice device : activeDevices.values()) {
            for (DeviceService service : device.getServices()) {
                if (uuid.equals(service.getServiceDescription().getUUID())) {
                    return device;
                }
            }
        }
    }
    return foundDevice;
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:15,代码来源:DefaultConnectableDeviceStore.java

示例13: onPairingRequired

import com.connectsdk.service.DeviceService; //导入依赖的package包/类
@Override
public void onPairingRequired(ConnectableDevice device, DeviceService service, final PairingType pairingType) {
    Log.d("SimpleDevicePicker", "pairing required for device " + device.getFriendlyName());

    Util.runOnUI(new Runnable() {
        @Override
        public void run() {
            showPairingDialog(pairingType);
        }
    });
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:12,代码来源:SimpleDevicePicker.java

示例14: setPairingType

import com.connectsdk.service.DeviceService; //导入依赖的package包/类
/**
 * set desirable pairing type for all services
 * @param pairingType
 */
public void setPairingType(PairingType pairingType) {
    Collection<DeviceService> services = getServices();
    for (DeviceService service : services) {
        service.setPairingType(pairingType);
    }
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:11,代码来源:ConnectableDevice.java

示例15: getServiceByName

import com.connectsdk.service.DeviceService; //导入依赖的package包/类
/**
 * Obtains a service from the ConnectableDevice with the provided serviceName
 *
 * @param serviceName Service ID of the targeted DeviceService (webOS, Netcast, DLNA, etc)
 * @return DeviceService with the specified serviceName or nil, if none exists
 */
public DeviceService getServiceByName(String serviceName) {
    for (DeviceService service : getServices()) {
        if (service.getServiceName().equals(serviceName)) {
            return service;
        }
    }

    return null;
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:16,代码来源:ConnectableDevice.java


注:本文中的com.connectsdk.service.DeviceService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。