Remove Android dependencies from pure-Java code.

This commit is contained in:
Moxie Marlinspike 2015-02-27 18:24:48 -08:00
parent 7431302b6b
commit 31d5e2984c
10 changed files with 24 additions and 22 deletions

View File

@ -20,6 +20,7 @@ dependencies {
compile 'org.whispersystems:axolotl-android:1.1.1'
compile (project(':java')) {
exclude group: 'org.whispersystems', module: 'axolotl-java'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
}

View File

@ -22,6 +22,7 @@ dependencies {
compile 'org.whispersystems:axolotl-java:1.1.1'
compile 'com.squareup.okhttp:okhttp:2.2.0'
compile 'org.apache.httpcomponents:httpclient:4.4'
}

View File

@ -16,13 +16,12 @@
*/
package org.whispersystems.textsecure.api;
import android.util.Log;
import com.google.protobuf.ByteString;
import com.google.protobuf.InvalidProtocolBufferException;
import org.whispersystems.libaxolotl.InvalidKeyException;
import org.whispersystems.libaxolotl.SessionBuilder;
import org.whispersystems.libaxolotl.logging.Log;
import org.whispersystems.libaxolotl.protocol.CiphertextMessage;
import org.whispersystems.libaxolotl.state.AxolotlStore;
import org.whispersystems.libaxolotl.state.PreKeyBundle;

View File

@ -16,11 +16,10 @@
*/
package org.whispersystems.textsecure.api.messages;
import android.util.Log;
import com.google.protobuf.ByteString;
import org.whispersystems.libaxolotl.InvalidVersionException;
import org.whispersystems.libaxolotl.logging.Log;
import org.whispersystems.textsecure.internal.push.PushMessageProtos.IncomingPushMessageSignal;
import org.whispersystems.textsecure.internal.util.Base64;
import org.whispersystems.textsecure.internal.util.Hex;

View File

@ -16,13 +16,13 @@
*/
package org.whispersystems.textsecure.api.util;
import android.util.Log;
import com.google.i18n.phonenumbers.NumberParseException;
import com.google.i18n.phonenumbers.PhoneNumberUtil;
import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat;
import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;
import org.whispersystems.libaxolotl.logging.Log;
import java.util.Locale;
/**

View File

@ -16,13 +16,12 @@
*/
package org.whispersystems.textsecure.internal.push;
import android.util.Log;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.http.conn.ssl.StrictHostnameVerifier;
import org.whispersystems.libaxolotl.IdentityKey;
import org.whispersystems.libaxolotl.ecc.ECPublicKey;
import org.whispersystems.libaxolotl.logging.Log;
import org.whispersystems.libaxolotl.state.PreKeyBundle;
import org.whispersystems.libaxolotl.state.PreKeyRecord;
import org.whispersystems.libaxolotl.state.SignedPreKeyRecord;
@ -72,6 +71,8 @@ import javax.net.ssl.TrustManager;
*/
public class PushServiceSocket {
private static final String TAG = PushServiceSocket.class.getSimpleName();
private static final String CREATE_ACCOUNT_SMS_PATH = "/v1/accounts/sms/code/%s";
private static final String CREATE_ACCOUNT_VOICE_PATH = "/v1/accounts/voice/code/%s";
private static final String VERIFY_ACCOUNT_PATH = "/v1/accounts/code/%s";
@ -289,7 +290,7 @@ public class PushServiceSocket {
String responseText = makeRequest(SIGNED_PREKEY_PATH, "GET", null);
return JsonUtil.fromJson(responseText, SignedPreKeyEntity.class);
} catch (NotFoundException e) {
Log.w("PushServiceSocket", e);
Log.w(TAG, e);
return null;
}
}
@ -309,7 +310,7 @@ public class PushServiceSocket {
throw new IOException("Server failed to allocate an attachment key!");
}
Log.w("PushServiceSocket", "Got attachment content location: " + attachmentKey.getLocation());
Log.w(TAG, "Got attachment content location: " + attachmentKey.getLocation());
uploadAttachment("PUT", attachmentKey.getLocation(), attachment.getData(),
attachment.getDataSize(), attachment.getKey());
@ -327,7 +328,7 @@ public class PushServiceSocket {
String response = makeRequest(path, "GET", null);
AttachmentDescriptor descriptor = JsonUtil.fromJson(response, AttachmentDescriptor.class);
Log.w("PushServiceSocket", "Attachment: " + attachmentId + " is at: " + descriptor.getLocation());
Log.w(TAG, "Attachment: " + attachmentId + " is at: " + descriptor.getLocation());
downloadExternalFile(descriptor.getLocation(), destination);
}
@ -375,7 +376,7 @@ public class PushServiceSocket {
}
output.close();
Log.w("PushServiceSocket", "Downloaded: " + url + " to: " + localDestination.getAbsolutePath());
Log.w(TAG, "Downloaded: " + url + " to: " + localDestination.getAbsolutePath());
} catch (IOException ioe) {
throw new PushNetworkException(ioe);
} finally {
@ -490,8 +491,8 @@ public class PushServiceSocket {
context.init(null, trustManagers, null);
URL url = new URL(String.format("%s%s", serviceUrl, urlFragment));
Log.w("PushServiceSocket", "Push service URL: " + serviceUrl);
Log.w("PushServiceSocket", "Opening URL: " + url);
Log.w(TAG, "Push service URL: " + serviceUrl);
Log.w(TAG, "Opening URL: " + url);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
@ -514,7 +515,7 @@ public class PushServiceSocket {
connection.connect();
if (body != null) {
Log.w("PushServiceSocket", method + " -- " + body);
Log.w(TAG, method + " -- " + body);
OutputStream out = connection.getOutputStream();
out.write(body.getBytes());
out.close();

View File

@ -16,10 +16,13 @@
*/
package org.whispersystems.textsecure.internal.push;
import android.util.Log;
import org.whispersystems.libaxolotl.logging.Log;
public class PushTransportDetails {
private static final String TAG = PushTransportDetails.class.getSimpleName();
private final int messageVersion;
public PushTransportDetails(int messageVersion) {
@ -37,7 +40,7 @@ public class PushTransportDetails {
paddingStart = i;
break;
} else if (messageWithPadding[i] != (byte)0x00) {
Log.w("PushTransportDetails", "Padding byte is malformed, returning unstripped padding.");
Log.w(TAG, "Padding byte is malformed, returning unstripped padding.");
return messageWithPadding;
}
}

View File

@ -1,6 +1,5 @@
package org.whispersystems.textsecure.internal.util;
import android.util.Log;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
@ -14,6 +13,7 @@ import com.fasterxml.jackson.databind.SerializerProvider;
import org.whispersystems.libaxolotl.IdentityKey;
import org.whispersystems.libaxolotl.InvalidKeyException;
import org.whispersystems.libaxolotl.logging.Log;
import java.io.IOException;

View File

@ -1,13 +1,12 @@
package org.whispersystems.textsecure.internal.websocket;
import android.util.Log;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import com.squareup.okhttp.internal.ws.WebSocket;
import com.squareup.okhttp.internal.ws.WebSocketListener;
import org.whispersystems.libaxolotl.logging.Log;
import org.whispersystems.textsecure.api.push.TrustStore;
import org.whispersystems.textsecure.api.util.CredentialsProvider;
import org.whispersystems.textsecure.internal.util.BlacklistingTrustManager;

View File

@ -1,9 +1,8 @@
package org.whispersystems.textsecure.internal.websocket;
import android.util.Log;
import com.google.protobuf.InvalidProtocolBufferException;
import org.whispersystems.libaxolotl.logging.Log;
import org.whispersystems.textsecure.api.push.TrustStore;
import org.whispersystems.textsecure.api.util.CredentialsProvider;
import org.whispersystems.textsecure.internal.util.Util;