set tablet, phone or pc identity

This commit is contained in:
Daniel Gultsch 2016-07-31 22:32:51 +02:00
parent 1b114beb0b
commit 9dc8e3db9d
2 changed files with 11 additions and 4 deletions

View File

@ -50,7 +50,6 @@ public abstract class AbstractGenerator {
"urn:xmpp:otr:0"
};
private String mVersion = null;
protected final String IDENTITY_TYPE = "phone";
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
@ -71,9 +70,17 @@ public abstract class AbstractGenerator {
return mXmppConnectionService.getString(R.string.app_name) + " " + getIdentityVersion();
}
public String getIdentityType() {
if ("chromium".equals(android.os.Build.BRAND)) {
return "pc";
} else {
return mXmppConnectionService.getString(R.string.default_resource).toLowerCase();
}
}
public String getCapHash() {
StringBuilder s = new StringBuilder();
s.append("client/" + IDENTITY_TYPE + "//" + getIdentityName() + "<");
s.append("client/" + getIdentityType() + "//" + getIdentityName() + "<");
MessageDigest md;
try {
md = MessageDigest.getInstance("SHA-1");

View File

@ -47,7 +47,7 @@ public class IqGenerator extends AbstractGenerator {
query.setAttribute("node", request.query().getAttribute("node"));
final Element identity = query.addChild("identity");
identity.setAttribute("category", "client");
identity.setAttribute("type", IDENTITY_TYPE);
identity.setAttribute("type", getIdentityType());
identity.setAttribute("name", getIdentityName());
for (final String feature : getFeatures()) {
query.addChild("feature").setAttribute("var", feature);
@ -61,7 +61,7 @@ public class IqGenerator extends AbstractGenerator {
query.addChild("name").setContent(mXmppConnectionService.getString(R.string.app_name));
query.addChild("version").setContent(getIdentityVersion());
if ("chromium".equals(android.os.Build.BRAND)) {
query.addChild("os").setContent("Chromium");
query.addChild("os").setContent("Chrome OS");
} else{
query.addChild("os").setContent("Android");
}