Skip to content

Commit 22765e9

Browse files
author
Ehab Abdou
committedJun 22, 2012
Commented code that was causing NullPointer Exception crashes
1 parent 551a254 commit 22765e9

File tree

5 files changed

+59
-51
lines changed

5 files changed

+59
-51
lines changed
 

‎build.properties ‎ant.properties

File renamed without changes.

‎build.xml

+38-32
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,49 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project name="WebSocket" default="help">
2+
<project name="ACTIVITY_ENTRY_NAME" default="help">
33

4-
<!-- The local.properties file is created and updated by the 'android'
5-
tool.
6-
It contains the path to the SDK. It should *NOT* be checked into
7-
Version Control Systems. -->
4+
<!-- The local.properties file is created and updated by the 'android' tool.
5+
It contains the path to the SDK. It should *NOT* be checked into
6+
Version Control Systems. -->
87
<property file="local.properties" />
98

10-
<!-- The build.properties file can be created by you and is never touched
11-
by the 'android' tool. This is the place to change some of the
12-
default property values used by the Ant rules.
9+
<!-- The ant.properties file can be created by you. It is only edited by the
10+
'android' tool to add properties to it.
11+
This is the place to change some Ant specific build properties.
1312
Here are some properties you may want to change/update:
1413
1514
source.dir
1615
The name of the source directory. Default is 'src'.
1716
out.dir
1817
The name of the output directory. Default is 'bin'.
1918
19+
For other overridable properties, look at the beginning of the rules
20+
files in the SDK, at tools/ant/build.xml
21+
2022
Properties related to the SDK location or the project target should
2123
be updated using the 'android' tool with the 'update' action.
2224
2325
This file is an integral part of the build system for your
2426
application and should be checked into Version Control Systems.
2527
2628
-->
27-
<property file="build.properties" />
29+
<property file="ant.properties" />
2830

29-
<!-- The default.properties file is created and updated by the 'android'
31+
<!-- The project.properties file is created and updated by the 'android'
3032
tool, as well as ADT.
33+
34+
This contains project specific properties such as project target, and library
35+
dependencies. Lower level build properties are stored in ant.properties
36+
(or in .classpath for Eclipse projects).
37+
3138
This file is an integral part of the build system for your
3239
application and should be checked into Version Control Systems. -->
33-
<property file="default.properties" />
40+
<loadproperties srcFile="project.properties" />
3441

35-
36-
<!-- Required pre-setup import -->
37-
<import file="${sdk.dir}/tools/ant/pre_setup.xml" />
42+
<!-- quick check on sdk.dir -->
43+
<fail
44+
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
45+
unless="sdk.dir"
46+
/>
3847

3948

4049
<!-- extension targets. Uncomment the ones where you want to do custom work
@@ -45,35 +54,32 @@
4554
<target name="-pre-compile">
4655
</target>
4756
48-
[This is typically used for code obfuscation.
49-
Compiled code location: ${out.classes.absolute.dir}
50-
If this is not done in place, override ${out.dex.input.absolute.dir}]
57+
/* This is typically used for code obfuscation.
58+
Compiled code location: ${out.classes.absolute.dir}
59+
If this is not done in place, override ${out.dex.input.absolute.dir} */
5160
<target name="-post-compile">
5261
</target>
5362
-->
5463

55-
<!-- Execute the Android Setup task that will setup some properties
56-
specific to the target, and import the build rules files.
57-
58-
The rules file is imported from
59-
<SDK>/tools/ant/
60-
Depending on the project type it can be either:
61-
- main_rules.xml
62-
- lib_rules.xml
63-
- test_rules.xml
64+
<!-- Import the actual build file.
6465
6566
To customize existing targets, there are two options:
6667
- Customize only one target:
6768
- copy/paste the target into this file, *before* the
68-
<setup> task.
69+
<import> task.
6970
- customize it to your needs.
70-
- Customize the whole script.
71+
- Customize the whole content of build.xml
7172
- copy/paste the content of the rules files (minus the top node)
72-
into this file, *after* the <setup> task
73-
- disable the import of the rules by changing the setup task
74-
below to <setup import="false" />.
73+
into this file, replacing the <import> task.
7574
- customize to your needs.
75+
76+
***********************
77+
****** IMPORTANT ******
78+
***********************
79+
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
80+
in order to avoid having your file be overridden by tools such as "android update project"
7681
-->
77-
<setup />
82+
<!-- version-tag: 1 -->
83+
<import file="${sdk.dir}/tools/ant/build.xml" />
7884

7985
</project>

‎local.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
# location of the SDK. This is only used by Ant
88
# For customization when using a Version Control System, please read the
99
# header note.
10-
sdk.dir=/Users/ukenco-op/android-sdk-mac_x86
10+
sdk.dir=/Applications/android-sdk-macosx
File renamed without changes.

‎src/com/strumsoft/phonegap/websocket/WebSocket.java

+20-18
Original file line numberDiff line numberDiff line change
@@ -669,24 +669,26 @@ private void _readHandshake(byte[] handShakeBody) throws IOException, NoSuchAlgo
669669
this.handshakeComplete = true;
670670
boolean isConnectionReady = true;
671671

672-
if (this.draft == WebSocket.Draft.DRAFT76) {
673-
if (handShakeBody == null) {
674-
isConnectionReady = true;
675-
}
676-
byte[] challenge = new byte[] { (byte) (this.number1 >> 24),
677-
(byte) ((this.number1 << 8) >> 24), (byte) ((this.number1 << 16) >> 24),
678-
(byte) ((this.number1 << 24) >> 24), (byte) (this.number2 >> 24),
679-
(byte) ((this.number2 << 8) >> 24), (byte) ((this.number2 << 16) >> 24),
680-
(byte) ((this.number2 << 24) >> 24), this.key3[0], this.key3[1], this.key3[2],
681-
this.key3[3], this.key3[4], this.key3[5], this.key3[6], this.key3[7] };
682-
MessageDigest md5 = MessageDigest.getInstance("MD5");
683-
byte[] expected = md5.digest(challenge);
684-
for (int i = 0; i < handShakeBody.length; i++) {
685-
if (expected[i] != handShakeBody[i]) {
686-
isConnectionReady = true;
687-
}
688-
}
689-
}
672+
//TODO: Figure out a better way to fix this.
673+
//Commented because it was causing a NullPointerException and because the code didn't seem to affect isConnectionReady
674+
// if (this.draft == WebSocket.Draft.DRAFT76) {
675+
// if (handShakeBody == null) {
676+
// isConnectionReady = true;
677+
// }
678+
// byte[] challenge = new byte[] { (byte) (this.number1 >> 24),
679+
// (byte) ((this.number1 << 8) >> 24), (byte) ((this.number1 << 16) >> 24),
680+
// (byte) ((this.number1 << 24) >> 24), (byte) (this.number2 >> 24),
681+
// (byte) ((this.number2 << 8) >> 24), (byte) ((this.number2 << 16) >> 24),
682+
// (byte) ((this.number2 << 24) >> 24), this.key3[0], this.key3[1], this.key3[2],
683+
// this.key3[3], this.key3[4], this.key3[5], this.key3[6], this.key3[7] };
684+
// MessageDigest md5 = MessageDigest.getInstance("MD5");
685+
// byte[] expected = md5.digest(challenge);
686+
// for (int i = 0; i < handShakeBody.length; i++) {
687+
// if (expected[i] != handShakeBody[i]) {
688+
// isConnectionReady = true;
689+
// }
690+
// }
691+
// }
690692

691693
if (isConnectionReady) {
692694
this.readyState = WEBSOCKET_STATE_OPEN;

0 commit comments

Comments
 (0)
Failed to load comments.