File tree Expand file tree Collapse file tree 8 files changed +29
-25
lines changed
src/main/java/com/reandroid Expand file tree Collapse file tree 8 files changed +29
-25
lines changed Original file line number Diff line number Diff line change 15
15
*/
16
16
package com .reandroid .apk ;
17
17
18
+ import com .reandroid .utils .CRCDigest ;
19
+
18
20
import java .io .IOException ;
19
21
import java .io .OutputStream ;
20
- import java .util .zip .CRC32 ;
21
22
23
+ @ Deprecated
22
24
public class CrcOutputStream extends OutputStream {
23
- private final CRC32 crc ;
25
+ private final CRCDigest crc ;
24
26
private long length ;
25
27
private long mCheckSum ;
26
28
public CrcOutputStream () {
27
29
super ();
28
- this .crc = new CRC32 ();
30
+ this .crc = new CRCDigest ();
29
31
}
30
32
public long getLength (){
31
33
return length ;
Original file line number Diff line number Diff line change 21
21
import com .reandroid .arsc .chunk .TableBlock ;
22
22
import com .reandroid .json .JSONException ;
23
23
import com .reandroid .json .JSONObject ;
24
+ import com .reandroid .utils .CRCDigest ;
24
25
25
26
import java .io .*;
26
27
@@ -58,9 +59,9 @@ public long getLength() throws IOException{
58
59
}
59
60
@ Override
60
61
public long getCrc () throws IOException {
61
- CrcOutputStream outputStream = new CrcOutputStream ();
62
+ CRCDigest outputStream = new CRCDigest ();
62
63
this .write (outputStream );
63
- return outputStream .getCrcValue ();
64
+ return outputStream .getValue ();
64
65
}
65
66
public TableBlock getTableBlock () throws IOException {
66
67
if (mCache != null ){
Original file line number Diff line number Diff line change 17
17
18
18
import com .reandroid .archive .BlockInputSource ;
19
19
import com .reandroid .arsc .chunk .TableBlock ;
20
+ import com .reandroid .utils .CRCDigest ;
20
21
21
22
import java .io .*;
22
23
@@ -54,9 +55,9 @@ public long getLength() throws IOException{
54
55
}
55
56
@ Override
56
57
public long getCrc () throws IOException {
57
- CrcOutputStream outputStream = new CrcOutputStream ();
58
+ CRCDigest outputStream = new CRCDigest ();
58
59
this .write (outputStream );
59
- return outputStream .getCrcValue ();
60
+ return outputStream .getValue ();
60
61
}
61
62
public TableBlock getTableBlock () throws IOException {
62
63
if (mCache !=null ){
Original file line number Diff line number Diff line change 1
1
package com .reandroid .apk .xmlencoder ;
2
2
3
3
import com .reandroid .apk .APKLogger ;
4
- import com .reandroid .apk .CrcOutputStream ;
5
4
import com .reandroid .archive .ByteInputSource ;
6
5
import com .reandroid .arsc .chunk .PackageBlock ;
7
6
import com .reandroid .arsc .chunk .xml .ResXmlDocument ;
7
+ import com .reandroid .utils .CRCDigest ;
8
8
import com .reandroid .utils .io .IOUtil ;
9
9
import com .reandroid .xml .source .XMLParserSource ;
10
10
import org .xmlpull .v1 .XmlPullParser ;
11
11
import org .xmlpull .v1 .XmlPullParserException ;
12
12
13
13
import java .io .IOException ;
14
14
import java .io .OutputStream ;
15
- import java .util .zip .CRC32 ;
16
15
17
16
public class XMLEncodeSource extends ByteInputSource {
18
17
private final PackageBlock packageBlock ;
@@ -31,7 +30,7 @@ public long getLength() throws IOException {
31
30
}
32
31
@ Override
33
32
public long getCrc () throws IOException {
34
- CRC32 crc32 = new CRC32 ();
33
+ CRCDigest crc32 = new CRCDigest ();
35
34
byte [] bytes = getArray ();
36
35
crc32 .update (bytes , 0 , bytes .length );
37
36
return crc32 .getValue ();
Original file line number Diff line number Diff line change 15
15
*/
16
16
package com .reandroid .archive ;
17
17
18
- import com .reandroid .apk .CrcOutputStream ;
19
18
import com .reandroid .arsc .base .Block ;
20
19
import com .reandroid .arsc .base .BlockRefresh ;
20
+ import com .reandroid .utils .CRCDigest ;
21
21
22
22
import java .io .IOException ;
23
23
import java .io .OutputStream ;
@@ -51,9 +51,9 @@ public long getLength() throws IOException{
51
51
@ Override
52
52
public long getCrc () throws IOException {
53
53
Block block = getBlock ();
54
- CrcOutputStream outputStream = new CrcOutputStream ();
54
+ CRCDigest outputStream = new CRCDigest ();
55
55
block .writeBytes (outputStream );
56
- return outputStream .getCrcValue ();
56
+ return outputStream .getValue ();
57
57
}
58
58
@ Override
59
59
public long write (OutputStream outputStream ) throws IOException {
Original file line number Diff line number Diff line change 17
17
18
18
import com .reandroid .arsc .chunk .TableBlock ;
19
19
import com .reandroid .arsc .chunk .xml .AndroidManifestBlock ;
20
+ import com .reandroid .utils .CRCDigest ;
20
21
import com .reandroid .utils .CompareUtil ;
21
22
import com .reandroid .utils .StringsUtil ;
22
23
import com .reandroid .utils .io .FileUtil ;
23
24
24
25
import java .io .*;
25
26
import java .util .Comparator ;
26
- import java .util .zip .CRC32 ;
27
27
28
28
public abstract class InputSource {
29
29
private final String name ;
@@ -174,7 +174,7 @@ public String toString(){
174
174
private void calculateCrc () throws IOException {
175
175
InputStream inputStream =openStream ();
176
176
long length =0 ;
177
- CRC32 crc = new CRC32 ();
177
+ CRCDigest crc = new CRCDigest ();
178
178
int bytesRead ;
179
179
byte [] buffer = new byte [1024 *64 ];
180
180
while ((bytesRead = inputStream .read (buffer )) != -1 ) {
Original file line number Diff line number Diff line change 15
15
*/
16
16
package com .reandroid .archive .io ;
17
17
18
+ import com .reandroid .utils .CRCDigest ;
18
19
import com .reandroid .utils .HexUtil ;
19
20
20
21
import java .io .IOException ;
21
22
import java .io .InputStream ;
22
- import java .util .zip .CRC32 ;
23
23
24
24
public class CountingInputStream <T extends InputStream > extends InputStream {
25
25
private final T inputStream ;
26
- private final CRC32 crc ;
26
+ private final CRCDigest crc ;
27
27
private long size ;
28
28
private long mCheckSum ;
29
29
private boolean mFinished ;
30
30
public CountingInputStream (T inputStream , boolean disableCrc ){
31
31
this .inputStream = inputStream ;
32
- CRC32 crc32 ;
32
+ CRCDigest crc32 ;
33
33
if (disableCrc ){
34
34
crc32 = null ;
35
35
}else {
36
- crc32 = new CRC32 ();
36
+ crc32 = new CRCDigest ();
37
37
}
38
38
this .crc = crc32 ;
39
39
}
Original file line number Diff line number Diff line change 15
15
*/
16
16
package com .reandroid .archive .io ;
17
17
18
+ import com .reandroid .utils .CRCDigest ;
19
+
18
20
import java .io .IOException ;
19
21
import java .io .InputStream ;
20
22
import java .io .OutputStream ;
21
- import java .util .zip .CRC32 ;
22
23
23
24
public class CountingOutputStream <T extends OutputStream > extends OutputStream {
24
25
private final T outputStream ;
25
- private CRC32 crc ;
26
+ private CRCDigest crc ;
26
27
private long size ;
27
28
private boolean mClosed ;
28
29
public CountingOutputStream (T outputStream , boolean disableCrc ){
29
30
this .outputStream = outputStream ;
30
- CRC32 crc32 ;
31
+ CRCDigest crc32 ;
31
32
if (disableCrc ){
32
33
crc32 = null ;
33
34
}else {
34
- crc32 = new CRC32 ();
35
+ crc32 = new CRCDigest ();
35
36
}
36
37
this .crc = crc32 ;
37
38
}
@@ -42,15 +43,15 @@ public CountingOutputStream(T outputStream){
42
43
public void disableCrc (boolean disableCrc ) {
43
44
if (!disableCrc ){
44
45
if (crc == null ){
45
- this .crc = new CRC32 ();
46
+ this .crc = new CRCDigest ();
46
47
}
47
48
}else {
48
49
this .crc = null ;
49
50
}
50
51
}
51
52
52
53
public void reset (){
53
- this .crc = new CRC32 ();
54
+ this .crc = new CRCDigest ();
54
55
this .size = 0L ;
55
56
}
56
57
public T getOutputStream () {
You can’t perform that action at this time.
0 commit comments