Add an encoding type while converting byte[] to string
This commit is contained in:
parent
1c067b1cb6
commit
bacdc3c539
1 changed files with 22 additions and 4 deletions
|
@ -244,7 +244,16 @@ public class OlmAccount extends CommonSerializeUtils implements Serializable {
|
||||||
|
|
||||||
if( null != (identityKeysBuffer = identityKeysJni())) {
|
if( null != (identityKeysBuffer = identityKeysJni())) {
|
||||||
try {
|
try {
|
||||||
identityKeysJsonObj = new JSONObject(new String(identityKeysBuffer));
|
String identityKeysString;
|
||||||
|
|
||||||
|
try {
|
||||||
|
identityKeysString = new String(identityKeysBuffer, "UTF-8");
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(LOG_TAG, "## identityKeys(): Exception : cannot convert with utf-8 charset " + e.getMessage());
|
||||||
|
identityKeysString = new String(identityKeysBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
identityKeysJsonObj = new JSONObject(identityKeysString);
|
||||||
//Log.d(LOG_TAG, "## identityKeys(): Identity Json keys=" + identityKeysJsonObj.toString());
|
//Log.d(LOG_TAG, "## identityKeys(): Identity Json keys=" + identityKeysJsonObj.toString());
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
identityKeysJsonObj = null;
|
identityKeysJsonObj = null;
|
||||||
|
@ -301,12 +310,21 @@ public class OlmAccount extends CommonSerializeUtils implements Serializable {
|
||||||
* @return one time keys in string dictionary if operation succeed, null otherwise
|
* @return one time keys in string dictionary if operation succeed, null otherwise
|
||||||
*/
|
*/
|
||||||
public Map<String, Map<String, String>> oneTimeKeys() {
|
public Map<String, Map<String, String>> oneTimeKeys() {
|
||||||
byte identityKeysBuffer[];
|
byte oneTimeKeysBuffer[];
|
||||||
JSONObject oneTimeKeysJsonObj = null;
|
JSONObject oneTimeKeysJsonObj = null;
|
||||||
|
|
||||||
if( null != (identityKeysBuffer = oneTimeKeysJni())) {
|
if( null != (oneTimeKeysBuffer = oneTimeKeysJni())) {
|
||||||
try {
|
try {
|
||||||
oneTimeKeysJsonObj = new JSONObject(new String(identityKeysBuffer));
|
String oneTimeKeysString;
|
||||||
|
|
||||||
|
try {
|
||||||
|
oneTimeKeysString = new String(oneTimeKeysBuffer, "UTF-8");
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(LOG_TAG, "## oneTimeKeys(): Exception : cannot convert with utf-8 charset " + e.getMessage());
|
||||||
|
oneTimeKeysString = new String(oneTimeKeysBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
oneTimeKeysJsonObj = new JSONObject(new String(oneTimeKeysString));
|
||||||
//Log.d(LOG_TAG, "## oneTimeKeys(): OneTime Json keys=" + oneTimeKeysJsonObj.toString());
|
//Log.d(LOG_TAG, "## oneTimeKeys(): OneTime Json keys=" + oneTimeKeysJsonObj.toString());
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
oneTimeKeysJsonObj = null;
|
oneTimeKeysJsonObj = null;
|
||||||
|
|
Loading…
Reference in a new issue