From 9dc8e3db9dba2eadcbba5e77d62edf6fa7ff8fe7 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 31 Jul 2016 22:32:51 +0200 Subject: set tablet, phone or pc identity --- .../eu/siacs/conversations/generator/AbstractGenerator.java | 11 +++++++++-- .../java/eu/siacs/conversations/generator/IqGenerator.java | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'src/main') diff --git a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java index 7964a38a..8edc24c3 100644 --- a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java +++ b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java @@ -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"); diff --git a/src/main/java/eu/siacs/conversations/generator/IqGenerator.java b/src/main/java/eu/siacs/conversations/generator/IqGenerator.java index ad650c3e..4116729a 100644 --- a/src/main/java/eu/siacs/conversations/generator/IqGenerator.java +++ b/src/main/java/eu/siacs/conversations/generator/IqGenerator.java @@ -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"); } -- cgit v1.2.3