org.deviceconnect.android.deviceplugin.linking.lib.BuildConfig.DEBUG - java examples

Here are the examples of the java api org.deviceconnect.android.deviceplugin.linking.lib.BuildConfig.DEBUG taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

85 Examples 7

19 View Complete Implementation : LinkingDeviceActivity.java
Copyright MIT License
Author : DeviceConnect
private void setupLightOffSetting() {
    Button btn = findViewById(R.id.select_light_off);
    if (btn == null || mDevice == null) {
        return;
    }
    byte[] illumination = mDevice.getIllumination();
    if (illumination == null) {
        btn.setText(getString(R.string.activity_device_not_selected));
        btn.setEnabled(false);
        return;
    }
    Integer patternId = mUtil.getLEDOffSetting(mDevice.getBdAddress());
    if (patternId == null) {
        setupDefaultOffSettingOfLight(mDevice);
        return;
    }
    try {
        IlluminationData data = new IlluminationData(illumination);
        for (Setting setting : data.getPattern().getChildren()) {
            if ((setting.getId() & 0xFF) == patternId) {
                btn.setText(setting.getName(0).getName());
            }
        }
    } catch (Exception e) {
        if (BuildConfig.DEBUG) {
            Log.w(TAG, "", e);
        }
    }
}

19 View Complete Implementation : LinkingNotifySensor.java
Copyright MIT License
Author : DeviceConnect
private void stopSensors(final String address) {
    if (BuildConfig.DEBUG) {
        Log.i(TAG, "LinkingNotifySensor#stopSensors: " + address);
    }
    Intent intent = new Intent(mContext.getPackageName() + ".sda.action.STOP_SENSOR");
    intent.setComponent(new ComponentName(LinkingUtil.PACKAGE_NAME, LinkingUtil.RECEIVER_NAME));
    intent.putExtra(mContext.getPackageName() + ".sda.extra.BD_ADDRESS", address);
    try {
        mLinkingDeviceManager.getContext().sendBroadcast(intent);
    } catch (ActivityNotFoundException e) {
        if (BuildConfig.DEBUG) {
            e.printStackTrace();
        }
    }
}

19 View Complete Implementation : LinkingDBAdapter.java
Copyright MIT License
Author : DeviceConnect
public boolean deleteRawData(final int vendorId, final int extraId) {
    String selection = LinkingBaseColumns.VENDOR_ID + "=? AND " + LinkingBaseColumns.EXTRA_ID + "=?";
    String[] selectionArgs = { String.valueOf(vendorId), String.valueOf(extraId) };
    try {
        int row = delete(TABLE_RAW_DATA, selection, selectionArgs);
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "LinkingDBAdapter#deleteRawData: " + row);
        }
        return row > 0;
    } catch (Exception e) {
        if (BuildConfig.DEBUG) {
            Log.e(TAG, "", e);
        }
    }
    return false;
}

19 View Complete Implementation : LinkingDevicePluginService.java
Copyright MIT License
Author : DeviceConnect
@Override
public void onManagerTerminated() {
    if (BuildConfig.DEBUG) {
        Log.d(TAG, "onManagerTerminated");
    }
    ((LinkingApplication) getApplication()).resetManager();
    removeAllServices();
}

19 View Complete Implementation : LinkingProximityProfile.java
Copyright MIT License
Author : DeviceConnect
@Override
public void onDestroy() {
    if (BuildConfig.DEBUG) {
        Log.i(TAG, "LinkingProximityProfile#destroy: " + getService().getId());
    }
    getLinkingDeviceManager().disableListenRange(getDevice(), mListener);
}

19 View Complete Implementation : LinkingNotifyNotification.java
Copyright MIT License
Author : DeviceConnect
private void stopNotifyNotification() {
    if (mNotifyNotification != null) {
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "Stop a key event.");
        }
        mNotifyNotification.release();
        mNotifyNotification = null;
    }
}

19 View Complete Implementation : LinkingNotifySensor.java
Copyright MIT License
Author : DeviceConnect
public synchronized void release() {
    mSensorMap.clear();
    mBatteryMap.clear();
    mHumidityMap.clear();
    mTemperatureMap.clear();
    mCountOfSensor.clear();
    if (mNotifySensor != null) {
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "Stop a sensor event.");
        }
        mNotifySensor.release();
        mNotifySensor = null;
    }
}

19 View Complete Implementation : LinkingBeaconManager.java
Copyright MIT License
Author : DeviceConnect
private void parseBeaconScanState(final Intent intent) {
    mScanState = LinkingBeaconUtil.ScanState.valueOf(intent.getIntExtra(LinkingBeaconUtil.SCAN_STATE, 0));
    mScanDetail = LinkingBeaconUtil.ScanDetail.valueOf(intent.getIntExtra(LinkingBeaconUtil.DETAIL, 0));
    if (mScanState == LinkingBeaconUtil.ScanState.RESULT_NG) {
        switch(mScanDetail) {
            case DETAIL_TIMEOUT:
                if (BuildConfig.DEBUG) {
                    Log.d(TAG, "@@ Restart the beacon scan.");
                }
                stopBeaconScan();
                stopForceBeaconScan();
                break;
            case DETAIL_META_DATA_NONE:
                if (BuildConfig.DEBUG) {
                    Log.w(TAG, "@@ meta data is not defined.");
                }
                break;
            default:
                if (BuildConfig.DEBUG) {
                    Log.e(TAG, "Unknown detail. detail=" + mScanDetail);
                }
                break;
        }
    }
    if (BuildConfig.DEBUG) {
        Log.d(TAG, "mScanState: " + mScanState);
        Log.d(TAG, "mScanDetail: " + mScanDetail);
    }
    for (OnBeaconScanStateListener listener : mOnBeaconScanStateListeners) {
        listener.onScanState(mScanState, mScanDetail);
    }
}

19 View Complete Implementation : LinkingDeviceOrientationProfile.java
Copyright MIT License
Author : DeviceConnect
@Override
public void onDestroy() {
    if (BuildConfig.DEBUG) {
        Log.i(TAG, "LinkingDeviceOrientationProfile#destroy: " + getService().getId());
    }
    getLinkingDeviceManager().disableListenSensor(getDevice(), mListener);
    mDispatcherManager.removeAllEventDispatcher();
}

19 View Complete Implementation : LinkingDBAdapter.java
Copyright MIT License
Author : DeviceConnect
public boolean deleteTemperature(final int vendorId, final int extraId) {
    String selection = LinkingBaseColumns.VENDOR_ID + "=? AND " + LinkingBaseColumns.EXTRA_ID + "=?";
    String[] selectionArgs = { String.valueOf(vendorId), String.valueOf(extraId) };
    try {
        int row = delete(TABLE_TEMPERATURE, selection, selectionArgs);
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "LinkingDBAdapter#deleteTemperature: " + row);
        }
        return row > 0;
    } catch (Exception e) {
        if (BuildConfig.DEBUG) {
            Log.e(TAG, "", e);
        }
    }
    return false;
}

19 View Complete Implementation : LinkingDevicePluginService.java
Copyright MIT License
Author : DeviceConnect
private void stopProximity(final Event event) {
    if (!ProximityProfile.PROFILE_NAME.equalsIgnoreCase(event.getProfile()) || !ProximityProfile.ATTRIBUTE_ON_DEVICE_PROXIMITY.equalsIgnoreCase(event.getAttribute())) {
        return;
    }
    if (BuildConfig.DEBUG) {
        Log.i(TAG, "stopProximity");
    }
    LinkingDeviceManager mgr = getLinkingDeviceManager();
    String serviceId = event.getServiceId();
    List<Event> events = EventManager.INSTANCE.getEventList(serviceId, ProximityProfile.PROFILE_NAME, null, ProximityProfile.ATTRIBUTE_ON_DEVICE_PROXIMITY);
    if (events.isEmpty()) {
        mgr.disableListenRange(mgr.findDeviceByBdAddress(serviceId), null);
    } else {
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "events=" + events.size());
        }
    }
}

19 View Complete Implementation : LinkingDevicePluginService.java
Copyright MIT License
Author : DeviceConnect
@Override
public void onManagerEventTransmitDisconnected(final String sessionKey) {
    if (BuildConfig.DEBUG) {
        Log.d(TAG, "onManagerEventTransmitDisconnected: " + sessionKey);
    }
    cleanupSession(sessionKey);
}

19 View Complete Implementation : ConfirmActivity.java
Copyright MIT License
Author : DeviceConnect
@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    LinkingUtil.Result result = LinkingUtil.Result.valueOf(resultCode);
    if (BuildConfig.DEBUG) {
        Log.i(TAG, "ConfirmActivity:onActivityResult");
        Log.i(TAG, "requestCode: " + requestCode);
        Log.i(TAG, "resultCode: " + result);
        Log.i(TAG, "mIndex: " + mIndex);
    }
    if (requestCode != REQUEST_CODE) {
        finishConfirmActivity();
        return;
    }
    if (result != LinkingUtil.Result.RESULT_OK && result != LinkingUtil.Result.RESULT_SENSOR_UNSUPPORTED) {
        finishConfirmActivity();
        return;
    }
    if (mRequestType.length <= mIndex) {
        finishConfirmActivity();
        return;
    }
    startSensor();
}

19 View Complete Implementation : LinkingDevicePluginService.java
Copyright MIT License
Author : DeviceConnect
private void stopBeacon() {
    if (BeaconUtil.isEmptyEvent(getLinkingBeaconManager())) {
        if (BuildConfig.DEBUG) {
            Log.i(TAG, "stop beacon");
        }
        getLinkingBeaconManager().stopBeaconScan();
    }
}

19 View Complete Implementation : LinkingDBAdapter.java
Copyright MIT License
Author : DeviceConnect
public boolean deleteGatt(final int vendorId, final int extraId) {
    String selection = LinkingBaseColumns.VENDOR_ID + "=? AND " + LinkingBaseColumns.EXTRA_ID + "=?";
    String[] selectionArgs = { String.valueOf(vendorId), String.valueOf(extraId) };
    try {
        int row = delete(TABLE_GATT, selection, selectionArgs);
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "LinkingDBAdapter#deleteGatt: " + row);
        }
        return row > 0;
    } catch (Exception e) {
        if (BuildConfig.DEBUG) {
            Log.e(TAG, "", e);
        }
    }
    return false;
}

19 View Complete Implementation : LinkingNotifyRange.java
Copyright MIT License
Author : DeviceConnect
private void stopNotifyRange() {
    if (mNotifyRange != null) {
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "Stop a range event.");
        }
        mNotifyRange.release();
        mNotifyRange = null;
    }
}

19 View Complete Implementation : LinkingBeaconManager.java
Copyright MIT License
Author : DeviceConnect
public synchronized void startBeaconScanWithTimeout(final int timeout) {
    if (isStartedBeaconScan()) {
        return;
    }
    if (BuildConfig.DEBUG) {
        Log.d(TAG, "startBeaconScanWithTimeout");
    }
    if (mTimeoutRunnable != null) {
        mTimeoutRunnable.cancel();
    }
    mTimeoutRunnable = new TimeoutRunnable(timeout) {

        @Override
        public void onTimeout() {
            if (BuildConfig.DEBUG) {
                Log.d(TAG, "startBeaconScanWithTimeout:onTimeout");
            }
            if (!isStartedBeaconScan()) {
                stopBeaconScan();
            }
        }
    };
    startBeaconScanInternal(LinkingBeaconUtil.ScanMode.HIGH);
}

19 View Complete Implementation : LinkingNotifySensor.java
Copyright MIT License
Author : DeviceConnect
private void startSensor(final String address, final int[] types, final int interval) {
    if (BuildConfig.DEBUG) {
        Log.i(TAG, "LinkingNotifySensor#startSensor: " + address);
    }
    Intent intent = new Intent(mContext.getPackageName() + ".sda.action.START_SENSOR");
    intent.setComponent(new ComponentName(LinkingUtil.PACKAGE_NAME, LinkingUtil.RECEIVER_NAME));
    intent.putExtra(mContext.getPackageName() + ".sda.extra.BD_ADDRESS", address);
    intent.putExtra(mContext.getPackageName() + ".sda.extra.SENSOR_INTERVAL", interval);
    intent.putExtra(mContext.getPackageName() + ".sda.extra.SENSOR_DURATION", -1);
    intent.putExtra(mContext.getPackageName() + ".sda.extra.X_THRESHOLD", 0.0F);
    intent.putExtra(mContext.getPackageName() + ".sda.extra.Y_THRESHOLD", 0.0F);
    intent.putExtra(mContext.getPackageName() + ".sda.extra.Z_THRESHOLD", 0.0F);
    for (int i = 0; i < types.length; i++) {
        start(intent, types[i]);
    }
    countUpSensor(address, types.length);
}

19 View Complete Implementation : LinkingDBAdapter.java
Copyright MIT License
Author : DeviceConnect
public boolean deleteBattery(final int vendorId, final int extraId) {
    String selection = LinkingBaseColumns.VENDOR_ID + "=? AND " + LinkingBaseColumns.EXTRA_ID + "=?";
    String[] selectionArgs = { String.valueOf(vendorId), String.valueOf(extraId) };
    try {
        int row = delete(TABLE_BATTERY, selection, selectionArgs);
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "LinkingDBAdapter#deleteBattery: " + row);
        }
        return row > 0;
    } catch (Exception e) {
        if (BuildConfig.DEBUG) {
            Log.e(TAG, "", e);
        }
    }
    return false;
}

19 View Complete Implementation : LinkingBatteryProfile.java
Copyright MIT License
Author : DeviceConnect
@Override
public void onDestroy() {
    if (BuildConfig.DEBUG) {
        Log.i(TAG, "LinkingBatteryProfile#destroy: " + getService().getId());
    }
    getLinkingDeviceManager().disableListenBattery(getDevice(), mListener);
}

19 View Complete Implementation : LinkingDBAdapter.java
Copyright MIT License
Author : DeviceConnect
public boolean deleteHumidity(final int vendorId, final int extraId) {
    String selection = LinkingBaseColumns.VENDOR_ID + "=? AND " + LinkingBaseColumns.EXTRA_ID + "=?";
    String[] selectionArgs = { String.valueOf(vendorId), String.valueOf(extraId) };
    try {
        int row = delete(TABLE_HUMIDITY, selection, selectionArgs);
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "LinkingDBAdapter#deleteHumidity: " + row);
        }
        return row > 0;
    } catch (Exception e) {
        if (BuildConfig.DEBUG) {
            Log.e(TAG, "", e);
        }
    }
    return false;
}

19 View Complete Implementation : LinkingKeyEventProfile.java
Copyright MIT License
Author : DeviceConnect
@Override
public void onDestroy() {
    if (BuildConfig.DEBUG) {
        Log.i(TAG, "LinkingKeyEventProfile#destroy: " + getService().getId());
    }
    getLinkingDeviceManager().disableListenButtonEvent(getDevice(), mListener);
}

19 View Complete Implementation : LinkingBeaconManager.java
Copyright MIT License
Author : DeviceConnect
private void stopBeaconScanInternal() {
    if (BuildConfig.DEBUG) {
        Log.i(TAG, "LinkingBeaconManager#stopBeaconScan");
    }
    Intent intent = new Intent();
    intent.setClreplacedName(LinkingBeaconUtil.LINKING_PACKAGE_NAME, LinkingBeaconUtil.BEACON_SERVICE_NAME);
    intent.setAction(mContext.getPackageName() + LinkingBeaconUtil.ACTION_STOP_BEACON_SCAN);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        mContext.startForegroundService(intent);
    } else {
        mContext.startService(intent);
    }
}

19 View Complete Implementation : LinkingDevicePluginService.java
Copyright MIT License
Author : DeviceConnect
private void stopKeyEvent(final Event event) {
    if (!KeyEventProfile.PROFILE_NAME.equalsIgnoreCase(event.getProfile()) || !KeyEventProfile.ATTRIBUTE_ON_DOWN.equalsIgnoreCase(event.getAttribute())) {
        return;
    }
    if (BuildConfig.DEBUG) {
        Log.i(TAG, "disableListenButtonEvent");
    }
    LinkingDeviceManager mgr = getLinkingDeviceManager();
    String serviceId = event.getServiceId();
    List<Event> events = EventManager.INSTANCE.getEventList(serviceId, KeyEventProfile.PROFILE_NAME, null, KeyEventProfile.ATTRIBUTE_ON_DOWN);
    if (events.isEmpty()) {
        mgr.disableListenButtonEvent(mgr.findDeviceByBdAddress(serviceId), null);
    } else {
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "events=" + events.size());
        }
    }
}

19 View Complete Implementation : LinkingBatteryProfile.java
Copyright MIT License
Author : DeviceConnect
@Override
public void onDestroy() {
    if (BuildConfig.DEBUG) {
        Log.i(TAG, "LinkingBatteryProfile#destroy: " + getService().getId());
    }
    getLinkingBeaconManager().removeOnBeaconBatteryEventListener(mListener);
}

19 View Complete Implementation : LinkingDevicePluginService.java
Copyright MIT License
Author : DeviceConnect
@Override
public void onDevicePluginReset() {
    if (BuildConfig.DEBUG) {
        Log.d(TAG, "onDevicePluginReset");
    }
    ((LinkingApplication) getApplication()).resetManager();
    resetService();
}

19 View Complete Implementation : LinkingDevicePluginService.java
Copyright MIT License
Author : DeviceConnect
private void stopDeviceOrientation(final Event event) {
    if (!DeviceOrientationProfile.PROFILE_NAME.equalsIgnoreCase(event.getProfile()) || !DeviceOrientationProfile.ATTRIBUTE_ON_DEVICE_ORIENTATION.equalsIgnoreCase(event.getAttribute())) {
        return;
    }
    if (BuildConfig.DEBUG) {
        Log.i(TAG, "stopDeviceOrientation");
    }
    LinkingDeviceManager mgr = getLinkingDeviceManager();
    String serviceId = event.getServiceId();
    List<Event> events = EventManager.INSTANCE.getEventList(serviceId, DeviceOrientationProfile.PROFILE_NAME, null, DeviceOrientationProfile.ATTRIBUTE_ON_DEVICE_ORIENTATION);
    if (events.isEmpty()) {
        mgr.disableListenSensor(mgr.findDeviceByBdAddress(serviceId), null);
    } else {
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "events=" + events.size());
        }
    }
}

19 View Complete Implementation : LinkingProximityProfile.java
Copyright MIT License
Author : DeviceConnect
@Override
public void onDestroy() {
    if (BuildConfig.DEBUG) {
        Log.i(TAG, "LinkingProximityProfile#destroy: " + getService().getId());
    }
    getLinkingBeaconManager().removeOnBeaconProximityEventListener(mListener);
}

19 View Complete Implementation : LinkingDevicePluginService.java
Copyright MIT License
Author : DeviceConnect
private void removeService(final DConnectService service) {
    if (BuildConfig.DEBUG) {
        Log.i(TAG, "Remove Service: " + service.getName());
    }
    if (service instanceof LinkingDestroy) {
        ((LinkingDestroy) service).onDestroy();
    }
    getServiceProvider().removeService(service);
}

19 View Complete Implementation : LinkingDBAdapter.java
Copyright MIT License
Author : DeviceConnect
public boolean deleteAtmosphericPressure(final int vendorId, final int extraId) {
    String selection = LinkingBaseColumns.VENDOR_ID + "=? AND " + LinkingBaseColumns.EXTRA_ID + "=?";
    String[] selectionArgs = { String.valueOf(vendorId), String.valueOf(extraId) };
    try {
        int row = delete(TABLE_ATMOSPHERIC_PRESSURE, selection, selectionArgs);
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "LinkingDBAdapter#deleteAtmosphericPressure: " + row);
        }
        return row > 0;
    } catch (Exception e) {
        if (BuildConfig.DEBUG) {
            Log.e(TAG, "", e);
        }
    }
    return false;
}

19 View Complete Implementation : LinkingDevicePluginService.java
Copyright MIT License
Author : DeviceConnect
@Override
public void onManagerUninstalled() {
    if (BuildConfig.DEBUG) {
        Log.d(TAG, "onManagerUninstalled");
    }
    ((LinkingApplication) getApplication()).resetManager();
    removeAllServices();
}

19 View Complete Implementation : ConfirmActivity.java
Copyright MIT License
Author : DeviceConnect
private void startSensor() {
    if (BuildConfig.DEBUG) {
        Log.i(TAG, "ConfirmActivity:startSensor type:" + mRequestType[mIndex]);
    }
    Intent intent = new Intent(LinkingUtil.ACTION_START_SENSOR);
    intent.setComponent(new ComponentName(LinkingUtil.PACKAGE_NAME, LinkingUtil.ACTIVITY_NAME));
    intent.putExtras(getIntent().getExtras());
    intent.putExtra(LinkingUtil.EXTRA_SENSOR_TYPE, mRequestType[mIndex]);
    mIndex++;
    try {
        startActivityForResult(intent, REQUEST_CODE);
    } catch (Exception e) {
        if (BuildConfig.DEBUG) {
            e.printStackTrace();
        }
        finishConfirmActivity();
    }
}

19 View Complete Implementation : LinkingBeaconActivity.java
Copyright MIT License
Author : DeviceConnect
private void setBeaconData() {
    if (mLinkingBeacon == null) {
        if (BuildConfig.DEBUG) {
            Log.e(TAG, "Linking beacon is not exist.");
        }
        return;
    }
    setVendorId(String.valueOf(mLinkingBeacon.getVendorId()));
    setExtraId(String.valueOf(mLinkingBeacon.getExtraId()));
    setVersion(String.valueOf(mLinkingBeacon.getVersion()));
    setTimeStamp(mLinkingBeacon.getTimeStamp());
    setStatus(mLinkingBeacon.isOnline() ? "Online" : "Offline");
    if (mLinkingBeacon.getBatteryData() != null) {
        setLowBattery(String.valueOf(mLinkingBeacon.getBatteryData().isLowBatteryFlag()));
        setBatteryLevel(getString(R.string.activity_beacon_unit_percent, mLinkingBeacon.getBatteryData().getLevel()));
    } else {
        setLowBattery("-");
        setBatteryLevel("-");
    }
    if (mLinkingBeacon.getTemperatureData() != null) {
        setTemperature(getString(R.string.activity_beacon_unit_c, mLinkingBeacon.getTemperatureData().getValue()));
    } else {
        setTemperature("-");
    }
    if (mLinkingBeacon.getAtmosphericPressureData() != null) {
        setAtmosphericPressure(getString(R.string.activity_beacon_unit_hectopascal, mLinkingBeacon.getAtmosphericPressureData().getValue()));
    } else {
        setAtmosphericPressure("-");
    }
    if (mLinkingBeacon.getHumidityData() != null) {
        setHumidity(getString(R.string.activity_beacon_unit_percent, mLinkingBeacon.getHumidityData().getValue()));
    } else {
        setHumidity("-");
    }
    if (mLinkingBeacon.getGattData() != null) {
        setDistance(getDistanceString(mLinkingBeacon.getGattData().getDistance()));
    } else {
        setDistance("-");
    }
    if (mLinkingBeacon.getRawData() != null) {
        setRawData(String.valueOf(mLinkingBeacon.getRawData().getValue()));
    } else {
        setRawData("-");
    }
}

19 View Complete Implementation : LinkingBeaconManager.java
Copyright MIT License
Author : DeviceConnect
private void parseBeaconResult(final Intent intent) {
    if (intent.getExtras() == null) {
        if (BuildConfig.DEBUG) {
            Log.w(TAG, "extras is null.");
        }
        return;
    }
    if (!intent.getExtras().containsKey(LinkingBeaconUtil.EXTRA_ID) || !intent.getExtras().containsKey(LinkingBeaconUtil.VENDOR_ID) || !intent.getExtras().containsKey(LinkingBeaconUtil.VERSION)) {
        if (BuildConfig.DEBUG) {
            Log.w(TAG, "extraId, vendorId, version is null.");
        }
        return;
    }
    int extraId = intent.getIntExtra(LinkingBeaconUtil.EXTRA_ID, -1);
    int vendorId = intent.getIntExtra(LinkingBeaconUtil.VENDOR_ID, -1);
    int version = intent.getIntExtra(LinkingBeaconUtil.VERSION, -1);
    LinkingBeacon beacon = findBeacon(extraId, vendorId);
    if (beacon == null) {
        beacon = new LinkingBeacon();
        beacon.setExtraId(extraId);
        beacon.setVendorId(vendorId);
        beacon.setVersion(version);
        beacon.setDisplayName(mContext.getString(R.string.linking_beacon_display_name, extraId));
        mLinkingBeacons.add(beacon);
        if (!mDBAdapter.insertBeacon(beacon)) {
            if (BuildConfig.DEBUG) {
                Log.e(TAG, "Failed to insert LinkingBeacon.");
            }
        }
    }
    parseGattData(intent, beacon);
    parseBatteryData(intent, beacon);
    parseAtmosphericPressureData(intent, beacon);
    parseHumidityData(intent, beacon);
    parseTemperatureData(intent, beacon);
    parseRawData(intent, beacon);
    parseButtonId(intent, beacon);
    if (!beacon.isOnline()) {
        beacon.setOnline(true);
        notifyBeaconConnectionListener(beacon);
    }
    if (beacon.isOnline()) {
        notifyBeaconEventListener(beacon);
    }
}

19 View Complete Implementation : LinkingDeviceActivity.java
Copyright MIT License
Author : DeviceConnect
private void setupVibrationOffSetting() {
    Button btn = findViewById(R.id.select_vibration_off);
    if (btn == null || mDevice == null) {
        return;
    }
    if (!mDevice.isSupportVibration()) {
        btn.setText(getString(R.string.activity_device_not_selected));
        btn.setEnabled(false);
        return;
    }
    Integer patternId = mUtil.getVibrationOffSetting(mDevice.getBdAddress());
    if (patternId == null) {
        setupDefaultOffSettingOfVibration(mDevice);
        return;
    }
    byte[] vibration = mDevice.getVibration();
    try {
        VibrationData data = new VibrationData(vibration);
        for (Setting setting : data.getPattern().getChildren()) {
            if ((setting.getId() & 0xFF) == patternId) {
                btn.setText(setting.getName(0).getName());
            }
        }
    } catch (Exception e) {
        if (BuildConfig.DEBUG) {
            Log.w(TAG, "", e);
        }
    }
}

19 View Complete Implementation : LinkingBeaconManager.java
Copyright MIT License
Author : DeviceConnect
public void onReceivedBeacon(final Intent intent) {
    if (BuildConfig.DEBUG) {
        Log.i(TAG, "@@ LinkingBeaconManager#onReceivedBeacon");
        Log.i(TAG, "intent=" + intent);
    }
    if (intent == null) {
        return;
    }
    String action = intent.getAction();
    if (LinkingBeaconUtil.ACTION_BEACON_SCAN_RESULT.equals(action)) {
        parseBeaconResult(intent);
    } else if (LinkingBeaconUtil.ACTION_BEACON_SCAN_STATE.equals(action)) {
        parseBeaconScanState(intent);
    }
}

19 View Complete Implementation : LinkingBeaconManager.java
Copyright MIT License
Author : DeviceConnect
private void startBeaconScanInternal(final LinkingBeaconUtil.ScanMode scanMode) {
    if (BuildConfig.DEBUG) {
        Log.i(TAG, "LinkingBeaconManager#startBeaconScan");
    }
    Intent intent = new Intent();
    intent.setClreplacedName(LinkingBeaconUtil.LINKING_PACKAGE_NAME, LinkingBeaconUtil.BEACON_SERVICE_NAME);
    intent.setAction(mContext.getPackageName() + LinkingBeaconUtil.ACTION_START_BEACON_SCAN);
    // intent.putExtra(mContext.getPackageName() + LinkingBeaconUtil.EXTRA_SERVICE_ID, new int[] {0, 1, 2, 3, 4, 5, 15});
    if (scanMode != null) {
        intent.putExtra(mContext.getPackageName() + LinkingBeaconUtil.EXTRA_SCAN_MODE, scanMode.getValue());
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        mContext.startForegroundService(intent);
    } else {
        mContext.startService(intent);
    }
}

19 View Complete Implementation : LinkingBeaconManager.java
Copyright MIT License
Author : DeviceConnect
private void checkConnectionOfBeacon() {
    if (BuildConfig.DEBUG) {
        Log.i(TAG, "LinkingBeaconManager#checkConnectionOfBeacon");
    }
    synchronized (mLinkingBeacons) {
        long now = System.currentTimeMillis();
        for (LinkingBeacon beacon : mLinkingBeacons) {
            if (beacon.isOnline()) {
                if (now - beacon.getTimeStamp() > INTERVAL) {
                    beacon.setOnline(false);
                    notifyBeaconConnectionListener(beacon);
                }
            }
        }
    }
}

19 View Complete Implementation : LinkingKeyEventProfile.java
Copyright MIT License
Author : DeviceConnect
@Override
public void onDestroy() {
    if (BuildConfig.DEBUG) {
        Log.i(TAG, "LinkingKeyEventProfile#destroy: " + getService().getId());
    }
    getLinkingBeaconManager().removeOnBeaconButtonEventListener(mListener);
}

19 View Complete Implementation : LinkingDevicePluginService.java
Copyright MIT License
Author : DeviceConnect
private void createLinkingBeaconList() {
    for (LinkingBeacon beacon : getLinkingBeaconManager().getLinkingBeacons()) {
        DConnectService service = findDConnectService(beacon.getServiceId());
        if (service == null) {
            if (BuildConfig.DEBUG) {
                Log.i(TAG, "Added Beacon: " + beacon.getDisplayName());
            }
            getServiceProvider().addService(new LinkingBeaconService(this, beacon));
        } else {
            ((LinkingBeaconService) service).setLinkingBeacon(beacon);
        }
    }
}

18 View Complete Implementation : LinkingBeaconManager.java
Copyright MIT License
Author : DeviceConnect
public void stopForceBeaconScan() {
    PreferenceUtil.getInstance(mContext).setForceBeaconScanStatus(false);
    if (BuildConfig.DEBUG) {
        Log.d(TAG, "stopForceBeaconScan: " + isStartedBeaconScan());
    }
    if (!isStartedBeaconScan()) {
        stopBeaconScanInternal();
    }
}

18 View Complete Implementation : LinkingDBAdapter.java
Copyright MIT License
Author : DeviceConnect
public boolean deleteBeacon(final LinkingBeacon beacon) {
    String selection = LinkingBaseColumns.VENDOR_ID + "=? AND " + LinkingBaseColumns.EXTRA_ID + "=?";
    String[] selectionArgs = { String.valueOf(beacon.getVendorId()), String.valueOf(beacon.getExtraId()) };
    try {
        int row = delete(TABLE_BEACON, selection, selectionArgs);
        return row > 0;
    } catch (Exception e) {
        if (BuildConfig.DEBUG) {
            Log.e(TAG, "", e);
        }
    }
    return false;
}

18 View Complete Implementation : ConfirmActivity.java
Copyright MIT License
Author : DeviceConnect
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_linking_confirm);
    if (BuildConfig.DEBUG) {
        Log.i(TAG, "ConfirmActivity:onCreate");
    }
    Intent intent = getIntent();
    if (intent != null) {
        mRequestType = intent.getIntArrayExtra(EXTRA_REQUEST_SENSOR_TYPE);
        if (BuildConfig.DEBUG) {
            if (mRequestType != null) {
                for (int type : mRequestType) {
                    Log.d(TAG, "RequestType: " + type);
                }
            }
        }
    }
    if (mRequestType == null || mRequestType.length == 0) {
        if (BuildConfig.DEBUG) {
            Log.e(TAG, "RequestType is null.");
        }
        finishConfirmActivity();
    } else {
        startSensor();
    }
}

18 View Complete Implementation : LinkingDeviceManager.java
Copyright MIT License
Author : DeviceConnect
public List<LinkingDevice> getDevices() {
    List<DeviceInfo> deviceInfoList = new GetDeviceInformation(mContext).getInformation();
    List<LinkingDevice> devices = new ArrayList<>();
    for (DeviceInfo info : deviceInfoList) {
        LinkingDevice device = new LinkingDevice();
        device.setBdAddress(info.getBdaddress());
        device.setIsConnected(info.getState() == 1);
        device.setModelId(info.getModelId());
        device.setIllumination(info.getIllumination());
        device.setName(info.getName());
        device.setUniqueId(info.getUniqueId());
        device.setVibration(info.getVibration());
        device.setDisplayName("Linking:" + info.getName() + " (" + info.getBdaddress() + ")");
        device.setFeature(info.getFeature());
        device.setExSensorType(info.getExSensorType());
        devices.add(device);
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "#### " + device);
        }
    }
    return devices;
}

18 View Complete Implementation : LinkingNotifyConnect.java
Copyright MIT License
Author : DeviceConnect
private synchronized void startNotifyConnect() {
    if (mNotifyConnect != null) {
        if (BuildConfig.DEBUG) {
            Log.w(TAG, "mNotifyConnect is already running.");
        }
        return;
    }
    mNotifyConnect = new NotifyConnect(mContext, new NotifyConnect.ConnectInterface() {

        @Override
        public void onConnect() {
            SharedPreferences preference = mContext.getSharedPreferences(Define.ConnectInfo, Context.MODE_PRIVATE);
            int deviceId = preference.getInt(LinkingUtil.DEVICE_ID, -1);
            int uniqueId = preference.getInt(LinkingUtil.DEVICE_UID, -1);
            if (BuildConfig.DEBUG) {
                Log.d(TAG, "@@ NotifyConnect#onConnect");
                Log.d(TAG, LinkingUtil.BD_ADDRESS + "=" + preference.getString(LinkingUtil.BD_ADDRESS, ""));
                Log.d(TAG, LinkingUtil.DEVICE_NAME + "=" + preference.getString(LinkingUtil.DEVICE_NAME, ""));
                Log.d(TAG, LinkingUtil.RECEIVE_TIME + "=" + preference.getLong(LinkingUtil.RECEIVE_TIME, -1));
                Log.d(TAG, LinkingUtil.CAPABILITY + "=" + preference.getInt(LinkingUtil.CAPABILITY, -1));
                Log.d(TAG, LinkingUtil.EX_SENSOR_TYPE + "=" + preference.getInt(LinkingUtil.EX_SENSOR_TYPE, -1));
            }
            LinkingDevice device = mLinkingDeviceManager.findDeviceByDeviceId(deviceId, uniqueId);
            if (device != null) {
                notifyConnect(device);
            }
        }

        @Override
        public void onDisconnect() {
            SharedPreferences preference = mContext.getSharedPreferences(Define.DisconnectInfo, Context.MODE_PRIVATE);
            int deviceId = preference.getInt(LinkingUtil.DEVICE_ID, -1);
            int uniqueId = preference.getInt(LinkingUtil.DEVICE_UID, -1);
            if (BuildConfig.DEBUG) {
                Log.d(TAG, "@@ NotifyConnect#onDisconnect");
                Log.d(TAG, LinkingUtil.DEVICE_NAME + "=" + preference.getString(LinkingUtil.DEVICE_NAME, ""));
                Log.d(TAG, LinkingUtil.RECEIVE_TIME + "=" + preference.getLong(LinkingUtil.RECEIVE_TIME, -1));
            }
            LinkingDevice device = mLinkingDeviceManager.findDeviceByDeviceId(deviceId, uniqueId);
            if (device != null) {
                device.setIsConnected(false);
                notifyDisconnect(device);
            }
        }
    });
}

18 View Complete Implementation : LinkingNotifyNotification.java
Copyright MIT License
Author : DeviceConnect
private void startNotifyNotification() {
    if (mNotifyNotification != null) {
        if (BuildConfig.DEBUG) {
            Log.w(TAG, "mNotifyNotification is already running.");
        }
        return;
    }
    if (BuildConfig.DEBUG) {
        Log.d(TAG, "startNotifyNotification");
    }
    mNotifyNotification = new NotifyNotification(mContext, () -> {
        SharedPreferences preference = mContext.getSharedPreferences(Define.NotificationInfo, Context.MODE_PRIVATE);
        int deviceId = preference.getInt(LinkingUtil.DEVICE_ID, -1);
        int uniqueId = preference.getInt(LinkingUtil.DEVICE_UID, -1);
        int keyCode = preference.getInt(LinkingUtil.DEVICE_BUTTON_ID, -1);
        if (BuildConfig.DEBUG) {
            Log.i(TAG, "NotifyNotification.NotificationInterface#onNotify");
            Log.i(TAG, "deviceId:" + deviceId);
            Log.i(TAG, "uniqueId:" + uniqueId);
            Log.i(TAG, "keyCode:" + keyCode);
        }
        LinkingDevice device = findDeviceFromKeyHolders(deviceId, uniqueId);
        if (device != null) {
            notifyOnKeyEvent(device, keyCode);
        } else {
            if (BuildConfig.DEBUG) {
                Log.w(TAG, "Not found a device.");
            }
        }
    });
}

18 View Complete Implementation : LinkingNotifyRange.java
Copyright MIT License
Author : DeviceConnect
private void startNotifyRange() {
    if (mNotifyRange != null) {
        if (BuildConfig.DEBUG) {
            Log.w(TAG, "mNotifyRange is already running.");
        }
        return;
    }
    if (BuildConfig.DEBUG) {
        Log.d(TAG, "startNotifyRange");
    }
    mNotifyRange = new NotifyRange(mContext, new NotifyRange.RangeInterface() {

        @Override
        public void onRangeChange() {
            if (mMap.isEmpty()) {
                if (BuildConfig.DEBUG) {
                    Log.w(TAG, "mMap is empty.");
                }
                return;
            }
            SharedPreferences preference = mContext.getSharedPreferences(Define.RangeInfo, Context.MODE_PRIVATE);
            String bdAddress = preference.getString(LinkingUtil.BD_ADDRESS, "");
            int range = preference.getInt(LinkingUtil.RANGE, -1);
            int rangeSetting = preference.getInt(LinkingUtil.RANGE_SETTING, -1);
            LinkingDevice device = findDeviceFromRangeHolders(bdAddress);
            if (device != null) {
                if (BuildConfig.DEBUG) {
                    Log.d(TAG, "NotifyRange: [" + device.getDisplayName() + "] " + range);
                }
                notifyOnChangeRange(device, LinkingDeviceManager.Range.valueOf(rangeSetting, range));
            } else {
                if (BuildConfig.DEBUG) {
                    Log.w(TAG, "Not found a device. bdAddress=" + bdAddress);
                }
            }
        }
    });
}

18 View Complete Implementation : LinkingNotifySensor.java
Copyright MIT License
Author : DeviceConnect
public synchronized void disableListenBattery(final LinkingDevice device, final LinkingDeviceManager.OnBatteryListener listener) {
    if (BuildConfig.DEBUG) {
        Log.i(TAG, "LinkingNotifySensor#disableListenBattery: " + device.getDisplayName());
    }
    List<LinkingDeviceManager.OnBatteryListener> listeners = mBatteryMap.get(device);
    if (listeners != null) {
        if (listener == null) {
            mBatteryMap.remove(device);
        } else {
            listeners.remove(listener);
            if (listeners.isEmpty()) {
                mBatteryMap.remove(device);
            }
        }
    }
    stopSensors(device);
}

18 View Complete Implementation : LinkingNotifySensor.java
Copyright MIT License
Author : DeviceConnect
public synchronized void enableListenHumidity(final LinkingDevice device, final LinkingDeviceManager.OnHumidityListener listener) {
    if (!device.isSupportHumidity()) {
        return;
    }
    List<LinkingDeviceManager.OnHumidityListener> listeners = mHumidityMap.get(device);
    if (listeners == null) {
        listeners = new CopyOnWriteArrayList<>();
        mHumidityMap.put(device, listeners);
    } else if (listeners.contains(listener)) {
        return;
    }
    listeners.add(listener);
    if (listeners.size() > 1) {
        if (BuildConfig.DEBUG) {
            Log.i(TAG, device.getDisplayName() + ": humidity is already running.");
        }
        return;
    }
    int[] type = { LinkingSensorData.SensorType.HUMIDITY.getValue() };
    startSensor(device.getBdAddress(), type, 1000);
}

18 View Complete Implementation : LinkingNotifySensor.java
Copyright MIT License
Author : DeviceConnect
public synchronized void enableListenTemperature(final LinkingDevice device, final LinkingDeviceManager.OnTemperatureListener listener) {
    if (!device.isSupportTemperature()) {
        return;
    }
    List<LinkingDeviceManager.OnTemperatureListener> listeners = mTemperatureMap.get(device);
    if (listeners == null) {
        listeners = new CopyOnWriteArrayList<>();
        mTemperatureMap.put(device, listeners);
    } else if (listeners.contains(listener)) {
        return;
    }
    listeners.add(listener);
    if (listeners.size() > 1) {
        if (BuildConfig.DEBUG) {
            Log.i(TAG, device.getDisplayName() + ": temperature is already running.");
        }
        return;
    }
    int[] type = { LinkingSensorData.SensorType.TEMPERATURE.getValue() };
    startSensor(device.getBdAddress(), type, 1000);
}