本文整理汇总了Java中com.getpebble.android.kit.util.PebbleDictionary.addBytes方法的典型用法代码示例。如果您正苦于以下问题:Java PebbleDictionary.addBytes方法的具体用法?Java PebbleDictionary.addBytes怎么用?Java PebbleDictionary.addBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.getpebble.android.kit.util.PebbleDictionary
的用法示例。
在下文中一共展示了PebbleDictionary.addBytes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetBytesLeft
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
@Test
public void testGetBytesLeft() throws Exception
{
PebbleCapabilities testCapabilities = new PebbleCapabilities(false, false, false, false, false, 100);
PebbleDictionary testDictionary = new PebbleDictionary();
assertEquals(92, PebbleUtil.getBytesLeft(testDictionary, testCapabilities));
testDictionary.addInt8(1, (byte) 20);
assertEquals(84, PebbleUtil.getBytesLeft(testDictionary, testCapabilities));
testDictionary.addInt32(2, 20);
assertEquals(73, PebbleUtil.getBytesLeft(testDictionary, testCapabilities));
testDictionary.addBytes(3, new byte[]{1, 2, 3, 4});
assertEquals(62, PebbleUtil.getBytesLeft(testDictionary, testCapabilities));
testDictionary.addString(4, "abcde");
assertEquals(50, PebbleUtil.getBytesLeft(testDictionary, testCapabilities));
testDictionary.addUint32(1, 20);
assertEquals(47, PebbleUtil.getBytesLeft(testDictionary, testCapabilities));
}
示例2: sendImagePacket
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
private void sendImagePacket()
{
PebbleDictionary data = new PebbleDictionary();
data.addUint8(0, (byte) 1);
data.addUint8(1, (byte) 2);
data.addUint16(2, (short) 0); //Image size placeholder
int maxBytesToSend = PebbleUtil.getBytesLeft(data, getService().getPebbleCommunication().getConnectedWatchCapabilities());
int bytesToSend = Math.min(callerImageBytes.length - callerImageNextByte, maxBytesToSend);
byte[] bytes = new byte[bytesToSend];
System.arraycopy(callerImageBytes, callerImageNextByte, bytes, 0, bytesToSend);
data.addUint16(2, (short) bytesToSend); //Image size placeholder
data.addBytes(3, bytes);
getService().getPebbleCommunication().sendToPebble(data);
Timber.d("Sent image packet %d / %d", callerImageNextByte, callerImageBytes.length);
callerNameUpdateRequired = false;
callerImageNextByte += bytesToSend;
if (callerImageNextByte >= callerImageBytes.length)
callerImageNextByte = -1;
}
示例3: sendWatchappIcon
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
private boolean sendWatchappIcon()
{
Timber.d("Sending icon");
PebbleDictionary data = new PebbleDictionary();
data.addUint8(0, (byte) 1);
data.addUint8(1, (byte) 2);
data.addInt32(2, curSendingNotification.id);
curSendingNotification.needsIconSending = false;
// Only send icon if it can fit into one Appmessage
if (curSendingNotification.iconData.length <= PebbleUtil.getBytesLeft(data, getService().getPebbleCommunication().getConnectedWatchCapabilities()))
{
data.addBytes(3, curSendingNotification.iconData);
getService().getPebbleCommunication().sendToPebble(data);
return true;
}
else
{
Timber.d("Sending failed! Icon cannot fit into AppMessage.");
return sendNextMessage(); //Icon sending failed, send next message in a row.
}
}
示例4: sendNowCast
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
private void sendNowCast()
{
if (m_busySending)
return;
m_busySending = true;
long now = System.currentTimeMillis();
int utcOffset = TimeZone.getDefault().getRawOffset();
PebbleDictionary out = new PebbleDictionary();
int len = m_nowcast.size();
byte[] precipitation = new byte[len]; // in tenths of mm
byte[] minutesInFuture = new byte[len];
int i = 0;
for (Forecast f : m_nowcast) {
if (m_nackCount > 5)
return;
precipitation[i] = (byte) Math.round(f.getPrecipitation().getPrecipitation() * 10);
minutesInFuture[i] = (byte)((f.getTimeFrom().getTime() - now + utcOffset) / 60000);
Log.d(TAG, "nowcast " + f.getTimeFrom() + " (" + minutesInFuture[i] + " min from now)" + ": " + f.getPrecipitation());
++i;
try {
Thread.sleep(SLEEP_BETWEEN_PACKETS);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
out.addBytes(KEY_NOWCAST_MINUTES, minutesInFuture);
out.addBytes(KEY_NOWCAST_PRECIPITATION, precipitation);
PebbleKit.sendDataToPebble(m_weatherService, WATCHAPP_UUID, out);
m_busySending = false;
}
示例5: sendNextListItems
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
private void sendNextListItems()
{
Timber.d("Sending action list items");
PebbleDictionary data = new PebbleDictionary();
byte[] bytes = new byte[3];
data.addUint8(0, (byte) 5);
data.addUint8(1, (byte) 0);
int segmentSize = Math.min(listSize - nextListItemToSend, 4);
bytes[0] = (byte) nextListItemToSend;
bytes[1] = (byte) listSize;
bytes[2] = (byte) (tertiaryTextMode ? 1 : 0);
byte[] textData = new byte[segmentSize * 19];
for (int i = 0; i < segmentSize; i++)
{
String text = TextUtil.prepareString(actionList.get(i + nextListItemToSend), 18);
System.arraycopy(text.getBytes(), 0, textData, i * 19, text.getBytes().length);
textData[19 * (i + 1) -1 ] = 0;
}
data.addBytes(2, bytes);
data.addBytes(3, textData);
getService().getPebbleCommunication().sendToPebble(data);
nextListItemToSend += 4;
if (nextListItemToSend >= listSize)
nextListItemToSend = -1;
}
示例6: sendConfigInvalidVersion
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
private void sendConfigInvalidVersion(int version)
{
PebbleDictionary data = new PebbleDictionary();
byte[] configBytes = new byte[13];
configBytes[0] = (byte) (WatchappHandler.SUPPORTED_PROTOCOL >>> 0x08);
configBytes[1] = (byte) WatchappHandler.SUPPORTED_PROTOCOL;
data.addUint8(0, (byte) 0);
data.addUint8(1, (byte) 0);
data.addBytes(2, configBytes);
Timber.d("Sending version mismatch config...");
getService().getPebbleCommunication().sendToPebble(data);
runOnNext = new Callable<Boolean>()
{
@Override
public Boolean call() throws Exception
{
//Pretend that I sent new message to prevent other modules sending potentially unsupported messages
return true;
}
};
WatchappHandler.showUpdateNotification(getService());
}
示例7: sendFakeCall
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
/**
* Pre 2.2 watchapp does not have update screen so we display fake call screen
*/
private void sendFakeCall()
{
PebbleDictionary data = new PebbleDictionary();
data.addUint8(0, (byte) 5);
data.addString(1, "Old PebbleDialer");
data.addString(2, "");
data.addString(3, "Check phone");
byte[] parameters = new byte[4];
parameters[0] = 1;
parameters[3] = 1;
data.addBytes(4, parameters);
data.addUint16(5, (short) 0);
getService().getPebbleCommunication().sendToPebble(data);
runOnNext = new Callable<Boolean>()
{
@Override
public Boolean call() throws Exception
{
//Pretend that I sent new message to prevent other modules sending potentially unsupported messages
return true;
}
};
WatchappHandler.showUpdateNotification(getService());
}
示例8: sendNumbers
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
public void sendNumbers(int offset)
{
PebbleDictionary data = new PebbleDictionary();
data.addUint8(0, (byte) 4);
data.addUint8(1, (byte) 0);
data.addUint16(2, (short) offset);
data.addUint16(3, (short) phoneNumbers.size());
byte[] numberActions = new byte[2];
for (int i = 0; i < 2; i++)
{
int listPos = offset + i;
if (listPos >= phoneNumbers.size())
break;
PebbleNumberEntry numberEntry = phoneNumbers.get(listPos);
data.addString(i + 4, TextUtil.prepareString(numberEntry.numberType));
data.addString(i + 6, TextUtil.prepareString(numberEntry.number));
numberActions[i] = (byte) numberEntry.numberAction;
}
data.addBytes(8, numberActions);
if (openWindow)
data.addUint8(999, (byte) 1);
Timber.d("sendNumbers %d", offset);
getService().getPebbleCommunication().sendToPebble(data);
}
示例9: sendMoreText
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
private void sendMoreText()
{
Timber.d("Sending more text... %d %d", curSendingNotification.id, curSendingNotification.nextChunkToSend);
PebbleDictionary data = new PebbleDictionary();
data.addUint8(0, (byte) 1);
data.addUint8(1, (byte) 1);
data.addInt32(2, curSendingNotification.id);
data.addBytes(3, curSendingNotification.textChunks.get(curSendingNotification.nextChunkToSend));
getService().getPebbleCommunication().sendToPebble(data);
curSendingNotification.nextChunkToSend++;
}
示例10: sendImagePart
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
public void sendImagePart()
{
Timber.d("SendImagePart %d", nextByteToSend);
//Substract appmessage overhead from maximum packet size
// (1 byte for number of entries)
// (3 entries - 3x7 bytes)
// (2 additional bytes (for entries 0 and 1))
// (1 additional byte for storing size of the image for checksum)
int maxImageFragmentSize = getService().getPebbleCommunication().getConnectedWatchCapabilities().getMaxAppmessageSize() - 3 * 7 - 2 - 1 - 1;
int bytesToSend = Math.min(imageData.length - nextByteToSend, maxImageFragmentSize);
byte[] bytes = new byte[bytesToSend + 1];
bytes[0] = (byte) ((byte) (nextByteToSend % 256) & 0xFF);
System.arraycopy(imageData, nextByteToSend, bytes, 1, bytesToSend);
PebbleDictionary data = new PebbleDictionary();
data.addUint8(0, (byte) 5);
data.addUint8(1, (byte) 0);
data.addBytes(2, bytes);
getService().getPebbleCommunication().sendToPebble(data);
nextByteToSend += bytesToSend;
if (nextByteToSend >= imageData.length)
nextByteToSend = -1;
}
示例11: sendConfigInvalidVersion
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
private void sendConfigInvalidVersion(int version)
{
PebbleDictionary data = new PebbleDictionary();
byte[] configBytes = new byte[13];
configBytes[8] = (byte) (WatchappHandler.SUPPORTED_PROTOCOL >>> 0x08);
configBytes[9] = (byte) WatchappHandler.SUPPORTED_PROTOCOL;
if (version == 0) //Pre-2.4 protocol
{
data.addUint8(0, (byte) 3);
data.addBytes(1, configBytes);
}
else
{
data.addUint8(0, (byte) 0);
data.addUint8(1, (byte) 0);
data.addBytes(2, configBytes);
}
Timber.d("Sending version mismatch config...");
getService().getPebbleCommunication().sendToPebble(data);
runOnNext = new Callable<Boolean>()
{
@Override
public Boolean call() throws Exception
{
//Pretend that I sent new message to prevent other modules sending potentially unsupported messages
return true;
}
};
if (version < WatchappHandler.SUPPORTED_PROTOCOL)
WatchappHandler.showUpdateNotification(getService());
}
示例12: sendNextListItems
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
private void sendNextListItems()
{
Timber.d("Sending action list items");
PebbleDictionary data = new PebbleDictionary();
byte[] bytes = new byte[3];
data.addUint8(0, (byte) 4);
data.addUint8(1, (byte) 0);
int segmentSize = Math.min(listSize - nextListItemToSend, 4);
bytes[0] = (byte) nextListItemToSend;
bytes[1] = (byte) listSize;
bytes[2] = (byte) (list.isTertiaryTextList() ? 1 : 0);
byte[] textData = new byte[segmentSize * 19];
for (int i = 0; i < segmentSize; i++)
{
String text = TextUtil.prepareString(list.getItem(i + nextListItemToSend), 18);
System.arraycopy(text.getBytes(), 0, textData, i * 19, text.getBytes().length);
textData[19 * (i + 1) -1 ] = 0;
}
data.addBytes(2, bytes);
data.addBytes(3, textData);
getService().getPebbleCommunication().sendToPebble(data);
nextListItemToSend += 4;
if (nextListItemToSend >= listSize)
nextListItemToSend = -1;
}
示例13: btnRefreshClick
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
public void btnRefreshClick(View v) {
PebbleDictionary data = new PebbleDictionary();
//data.addString(PebbleMessage.PBL_MESSAGE, new String(send));
data.addBytes(PebbleMessage.PBL_RESET, new byte[]{'a'});
PebbleKit.sendDataToPebbleWithTransactionId(getApplicationContext(), PebbleMessage.WECHATPEBBLE_UUID, data, 2);
Log.d("Main","Manual refresh");
}
示例14: sendUpdatePacket
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
private void sendUpdatePacket()
{
PebbleDictionary data = new PebbleDictionary();
data.addUint8(0, (byte) 1);
data.addUint8(1, (byte) 0);
boolean nameAtBottomWhenImageDisplayed = callerImage != null && getService().getGlobalSettings().getBoolean("bottomCallerName", true);
if (name != null && type != null)
{
data.addString(2, TextUtil.prepareString(type, 30));
data.addString(3, TextUtil.prepareString(number, 30));
}
else
{
data.addString(2, "");
data.addString(3, "");
}
List<Byte> vibrationPattern;
if (vibrating)
{
String vibrationPatternString = getService().getGlobalSettings().getString("vibrationPattern", "100, 100, 100, 1000");
vibrationPattern = PebbleVibrationPattern.parseVibrationPattern(vibrationPatternString);
}
else
{
vibrationPattern = PebbleVibrationPattern.EMPTY_VIBRATION_PATTERN;
}
byte[] parameters = new byte[8 + vibrationPattern.size()];
parameters[0] = (byte) (callState == CallState.ESTABLISHED ? 1 : 0);
parameters[1] = (byte) (nameAtBottomWhenImageDisplayed ? 1 : 0);
parameters[6] = (byte) (identityUpdateRequired ? 1 : 0);
parameters[2] = (byte) getCallAction(getUserSelectedAction(getExtendedButtonId("Up"))).getIcon();
parameters[3] = (byte) getCallAction(getUserSelectedAction(getExtendedButtonId("Select"))).getIcon();
parameters[4] = (byte) getCallAction(getUserSelectedAction(getExtendedButtonId("Down"))).getIcon();
parameters[7] = (byte) vibrationPattern.size();
for (int i = 0; i < vibrationPattern.size(); i++)
parameters[8 + i] = vibrationPattern.get(i);
data.addBytes(4, parameters);
if (callState == CallState.ESTABLISHED)
data.addUint16(5, (short) Math.min(65000, (System.currentTimeMillis() - callStartTime) / 1000));
data.addUint8(999, (byte) 1);
callerImageNextByte = -1;
if (identityUpdateRequired && getService().getPebbleCommunication().getConnectedWatchCapabilities().hasColorScreen())
{
int imageSize = 0;
if (callerImage != null)
{
processContactImage();
imageSize = callerImageBytes.length;
}
data.addUint16(7, (short) imageSize);
if (imageSize != 0)
callerImageNextByte = 0;
Timber.d("Image size: %d", imageSize);
}
getService().getPebbleCommunication().sendToPebble(data);
Timber.d("Sent Call update packet. New identity: %b", identityUpdateRequired);
callerNameUpdateRequired = identityUpdateRequired;
updateRequired = false;
identityUpdateRequired = false;
}
示例15: sendConfig
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
private void sendConfig()
{
PebbleDictionary data = new PebbleDictionary();
List<Integer> pickedGroupIds = ListSerialization.loadIntegerList(getService().getGlobalSettings(), "displayedGroupsListNew");
pickedContactGroups = ContactGroupsPickerDialog.getSpecificContactGroups(getService(), pickedGroupIds);
byte[] configBytes = new byte[8];
configBytes[0] = (byte) (WatchappHandler.SUPPORTED_PROTOCOL >>> 0x08);
configBytes[1] = (byte) WatchappHandler.SUPPORTED_PROTOCOL;
boolean callWaiting = CallModule.get(getService()).getCallState() != CallModule.CallState.NO_CALL;
byte flags = 0;
flags |= (byte) (callWaiting ? 0x01 : 0);
flags |= (byte) (getService().getGlobalSettings().getBoolean("closeToLastApp", false) ? 0x02 : 0);
flags |= (byte) (getService().getGlobalSettings().getBoolean("skipGroupFiltering", false) ? 0x04 : 0);
flags |= (byte) (getService().getGlobalSettings().getBoolean("lightOnCallWindow", false) ? 0x08 : 0);
flags |= (byte) (getService().getGlobalSettings().getBoolean("dontVibrateWhenCharging", true) ? 0x10 : 0);
flags |= (byte) (getService().getGlobalSettings().getBoolean("enableCallTimer", true) ? 0x20 : 0);
flags |= (byte) (getService().getGlobalSettings().getBoolean("popupOnOutgoing", true) ? 0x40 : 0);
configBytes[2] = flags;
configBytes[3] = (byte) pickedContactGroups.size();
configBytes[4] = Byte.parseByte(getService().getGlobalSettings().getString("fontTimer", "2"));
configBytes[5] = Byte.parseByte(getService().getGlobalSettings().getString("fontName", "7"));
configBytes[6] = Byte.parseByte(getService().getGlobalSettings().getString("fontNumberType", "2"));
configBytes[7] = Byte.parseByte(getService().getGlobalSettings().getString("fontNumber", "3"));
data.addUint8(0, (byte) 0);
data.addUint8(1, (byte) 0);
data.addBytes(2, configBytes);
Timber.d("Sending config... CallWaiting=%b", callWaiting);
getService().getPebbleCommunication().sendToPebble(data);
if (!callWaiting && pickedContactGroups.size() > 0)
nextGroupNameToSend = 0;
}