22
33import android .content .Intent ;
44
5- import net .sharksystem .EncounterConnectionType ;
65import net .sharksystem .SharkNotSupportedException ;
76import net .sharksystem .asap .ASAPException ;
7+ import net .sharksystem .asap .ASAPHop ;
8+ import net .sharksystem .asap .utils .ASAPSerialization ;
9+ import net .sharksystem .utils .Log ;
10+
11+ import java .io .IOException ;
812
913public class ASAPChunkReceivedBroadcastIntent extends Intent {
1014
11- private final String senderPoint2Point ;
12- private final boolean verified ;
13- private final boolean encrypted ;
14- private final EncounterConnectionType connectionType ;
15+ private final ASAPHop asapHop ;
1516 private CharSequence folder ;
1617 private CharSequence uri ;
1718 private int era ;
@@ -21,8 +22,7 @@ public class ASAPChunkReceivedBroadcastIntent extends Intent {
2122 public ASAPChunkReceivedBroadcastIntent (CharSequence format , CharSequence senderE2E ,
2223 CharSequence folderName ,
2324 CharSequence uri , int era ,
24- String senderPoint2Point , boolean verified , boolean encrypted ,
25- EncounterConnectionType connectionType ) throws ASAPException {
25+ ASAPHop asapHop ) throws ASAPException {
2626
2727 super ();
2828
@@ -36,23 +36,24 @@ public ASAPChunkReceivedBroadcastIntent(CharSequence format, CharSequence sender
3636 this .putExtra (ASAPAndroid .FOLDER , folderName );
3737 this .putExtra (ASAPServiceMethods .URI_TAG , uri );
3838 this .putExtra (ASAPAndroid .SENDER_E2E , senderE2E );
39- this .putExtra (ASAPAndroid .SENDER_POINT2POINT , senderPoint2Point );
40- this .putExtra (ASAPAndroid .VERIFIED , verified );
41- this .putExtra (ASAPAndroid .ENCRYPTED , encrypted );
42- this .putExtra (ASAPAndroid .CONNECTION_TYPE , connectionType );
39+ try {
40+ byte [] asapHopBytes = ASAPSerialization .asapHop2ByteArray (asapHop );
41+ this .putExtra (ASAPAndroid .ASAP_HOP , asapHopBytes );
42+ }
43+ catch (IOException e ) {
44+ // ignore
45+ Log .writeLogErr (this , "cannot serialize ASAPHop: " + asapHop );
46+ }
4347
4448 this .format = format ;
4549 this .folder = folderName ;
4650 this .uri = uri ;
4751 this .era = era ;
4852 this .senderE2E = senderE2E ;
49- this .senderPoint2Point = senderPoint2Point ;
50- this .verified = verified ;
51- this .encrypted = encrypted ;
52- this .connectionType = connectionType ;
53+ this .asapHop = asapHop ;
5354 }
5455
55- public ASAPChunkReceivedBroadcastIntent (Intent intent ) throws ASAPException {
56+ public ASAPChunkReceivedBroadcastIntent (Intent intent ) throws ASAPException , IOException {
5657 super ();
5758
5859 // just parse extras
@@ -61,10 +62,8 @@ public ASAPChunkReceivedBroadcastIntent(Intent intent) throws ASAPException {
6162 this .uri = intent .getStringExtra (ASAPServiceMethods .URI_TAG );
6263 this .era = intent .getIntExtra (ASAPServiceMethods .ERA_TAG , 0 );
6364 this .senderE2E = intent .getStringExtra (ASAPAndroid .SENDER_E2E );
64- this .senderPoint2Point = intent .getStringExtra (ASAPAndroid .SENDER_POINT2POINT );
65- this .verified = intent .getBooleanExtra (ASAPAndroid .VERIFIED , false );
66- this .encrypted = intent .getBooleanExtra (ASAPAndroid .ENCRYPTED , false );
67- this .connectionType = null ;
65+ byte [] asapHopBytes = intent .getByteArrayExtra (ASAPAndroid .ASAP_HOP );
66+ this .asapHop = ASAPSerialization .byteArray2ASAPHop (asapHopBytes );
6867 }
6968
7069 public CharSequence getFoldername () {
@@ -86,20 +85,7 @@ public int getEra() {
8685
8786 public CharSequence getFormat () { return this .format ; }
8887
89- public String getSenderPoint2Point () {
90- return this .senderPoint2Point ;
91- }
92-
93- public boolean getVerified () {
94- return this .verified ;
95- }
96-
97- public boolean getEncrypted () {
98- return this .encrypted ;
99- }
100-
101- // TODO
102- public EncounterConnectionType getConnectionType () {
103- throw new SharkNotSupportedException ("no implemented yet" );
88+ public ASAPHop getASAPHop () {
89+ return this .asapHop ;
10490 }
10591}
0 commit comments