2 * Copyright (C) 2013 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 package org
.strongswan
.android
.logic
.imc
;
18 import org
.strongswan
.android
.logic
.imc
.attributes
.Attribute
;
19 import org
.strongswan
.android
.logic
.imc
.attributes
.AttributeType
;
20 import org
.strongswan
.android
.logic
.imc
.collectors
.Collector
;
21 import org
.strongswan
.android
.logic
.imc
.collectors
.DeviceIdCollector
;
22 import org
.strongswan
.android
.logic
.imc
.collectors
.InstalledPackagesCollector
;
23 import org
.strongswan
.android
.logic
.imc
.collectors
.PortFilterCollector
;
24 import org
.strongswan
.android
.logic
.imc
.collectors
.ProductInformationCollector
;
25 import org
.strongswan
.android
.logic
.imc
.collectors
.SettingsCollector
;
26 import org
.strongswan
.android
.logic
.imc
.collectors
.StringVersionCollector
;
28 import android
.content
.Context
;
30 public class AndroidImc
32 private final Context mContext
;
34 public AndroidImc(Context context
)
40 * Get a measurement (the binary encoding of the requested attribute) for
41 * the given vendor specific attribute type.
43 * @param vendor vendor ID
44 * @param type vendor specific attribute type
45 * @return encoded attribute, or null if not available or failed
47 public byte[] getMeasurement(int vendor
, int type
)
49 return getMeasurement(vendor
, type
, null);
53 * Get a measurement (the binary encoding of the requested attribute) for
54 * the given vendor specific attribute type.
56 * @param vendor vendor ID
57 * @param type vendor specific attribute type
58 * @param args optional arguments for a measurement
59 * @return encoded attribute, or null if not available or failed
61 public byte[] getMeasurement(int vendor
, int type
, String
[] args
)
63 AttributeType attributeType
= AttributeType
.fromValues(vendor
, type
);
64 Collector collector
= null;
66 switch (attributeType
)
68 case IETF_PRODUCT_INFORMATION
:
69 collector
= new ProductInformationCollector();
71 case IETF_STRING_VERSION
:
72 collector
= new StringVersionCollector();
74 case IETF_PORT_FILTER
:
75 collector
= new PortFilterCollector();
77 case IETF_INSTALLED_PACKAGES
:
78 collector
= new InstalledPackagesCollector(mContext
);
81 collector
= new SettingsCollector(mContext
, args
);
84 collector
= new DeviceIdCollector(mContext
);
89 if (collector
!= null)
91 Attribute attribute
= collector
.getMeasurement();
92 if (attribute
!= null)
94 return attribute
.getEncoding();