Révision 340558f2 TestXamConnections/TestXamConnections.Android/Connection/InternConnectionService.cs
TestXamConnections/TestXamConnections.Android/Connection/InternConnectionService.cs | ||
---|---|---|
14 | 14 |
* Pré-installée sur l'appareil |
15 | 15 |
* Basée sur filtrage d'intent sur BroadcastReceiver |
16 | 16 |
*/ |
17 |
public class InternConnectionService : IConnectionService
|
|
17 |
public class InternConnexionService : IConnexionService
|
|
18 | 18 |
{ |
19 |
public EventHandler<byte[]> DataReceivedEvent { get; set; }
|
|
19 |
public EventHandler<byte[]> DonneesRecuesEvent { get; set; }
|
|
20 | 20 |
|
21 | 21 |
private readonly IntentReceiver intentReceiver; |
22 | 22 |
private readonly Context appContext; |
... | ... | |
24 | 24 |
/* La fonction connect dans le cas du connexion en interne |
25 | 25 |
* Est en fait, la configuration de l'IntentReceiver |
26 | 26 |
*/ |
27 |
public Task<bool> Connect(Dictionary<string, string> param)
|
|
27 |
public Task<bool> Connexion(Dictionary<string, string> param)
|
|
28 | 28 |
{ |
29 |
if (param.ContainsKey(ConnectionConstants.RECEIVABLE_INTENTS_KEY))
|
|
29 |
if (param.ContainsKey(ConnexionConstantes.RECEIVABLE_INTENTS_KEY))
|
|
30 | 30 |
{ |
31 | 31 |
// Récupérations des intents recevable sous forme de csv |
32 | 32 |
List<string> intents = new List<string>(); |
33 |
intents.AddRange(param[ConnectionConstants.RECEIVABLE_INTENTS_KEY].Split(","));
|
|
33 |
intents.AddRange(param[ConnexionConstantes.RECEIVABLE_INTENTS_KEY].Split(","));
|
|
34 | 34 |
// Ajout des intents recevable au IntentFilter |
35 | 35 |
IntentFilter intentFilter = new IntentFilter(); |
36 | 36 |
intents.ForEach(intent => intentFilter.AddAction(intent)); |
... | ... | |
44 | 44 |
return Task.FromResult(true); |
45 | 45 |
} |
46 | 46 |
|
47 |
public Task<bool> SendCommand(byte[] commandBytes)
|
|
47 |
public Task<bool> EnvoiCommande(byte[] commandBytes)
|
|
48 | 48 |
{ |
49 | 49 |
string command = Encoding.ASCII.GetString(commandBytes); |
50 | 50 |
Intent launchIntent = appContext.PackageManager.GetLaunchIntentForPackage(command); |
... | ... | |
56 | 56 |
return Task.FromResult(false); |
57 | 57 |
} |
58 | 58 |
|
59 |
public InternConnectionService()
|
|
59 |
public InternConnexionService()
|
|
60 | 60 |
{ |
61 | 61 |
intentReceiver = new IntentReceiver(); |
62 | 62 |
intentReceiver.OnIntentReceived += IntentReceived; |
... | ... | |
68 | 68 |
{ |
69 | 69 |
switch (recIntent.Action) |
70 | 70 |
{ |
71 |
case AgridentConstants.ACTION_AGRIDENT_SUCCESS: |
|
72 |
string readData = recIntent.GetStringExtra(AgridentConstants.KEY_BARCODE_DATA); |
|
73 |
DataReceivedEvent.Invoke(this, Encoding.ASCII.GetBytes(readData));
|
|
71 |
case AgridentConstantes.ACTION_AGRIDENT_SUCCESS:
|
|
72 |
string readData = recIntent.GetStringExtra(AgridentConstantes.KEY_BARCODE_DATA);
|
|
73 |
DonneesRecuesEvent.Invoke(this, Encoding.ASCII.GetBytes(readData));
|
|
74 | 74 |
break; |
75 | 75 |
|
76 |
case AgridentConstants.ACTION_AGRIDENT_ERROR: |
|
77 |
DataReceivedEvent.Invoke(this, Encoding.ASCII.GetBytes(AgridentConstants.ACTION_AGRIDENT_ERROR));
|
|
76 |
case AgridentConstantes.ACTION_AGRIDENT_ERROR:
|
|
77 |
DonneesRecuesEvent.Invoke(this, Encoding.ASCII.GetBytes(AgridentConstantes.ACTION_AGRIDENT_ERROR));
|
|
78 | 78 |
break; |
79 | 79 |
|
80 | 80 |
default: |
Formats disponibles : Unified diff