├── .github
├── Contributing.md
├── ISSUE_TEMPLATE.md
└── PULL_REQUEST_TEMPLATE.md
├── .gitignore
├── AndroidAgent.iml
├── COPYING
├── Changes
├── README.md
├── app
├── app.iml
├── build.gradle
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── org
│ │ └── ocs
│ │ └── android
│ │ ├── actions
│ │ ├── CoolSSLSocketFactory.java
│ │ ├── Inventory.java
│ │ ├── OCSFiles.java
│ │ ├── OCSLog.java
│ │ ├── OCSProtocol.java
│ │ ├── OCSProtocolException.java
│ │ ├── OCSSettings.java
│ │ ├── PrefsParser.java
│ │ ├── PrologReplyParser.java
│ │ └── Utils.java
│ │ ├── agent
│ │ ├── AboutDialog.java
│ │ ├── AsyncOperations.java
│ │ ├── ExpandableSectionAdapter.java
│ │ ├── OCSDownloadIdParams.java
│ │ ├── OCSDownloadInfos.java
│ │ ├── OCSPrologReply.java
│ │ ├── activity
│ │ │ ├── OCSAgentActivity.java
│ │ │ ├── OCSInstallPackageActivity.java
│ │ │ ├── OCSPrefsActivity.java
│ │ │ └── OCSShowInventory.java
│ │ ├── receiver
│ │ │ ├── OCSBootReceiver.java
│ │ │ ├── OCSEventReceiver.java
│ │ │ └── OCSInstallReceiver.java
│ │ └── service
│ │ │ ├── OCSAgentService.java
│ │ │ └── OCSDownloadService.java
│ │ └── sections
│ │ ├── OCSBios.java
│ │ ├── OCSDrive.java
│ │ ├── OCSDrives.java
│ │ ├── OCSHardware.java
│ │ ├── OCSInput.java
│ │ ├── OCSInputs.java
│ │ ├── OCSJavaInfos.java
│ │ ├── OCSNetwork.java
│ │ ├── OCSNetworks.java
│ │ ├── OCSSection.java
│ │ ├── OCSSectionInterface.java
│ │ ├── OCSSims.java
│ │ ├── OCSSoftware.java
│ │ ├── OCSSoftwares.java
│ │ ├── OCSStorage.java
│ │ ├── OCSStorages.java
│ │ ├── OCSVideos.java
│ │ └── SystemInfos.java
│ └── res
│ ├── drawable-hdpi
│ ├── ic_menu_goto.png
│ ├── ic_menu_info_details.png
│ ├── ic_menu_moreoverflow_normal_holo_dark.png
│ ├── ic_menu_set_as.png
│ └── ic_sysbar_quicksettings.png
│ ├── drawable-ldpi
│ ├── ic_menu_goto.png
│ ├── ic_menu_info_details.png
│ ├── ic_menu_moreoverflow_normal_holo_dark.png
│ ├── ic_menu_set_as.png
│ └── ic_sysbar_quicksettings.png
│ ├── drawable-mdpi
│ ├── ic_menu_goto.png
│ ├── ic_menu_info_details.png
│ ├── ic_menu_moreoverflow_normal_holo_dark.png
│ ├── ic_menu_set_as.png
│ └── ic_sysbar_quicksettings.png
│ ├── drawable-xhdpi
│ ├── ic_menu_goto.png
│ ├── ic_menu_info_details.png
│ ├── ic_menu_moreoverflow_normal_holo_dark.png
│ ├── ic_menu_set_as.png
│ └── ic_sysbar_quicksettings.png
│ ├── drawable-xxhdpi
│ ├── ic_menu_goto.png
│ ├── ic_menu_info_details.png
│ ├── ic_menu_moreoverflow_normal_holo_dark.png
│ ├── ic_menu_set_as.png
│ └── ic_sysbar_quicksettings.png
│ ├── drawable-xxxhdpi
│ ├── ic_menu_goto.png
│ ├── ic_menu_info_details.png
│ ├── ic_menu_moreoverflow_normal_holo_dark.png
│ ├── ic_menu_set_as.png
│ └── ic_sysbar_quicksettings.png
│ ├── drawable
│ ├── button_effect.xml
│ ├── ic_notification.png
│ ├── ic_ocs_android.png
│ └── ocs_landscape.png
│ ├── layout
│ ├── about.xml
│ ├── actvity_show_inventory.xml
│ ├── list_header.xml
│ ├── list_item.xml
│ ├── ocs_agent.xml
│ └── ocs_install_package.xml
│ ├── menu
│ └── activity_main.xml
│ ├── values-de
│ ├── strings.xml
│ └── strings_prefs.xml
│ ├── values-fr
│ ├── strings.xml
│ └── strings_prefs.xml
│ ├── values
│ ├── arrays.xml
│ ├── colors.xml
│ ├── strings.xml
│ ├── strings_nt.xml
│ └── strings_prefs.xml
│ └── xml
│ └── preferences.xml
├── build.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.github/Contributing.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | OCS Inventory
6 |
7 | Some Links:
8 | Ask question |
9 | Installation |
10 | Website
11 |
12 |
13 | # OCS Inventory Contributing Guidelines
14 |
15 | ## Pull Request Process
16 |
17 | 1. Fork it!
18 | 2. Create your feature branch: `git checkout -b my-new-feature`
19 | 3. Add your changes: `git add folder/file1.php`
20 | 4. Commit your changes: `git commit -m 'Add some feature'`
21 | 5. Push to the branch: `git push origin my-new-feature`
22 | 6. Submit a pull request !
23 |
24 | ## Pull Request Informations
25 |
26 | When contributing, please open an issue before or contact the team using mail. This will prevent all the duplicate of work.
27 | Also, check if your contribution is not already in the roadmap or affiliated to an issue.
28 |
29 | If you are contributing on a small scale (translation, a few line modification), you don't need open an issue or contact the team but you will need to explain what you've done in the Pull Request comment and provide as accurate commit messages as possible.
30 | Cf. Commits Messages Name Informations
31 |
32 | If you need to discuss about a big change or need some help of our team during the development of your contribution,
33 | we can use other communication method like Telegram, IRC, Skype.
34 |
35 | ## Commits Messages Name Informations
36 |
37 | Try to create as accurate as possible commit messages.
38 | This will help us to speed up the review process and to reduce the misunderstanding (which can lead to a Pull Request to be rejected)
39 |
40 | There is no commit messages convention but here are some examples :
41 | 1. Create as short as possible commit name
42 | 2. One commit for one modification
43 | 3. Always leave the second commit line blank
44 |
45 | If it seems difficult to summarize what your commit does, it may be because it includes several logical changes or bug fixes, and are better split up into several commits using `git add -p`.
46 |
47 | ## Code of Conduct
48 |
49 | ### Our Pledge
50 |
51 | In the interest of fostering an open and welcoming environment, we as
52 | contributors and maintainers pledge to making participation in our project and
53 | our community a harassment-free experience for everyone, regardless of age, body
54 | size, disability, ethnicity, gender identity and expression, level of experience,
55 | nationality, personal appearance, race, religion, or sexual identity and
56 | orientation.
57 |
58 | ### Our Standards
59 |
60 | Examples of behavior that contributes to creating a positive environment
61 | include:
62 |
63 | * Using welcoming and inclusive language
64 | * Being respectful of differing viewpoints and experiences
65 | * Gracefully accepting constructive criticism
66 | * Focusing on what is best for the community
67 | * Showing empathy towards other community members
68 |
69 | Examples of unacceptable behavior by participants include:
70 |
71 | * The use of sexualized language or imagery and unwelcome sexual attention or
72 | advances
73 | * Trolling, insulting/derogatory comments, and personal or political attacks
74 | * Public or private harassment
75 | * Publishing others' private information, such as a physical or electronic
76 | address, without explicit permission
77 | * Other conduct which could reasonably be considered inappropriate in a
78 | professional setting
79 |
80 | ### Our Responsibilities
81 |
82 | Project maintainers are responsible for clarifying the standards of acceptable
83 | behavior and are expected to take appropriate and fair corrective action in
84 | response to any instances of unacceptable behavior.
85 |
86 | Project maintainers have the right and responsibility to remove, edit, or
87 | reject comments, commits, code, wiki edits, issues, and other contributions
88 | that are not aligned to this Code of Conduct, or to ban temporarily or
89 | permanently any contributor for other behaviors that they deem inappropriate,
90 | threatening, offensive, or harmful.
91 |
92 | ### Scope
93 |
94 | This Code of Conduct applies both within project spaces and in public spaces
95 | when an individual is representing the project or its community. Examples of
96 | representing a project or community include using an official project e-mail
97 | address, posting via an official social media account, or acting as an appointed
98 | representative at an online or offline event. Representation of a project may be
99 | further defined and clarified by project maintainers.
100 |
101 | ### Enforcement
102 |
103 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
104 | reported by contacting the project team at `contact@ocsinventory-ng.org` . All
105 | complaints will be reviewed and investigated and will result in a response that
106 | is deemed necessary and appropriate to the circumstances. The project team is
107 | obligated to maintain confidentiality with regard to the reporter of an incident.
108 | Further details of specific enforcement policies may be posted separately.
109 |
110 | Project maintainers who do not follow or enforce the Code of Conduct in good
111 | faith may face temporary or permanent repercussions as determined by other
112 | members of the project's leadership.
113 |
114 | ### Attribution
115 |
116 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
117 | available at [http://contributor-covenant.org/version/1/4][version]
118 |
119 | [homepage]: http://contributor-covenant.org
120 | [version]: http://contributor-covenant.org/version/1/4/
121 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | *It's hard to solve a problem when important details are missing, that why we added this template, to help you and us.*
2 |
3 | ### General informations
4 | Android version :
5 |
6 | ### OCS Inventory informations
7 | Android agent version :
8 |
9 | ### Problem's description
10 | *Describe your problem here*
11 |
12 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ## Must read before submitting
2 | Please, take a look to our contributing guidelines before submitting your pull request.
3 | There's some simple rules that will help us to speed up the review process and avoid any misunderstanding
4 |
5 | [Contributors GuideLines](https://github.com/OCSInventory-NG/OCSInventory-ocsreports/blob/master/.github/Contributing.md)
6 |
7 | ## Status
8 | **READY/IN DEVELOPMENT/HOLD**
9 |
10 | ## Description
11 | A few sentences describing the overall goals of the pull request's commits.
12 |
13 | ## Related Issues
14 | Put here all the related issues link
15 |
16 | ## Todos
17 | - [ ] Tests
18 | - [ ] Documentation
19 |
20 | ## Test environment
21 | If some tests has been already made, please give us your test environment' specs
22 |
23 | #### General informations
24 | Android version :
25 |
26 | #### OCS Inventory informations
27 | Android agent version :
28 |
29 | ## Deploy Notes
30 | Notes regarding deployment the contained body of work. These should note any dependencies changes,
31 | logical changes, etc.
32 |
33 | 1.
34 |
35 | ## Impacted Areas in Application
36 | List general components of the application that this PR will affect:
37 |
38 | *
39 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Built application files
3 | build/
4 |
5 | # Crashlytics configuations
6 | com_crashlytics_export_strings.xml
7 |
8 | # Local configuration file (sdk path, etc)
9 | local.properties
10 |
11 | # Gradle generated files
12 | .gradle/
13 |
14 | # Signing files
15 | .signing/
16 |
17 | # User-specific configurations
18 | .idea
19 | *.iml
20 |
21 | # OS-specific files
22 | .DS_Store
23 | .DS_Store?
24 | ._*
25 | .Spotlight-V100
26 | .Trashes
27 | ehthumbs.db
28 | Thumbs.db
29 |
--------------------------------------------------------------------------------
/AndroidAgent.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Changes:
--------------------------------------------------------------------------------
1 | Revision history for Ocsinventory NG Android Agent
2 |
3 | 2.7
4 | * Update gradle
5 | * Improve stability
6 | * Add phone number inventory (main sim only)
7 |
8 | 2.3.1
9 | * Fix permissions on android 6 and more
10 |
11 | 2.3.0
12 | * New graphics chart
13 | * App redesign
14 | * Update to new android API
15 |
16 | 2.1.7
17 | * Bug on proxy option corrected. The option was not applied.
18 |
19 | 2.1.6
20 | * Bugs correction on package installation managment notifications
21 | * Add InstallReceiver class
22 |
23 | 2.1.5
24 | * Package renamed to org.orcinventoryng.android
25 | * Import exported configuration file the name org.orcinventoryng.android.agent_preferences.xml OR org.orcinventory.android.agent_preferences.xml
26 |
27 | 2.1.4
28 | * Nicolas Ricquemaque contribution.
29 | * New settings : Automatic mode's networks behavior management.
30 | * New settings : Notifications hidding management
31 | * Load configuration from sdcard when start with a "force_update" extra.
32 |
33 | 2.1.3
34 | * On first start after installation, load automaticaly the configuration if present on the sdcard.
35 |
36 | 2.1.2
37 | * Change cpu number evaluation method to obtains correct value.
38 |
39 | 2.1.1.1
40 | * Correction OCSEventreceiver option force_update was always set to true
41 |
42 | 2.1.1
43 | * Add extra to OCSEventReceiver to save inventory on disk
44 | * Force inventory with OCSEventReceiver
45 | * Remove OCSFiles singleton
46 | * Fix unit conversion bug for cache
47 | * Change inventory file name (host + date)
48 | * Use OCSSettings instead of direct call to PreferenceManager
49 | * Change address detection
50 | * Do not force to enable wifi
51 | * Specify the same process name as service for activity in manifest for good settings share
52 | * Add DEVICEID in SIM section for phone id (IMEI) info
53 | * Java info returned in software section
54 | * Kernel version returned in Hardware/OSComments + tag "*ROOTED*" if device is rooted.
55 |
56 | 2.1.0.1
57 | * Cédric Cabessa contribution
58 | * Add permission RECEIVE_BOOT_COMPLETED into Manifest
59 | * Corrections about size image caps when multiples cameras
60 | * Move configuration strings to strings_nt.xml (no translatable strings)
61 |
62 | 2.1.0
63 | * Correct SIM XML section name.
64 | * 1st Publication version
65 |
66 | 0.9.9
67 | * Change launch and notification icon
68 | * Add SIMS section with check mask 0x80000
69 |
70 | 0.9.8
71 | * In hardware section : the field checksum is correctly calculated from sections changes since last successful upload.
72 | * New logo
73 | * Logo centred on main activity background.
74 | * Different layout in lanscape disposition.
75 |
76 | 0.9.7
77 | * Messages corrections in settings
78 | * Wifi speed information added
79 | * Correction : crash when camera already open
80 |
81 | 0.9.6
82 | * Messages corrections
83 | * device uid not exported with settings
84 |
85 | 0.9.5
86 | * Correction on Inputs sections (not exported)
87 | * Add camera in inputs
88 |
89 | 0.9.4
90 | * Device uid exclude of import settings operation
91 | * Change icon
92 | * Change default language to English
93 | * Translations corrections
94 | * On opening, Log file deleted if size > 100000 bytes
95 | * Add option hide system software ( true by default)
96 |
97 | 0.9.3
98 | * Bug deteted in android 4.x : network operation cant be executed in the main thread as do in service mode. Work in 2.x & 3
99 | .0 but exception in 4.1 => send inventory executed in an Async Task
100 |
101 | 0.9.2
102 | * Replace OCSShowActivity by a structured Listview activity
103 | * Add OCS section object to contain a section usable by a ListView adapter
104 | * Each section implement a getSection() meth. returning a such as object
105 |
106 | 0.9.1
107 | * Add service mode (automatic)
108 | * Many corrections
109 | * Add notifications
110 | * Use standard android settings menus
111 | * Lot of corrections
112 |
113 | 0.9
114 | * Initial version
115 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AndroidAgent
2 |
3 | OCS Inventory NG Android Agent
4 | Web site : https://ocsinventory-ng.org/
5 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 26
5 | buildToolsVersion '26.0.3'
6 |
7 | useLibrary 'org.apache.http.legacy'
8 |
9 | defaultConfig {
10 | applicationId "org.ocs.android.agent"
11 | minSdkVersion 26
12 | targetSdkVersion 26
13 | }
14 |
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
19 | }
20 | }
21 | productFlavors {
22 | }
23 | }
24 |
25 | dependencies {
26 | implementation 'com.android.support:support-v4:26.1.0'
27 | implementation 'com.android.support:appcompat-v7:26.1.0'
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
23 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
50 |
54 |
55 |
56 |
57 |
58 |
59 |
63 |
64 |
69 |
72 |
73 |
78 |
81 |
82 |
83 |
86 |
87 |
90 |
91 |
92 |
96 |
97 |
100 |
101 |
102 |
103 |
104 |
105 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/actions/CoolSSLSocketFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.actions;
22 |
23 | import android.util.Log;
24 |
25 | import org.apache.http.conn.ssl.SSLSocketFactory;
26 |
27 | import java.io.IOException;
28 | import java.net.Socket;
29 | import java.security.KeyManagementException;
30 | import java.security.KeyStore;
31 | import java.security.KeyStoreException;
32 | import java.security.NoSuchAlgorithmException;
33 | import java.security.UnrecoverableKeyException;
34 | import java.security.cert.CertificateException;
35 | import java.security.cert.X509Certificate;
36 |
37 | import javax.net.ssl.SSLContext;
38 | import javax.net.ssl.TrustManager;
39 | import javax.net.ssl.X509TrustManager;
40 |
41 | public class CoolSSLSocketFactory extends SSLSocketFactory {
42 | private SSLContext sslContext = SSLContext.getInstance("TLS");
43 |
44 | public CoolSSLSocketFactory(
45 | KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException,
46 | UnrecoverableKeyException {
47 |
48 | super(truststore);
49 |
50 | TrustManager tm = new X509TrustManager() {
51 | public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
52 | }
53 |
54 | public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
55 | for (X509Certificate aChain : chain) {
56 | Log.d("X509", aChain.getSubjectDN().toString());
57 | }
58 | }
59 |
60 | public X509Certificate[] getAcceptedIssuers() {
61 | return null;
62 | }
63 | };
64 | Log.d("X509", "CoolSSLSocketFactory");
65 | sslContext.init(null, new TrustManager[]{ tm }, null);
66 | setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
67 | }
68 |
69 | @Override
70 | public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException {
71 | return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose);
72 | }
73 |
74 | @Override
75 | public Socket createSocket() throws IOException {
76 | return sslContext.getSocketFactory().createSocket();
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/actions/OCSLog.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.actions;
22 |
23 | import android.os.Environment;
24 | import android.util.Log;
25 |
26 | import java.io.File;
27 | import java.io.FileWriter;
28 | import java.io.IOException;
29 | import java.text.DateFormat;
30 | import java.util.Date;
31 |
32 | public class OCSLog {
33 | private static String TAG = "OCSLOG";
34 | private static OCSLog instance;
35 | private File logFile;
36 |
37 | public OCSLog() {
38 | File rep = Environment.getExternalStoragePublicDirectory("ocs");
39 |
40 | Log.d(TAG, Environment.getExternalStorageDirectory().getPath());
41 |
42 | if (!rep.isDirectory()) {
43 | rep.delete();
44 | }
45 | if (!rep.exists()) {
46 | if (!rep.mkdir()) {
47 | Log.e(TAG, "Cannot create directory : " + rep.getPath());
48 | return;
49 | } else {
50 | Log.d(TAG, rep.getPath() + " created");
51 | }
52 | }
53 | logFile = new File(rep, "ocslog.txt");
54 | if (logFile.length() > 100000L) {
55 | logFile.delete();
56 | }
57 | }
58 |
59 | public static OCSLog getInstance() {
60 | if (instance == null) {
61 | instance = new OCSLog();
62 | }
63 | return instance;
64 | }
65 |
66 | public void debug(String paramString) {
67 | if (paramString != null && OCSSettings.getInstance() != null && OCSSettings.getInstance().getDebug() && logFile != null) {
68 | Log.d("OCSLOG", paramString);
69 | log(paramString);
70 | }
71 | }
72 |
73 | public void error(String paramString) {
74 | if (paramString != null && OCSSettings.getInstance() != null) {
75 | Log.e("OCSLOG", paramString);
76 | log(paramString);
77 | }
78 | }
79 |
80 | private void log(String paramString) {
81 | if (logFile == null) {
82 | return;
83 | }
84 | Date localDate = new Date();
85 | String strDate = DateFormat.getInstance().format(localDate);
86 | try {
87 | FileWriter fileWriter = new FileWriter(logFile, true);
88 | fileWriter.append(strDate).append(":").append(paramString).append("\n");
89 | fileWriter.close();
90 | } catch (IOException e) {
91 | }
92 | }
93 | }
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/actions/OCSProtocolException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.actions;
22 |
23 | public class OCSProtocolException extends Exception {
24 | private static final long serialVersionUID = 8115364599391499226L;
25 |
26 | public OCSProtocolException(String s) {
27 | super(s);
28 | OCSLog ocslog = OCSLog.getInstance();
29 | ocslog.error(s);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/actions/OCSSettings.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.actions;
22 |
23 | import android.content.Context;
24 | import android.content.SharedPreferences;
25 | import android.content.SharedPreferences.Editor;
26 | import android.preference.PreferenceManager;
27 |
28 | import org.ocs.android.agent.R;
29 |
30 | public class OCSSettings {
31 | private static OCSSettings instance = null;
32 |
33 | private Context ctx;
34 | private SharedPreferences prefs;
35 |
36 | private final String KLASTUPDT = "k_lastupdt";
37 | private final String KDEVICEUID = "k_deviceUid";
38 |
39 | private final String KSERVERURL = "k_serverurl";
40 | private final String KDEVICETAG = "k_devicetag";
41 | private final String KAUTOMODE = "k_automode";
42 | private final String KAUTOMODENETWORK = "k_automodeNetwork";
43 | private final String KFREQMAJ = "k_freqmaj";
44 | private final String KFREQWAKE = "k_freqwake";
45 | private final String KDEBUG = "k_debug";
46 | private final String KGZIP = "k_gzip";
47 | private final String KSTRICTSSL = "k_strictssl";
48 | private final String KPROXY = "k_proxy";
49 | private final String KPROXYADR = "k_proxyadr";
50 | private final String KPROXYPORT = "k_proxyport";
51 | private final String KCACHE = "k_cache";
52 | private final String KCACHELEN = "k_cachelen";
53 |
54 | private final String KAUTH = "k_auth";
55 | private final String KLOGIN = "k_login";
56 | private final String KPASSWD = "k_passwd";
57 | private final String KSYSHIDE = "k_syshide";
58 | private final String KCOMPUA = "k_compua";
59 | private final String KHIDENOTIF = "k_hideNotif";
60 |
61 | public OCSSettings(Context ctx) {
62 | prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
63 | this.ctx = ctx;
64 | }
65 |
66 | public void logSettings() {
67 | OCSLog ocslog = OCSLog.getInstance();
68 | if (ocslog == null) {
69 | return;
70 | }
71 | ocslog.debug("deviceUid : " + getDeviceUid());
72 | ocslog.debug("debug : " + getDebug());
73 | ocslog.debug("autostart : " + isAutoMode());
74 | ocslog.debug("serverURL : " + getServerUrl());
75 | ocslog.debug("gzip : " + getGzip());
76 | ocslog.debug("TAG : " + getDeviceTag());
77 | ocslog.debug("STRICTSSL : " + isSSLStrict());
78 | }
79 |
80 | public static OCSSettings getInstance(Context ctx) {
81 | if (instance == null) {
82 | instance = new OCSSettings(ctx);
83 | }
84 | return instance;
85 | }
86 |
87 | public static OCSSettings getInstance() {
88 | return instance;
89 | }
90 |
91 | public void setDeviceUid(String uid) {
92 | Editor e = prefs.edit();
93 | e.putString(KDEVICEUID, uid);
94 | e.apply();
95 | }
96 |
97 | public void setLastUpdt(long l) {
98 | Editor e = prefs.edit();
99 | e.putLong(KLASTUPDT, l);
100 | e.apply();
101 | }
102 |
103 | public void setFreqMaj(String f) {
104 | Editor e = prefs.edit();
105 | e.putString(KFREQMAJ, f);
106 | e.apply();
107 | }
108 |
109 |
110 | public boolean isAutoMode() {
111 | return prefs.getBoolean(KAUTOMODE, false);
112 | }
113 |
114 | public int getAutoModeNetwork() {
115 | String p = prefs.getString(KAUTOMODENETWORK, "");
116 | return Integer.parseInt(p);
117 | }
118 |
119 | public int getHiddenNotif() {
120 | String p = prefs.getString(KHIDENOTIF, "");
121 | return Integer.parseInt(p);
122 | }
123 |
124 | public String getDeviceUid() {
125 | return prefs.getString(KDEVICEUID, null);
126 | }
127 |
128 | public boolean getDebug() {
129 | return prefs.getBoolean(KDEBUG, false);
130 | }
131 |
132 | public String getServerUrl() {
133 | return prefs.getString(KSERVERURL, ctx.getString(R.string.pref_default_serverurl));
134 | }
135 |
136 | public boolean getGzip() {
137 | return prefs.getBoolean(KGZIP, false);
138 | }
139 |
140 | public String getDeviceTag() {
141 |
142 | return prefs.getString(KDEVICETAG, ctx.getString(R.string.pref_default_devicetag));
143 | }
144 |
145 | public boolean isSSLStrict() {
146 | return prefs.getBoolean(KSTRICTSSL, true);
147 | }
148 |
149 | public boolean isProxy() {
150 | return prefs.getBoolean(KPROXY, false);
151 | }
152 |
153 | public boolean isAuth() {
154 | return prefs.getBoolean(KAUTH, false);
155 | }
156 |
157 | public String getProxyAdr() {
158 | return prefs.getString(KPROXYADR, "");
159 | }
160 |
161 | public int getProxyPort() {
162 | String p = prefs.getString(KPROXYPORT, "");
163 | return Integer.parseInt(p);
164 | }
165 |
166 | public String getLogin() {
167 | return prefs.getString(KLOGIN, "");
168 | }
169 |
170 | public String getPasswd() {
171 | return prefs.getString(KPASSWD, "");
172 | }
173 |
174 | public long getLastUpdt() {
175 | return prefs.getLong(KLASTUPDT, 0L);
176 | }
177 |
178 | public int getCacheLen() {
179 | int c = 0; // Return 0 if cache not enabled
180 | if (prefs.getBoolean(KCACHE, true)) {
181 | c = Integer.parseInt(prefs.getString(KCACHELEN, ctx.getString(R.string.pref_default_cachelen)));
182 | }
183 | return c;
184 | }
185 |
186 | public int getFreqWake() {
187 | int r = 60;
188 | if (prefs.getBoolean(KAUTOMODE, true)) {
189 | r = Integer.parseInt(prefs.getString(KFREQWAKE, ctx.getString(R.string.pref_default_freqwake)));
190 | }
191 | return r;
192 | }
193 |
194 | public int getFreqMaj() {
195 | return Integer.parseInt(prefs.getString(KFREQMAJ, ctx.getString(R.string.pref_default_freqmaj)));
196 | }
197 |
198 | public boolean isSysHide() {
199 | return prefs.getBoolean(KSYSHIDE, true);
200 | }
201 |
202 | public boolean isCompUAEnabled() {
203 | return prefs.getBoolean(KCOMPUA, false);
204 | }
205 | }
206 |
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/actions/PrefsParser.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.actions;
22 |
23 | import android.content.SharedPreferences;
24 | import android.content.SharedPreferences.Editor;
25 | import android.util.Log;
26 |
27 | import org.xml.sax.Attributes;
28 | import org.xml.sax.SAXException;
29 | import org.xml.sax.helpers.DefaultHandler;
30 |
31 | import java.io.File;
32 |
33 | import javax.xml.parsers.SAXParser;
34 | import javax.xml.parsers.SAXParserFactory;
35 |
36 | public class PrefsParser extends DefaultHandler {
37 | private String keyName;
38 | private String keyValue;
39 | private Editor edit;
40 |
41 | public void parseDocument(File paramFile, SharedPreferences prefs) {
42 | Log.d("PARSE", "Start parseDocument ");
43 | edit = prefs.edit();
44 |
45 | SAXParserFactory localSAXParserFactory = SAXParserFactory.newInstance();
46 | try {
47 | SAXParser localSAXParser = localSAXParserFactory.newSAXParser();
48 | localSAXParser.parse(paramFile, this);
49 | } catch (Exception e) {
50 | e.printStackTrace();
51 | }
52 | }
53 |
54 | public void characters(char[] paramArrayOfChar, int paramInt1, int paramInt2) throws SAXException {
55 | String str = new String(paramArrayOfChar, paramInt1, paramInt2);
56 | keyValue = str;
57 | Log.d("PARSE", "characters" + str);
58 | }
59 |
60 | public void endElement(String uri, String localName, String qName) throws SAXException {
61 | Log.d("PARSE", "endElement");
62 | Log.d("PARSE", "uri : " + uri);
63 | Log.d("PARSE", "lName : " + localName);
64 | Log.d("PARSE", "qName : " + qName);
65 | if ("map".equals(qName)) {
66 | edit.apply();
67 | } else if ("string".equals(qName) && !"k_deviceUid".equals(keyName)) {
68 | Log.d("PARSE", keyName + "/" + keyValue);
69 | edit.putString(keyName, keyValue);
70 | }
71 | }
72 |
73 | public void startElement(String uri, String local, String qName, Attributes attributes) throws SAXException {
74 | keyName = attributes.getValue("", "name");
75 | keyValue = attributes.getValue("", "value");
76 | Log.d("PARSE", "startElement");
77 | Log.d("PARSE", "uri : " + uri);
78 | Log.d("PARSE", "local : " + local);
79 | Log.d("PARSE", "qName : " + qName);
80 | if (qName.equalsIgnoreCase("boolean")) {
81 | Log.d("PARSE", keyName + "/" + keyValue);
82 | edit.putBoolean(keyName, "true".equals(keyValue));
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/actions/PrologReplyParser.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.actions;
22 |
23 | import android.util.Log;
24 |
25 | import org.ocs.android.agent.OCSDownloadIdParams;
26 | import org.ocs.android.agent.OCSPrologReply;
27 | import org.xml.sax.Attributes;
28 | import org.xml.sax.SAXException;
29 | import org.xml.sax.helpers.DefaultHandler;
30 |
31 | import java.io.ByteArrayInputStream;
32 | import java.io.InputStream;
33 |
34 | import javax.xml.parsers.SAXParser;
35 | import javax.xml.parsers.SAXParserFactory;
36 |
37 | public class PrologReplyParser extends DefaultHandler {
38 | private String currentTag;
39 | private OCSPrologReply reply = new OCSPrologReply();
40 |
41 | public OCSPrologReply parseDocument(String strReply) {
42 | Log.d("PrologReplyParser", strReply);
43 | ByteArrayInputStream bais = new ByteArrayInputStream(strReply.getBytes());
44 |
45 | return parseDocument(bais);
46 | }
47 |
48 | public OCSPrologReply parseDocument(InputStream is) {
49 | Log.d("PrologReplyParser", "");
50 | SAXParserFactory localSAXParserFactory = SAXParserFactory.newInstance();
51 | try {
52 | SAXParser localSAXParser = localSAXParserFactory.newSAXParser();
53 | localSAXParser.parse(is, this);
54 | } catch (Exception e) {
55 | e.printStackTrace();
56 | }
57 | return reply;
58 | }
59 |
60 |
61 | public void startElement(String uri, String local, String qName, Attributes attributes) throws SAXException {
62 | if ("PARAM".equals(qName)) {
63 | String id = attributes.getValue("", "ID");
64 | if (id != null) {
65 | OCSDownloadIdParams dip = new OCSDownloadIdParams();
66 | dip.setId(id);
67 | dip.setSchedule(attributes.getValue("", "SCHEDULE"));
68 | dip.setCertFile(attributes.getValue("", "CERT_FILE"));
69 | dip.setType(attributes.getValue("", "TYPE"));
70 | dip.setInfoLoc(attributes.getValue("", "INFO_LOC"));
71 | dip.setCertPath(attributes.getValue("", "CERT_PATH"));
72 | dip.setPackLoc(attributes.getValue("", "PACK_LOC"));
73 | dip.setForce(attributes.getValue("", "FORCE"));
74 | dip.setPostcmd(attributes.getValue("", "POSTCMD"));
75 | reply.getIdList().add(dip);
76 | } else {
77 | String frag_lat = attributes.getValue("", "FRAG_LATENCY");
78 | if (frag_lat != null) {
79 | reply.setFragLatency(frag_lat);
80 | reply.setPeriodLatency(attributes.getValue("", "PERIOD_LATENCY"));
81 | reply.setOn(attributes.getValue("", "ON"));
82 | reply.setType(attributes.getValue("", "TYPE"));
83 | reply.setCycleLatency(attributes.getValue("", "CYCLE_LATENCY"));
84 | reply.setTimeout(attributes.getValue("", "TIMEOUT"));
85 | reply.setPeriodeLength(attributes.getValue("", "PERIOD_LENGTH"));
86 | reply.setExecutionTimeout(attributes.getValue("", "EXECUTION_TIMEOUT"));
87 | }
88 | }
89 | }
90 | currentTag = qName;
91 | }
92 |
93 | public void characters(char[] paramArrayOfChar, int paramInt1, int paramInt2) throws SAXException {
94 | String str = new String(paramArrayOfChar, paramInt1, paramInt2);
95 | if ("RESPONSE".equals(currentTag)) {
96 | reply.setResponse(str);
97 | } else if ("PROLOG_FREQ".equals(currentTag)) {
98 | reply.setPrologFreq(str);
99 | } else if ("NAME".equals(currentTag) && reply.getOptName() == null) {
100 | reply.setOptName(str);
101 | }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/agent/AboutDialog.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.agent;
22 |
23 | import android.app.Dialog;
24 | import android.content.Context;
25 | import android.content.pm.PackageManager.NameNotFoundException;
26 | import android.os.Bundle;
27 | import android.widget.TextView;
28 |
29 | import org.ocs.android.actions.OCSSettings;
30 |
31 | import java.text.SimpleDateFormat;
32 | import java.util.Date;
33 | import java.util.Locale;
34 |
35 | public class AboutDialog extends Dialog {
36 | private static Context mContext;
37 |
38 | public AboutDialog(Context context) {
39 | super(context);
40 | mContext = context;
41 | }
42 |
43 | /**
44 | * Standard Android on create method that gets called when the activity initialized.
45 | */
46 | @Override
47 | public void onCreate(Bundle savedInstanceState) {
48 | setContentView(R.layout.about);
49 |
50 | OCSSettings ocssettings = OCSSettings.getInstance(mContext);
51 |
52 | long lastUpdt = ocssettings.getLastUpdt();
53 |
54 | StringBuilder sb = new StringBuilder("OCS Inventory NG android Agent \n");
55 | sb.append("Version :");
56 | try {
57 | sb.append(mContext.getPackageManager().
58 | getPackageInfo(mContext.getPackageName(), 0).versionName);
59 | } catch (NameNotFoundException e) {
60 | }
61 | sb.append("\n");
62 | if (lastUpdt > 0) {
63 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.US);
64 | sb.append("Last upload : ");
65 | sb.append(sdf.format(new Date(lastUpdt)));
66 | sb.append("\n");
67 | if (ocssettings.isAutoMode()) {
68 | int freq = ocssettings.getFreqMaj();
69 | long nextUpdt = lastUpdt + freq * 3600000L;
70 | sb.append("Next upload : ");
71 | sb.append(sdf.format(new Date(nextUpdt)));
72 | } else {
73 | sb.append("Mode manuel");
74 | }
75 | }
76 |
77 | TextView tv = (TextView) findViewById(R.id.test_about);
78 | tv.setText(sb.toString());
79 | }
80 | }
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/agent/AsyncOperations.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.agent;
22 |
23 | import android.app.Activity;
24 | import android.app.ProgressDialog;
25 | import android.content.Context;
26 | import android.content.Intent;
27 | import android.os.AsyncTask;
28 | import android.widget.TextView;
29 | import android.widget.Toast;
30 |
31 | import org.ocs.android.actions.Inventory;
32 | import org.ocs.android.actions.OCSFiles;
33 | import org.ocs.android.actions.OCSLog;
34 | import org.ocs.android.actions.OCSProtocol;
35 | import org.ocs.android.actions.OCSProtocolException;
36 | import org.ocs.android.agent.service.OCSDownloadService;
37 |
38 | public class AsyncOperations extends AsyncTask {
39 | private final Activity mActivity;
40 | private ProgressDialog mProgressDialog;
41 | private TextView mTvStatus;
42 | private Context mAppCtx;
43 | private boolean mSend;
44 | private boolean mDownload = false;
45 |
46 | public AsyncOperations(boolean send, ProgressDialog progressDialog, TextView status, Activity act, Context ctx) {
47 | mSend = send;
48 | mProgressDialog = progressDialog;
49 | mTvStatus = status;
50 | mAppCtx = ctx;
51 | mActivity = act;
52 | }
53 |
54 | @Override
55 | protected void onPreExecute() {
56 | mTvStatus.setText(R.string.state_build_inventory);
57 | }
58 |
59 | @Override
60 | protected void onPostExecute(String msg) {
61 | OCSLog.getInstance().debug("onPostExecute [" + msg + "]");
62 | mProgressDialog.dismiss();
63 | if (mDownload) {
64 | // Toast cant be build in the thread doInBackground
65 | Toast toast = Toast.makeText(mAppCtx, mAppCtx.getString(R.string.start_download_service), Toast.LENGTH_LONG);
66 | toast.show();
67 | }
68 |
69 | mTvStatus.setText(msg);
70 | }
71 |
72 | @Override
73 | protected String doInBackground(Void... params) {
74 | Inventory inventory = Inventory.getInstance(mActivity);
75 |
76 | OCSProtocol ocsproto = new OCSProtocol(mAppCtx.getApplicationContext());
77 |
78 | if (!mSend) {
79 | String status = new OCSFiles(mAppCtx).copyToExternal(inventory);
80 | if ("OK".equals(status)) {
81 | status = mAppCtx.getString(R.string.state_saved);
82 | }
83 | return status;
84 | }
85 | publishProgress(R.string.state_send_prolog);
86 |
87 | OCSPrologReply reply;
88 | String rep;
89 | try {
90 | reply = ocsproto.sendPrologueMessage();
91 | } catch (OCSProtocolException e1) {
92 | return e1.getMessage();
93 | }
94 | OCSLog.getInstance().debug("Retour send prolog [" + reply.getResponse() + "]");
95 | OCSLog.getInstance().debug(reply.log());
96 | if ("ERROR".equals(reply.getResponse())) {
97 | return reply.getResponse();
98 | } else {
99 | publishProgress(R.string.state_send_inventory);
100 | try {
101 | rep = ocsproto.sendInventoryMessage(inventory);
102 | } catch (OCSProtocolException e) {
103 | return e.getMessage();
104 | }
105 |
106 |
107 | OCSLog.getInstance().debug("Retour send inventory [" + rep + "]");
108 |
109 | if (!reply.getIdList().isEmpty()) {
110 | OCSLog.getInstance().debug(mAppCtx.getString(R.string.start_download_service));
111 |
112 | // Some downlowds requiered invoke download service
113 | Intent dldService = new Intent(mAppCtx, OCSDownloadService.class);
114 | mAppCtx.startService(dldService);
115 | mDownload = true; // Info for postexecute stage
116 | }
117 |
118 | if (rep == null) {
119 | return mAppCtx.getString(R.string.state_send_error);
120 | } else if (rep.length() == 0) {
121 | return mAppCtx.getString(R.string.state_sent_inventory);
122 | } else {
123 | return rep;
124 | }
125 | }
126 | }
127 |
128 | protected void onProgressUpdate(Integer... progress) {
129 | mProgressDialog.setMessage(mAppCtx.getString(progress[0]));
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/agent/ExpandableSectionAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.agent;
22 |
23 | import android.content.Context;
24 | import android.view.LayoutInflater;
25 | import android.view.View;
26 | import android.view.ViewGroup;
27 | import android.widget.BaseExpandableListAdapter;
28 | import android.widget.TextView;
29 |
30 | import org.ocs.android.sections.OCSSection;
31 |
32 | import java.util.HashMap;
33 | import java.util.List;
34 |
35 | public class ExpandableSectionAdapter extends BaseExpandableListAdapter {
36 | // Context
37 | private Context myContext;
38 | //
39 | private HashMap> myDatas;
40 |
41 | public ExpandableSectionAdapter(Context myContext, HashMap> myDatas) {
42 | this.myContext = myContext;
43 | this.myDatas = myDatas;
44 | }
45 |
46 | /**
47 | * Number of Sections
48 | *
49 | * @return int
50 | */
51 | @Override
52 | public int getGroupCount() {
53 | return myDatas.size();
54 | }
55 |
56 | /**
57 | * Number of details on a specific section
58 | */
59 | @Override
60 | public int getChildrenCount(int groupPosition) {
61 | return myDatas.get(getGroup(groupPosition)).size();
62 | }
63 |
64 | /**
65 | * Get section name
66 | * @return String
67 | */
68 | @Override
69 | public Object getGroup(int groupPosition) {
70 | return myDatas.keySet().toArray()[groupPosition];
71 | }
72 |
73 | /**
74 | * Get details of a Section
75 | * @return Section
76 | */
77 | @Override
78 | public Object getChild(int groupPosition, int childPosition) {
79 | return myDatas.get(getGroup(groupPosition)).get(childPosition);
80 | }
81 |
82 | @Override
83 | public long getGroupId(int groupPosition) {
84 | return groupPosition;
85 | }
86 |
87 | @Override
88 | public long getChildId(int groupPosition, int childPosition) {
89 | return childPosition;
90 | }
91 |
92 | @Override
93 | public boolean hasStableIds() {
94 | return false;
95 | }
96 |
97 | /**
98 | * Display section title
99 | */
100 | @Override
101 | public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
102 | View maView = convertView;
103 |
104 | // Get this group title
105 | String headerTitle = (String) getGroup(groupPosition);
106 |
107 | if (maView == null) {
108 | LayoutInflater monLayoutInflater = (LayoutInflater) myContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
109 | maView = monLayoutInflater.inflate(R.layout.list_header, parent, false);
110 | }
111 |
112 | // Display it :-)
113 | TextView lblListHeader = (TextView) maView.findViewById(R.id.list_header_name);
114 | lblListHeader.setText(headerTitle);
115 |
116 | return maView;
117 | }
118 |
119 | /**
120 | * Display section details
121 | */
122 | @Override
123 | public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
124 | View maView = convertView;
125 |
126 | // Get part of details of this section
127 | final OCSSection maSection = (OCSSection) getChild(groupPosition, childPosition);
128 |
129 | if (maView == null) {
130 | LayoutInflater monLayoutInflater = (LayoutInflater) myContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
131 | maView = monLayoutInflater.inflate(R.layout.list_item, parent, false);
132 | }
133 |
134 | // Display it :-)
135 | TextView itemName = (TextView) maView.findViewById(R.id.list_item_name);
136 | TextView itemDetail = (TextView) maView.findViewById(R.id.list_item_detail);
137 |
138 | itemName.setText(maSection.getTitle());
139 | itemDetail.setText(maSection.toString());
140 | return maView;
141 | }
142 |
143 | @Override
144 | public boolean isChildSelectable(int groupPosition, int childPosition) {
145 | return false;
146 | }
147 | }
148 |
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/agent/OCSDownloadIdParams.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.agent;
22 |
23 |
24 | /*
25 | *
27 | *
28 | */
29 | public class OCSDownloadIdParams {
30 | private String id;
31 | private String schedule;
32 | private String certFile;
33 | private String type;
34 | private String infoLoc;
35 | private String certPath;
36 | private String packLoc;
37 | private boolean force;
38 | private String postcmd;
39 |
40 | private OCSDownloadInfos infos = null;
41 | private int downloaded = 0;
42 |
43 |
44 | public int getDownloaded() {
45 | return downloaded;
46 | }
47 |
48 | public void setDownloaded(int downloaded) {
49 | this.downloaded = downloaded;
50 | }
51 |
52 | public OCSDownloadInfos getInfos() {
53 | return infos;
54 | }
55 |
56 | public void setInfos(OCSDownloadInfos infos) {
57 | this.infos = infos;
58 | }
59 |
60 | public String getId() {
61 | return id;
62 | }
63 |
64 | public void setId(String str) {
65 | this.id = str;
66 | }
67 |
68 | public String getSchedule() {
69 | return schedule;
70 | }
71 |
72 | public void setSchedule(String schedule) {
73 | this.schedule = schedule;
74 | }
75 |
76 | public String getCertFile() {
77 | return certFile;
78 | }
79 |
80 | public void setCertFile(String certFile) {
81 | this.certFile = certFile;
82 | }
83 |
84 | public String getType() {
85 | return type;
86 | }
87 |
88 | public void setType(String type) {
89 | this.type = type;
90 | }
91 |
92 | public String getInfoLoc() {
93 | return infoLoc;
94 | }
95 |
96 | public void setInfoLoc(String infoLoc) {
97 | this.infoLoc = infoLoc;
98 | }
99 |
100 | public String getCertPath() {
101 | return certPath;
102 | }
103 |
104 | public void setCertPath(String certPath) {
105 | this.certPath = certPath;
106 | }
107 |
108 | public String getPackLoc() {
109 | return packLoc;
110 | }
111 |
112 | public void setPackLoc(String packLoc) {
113 | this.packLoc = packLoc;
114 | }
115 |
116 | public boolean isForce() {
117 | return force;
118 | }
119 |
120 | public void setForce(boolean force) {
121 | this.force = force;
122 | }
123 |
124 | public void setForce(String str) {
125 | if (str == null) {
126 | return;
127 | }
128 | this.force = "1".equals(str);
129 | }
130 |
131 | public String getPostcmd() {
132 | return postcmd;
133 | }
134 |
135 | public void setPostcmd(String postcmd) {
136 | this.postcmd = postcmd;
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/agent/OCSDownloadInfos.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.agent;
22 |
23 | import android.util.Log;
24 |
25 | public class OCSDownloadInfos {
26 | private String id;
27 | private int pri;
28 | private String act;
29 | private String digest;
30 | private String proto;
31 | private int frags;
32 | private String digestAlgo;
33 | private String digestEncode;
34 | private String path;
35 | private String notifyText;
36 | private String notifyCountdown;
37 | private boolean notifyUser;
38 | private boolean notifyCanAbort;
39 | private boolean notifyCanDelay;
40 | private boolean needDoneAction;
41 | private String needDoneActionText;
42 |
43 |
44 | public OCSDownloadInfos(String strinfos) {
45 | id = extrAttr(strinfos, "ID");
46 | act = extrAttr(strinfos, "ACT");
47 | digest = extrAttr(strinfos, "DIGEST");
48 | proto = extrAttr(strinfos, "PROTO");
49 | digestAlgo = extrAttr(strinfos, "DIGEST_ALGO");
50 | digestEncode = extrAttr(strinfos, "DIGEST_ENCODE");
51 | path = extrAttr(strinfos, "PATH");
52 | notifyCountdown = extrAttr(strinfos, "NOTIFY_COUNTDOWN");
53 | notifyCanAbort = extrAttr(strinfos, "NOTIFY_CAN_ABORT").equals("1");
54 | notifyCanDelay = extrAttr(strinfos, "NOTIFY_CAN_DELAY").equals("1");
55 | needDoneAction = extrAttr(strinfos, "NEED_DONE_ACTION").equals("1");
56 | needDoneActionText = extrAttr(strinfos, "NEED_DONE_ACTION_TEXT");
57 | try {
58 | pri = Integer.parseInt(extrAttr(strinfos, "PRI"));
59 | } catch (NumberFormatException e) {
60 | }
61 |
62 | try {
63 | frags = Integer.parseInt(extrAttr(strinfos, "FRAGS"));
64 | } catch (NumberFormatException e) {
65 | }
66 | }
67 |
68 | private String extrAttr(String doc, String attrName) {
69 | int x = doc.indexOf(attrName);
70 | x = doc.indexOf("\"", x);
71 | int y = doc.indexOf("\"", x + 1);
72 | Log.i("extrattr", attrName + ":" + doc.substring(x + 1, y));
73 | return doc.substring(x + 1, y);
74 | }
75 |
76 | public String getId() {
77 | return id;
78 | }
79 |
80 | public int getPri() {
81 | return pri;
82 | }
83 |
84 | /**
85 | * @return action requested
86 | */
87 | public String getAct() {
88 | return act;
89 | }
90 |
91 | /**
92 | * @return digest value as string
93 | */
94 | public String getDigest() {
95 | return digest;
96 | }
97 |
98 | /**
99 | * @return protocol to use (HTTP/HTTPS)
100 | */
101 | public String getProto() {
102 | return proto;
103 | }
104 |
105 | /**
106 | * @return number of fragments
107 | */
108 | public int getFrags() {
109 | return frags;
110 | }
111 |
112 | public String getNeedDoneActionText() {
113 | return needDoneActionText;
114 | }
115 |
116 | public String getDigestAlgo() {
117 | return digestAlgo;
118 | }
119 |
120 | public String getDigestEncode() {
121 | return digestEncode;
122 | }
123 |
124 | public String getPath() {
125 | return path;
126 | }
127 |
128 | public String getNotifyText() {
129 | return notifyText;
130 | }
131 |
132 | public String getNotifyCountdown() {
133 | return notifyCountdown;
134 | }
135 |
136 | public boolean isNotifyUser() {
137 | return notifyUser;
138 | }
139 |
140 | public boolean isNotifyCanAbort() {
141 | return notifyCanAbort;
142 | }
143 |
144 | public boolean isNotifyCanDelay() {
145 | return notifyCanDelay;
146 | }
147 |
148 | public boolean isNeedDoneAction() {
149 | return needDoneAction;
150 | }
151 | }
152 |
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/agent/OCSPrologReply.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.agent;
22 |
23 | import java.util.ArrayList;
24 |
25 |
26 | /*
27 | *
30 | *
31 | */
32 | public class OCSPrologReply {
33 | final private int DEF_PERIODE_LENGTH = 10;
34 |
35 | private String type;
36 | private String response;
37 | private String prologFreq;
38 | private String optName;
39 |
40 | private int periodLatency; // Wait between 2 periods of deployment (def 1 sec)
41 | private int cycleLatency; // Wait between 2 cycles (def 60 sec )
42 | private int fragLatency; // Wait between 2 fragment download ( def. 10 sec )
43 | private int timeout; // Validity of a package from 1st consideration
44 | private int periodeLength; // Nombre de cycle dans la periode def 10
45 | private int executionTimeout;
46 | private boolean on;
47 | private ArrayList idList;
48 |
49 | public OCSPrologReply() {
50 | idList = new ArrayList<>();
51 | optName = null;
52 | response = "";
53 | }
54 |
55 | public String log() {
56 | StringBuilder sb = new StringBuilder();
57 | sb.append("OPTION: ").append(getOptName()).append("\n");
58 | sb.append("prologFreq: ").append(getPrologFreq()).append("\n");
59 | sb.append("periodLatency: ").append(getPeriodLatency()).append("\n");
60 | sb.append("cycleLatency: ").append(getCycleLatency()).append("\n");
61 | for (OCSDownloadIdParams dip : getIdList()) {
62 | sb.append("PARAM ID: ").append(dip.getId()).append("TYPE:").append(dip.getType()).append("\n");
63 | }
64 | return sb.toString();
65 | }
66 |
67 | public String getResponse() {
68 | return response;
69 | }
70 |
71 | public void setResponse(String response) {
72 | this.response = response;
73 | }
74 |
75 | public String getPrologFreq() {
76 | return prologFreq;
77 | }
78 |
79 | public void setPrologFreq(String prologFreq) {
80 | this.prologFreq = prologFreq;
81 | }
82 |
83 | public String getOptName() {
84 | return optName;
85 | }
86 |
87 | public void setOptName(String optName) {
88 | this.optName = optName;
89 | }
90 |
91 | /**
92 | * Wait between 2 fragment download ( def. 10 sec )
93 | */
94 | public int getFragLatency() {
95 | return fragLatency;
96 | }
97 |
98 | public void setFragLatency(int fragLatency) {
99 | this.fragLatency = fragLatency;
100 | }
101 |
102 | public void setFragLatency(String str) {
103 | try {
104 | setFragLatency(Integer.parseInt(str));
105 | } catch (NumberFormatException e) {
106 | }
107 | }
108 |
109 | /**
110 | * Wait between 2 periods of deployment (def 1 sec)
111 | */
112 | public int getPeriodLatency() {
113 | return periodLatency;
114 | }
115 |
116 | public void setPeriodLatency(int periodLatency) {
117 | this.periodLatency = periodLatency;
118 | }
119 |
120 | public void setPeriodLatency(String str) {
121 | try {
122 | setPeriodLatency(Integer.parseInt(str));
123 | } catch (NumberFormatException e) {
124 | }
125 | }
126 |
127 | /**
128 | * Wait between 2 cycles (def 60 sec )
129 | */
130 | public int getCycleLatency() {
131 | return cycleLatency;
132 | }
133 |
134 | public void setCycleLatency(int cycleLatency) {
135 | this.cycleLatency = cycleLatency;
136 | }
137 |
138 | public void setCycleLatency(String str) {
139 | try {
140 | setCycleLatency(Integer.parseInt(str));
141 | } catch (NumberFormatException e) {
142 | }
143 | }
144 |
145 | public int getTimeout() {
146 | return timeout;
147 | }
148 |
149 | public void setTimeout(int timeout) {
150 | this.timeout = timeout;
151 | }
152 |
153 | public void setTimeout(String str) {
154 | try {
155 | this.timeout = Integer.parseInt(str);
156 | } catch (NumberFormatException e) {
157 | }
158 | }
159 |
160 | public int getPeriodeLength() {
161 | return periodeLength;
162 | }
163 |
164 | public void setPeriodeLength(int periodeLength) {
165 | this.periodeLength = periodeLength;
166 | }
167 |
168 | public void setPeriodeLength(String str) {
169 | try {
170 | setPeriodeLength(Integer.parseInt(str));
171 | } catch (NumberFormatException e) {
172 | setPeriodeLength(DEF_PERIODE_LENGTH);
173 | }
174 | }
175 |
176 | public int getExecutionTimeout() {
177 | return executionTimeout;
178 | }
179 |
180 | public void setExecutionTimeout(int executionTimeout) {
181 | this.executionTimeout = executionTimeout;
182 | }
183 |
184 | public void setExecutionTimeout(String str) {
185 | try {
186 | setExecutionTimeout(Integer.parseInt(str));
187 | } catch (NumberFormatException e) {
188 | }
189 | }
190 |
191 | public boolean isOn() {
192 | return on;
193 | }
194 |
195 | public void setOn(boolean on) {
196 | this.on = on;
197 | }
198 |
199 | public void setOn(String str) {
200 | if (str == null) {
201 | return;
202 | }
203 | this.on = "1".equals(str);
204 | }
205 |
206 | public String getType() {
207 | return type;
208 | }
209 |
210 | public void setType(String type) {
211 | this.type = type;
212 | }
213 |
214 | public ArrayList getIdList() {
215 | return idList;
216 | }
217 |
218 | public void setIdList(ArrayList idList) {
219 | this.idList = idList;
220 | }
221 | }
222 |
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/agent/activity/OCSShowInventory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.agent.activity;
22 |
23 | import android.os.Bundle;
24 | import android.support.annotation.Nullable;
25 | import android.support.v7.app.AppCompatActivity;
26 | import android.widget.ExpandableListAdapter;
27 | import android.widget.ExpandableListView;
28 |
29 | import org.ocs.android.actions.Inventory;
30 | import org.ocs.android.agent.ExpandableSectionAdapter;
31 | import org.ocs.android.agent.R;
32 |
33 | /**
34 | * Display inventory to the user
35 | */
36 | public class OCSShowInventory extends AppCompatActivity {
37 |
38 | @Override
39 | protected void onCreate(@Nullable Bundle savedInstanceState) {
40 | super.onCreate(savedInstanceState);
41 |
42 | setContentView(R.layout.actvity_show_inventory);
43 |
44 | // Get the listview
45 | ExpandableListView maListView = (ExpandableListView) findViewById(R.id.myListView);
46 |
47 | // Set datas
48 | ExpandableListAdapter monListAdapter = new ExpandableSectionAdapter(this, Inventory.getInstance(this).getAllSections());
49 |
50 | // Set list adapter
51 | maListView.setAdapter(monListAdapter);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/agent/receiver/OCSBootReceiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.agent.receiver;
22 |
23 | import android.app.AlarmManager;
24 | import android.app.PendingIntent;
25 | import android.content.BroadcastReceiver;
26 | import android.content.Context;
27 | import android.content.Intent;
28 | import android.util.Log;
29 |
30 | import org.ocs.android.actions.OCSLog;
31 | import org.ocs.android.actions.OCSSettings;
32 |
33 | import java.util.Calendar;
34 |
35 | public class OCSBootReceiver extends BroadcastReceiver {
36 |
37 | @Override
38 | public void onReceive(final Context ctx, final Intent intent) {
39 | Log.d("OCSBOOT", "on Receive called");
40 | OCSSettings ocssetting = OCSSettings.getInstance(ctx);
41 | OCSLog ocslog = OCSLog.getInstance();
42 | ocslog.debug("OCSBootReceiver : " + intent.getAction());
43 | if (ocssetting == null) {
44 | ocslog.error("NULL OSSETTING");
45 | return;
46 | }
47 |
48 | if (!ocssetting.isAutoMode()) {
49 | return;
50 | }
51 | int interval = ocssetting.getFreqWake();
52 | ocslog.debug("OCSBootReceiver interval : " + interval);
53 |
54 | AlarmManager alarmManager = (AlarmManager) ctx.getSystemService(Context.ALARM_SERVICE);
55 | Intent i = new Intent(ctx, OCSEventReceiver.class);
56 |
57 | PendingIntent intentExecuted = PendingIntent.getBroadcast(ctx, 0, i, PendingIntent.FLAG_CANCEL_CURRENT);
58 | Calendar start = Calendar.getInstance();
59 | start.add(Calendar.SECOND, 5);
60 | alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, start.getTimeInMillis(), interval * 60000L, intentExecuted);
61 | }
62 | }
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/agent/receiver/OCSEventReceiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.agent.receiver;
22 |
23 | import android.content.BroadcastReceiver;
24 | import android.content.Context;
25 | import android.content.Intent;
26 | import android.util.Log;
27 |
28 | import org.ocs.android.agent.service.OCSAgentService;
29 |
30 | public class OCSEventReceiver extends BroadcastReceiver {
31 | private static final String LOGTAG = "OCSEventReceiver";
32 |
33 | @Override
34 | public void onReceive(final Context ctx, final Intent intent) {
35 | Log.d(LOGTAG, "Called");
36 | Intent eventService = new Intent(ctx, OCSAgentService.class);
37 | boolean forceUpdate = intent.getBooleanExtra(OCSAgentService.FORCE_UPDATE, false);
38 | eventService.putExtra(OCSAgentService.FORCE_UPDATE, forceUpdate);
39 | boolean saveInventory = intent.getBooleanExtra(OCSAgentService.SAVE_INVENTORY, false);
40 | eventService.putExtra(OCSAgentService.SAVE_INVENTORY, saveInventory);
41 | ctx.startService(eventService);
42 | Log.d(LOGTAG, "After start service");
43 | }
44 | }
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/agent/receiver/OCSInstallReceiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.agent.receiver;
22 |
23 | import android.content.BroadcastReceiver;
24 | import android.content.Context;
25 | import android.content.Intent;
26 | import android.content.pm.PackageInfo;
27 | import android.content.pm.PackageManager;
28 | import android.content.pm.PackageManager.NameNotFoundException;
29 | import android.os.AsyncTask;
30 | import android.widget.Toast;
31 |
32 | import org.ocs.android.actions.OCSLog;
33 | import org.ocs.android.actions.OCSProtocol;
34 | import org.ocs.android.actions.OCSProtocolException;
35 |
36 | import java.io.File;
37 | import java.io.FileInputStream;
38 |
39 | public class OCSInstallReceiver extends BroadcastReceiver {
40 | private OCSLog mOCSlog;
41 | private String mStatus;
42 | private String mOCSid;
43 |
44 | @Override
45 | public void onReceive(final Context ctx, final Intent intent) {
46 | mOCSlog = OCSLog.getInstance();
47 | byte buffer[] = new byte[80];
48 |
49 | String data = intent.getData().toString();
50 | mOCSlog.debug("OCSInstallReceiver : " + intent.getAction());
51 | Toast.makeText(ctx, "OCSInstallReceiver : " + intent.getAction(), Toast.LENGTH_SHORT).show();
52 | String packageName = data.split(":")[1];
53 | mOCSlog.debug("Package : " + packageName);
54 | try {
55 | mOCSlog.debug("Lecture " + packageName + ".inst");
56 | FileInputStream fis = ctx.openFileInput(packageName + ".inst");
57 | // Read and store to buffer
58 | fis.read(buffer);
59 | String s = new String(buffer);
60 | String t[] = s.split(":");
61 | mOCSid = t[0];
62 | int version = Integer.parseInt(t[1]);
63 | fis.close();
64 |
65 | if (isPkgInstalled(ctx, packageName, version)) {
66 | mOCSlog.debug("Package installed return success to OCS server");
67 | mStatus = "SUCCESS";
68 | } else {
69 | mOCSlog.debug("Package not installed return fail to OCS server");
70 | mStatus = "ERR_ABORTED";
71 | }
72 |
73 | AsyncSend task = new AsyncSend(ctx);
74 | task.execute();
75 |
76 | // Clean download files
77 | File fapk = new File(ctx.getExternalCacheDir(), mOCSid + ".apk");
78 | fapk.delete();
79 | File finst = new File(ctx.getFilesDir(), packageName + ".inst");
80 | finst.delete();
81 | File finfo = new File(ctx.getFilesDir(), mOCSid + ".info");
82 | finfo.delete();
83 | } catch (Exception e) {
84 | mOCSlog.error(e.getMessage());
85 | }
86 | }
87 |
88 | /**
89 | * Check if a package is installed with a given version code
90 | *
91 | * @param pkg Package name
92 | * @param version Version code
93 | * @return true if installed
94 | */
95 | private boolean isPkgInstalled(Context ctx, String pkg, int version) {
96 | PackageManager pm = ctx.getPackageManager();
97 |
98 | mOCSlog.debug("Check installation " + pkg + "/" + version);
99 | try {
100 | PackageInfo lpInfo = pm.getPackageInfo(pkg, PackageManager.GET_ACTIVITIES);
101 | return (lpInfo.versionCode == version);
102 | } catch (NameNotFoundException e) {
103 | mOCSlog.error("Package notfound");
104 | return false;
105 | }
106 | }
107 |
108 | private class AsyncSend extends AsyncTask {
109 | private Context mContext;
110 |
111 | AsyncSend(Context ctx) {
112 | mContext = ctx;
113 | }
114 |
115 | @Override
116 | protected Void doInBackground(Void... params) {
117 | OCSProtocol ocsproto = new OCSProtocol(mContext.getApplicationContext());
118 | try {
119 | ocsproto.sendRequestMessage("DOWNLOAD", mOCSid, mStatus);
120 | } catch (OCSProtocolException e) {
121 | mOCSlog.error(e.getMessage());
122 | }
123 | return null;
124 | }
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/sections/OCSBios.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.sections;
22 |
23 | import android.Manifest;
24 | import android.content.Context;
25 | import android.content.pm.PackageManager;
26 | import android.os.Build;
27 | import android.support.v4.app.ActivityCompat;
28 | import android.text.format.DateFormat;
29 |
30 | import org.ocs.android.actions.OCSLog;
31 |
32 | import java.util.ArrayList;
33 |
34 | /*
35 | *
36 | Asset-1234567890
37 | 03/26/2008
38 | American Megatrends Inc.
39 | 0802
40 | ASUSTeK Computer INC.
41 | P5KPL-VM
42 | MT7084K06409125
43 | System manufacturer
44 | System Product Name
45 | System Serial Number
46 | *
47 | *
48 |
49 | BIOS (BDATE | BMANUFACTURER | BVERSION | SMANUFACTURER | SMODEL | SSN | TYPE | ASSETTAG)
50 | */
51 | public class OCSBios implements OCSSectionInterface {
52 |
53 | final private String sectionTag = "BIOS";
54 |
55 | private String assettag;
56 | private String date;
57 | private String manufacturer;
58 | private String version;
59 | private String serial;
60 | private String type;
61 | private String smodel;
62 |
63 | public OCSBios(Context mCtx) {
64 | type = "Mobile";
65 | OCSLog ocslog = OCSLog.getInstance();
66 | assettag = Build.ID + "-0123456789";
67 | date = (String) DateFormat.format("MM/dd/yy", Build.TIME);
68 | manufacturer = Build.MANUFACTURER;
69 | version = Build.BOOTLOADER;
70 | ocslog.debug("BIOS version: " + version);
71 | try {
72 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
73 | serial = Build.getSerial();
74 | }
75 | } catch (SecurityException e) {
76 | serial = SystemInfos.getInstance().getSerial();
77 | }
78 | ocslog.debug("OCSBIOS serial " + serial);
79 | smodel = Build.MODEL;
80 | ocslog.debug("OCSBIOS model: " + smodel);
81 | }
82 | /*
83 |
84 | */
85 |
86 | public OCSSection getSection() {
87 | OCSSection s = new OCSSection(sectionTag);
88 | s.setAttr("TYPE", type);
89 | s.setAttr("ASSETTAG", assettag);
90 | s.setAttr("BDATE", date);
91 | s.setAttr("BMANUFACTURER", manufacturer);
92 | s.setAttr("BVERSION", version);
93 | s.setAttr("MMANUFACTURER", manufacturer);
94 | s.setAttr("MSN", serial);
95 | s.setAttr("SMANUFACTURER", manufacturer);
96 | s.setAttr("SMODEL", smodel);
97 | s.setAttr("SSN", serial);
98 | s.setTitle(assettag);
99 | return s;
100 | }
101 |
102 | public ArrayList getSections() {
103 | ArrayList lst = new ArrayList<>();
104 | lst.add(getSection());
105 | return lst;
106 | }
107 |
108 | public String toString() {
109 | return getSection().toString();
110 | }
111 |
112 | public String toXML() {
113 | return getSection().toXML();
114 | }
115 |
116 | public String getSectionTag() {
117 | return sectionTag;
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/sections/OCSDrive.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.sections;
22 |
23 | import android.os.StatFs;
24 | import android.text.format.DateFormat;
25 |
26 | import java.io.File;
27 |
28 | public class OCSDrive {
29 | private String createdate;
30 | private String filesystem = null;
31 | private String type;
32 | private long free;
33 | private String label = null;
34 | private String serial;
35 | private long total;
36 | private String volumName = null;
37 |
38 | public OCSDrive(String fs) {
39 | File d = new File(fs);
40 | StatFs statfs = new StatFs(fs);
41 | long bs = statfs.getBlockSize();
42 | long bc = statfs.getBlockCount();
43 | long fb = statfs.getFreeBlocks();
44 |
45 | total = bs * bc / 1048576L;
46 | free = bs * fb / 1048576L;
47 | type = fs;
48 | createdate = (String) DateFormat.format("MM/dd/yy mm:ss", d.lastModified());
49 | }
50 |
51 | /*
52 | * 2011/11/17 20:47:06
53 | * ext4 29584
54 | * e340fd1a-108f-4523-a4f5-25d1c09bb0f2
55 | * 37547 / /dev/sda2
56 | */
57 | public OCSSection getSection() {
58 | OCSSection s = new OCSSection("DRIVES");
59 | s.setAttr("CREATEDATE", createdate);
60 | s.setAttr("FILESYSTEM", filesystem);
61 | s.setAttr("TYPE", type);
62 | s.setAttr("FREE", String.valueOf(free));
63 | s.setAttr("LABEL", label);
64 | s.setAttr("SERIAL", null);
65 | s.setAttr("TOTAL", String.valueOf(total));
66 | s.setAttr("VOLUMN", volumName);
67 | s.setTitle(volumName);
68 | return s;
69 | }
70 |
71 | public String toXml() {
72 | return getSection().toXML();
73 | }
74 |
75 | public String toString() {
76 | return getSection().toString();
77 | }
78 |
79 | public String toXML() {
80 | return getSection().toXML();
81 | }
82 |
83 | public String getCreatedate() {
84 | return createdate;
85 | }
86 |
87 | public void setCreatedate(String createdate) {
88 | this.createdate = createdate;
89 | }
90 |
91 | public String getFilesystem() {
92 | return filesystem;
93 | }
94 |
95 | public void setFilesystem(String filesystem) {
96 | this.filesystem = filesystem;
97 | }
98 |
99 | public String getType() {
100 | return type;
101 | }
102 |
103 | public void setType(String type) {
104 | this.type = type;
105 | }
106 |
107 | public long getFree() {
108 | return free;
109 | }
110 |
111 | public void setFree(long free) {
112 | this.free = free;
113 | }
114 |
115 | public String getLabel() {
116 | return label;
117 | }
118 |
119 | public void setLabel(String label) {
120 | this.label = label;
121 | }
122 |
123 | public String getSerial() {
124 | return serial;
125 | }
126 |
127 | public void setSerial(String serial) {
128 | this.serial = serial;
129 | }
130 |
131 | public long getTotal() {
132 | return total;
133 | }
134 |
135 | public void setTotal(long total) {
136 | this.total = total;
137 | }
138 |
139 | public String getVolumName() {
140 | return volumName;
141 | }
142 |
143 | public void setVolumName(String volumName) {
144 | this.volumName = volumName;
145 | }
146 | }
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/sections/OCSDrives.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.sections;
22 |
23 | import android.util.Log;
24 |
25 | import org.ocs.android.actions.OCSLog;
26 |
27 | import java.io.BufferedReader;
28 | import java.io.File;
29 | import java.io.FileReader;
30 | import java.io.IOException;
31 | import java.io.InputStream;
32 | import java.io.InputStreamReader;
33 | import java.util.ArrayList;
34 | import java.util.regex.Matcher;
35 | import java.util.regex.Pattern;
36 |
37 | public class OCSDrives implements OCSSectionInterface {
38 | final private String sectionTag = "DRIVES";
39 |
40 | private final String DFPATH = "/system/bin/df";
41 | private final String MOUNTSPATH = "/proc/mounts";
42 |
43 | public ArrayList drives;
44 |
45 | public OCSDrives() {
46 | drives = new ArrayList<>();
47 | OCSLog ocslog = OCSLog.getInstance();
48 | // Lecture des FS a partir de la commande df
49 | try {
50 | // Lancement de la commande
51 | InputStream is = new ProcessBuilder(DFPATH).start().getInputStream();
52 |
53 | BufferedReader br = new BufferedReader(new InputStreamReader(is), 8192);
54 | String ligne;
55 | while ((ligne = br.readLine()) != null) {
56 | Log.i("df : ", ligne);
57 | // Parsing the df line
58 | String strPattern = "^(/.*?):*\\s.*";
59 | Pattern p = Pattern.compile(strPattern, Pattern.CASE_INSENSITIVE);
60 | Matcher m = p.matcher(ligne);
61 | if (m.find() && m.group(1) != null) {
62 | ocslog.debug("Add drive " + m.group(1));
63 | try {
64 | OCSDrive drive = new OCSDrive(m.group(1).trim());
65 | drives.add(drive);
66 | } catch (IllegalArgumentException e) {
67 | ocslog.debug("Error - adding drive " + m.group(1) + e.toString());
68 | }
69 | }
70 | }
71 | is.close();
72 | } catch (IOException localIOException) {
73 | Log.e("ERREUR", "Message :" + localIOException.getMessage());
74 | }
75 | /*
76 | * Complement avec le fichier /proc/mounts
77 | */
78 | try {
79 | File f = new File(MOUNTSPATH);
80 | BufferedReader bReader = new BufferedReader(new FileReader(f), 8192);
81 | String line;
82 | while ((line = bReader.readLine()) != null) {
83 | ocslog.debug(line);
84 | Pattern p = Pattern.compile("(.*?)\\s+(.*?)\\s+(.*?)\\s.*", Pattern.CASE_INSENSITIVE);
85 | Matcher m = p.matcher(line);
86 | if (m.find()) {
87 | String dev = m.group(1);
88 | String type = m.group(2);
89 | String fs = m.group(3);
90 | ocslog.debug("Volumename :" + dev);
91 | ocslog.debug("type :" + type);
92 | ocslog.debug("filesystem :" + fs);
93 |
94 | for (int i = 0; i < drives.size(); i++) {
95 | OCSDrive d = drives.get(i);
96 | if (type.matches(d.getType())) {
97 | ocslog.debug("MATCH :" + type);
98 | d.setFilesystem(fs);
99 | d.setVolumName(dev);
100 | break;
101 | }
102 | }
103 | }
104 | }
105 | bReader.close();
106 | } catch (IOException e) {
107 | // TODO Auto-generated catch block
108 | e.printStackTrace();
109 | }
110 | }
111 |
112 | public String toXML() {
113 | StringBuilder strOut = new StringBuilder();
114 | for (OCSDrive o : drives) {
115 | strOut.append(o.toXml());
116 | }
117 | return strOut.toString();
118 | }
119 |
120 | public String toString() {
121 | StringBuilder strOut = new StringBuilder();
122 | for (OCSDrive o : drives) {
123 | strOut.append(o.toString());
124 | }
125 | return strOut.toString();
126 | }
127 |
128 | public ArrayList getSections() {
129 | ArrayList lst = new ArrayList<>();
130 | for (OCSDrive o : drives) {
131 | lst.add(o.getSection());
132 | }
133 | return lst;
134 | }
135 |
136 | public String getSectionTag() {
137 | return sectionTag;
138 | }
139 | }
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/sections/OCSInput.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.sections;
22 |
23 |
24 | public class OCSInput {
25 | private String type = null;
26 | private String manufacturer = "NA";
27 | private String caption = "NA";
28 | private String description = "NA";
29 | private String interf = "";
30 | private String pointtype = "";
31 |
32 | /*
33 |
34 | INPUTS (TYPE | MANUFACTURER | CAPTION | DESCRIPTION | INTERFACE | POINTTYPE
35 | */
36 |
37 | public OCSSection getSection() {
38 | OCSSection s = new OCSSection("INPUTS");
39 | s.setAttr("TYPE", type);
40 | s.setAttr("MANUFACTURER", manufacturer);
41 | s.setAttr("CAPTION", caption);
42 | s.setAttr("DESCRIPTION", description);
43 | s.setAttr("INTERFACE", interf);
44 | s.setAttr("POINTTYPE", pointtype);
45 | s.setTitle(type);
46 | return s;
47 | }
48 |
49 | public String toString() {
50 | return getSection().toString();
51 | }
52 |
53 | public String toXml() {
54 | return getSection().toXML();
55 | }
56 |
57 | public String getType() {
58 | return type;
59 | }
60 |
61 | public void setType(String type) {
62 | this.type = type;
63 | }
64 |
65 | public String getManufacturer() {
66 | return manufacturer;
67 | }
68 |
69 | public void setManufacturer(String manufacturer) {
70 | this.manufacturer = manufacturer;
71 | }
72 |
73 | public String getCaption() {
74 | return caption;
75 | }
76 |
77 | public void setCaption(String caption) {
78 | this.caption = caption;
79 | }
80 |
81 | public String getDescription() {
82 | return description;
83 | }
84 |
85 | public void setDescription(String description) {
86 | this.description = description;
87 | }
88 |
89 | public String getInterf() {
90 | return interf;
91 | }
92 |
93 | public void setInterf(String interf) {
94 | this.interf = interf;
95 | }
96 |
97 | public String getPointtype() {
98 | return pointtype;
99 | }
100 |
101 | public void setPointtype(String pointtype) {
102 | this.pointtype = pointtype;
103 | }
104 | }
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/sections/OCSInputs.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.sections;
22 |
23 | import android.content.Context;
24 | import android.content.res.Configuration;
25 | import android.hardware.Camera;
26 | import android.os.Build;
27 |
28 | import org.ocs.android.actions.OCSLog;
29 |
30 | import java.util.ArrayList;
31 |
32 |
33 | public class OCSInputs implements OCSSectionInterface {
34 | final private String sectionTag = "INPUTS";
35 | public ArrayList inputs;
36 |
37 | public OCSInputs(Context ctx) {
38 | OCSLog ocslog = OCSLog.getInstance();
39 |
40 | inputs = new ArrayList<>();
41 |
42 | ocslog.debug("OCSInputs");
43 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
44 | ocslog.debug("OCSInputs BUILD Build.VERSION.SDK_INT ");
45 | Configuration config = ctx.getResources().getConfiguration();
46 | ocslog.debug("config.keyboard " + config.keyboard);
47 | ocslog.debug("config.touchscreen " + config.touchscreen);
48 |
49 | OCSInput inkb = new OCSInput();
50 | inkb.setType("keybord");
51 | switch (config.keyboard) {
52 | case Configuration.KEYBOARD_QWERTY:
53 | inkb.setCaption("Keyboard querty");
54 | break;
55 | case Configuration.KEYBOARD_12KEY:
56 | inkb.setCaption("Keyboard 12 keys");
57 | break;
58 | case Configuration.KEYBOARD_NOKEYS:
59 | inkb.setCaption("No hardware keys");
60 | break;
61 | default:
62 | break;
63 | }
64 | inputs.add(inkb);
65 |
66 | OCSInput ocsin = new OCSInput();
67 | ocsin.setType("Touchscreeen");
68 | switch (config.touchscreen) {
69 | case Configuration.TOUCHSCREEN_STYLUS:
70 | ocsin.setCaption("Stylus touchscreen");
71 | break;
72 | case Configuration.TOUCHSCREEN_FINGER:
73 | ocsin.setCaption("Finger touchscreen");
74 | break;
75 | case Configuration.TOUCHSCREEN_NOTOUCH:
76 | ocsin.setCaption("NO touchscreen");
77 | break;
78 | default:
79 | break;
80 | }
81 | inputs.add(ocsin);
82 | }
83 |
84 |
85 | // About cameras
86 | ocslog.debug("Search camera infos on build : " + Build.VERSION.SDK_INT);
87 |
88 | int numberOfCameras = Camera.getNumberOfCameras();
89 | ocslog.debug("Number of cameras : " + numberOfCameras);
90 | Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
91 | for (int i = 0; i < numberOfCameras; i++) {
92 | OCSInput ocsci = new OCSInput();
93 | String sSz = getCameraMaxImgSize(openCamera(i));
94 | ocsci.setType("Camera");
95 | Camera.getCameraInfo(i, cameraInfo);
96 | if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
97 | ocsci.setCaption("facing back");
98 | } else {
99 | ocsci.setCaption("facing front");
100 | }
101 | ocsci.setDescription("Image size " + sSz);
102 | inputs.add(ocsci);
103 | }
104 |
105 | ocslog.debug("OCSInputs done");
106 | }
107 |
108 | private Camera openCamera(int idx) {
109 | try {
110 | return Camera.open(idx);
111 | } catch (RuntimeException e) {
112 | return null;
113 | }
114 | }
115 |
116 |
117 | private String getCameraMaxImgSize(Camera cam) {
118 | if (cam == null) {
119 | return "busy";
120 | }
121 | Camera.Parameters params = cam.getParameters();
122 | long max_v = 0;
123 | Camera.Size max_sz = null;
124 | for (Camera.Size sz : params.getSupportedPictureSizes()) {
125 | long v = sz.height * sz.width;
126 | android.util.Log.d("OCSINPUT", String.valueOf(v));
127 | if (v > max_v) {
128 | max_v = v;
129 | max_sz = sz;
130 | }
131 | }
132 | cam.release();
133 | return String.valueOf(max_sz.width) + "x" + String.valueOf(max_sz.height);
134 | }
135 |
136 | public String toXML() {
137 | StringBuilder strOut = new StringBuilder();
138 | for (OCSInput o : inputs) {
139 | strOut.append(o.toXml());
140 | }
141 | return strOut.toString();
142 | }
143 |
144 | public String toString() {
145 | StringBuilder strOut = new StringBuilder();
146 | for (OCSInput o : inputs) {
147 | strOut.append(o.toString());
148 | }
149 | return strOut.toString();
150 | }
151 |
152 | public ArrayList getSections() {
153 | ArrayList lst = new ArrayList<>();
154 | for (OCSInput o : inputs) {
155 | lst.add(o.getSection());
156 | }
157 | return lst;
158 | }
159 |
160 | public String getSectionTag() {
161 | return sectionTag;
162 | }
163 | }
164 |
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/sections/OCSJavaInfos.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.sections;
22 |
23 | import java.util.ArrayList;
24 | import java.util.Locale;
25 | import java.util.Properties;
26 |
27 |
28 | public class OCSJavaInfos implements OCSSectionInterface {
29 | final private String sectionTag = "JAVAINFOS";
30 |
31 | private String javaname;
32 | private String javapathlevel;
33 | private String javacountry;
34 | private String javaclasspath;
35 | private String javahome;
36 |
37 |
38 | public OCSJavaInfos() {
39 |
40 | Properties sp = System.getProperties();
41 | javaname = sp.getProperty("java.vm.name") + sp.getProperty("java.vm.version");
42 | javapathlevel = "";
43 | javacountry = Locale.getDefault().getCountry();
44 | javaclasspath = sp.getProperty("java.class.path");
45 | javahome = sp.getProperty("java.home");
46 | }
47 |
48 | /*
49 |
50 | *
51 | */
52 | public OCSSection getSection() {
53 | OCSSection s = new OCSSection(sectionTag);
54 | s.setAttr("JAVANAME", javaname);
55 | s.setAttr("JAVAPATHLEVEL", javapathlevel);
56 | s.setAttr("JAVACOUNTRY", javacountry);
57 | s.setAttr("JAVACLASSPATH", javaclasspath);
58 | s.setAttr("JAVAHOME", javahome);
59 | s.setTitle(javaname);
60 | return s;
61 | }
62 |
63 | public ArrayList getSections() {
64 | ArrayList lst = new ArrayList<>();
65 | lst.add(getSection());
66 | return lst;
67 | }
68 |
69 | public String toString() {
70 | return getSection().toString();
71 | }
72 |
73 | public String toXML() {
74 | return getSection().toXML();
75 | }
76 |
77 | public String getSectionTag() {
78 | return sectionTag;
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/sections/OCSNetwork.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.sections;
22 |
23 |
24 | public class OCSNetwork {
25 | public static String STATUS_UP = "Up";
26 | public static String STATUS_DOWN = "Down";
27 |
28 | private String description;
29 | private String driver;
30 | private String ipAdress;
31 | private String ipDHCP;
32 | private String ipGateway;
33 | private String ipMask;
34 | private String ipSubnet;
35 | private String macaddr;
36 | private String status;
37 | private String type;
38 | private String speed;
39 | private String dns1;
40 | private String dns2;
41 |
42 | public OCSNetwork(String desc) {
43 | this.description = desc;
44 | }
45 |
46 | /*
47 | * eth0 atl1
48 | * 192.168.0.10
49 | * 192.168.0.254 255.255.255.0
50 | * 192.168.0.0 00:1f:c6:b6:a1:1e
51 | * 0000:02:00.0 Upmacaddr
52 | * Ethernet
53 | */
54 | public OCSSection getSection() {
55 | OCSSection s = new OCSSection("NETWORKS");
56 | s.setAttr("DESCRIPTION", description);
57 | s.setAttr("DRIVER", driver);
58 | s.setAttr("IPADDRESS", ipAdress);
59 | s.setAttr("IPDHCP", ipDHCP);
60 | s.setAttr("IPGATEWAY", ipGateway);
61 | s.setAttr("IPMASK", ipMask);
62 | s.setAttr("IPSUBNET", ipSubnet);
63 | s.setAttr("MACADDR", macaddr);
64 | s.setAttr("STATUS", status);
65 | s.setAttr("TYPE", type);
66 | s.setAttr("SPEED", speed);
67 | s.setTitle(type);
68 | return s;
69 | }
70 |
71 | public String toXml() {
72 | return getSection().toXML();
73 | }
74 |
75 | public String toString() {
76 | return getSection().toString();
77 | }
78 |
79 | public String getDescription() {
80 | return description;
81 | }
82 |
83 | public void setDescription(String description) {
84 | this.description = description;
85 | }
86 |
87 | public String getDriver() {
88 | return driver;
89 | }
90 |
91 | public void setDriver(String driver) {
92 | this.driver = driver;
93 | }
94 |
95 | public String getIpAdress() {
96 | return ipAdress;
97 | }
98 |
99 | public void setIpAdress(String ipAdress) {
100 | this.ipAdress = ipAdress;
101 | }
102 |
103 | public String getIpDHCP() {
104 | return ipDHCP;
105 | }
106 |
107 | public void setIpDHCP(String ipDHCP) {
108 | this.ipDHCP = ipDHCP;
109 | }
110 |
111 | public String getIpGateway() {
112 | return ipGateway;
113 | }
114 |
115 | public void setIpGatewey(String ipGateway) {
116 | this.ipGateway = ipGateway;
117 | }
118 |
119 | public String getIpMask() {
120 | return ipMask;
121 | }
122 |
123 | public void setIpMask(String ipMask) {
124 | this.ipMask = ipMask;
125 | }
126 |
127 | public String getIpSubnet() {
128 | return ipSubnet;
129 | }
130 |
131 | public void setIpSubnet(String ipSubnet) {
132 | this.ipSubnet = ipSubnet;
133 | }
134 |
135 | public String getMacaddr() {
136 | return macaddr;
137 | }
138 |
139 | public void setMacaddr(String macaddr) {
140 | this.macaddr = macaddr;
141 | }
142 |
143 | public String getStatus() {
144 | return status;
145 | }
146 |
147 | public void setStatus(String status) {
148 | this.status = status;
149 | }
150 |
151 | public String getType() {
152 | return type;
153 | }
154 |
155 | public void setType(String type) {
156 | this.type = type;
157 | }
158 |
159 | public String getDns1() {
160 | return dns1;
161 | }
162 |
163 | public void setDns1(String dns1) {
164 | this.dns1 = dns1;
165 | }
166 |
167 | public String getDns2() {
168 | return dns2;
169 | }
170 |
171 | public void setDns2(String dns2) {
172 | this.dns2 = dns2;
173 | }
174 |
175 | public void setSpeed(String speed) {
176 | this.speed = speed;
177 | }
178 | }
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/sections/OCSNetworks.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.sections;
22 |
23 | import android.content.Context;
24 | import android.net.DhcpInfo;
25 | import android.net.wifi.WifiInfo;
26 | import android.net.wifi.WifiManager;
27 | import android.os.Build;
28 |
29 | import org.ocs.android.actions.OCSLog;
30 | import org.ocs.android.actions.Utils;
31 |
32 | import java.net.InetAddress;
33 | import java.net.NetworkInterface;
34 | import java.net.SocketException;
35 | import java.util.ArrayList;
36 | import java.util.Enumeration;
37 |
38 | public class OCSNetworks implements OCSSectionInterface {
39 | final private String sectionTag = "NETWORKS";
40 | private ArrayList networks;
41 |
42 | public OCSNetworks(Context ctx) {
43 | OCSLog ocslog = OCSLog.getInstance();
44 |
45 | this.networks = new ArrayList<>();
46 |
47 | WifiManager wifii = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE);
48 | if (wifii != null) {
49 | if (wifii.getWifiState() == WifiManager.WIFI_STATE_UNKNOWN) {
50 | return;
51 | }
52 | if (wifii.isWifiEnabled()) {
53 | DhcpInfo d = wifii.getDhcpInfo();
54 |
55 | OCSNetwork netw = new OCSNetwork("Wifi/3G interface");
56 |
57 | if (wifii.getWifiState() == WifiManager.WIFI_STATE_ENABLED) {
58 | netw.setStatus(OCSNetwork.STATUS_UP);
59 | } else {
60 | netw.setStatus(OCSNetwork.STATUS_DOWN);
61 | }
62 |
63 | netw.setIpAdress(Utils.intToIp(d.ipAddress));
64 | netw.setIpGatewey(Utils.intToIp(d.gateway));
65 | netw.setIpMask(Utils.intToIp(d.netmask));
66 | netw.setIpDHCP(Utils.intToIp(d.serverAddress));
67 |
68 | WifiInfo wInfos = wifii.getConnectionInfo();
69 | netw.setMacaddr(wInfos.getMacAddress());
70 | netw.setDriver("Wifi");
71 | netw.setType("Wifi");
72 |
73 | String speed = String.valueOf(wInfos.getLinkSpeed());
74 | netw.setSpeed(speed + " Mb/s");
75 |
76 | //String s_dns1="DNS 1: "+String.valueOf(d.dns1);
77 | //String s_dns2="DNS 2: "+String.valueOf(d.dns2);
78 |
79 | networks.add(netw);
80 | }
81 | }
82 |
83 | // Check non wifi address, this method will return less informations, but at least we
84 | // have all the ip
85 | Enumeration listeNI;
86 | try {
87 | listeNI = NetworkInterface.getNetworkInterfaces();
88 | } catch (SocketException e) {
89 | ocslog.error("Error : during call getNetworkInterfaces()");
90 | ocslog.error(e.getMessage());
91 | return;
92 | }
93 | while (listeNI.hasMoreElements()) {
94 | NetworkInterface ni = listeNI.nextElement();
95 | Enumeration listeIPAdr = ni.getInetAddresses();
96 | String name = ni.getName();
97 |
98 | ocslog.debug("OCSNET Name :" + ni.getName());
99 |
100 | while (listeIPAdr.hasMoreElements()) {
101 | InetAddress ipAdr = listeIPAdr.nextElement();
102 | if (!ipAdr.isLoopbackAddress() && !ipAdr.isLinkLocalAddress()) {
103 | OCSNetwork netw = new OCSNetwork(name);
104 | netw.setIpAdress(ipAdr.getHostAddress());
105 |
106 | try {
107 | netw.setMacaddr(Utils.bytesToHex(ni.getHardwareAddress()));
108 | } catch (SocketException ignored) {
109 | }
110 | // this ip may be already presents as a wifi address
111 | boolean isWifi = false;
112 | for (OCSNetwork tmp : networks) {
113 | if (tmp.getIpAdress().equals(netw.getIpAdress())) {
114 | isWifi = true;
115 | break;
116 | }
117 | }
118 | if (!isWifi) {
119 | networks.add(netw);
120 | }
121 | }
122 | }
123 | }
124 | }
125 |
126 | /*
127 | * ex Linux
128 |
129 | eth0
130 | atl1
131 | 192.168.0.10
132 |
133 | 192.168.0.254
134 | 255.255.255.0
135 | 192.168.0"SIMS".0
136 | 00:1f:c6:b6:a1:1e
137 | 0000:02:00.0
138 | Up
139 | Ethernet
140 |
141 |
142 | */
143 | public String toXML() {
144 | StringBuilder strOut = new StringBuilder();
145 | for (OCSNetwork o : networks) {
146 | strOut.append(o.toXml());
147 | }
148 | return strOut.toString();
149 | }
150 |
151 | public String toString() {
152 | StringBuilder strOut = new StringBuilder();
153 | for (OCSNetwork o : networks) {
154 | strOut.append(o.toString());
155 | }
156 | return strOut.toString();
157 | }
158 |
159 | public int getMain() {
160 | return 0;
161 | }
162 |
163 | public ArrayList getNetworks() {
164 | return networks;
165 | }
166 |
167 | public ArrayList getSections() {
168 | ArrayList lst = new ArrayList<>();
169 | for (OCSNetwork o : networks) {
170 | lst.add(o.getSection());
171 | }
172 | return lst;
173 | }
174 |
175 | public String getSectionTag() {
176 | return sectionTag;
177 | }
178 | }
179 |
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/sections/OCSSection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.sections;
22 |
23 | import org.ocs.android.actions.OCSLog;
24 |
25 | import java.util.HashMap;
26 | import java.util.Map;
27 |
28 | public class OCSSection {
29 | private String name; // Section name ie BIOS
30 | private String titre; // Section title for display
31 | private Map attrs;
32 | private OCSLog ocslog = OCSLog.getInstance();
33 |
34 | public OCSSection(String pName) {
35 | name = pName;
36 | attrs = new HashMap<>();
37 | }
38 |
39 | public void setAttr(String k, String v) {
40 | attrs.put(k, v);
41 | }
42 |
43 | public String toXML() {
44 | StringBuffer strOut = new StringBuffer(" <");
45 | strOut.append(name);
46 | strOut.append(">\n");
47 | for (String k : attrs.keySet()) {
48 | String v = attrs.get(k);
49 | xmlLine(strOut, k, v);
50 | }
51 | strOut.append(" ");
52 | strOut.append(name);
53 | strOut.append(">\n");
54 | return strOut.toString();
55 | }
56 |
57 | public String toString() {
58 | StringBuilder strOut = new StringBuilder("");
59 | for (String k : attrs.keySet()) {
60 | ocslog.debug("Key : " + k);
61 | String v = attrs.get(k);
62 | ocslog.debug("Val : " + v);
63 | if (v != null) {
64 | strOut.append(k).append(": ").append(v).append("\n");
65 | }
66 | }
67 | return strOut.toString();
68 | }
69 |
70 | public String getTitle() {
71 | return titre;
72 | }
73 |
74 | public void setTitle(String t) {
75 | titre = t;
76 | }
77 |
78 | private void xmlLine(StringBuffer sbOut, String tag, String val) {
79 | xmlLine(sbOut, 6, tag, val);
80 | }
81 |
82 | private void xmlLine(StringBuffer sbOut, int n, String tag, String val) {
83 | for (int i = 0; i < n; i++) {
84 | sbOut.append(' ');
85 | }
86 | if (val == null) {
87 | sbOut.append('<').append(tag).append("/>\n");
88 | } else {
89 | sbOut.append('<').append(tag).append('>').append(val).append("").append(tag).append(">\n");
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/sections/OCSSectionInterface.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.sections;
22 |
23 | import java.util.ArrayList;
24 |
25 | /**
26 | * Generic interface for OCS sections (part of inventory)
27 | */
28 | public interface OCSSectionInterface {
29 | /**
30 | * Name of the section
31 | *
32 | * @return Name of the section
33 | */
34 | String getSectionTag();
35 |
36 | /**
37 | *
38 | * @return Section[]
39 | */
40 | ArrayList getSections();
41 |
42 | String toString();
43 |
44 | String toXML();
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/sections/OCSSims.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.sections;
22 |
23 | import android.content.Context;
24 | import android.telephony.TelephonyManager;
25 |
26 | import org.ocs.android.actions.OCSLog;
27 |
28 | import java.util.ArrayList;
29 |
30 |
31 | public class OCSSims implements OCSSectionInterface {
32 | final private String sectionTag = "SIM";
33 | private String simcountry;
34 | private String simoperator;
35 | private String simopname;
36 | private String simserial;
37 | private String device_id;
38 | private String phonenumber;
39 |
40 | public OCSSims(Context ctx) {
41 | OCSLog ocslog = OCSLog.getInstance();
42 | TelephonyManager mng = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
43 | ocslog.debug("Get TelephonyManager infos");
44 | if (mng == null) {
45 | ocslog.error("TelephonyManager information not found");
46 | } else {
47 | device_id = mng.getDeviceId();
48 | simcountry = mng.getSimCountryIso();
49 | simoperator = mng.getSimOperator();
50 | simopname = mng.getSimOperatorName();
51 | simserial = mng.getSimSerialNumber();
52 | phonenumber = mng.getLine1Number();
53 | ocslog.debug("device_id : " + device_id);
54 | }
55 | }
56 |
57 | /*
58 | *
59 | *
60 | */
61 | public OCSSection getSection() {
62 | OCSSection s = new OCSSection(sectionTag);
63 | s.setAttr("OPERATOR", simoperator);
64 | s.setAttr("OPNAME", simopname);
65 | s.setAttr("COUNTRY", simcountry);
66 | s.setAttr("SERIALNUMBER", simserial);
67 | s.setAttr("DEVICEID", device_id);
68 | s.setAttr("PHONENUMBER", phonenumber);
69 | s.setTitle(simserial);
70 | return s;
71 | }
72 |
73 | public ArrayList getSections() {
74 | ArrayList lst = new ArrayList<>();
75 | lst.add(getSection());
76 | return lst;
77 | }
78 |
79 | public String toString() {
80 | return getSection().toString();
81 | }
82 |
83 | public String toXML() {
84 | return getSection().toXML();
85 | }
86 |
87 | public String getSectionTag() {
88 | return sectionTag;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/sections/OCSSoftware.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.sections;
22 |
23 |
24 | public class OCSSoftware {
25 | private String comments;
26 | private String filesize;
27 | private String folder;
28 | private String installDate;
29 | private String name;
30 | private String publisher;
31 | private String version;
32 |
33 | public OCSSection getSection() {
34 | OCSSection s = new OCSSection("SOFTWARES");
35 | s.setAttr("PUBLISHER", publisher);
36 | s.setAttr("NAME", name);
37 | s.setAttr("VERSION", version);
38 | s.setAttr("FOLDER", folder);
39 | s.setAttr("FILESIZE", filesize);
40 | s.setAttr("COMMENTS", "");
41 | s.setAttr("INSTALLDATE", "");
42 | s.setTitle(name);
43 | return s;
44 | }
45 |
46 | public String toXml() {
47 | return getSection().toXML();
48 | }
49 |
50 | public String toString() {
51 | return getSection().toString();
52 | }
53 |
54 | public String getComments() {
55 | return comments;
56 | }
57 |
58 | public void setComments(String comments) {
59 | this.comments = comments;
60 | }
61 |
62 | public String getFilesize() {
63 | return filesize;
64 | }
65 |
66 | public void setFilesize(String filesize) {
67 | this.filesize = filesize;
68 | }
69 |
70 | public String getFolder() {
71 | return folder;
72 | }
73 |
74 | public void setFolder(String folder) {
75 | this.folder = folder;
76 | }
77 |
78 | public String getInstallDate() {
79 | return installDate;
80 | }
81 |
82 | public void setInstallDate(String installDate) {
83 | this.installDate = installDate;
84 | }
85 |
86 | public String getName() {
87 | return name;
88 | }
89 |
90 | public void setName(String name) {
91 | this.name = name;
92 | }
93 |
94 | public String getPublisher() {
95 | return publisher;
96 | }
97 |
98 | public void setPublisher(String publisher) {
99 | this.publisher = publisher;
100 | }
101 |
102 | public String getVersion() {
103 | return version;
104 | }
105 |
106 | public void setVersion(String version) {
107 | this.version = version;
108 | }
109 | }
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/sections/OCSSoftwares.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.sections;
22 |
23 | import android.content.Context;
24 | import android.content.pm.ApplicationInfo;
25 | import android.content.pm.PackageInfo;
26 | import android.content.pm.PackageManager;
27 | import android.content.pm.PackageManager.NameNotFoundException;
28 | import android.content.pm.PackageStats;
29 | import android.content.pm.ProviderInfo;
30 | import android.os.Build;
31 | import android.text.format.DateFormat;
32 |
33 | import org.ocs.android.actions.OCSLog;
34 | import org.ocs.android.actions.OCSSettings;
35 |
36 | import java.util.ArrayList;
37 | import java.util.List;
38 | import java.util.Properties;
39 |
40 | public class OCSSoftwares implements OCSSectionInterface {
41 | final private String sectionTag = "SOFTWARES";
42 | private ArrayList softs;
43 |
44 | public OCSSoftwares(Context ctx) {
45 | OCSLog ocslog = OCSLog.getInstance();
46 | softs = new ArrayList<>();
47 |
48 | PackageManager pm = ctx.getPackageManager();
49 | List pis = ctx.getPackageManager().getInstalledPackages(
50 | PackageManager.GET_ACTIVITIES | PackageManager.GET_PROVIDERS);
51 | for (PackageInfo pi : pis) {
52 | // Exclude systeme softwares i required
53 | if (OCSSettings.getInstance(ctx).isSysHide() && (pi.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
54 | continue;
55 | }
56 | OCSSoftware oSoft = new OCSSoftware();
57 | try {
58 | PackageInfo lpInfo = pm.getPackageInfo(pi.packageName,
59 | PackageManager.GET_ACTIVITIES | PackageManager.GET_PROVIDERS);
60 |
61 | ocslog.debug("PKG name " + lpInfo.packageName);
62 | ocslog.debug("PKG version " + String.valueOf(lpInfo.versionCode));
63 | ocslog.debug("PKG version name " + lpInfo.versionName);
64 | oSoft.setVersion(lpInfo.versionName);
65 | oSoft.setPublisher(lpInfo.packageName);
66 | } catch (NameNotFoundException e) {
67 | ocslog.error("Error :" + e.getMessage());
68 | }
69 | PackageStats stats = new PackageStats(pi.packageName);
70 | ocslog.debug("PKG size " + String.valueOf(stats.codeSize));
71 | ocslog.debug("PKG folder " + pi.applicationInfo.dataDir);
72 | oSoft.setFilesize(String.valueOf(stats.codeSize));
73 | oSoft.setFolder(pi.applicationInfo.dataDir);
74 |
75 | if (pi.applicationInfo.name != null) {
76 | oSoft.setName(pi.applicationInfo.name);
77 | } else if (pi.applicationInfo.className != null) {
78 | oSoft.setName(pi.applicationInfo.className);
79 | } else {
80 | String v[] = oSoft.getPublisher().split("\\.");
81 | if (v.length > 0) {
82 | oSoft.setName(v[v.length - 1]);
83 | } else {
84 | oSoft.setName(oSoft.getPublisher());
85 | }
86 | }
87 | ocslog.debug("PKG appname " + oSoft.getName());
88 |
89 | if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) {
90 | String datei = (String) DateFormat.format("MM/dd/yy mm:ss", pi.firstInstallTime);
91 | ocslog.debug("PKG INSTALL :" + datei);
92 | oSoft.setInstallDate(datei);
93 | }
94 | ProviderInfo[] provsi = pi.providers;
95 |
96 | if (provsi != null) {
97 | for (ProviderInfo aProvsi : provsi) {
98 | ocslog.debug("PKG Provider " + aProvsi.authority);
99 | if (aProvsi.descriptionRes != 0) {
100 | ocslog.debug("PKG Desc " + String.valueOf(aProvsi.descriptionRes));
101 | }
102 | }
103 | if (provsi.length > 0) {
104 | oSoft.setPublisher(provsi[0].authority);
105 | }
106 | }
107 | softs.add(oSoft);
108 | }
109 | Properties sp = System.getProperties();
110 | OCSSoftware jsoft = new OCSSoftware();
111 | jsoft.setName(sp.getProperty("java.vm.name"));
112 | jsoft.setVersion(sp.getProperty("java.vm.version"));
113 | jsoft.setFolder(sp.getProperty("java.home"));
114 | jsoft.setPublisher(sp.getProperty("java.vm.vendor"));
115 | jsoft.setFilesize("n.a");
116 | jsoft.setInstallDate("n.a.");
117 | softs.add(jsoft);
118 | }
119 |
120 | public String toXML() {
121 | StringBuilder strOut = new StringBuilder();
122 | for (OCSSoftware o : softs) {
123 | strOut.append(o.toXml());
124 | }
125 | return strOut.toString();
126 | }
127 |
128 | public String toString() {
129 | StringBuilder strOut = new StringBuilder();
130 | for (OCSSoftware o : softs) {
131 | strOut.append(o.toString());
132 | }
133 | return strOut.toString();
134 | }
135 |
136 | public ArrayList getSections() {
137 | ArrayList lst = new ArrayList<>();
138 | for (OCSSoftware o : softs) {
139 | lst.add(o.getSection());
140 | }
141 | return lst;
142 | }
143 |
144 | public String getSectionTag() {
145 | return sectionTag;
146 | }
147 | }
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/sections/OCSStorage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.sections;
22 |
23 | import android.os.StatFs;
24 |
25 | import java.io.File;
26 |
27 | public class OCSStorage {
28 | private String description;
29 | private long disksize;
30 | private String firmware = null;
31 | private String manufacturer = "NA";
32 | private String model = "NA";
33 | private String name = "NA";
34 | private String serialnumber = null;
35 | private String type = "ROM";
36 |
37 | public OCSStorage(File d, String description) {
38 | String pathESD = d.getPath();
39 | StatFs statfs = new StatFs(pathESD);
40 | long bs = statfs.getBlockSize();
41 | long bc = statfs.getBlockCount();
42 |
43 | this.description = description;
44 | this.disksize = bs * bc / 1048576L;
45 | }
46 |
47 | /*
48 | * Exemple Linux IDE
49 | * 801
50 | * PNY USB2.0 FD
51 | *
52 | * disk
53 | *
55 | */
56 | public OCSSection getSection() {
57 | OCSSection s = new OCSSection("STORAGES");
58 | s.setAttr("DESCRIPTION", description);
59 | s.setAttr("DISKSIZE", String.valueOf(disksize));
60 | s.setAttr("FIRMWARE", firmware);
61 | s.setAttr("MANUFACTURER", manufacturer);
62 | s.setAttr("MODEL", model);
63 | s.setAttr("NAME", name);
64 | s.setAttr("SERIALNUMBER", serialnumber);
65 | s.setAttr("TYPE", type);
66 | s.setTitle(description);
67 | return s;
68 | }
69 |
70 | public String toXml() {
71 | return getSection().toXML();
72 | }
73 |
74 | public String toString() {
75 | return getSection().toString();
76 | }
77 |
78 | public String getDescription() {
79 | return description;
80 | }
81 |
82 | public void setDescription(String description) {
83 | this.description = description;
84 | }
85 |
86 | public long getDisksize() {
87 | return disksize;
88 | }
89 |
90 | public void setDisksize(long disksize) {
91 | this.disksize = disksize;
92 | }
93 |
94 | public String getFirmware() {
95 | return firmware;
96 | }
97 |
98 | public void setFirmware(String firmware) {
99 | this.firmware = firmware;
100 | }
101 |
102 | public String getManufacturer() {
103 | return manufacturer;
104 | }
105 |
106 | public void setManufacturer(String manufacturer) {
107 | this.manufacturer = manufacturer;
108 | }
109 |
110 | public String getModel() {
111 | return model;
112 | }
113 |
114 | public void setModel(String model) {
115 | this.model = model;
116 | }
117 |
118 | public String getName() {
119 | return name;
120 | }
121 |
122 | public void setName(String name) {
123 | this.name = name;
124 | }
125 |
126 | public String getSerialnumber() {
127 | return serialnumber;
128 | }
129 |
130 | public void setSerialnumber(String serialnumber) {
131 | this.serialnumber = serialnumber;
132 | }
133 |
134 | public String getType() {
135 | return type;
136 | }
137 |
138 | public void setType(String type) {
139 | this.type = type;
140 | }
141 | }
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/sections/OCSStorages.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.sections;
22 |
23 | import android.os.Environment;
24 |
25 | import java.util.ArrayList;
26 |
27 | public class OCSStorages implements OCSSectionInterface {
28 | final private String sectionTag = "STORAGES";
29 |
30 | private ArrayList storages;
31 |
32 | public OCSStorages() {
33 | storages = new ArrayList<>();
34 |
35 | OCSStorage stExternal = new OCSStorage(Environment.getExternalStorageDirectory(), "External storage");
36 | OCSStorage stInternal = new OCSStorage(Environment.getDataDirectory(), "Internal storage");
37 | storages.add(stExternal);
38 | storages.add(stInternal);
39 | }
40 |
41 | public String toXML() {
42 | StringBuilder strOut = new StringBuilder();
43 | for (OCSStorage o : storages) {
44 | strOut.append(o.toXml());
45 | }
46 | return strOut.toString();
47 | }
48 |
49 | public String toString() {
50 | StringBuilder strOut = new StringBuilder();
51 | for (OCSStorage o : storages) {
52 | strOut.append(o.toString());
53 | }
54 | return strOut.toString();
55 | }
56 |
57 | public ArrayList getSections() {
58 | ArrayList lst = new ArrayList<>();
59 | for (OCSStorage o : storages) {
60 | lst.add(o.getSection());
61 | }
62 | return lst;
63 | }
64 |
65 | public String getSectionTag() {
66 | return sectionTag;
67 | }
68 | }
--------------------------------------------------------------------------------
/app/src/main/java/org/ocs/android/sections/OCSVideos.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2016 OCSInventory-NG/AndroidAgent contributors : mortheres, cdpointpoint,
3 | * Cédric Cabessa, Nicolas Ricquemaque, Anael Mobilia
4 | *
5 | * This file is part of OCSInventory-NG/AndroidAgent.
6 | *
7 | * OCSInventory-NG/AndroidAgent is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * OCSInventory-NG/AndroidAgent is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with OCSInventory-NG/AndroidAgent. if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 | */
21 | package org.ocs.android.sections;
22 |
23 | import android.content.Context;
24 | import android.util.DisplayMetrics;
25 | import android.view.Display;
26 | import android.view.WindowManager;
27 |
28 | import java.util.ArrayList;
29 |
30 | public class OCSVideos implements OCSSectionInterface {
31 | final private String sectionTag = "VIDEOS";
32 |
33 | private String resolution;
34 | private String name = "Embedded display";
35 |
36 | public OCSVideos(Context ctx) {
37 | DisplayMetrics localDisplayMetrics = new DisplayMetrics();
38 | WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
39 | Display disp = wm.getDefaultDisplay();
40 | disp.getMetrics(localDisplayMetrics);
41 | resolution = String.valueOf(localDisplayMetrics.widthPixels) + "*" + String.valueOf(
42 | localDisplayMetrics.heightPixels);
43 | }
44 |
45 | public OCSSection getSection() {
46 | OCSSection s = new OCSSection("VIDEOS");
47 | s.setAttr("NAME", name);
48 | s.setAttr("RESOLUTION", resolution);
49 | s.setTitle(name);
50 | return s;
51 | }
52 |
53 | public String toXML() {
54 | return getSection().toXML();
55 | }
56 |
57 | public String toString() {
58 | return getSection().toString();
59 | }
60 |
61 | public ArrayList getSections() {
62 | ArrayList lst = new ArrayList<>();
63 | lst.add(getSection());
64 | return lst;
65 | }
66 |
67 | public String getSectionTag() {
68 | return sectionTag;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_menu_goto.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-hdpi/ic_menu_goto.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_menu_info_details.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-hdpi/ic_menu_info_details.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_menu_moreoverflow_normal_holo_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-hdpi/ic_menu_moreoverflow_normal_holo_dark.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_menu_set_as.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-hdpi/ic_menu_set_as.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_sysbar_quicksettings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-hdpi/ic_sysbar_quicksettings.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-ldpi/ic_menu_goto.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-ldpi/ic_menu_goto.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-ldpi/ic_menu_info_details.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-ldpi/ic_menu_info_details.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-ldpi/ic_menu_moreoverflow_normal_holo_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-ldpi/ic_menu_moreoverflow_normal_holo_dark.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-ldpi/ic_menu_set_as.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-ldpi/ic_menu_set_as.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-ldpi/ic_sysbar_quicksettings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-ldpi/ic_sysbar_quicksettings.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_menu_goto.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-mdpi/ic_menu_goto.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_menu_info_details.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-mdpi/ic_menu_info_details.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_menu_moreoverflow_normal_holo_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-mdpi/ic_menu_moreoverflow_normal_holo_dark.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_menu_set_as.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-mdpi/ic_menu_set_as.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_sysbar_quicksettings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-mdpi/ic_sysbar_quicksettings.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_menu_goto.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-xhdpi/ic_menu_goto.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_menu_info_details.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-xhdpi/ic_menu_info_details.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_menu_moreoverflow_normal_holo_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-xhdpi/ic_menu_moreoverflow_normal_holo_dark.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_menu_set_as.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-xhdpi/ic_menu_set_as.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_sysbar_quicksettings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-xhdpi/ic_sysbar_quicksettings.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_menu_goto.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-xxhdpi/ic_menu_goto.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_menu_info_details.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-xxhdpi/ic_menu_info_details.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_menu_moreoverflow_normal_holo_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-xxhdpi/ic_menu_moreoverflow_normal_holo_dark.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_menu_set_as.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-xxhdpi/ic_menu_set_as.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_sysbar_quicksettings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-xxhdpi/ic_sysbar_quicksettings.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_menu_goto.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-xxxhdpi/ic_menu_goto.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_menu_info_details.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-xxxhdpi/ic_menu_info_details.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_menu_moreoverflow_normal_holo_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-xxxhdpi/ic_menu_moreoverflow_normal_holo_dark.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_menu_set_as.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-xxxhdpi/ic_menu_set_as.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_sysbar_quicksettings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable-xxxhdpi/ic_sysbar_quicksettings.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/button_effect.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 |
11 | -
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_notification.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable/ic_notification.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_ocs_android.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable/ic_ocs_android.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ocs_landscape.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/app/src/main/res/drawable/ocs_landscape.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/about.xml:
--------------------------------------------------------------------------------
1 |
23 |
26 |
27 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/actvity_show_inventory.xml:
--------------------------------------------------------------------------------
1 |
23 |
27 |
28 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_header.xml:
--------------------------------------------------------------------------------
1 |
23 |
27 |
28 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item.xml:
--------------------------------------------------------------------------------
1 |
23 |
27 |
28 |
33 |
34 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/ocs_agent.xml:
--------------------------------------------------------------------------------
1 |
23 |
29 |
30 |
38 |
39 |
52 |
53 |
62 |
63 |
74 |
75 |
86 |
87 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/ocs_install_package.xml:
--------------------------------------------------------------------------------
1 |
23 |
27 |
28 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/activity_main.xml:
--------------------------------------------------------------------------------
1 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/values-de/strings.xml:
--------------------------------------------------------------------------------
1 |
23 |
24 | Konfiguration
25 | Import
26 | Export
27 | Info
28 |
29 |
30 | Bereit
31 | Inventarisierung senden
32 | Inventarisierung anzeigen
33 | Inventarisierung speichern
34 | OCS Konfigurationszustand
35 | OCSInventory\nNG
36 | Zeige Inventarisierungszustand
37 | Inventarisierung auf der SD-Karte gespeichert
38 | Prolog an Server senden
39 | Inventarisierung an den Server senden
40 | Inventarisierung übertragen
41 | Übertragungsfehler
42 | Übertragung
43 | Aktuelle Inventarisierung
44 |
45 | Inventarisierung an den Server senden
46 | OCS-NG Benachrichtigung
47 |
48 | Konfiguration exportiert
49 | Konfiguration importiert
50 |
51 | Stunden
52 | Minuten
53 |
54 | Unmögliche Verbindung auf :
55 | Heruntergeladene Pakete availables
56 | Useragent 2.0 für Vereinbarkeit
57 | Strom useragent
58 | Benutzer-Agent 2.0
59 | Useragent Vereinbarkeit
60 | Installation
61 | Starten des Update-Service
62 | Sie müssen alle Berechtigungen akzeptieren
63 |
64 |
65 |
--------------------------------------------------------------------------------
/app/src/main/res/values-de/strings_prefs.xml:
--------------------------------------------------------------------------------
1 |
23 |
24 |
25 | Allgemein
26 | Debug
27 | Erzeuge eine Trace-Datei auf der SD-Karte
28 | TAG
29 | Kategoriename (TAG) in OCS
30 | Smartphone
31 | Automatikmodus
32 | Automatische Inventarisierung
33 |
34 | Abhängig von der Netzwerkstatus
35 | Data oder WIFI, kein roaming
36 | Data oder WIFI, alles Netze
37 | Nur WIFI
38 |
39 | Inventarisierungsintervall
40 | Zeitraum in Stunden
41 | Häufigkeit der Inventarisierung
42 | Wake-Up Interval
43 | Überprüfungszeitraum
44 | Häufigkeit in Minuten
45 |
46 | Server
47 | URL des Servers
48 | URL des OCS Servers
49 | http://ocsinventory-ng.org/ocsinventory
50 | ein
51 | aus
52 | SSL Kontrolle
53 |
54 | Proxy http
55 | Adresse
56 | IP-Adresse des Proxy
57 | Port
58 | Port des Proxy
59 |
60 | Authentifizierung
61 | Benutzername
62 | Passwort
63 |
64 | Cache
65 | Cache für Inventarisierungen auf dem Smartphone
66 |
67 | Interval
68 | Haltbarkeit des Cache
69 |
70 | 5 Minuten
71 | 15 Minuten
72 | 30 Minuten
73 | 1 Stunde
74 |
75 | System software
76 | Ausschließen System Software von Inventarisierung
77 | Ausgeschlossen von Inventarisierung
78 | Im Inventarisierung
79 |
80 | Verbergung Meldungen
81 | Keine
82 | Inventare
83 | Downloads
84 | All
85 |
86 |
87 |
--------------------------------------------------------------------------------
/app/src/main/res/values-fr/strings.xml:
--------------------------------------------------------------------------------
1 |
23 |
24 | Configuration
25 | Import de la configuration
26 | Export de la configuration
27 | A propos
28 |
29 |
30 | Prêt
31 | Envoyer l\'inventaire
32 | Afficher l\'inventaire
33 | Enregistrer l\'inventaire
34 | Configuration
35 | OCSInventory\nNG
36 | Inventaire
37 | Inventaire enregistré sur la carte SD
38 | Envoi du prolog au serveur
39 | Envoi de l\'inventaire au serveur
40 | Inventaire transmis
41 | Erreur de transmission
42 | Transmission
43 | Inventaire en cours
44 |
45 | Inventaire transmis au serveur OCS
46 | Notification OCS-NG
47 |
48 | Configuration exportée
49 | Configuration importée
50 |
51 | heures
52 | minutes
53 |
54 | Impossible de contacter :
55 | Paquets téléchargés disponibles
56 | Ne pas inclure les logiciels systèmes
57 | Installation
58 | Lancement du service d\'update
59 | Vous devez accepter toutes les permissions
60 |
61 |
62 |
--------------------------------------------------------------------------------
/app/src/main/res/values-fr/strings_prefs.xml:
--------------------------------------------------------------------------------
1 |
23 |
24 |
25 | Général
26 | Débug
27 | Produit un fichier de trace sur la carte SD
28 | TAG
29 | Catégorie (TAG) dans OCS
30 | Smartphone
31 | Mode automatique
32 | Inventaire automatique
33 |
34 | En fonction du réseau
35 | Data ou WIFI, sauf en roaming
36 | Data ou WIFI, tous réseaux
37 | WIFI seulement
38 |
39 | Fréquence d\'inventaire
40 | Intervalle en heures
41 | Fréquence d\'envoi de l\'inventaire
42 | Fréquence de réveil
43 | Intervalle de vérification
44 | Intervalle en minutes
45 |
46 | Serveur
47 | URL du serveur
48 | URL du serveur OCS
49 | http://ocsinventory-ng/ocsinventory
50 | Activé
51 | Désactivé
52 | Contrôle SSL
53 |
54 | Proxy HTTP
55 | Adresse
56 | Adresse IP du proxy
57 | Port
58 | Port du proxy
59 |
60 | Authentification
61 | Identifiant
62 | Mot de passe
63 |
64 | Cache
65 | Cache de l\'inventaire sur l\'appareil
66 |
67 | Durée de vie du cache
68 | Durée de vie du cache
69 |
70 | 5 minutes
71 | 15 minutes
72 | 30 minutes
73 | 1 heure
74 |
75 | Logiciels système
76 | Exclus de l\'inventaire
77 | Inclus dans l\'inventaire
78 |
79 | Compatibilité de l\'agent
80 | Agent v2.0 (compatibilité)
81 | Agent v2.0
82 | Agent actuel
83 |
84 | Cacher les notifications
85 | Aucune
86 | Inventaires
87 | Téléchargements
88 | Toutes
89 |
90 |
91 |
--------------------------------------------------------------------------------
/app/src/main/res/values/arrays.xml:
--------------------------------------------------------------------------------
1 |
23 |
24 |
25 | - @string/pref_list_freq_5mn
26 | - @string/pref_list_freq_15mn
27 | - @string/pref_list_freq_30mn
28 | - @string/pref_list_freq_1h
29 |
30 |
31 |
32 | - 300000
33 | - 900000
34 | - 1800000
35 | - 3600000
36 |
37 |
38 |
39 | - @string/pref_list_Network_noroaming
40 | - @string/pref_list_Network_any
41 | - @string/pref_list_Network_wifi
42 |
43 |
44 | - 0
45 | - 1
46 | - 2
47 |
48 |
49 |
50 | - @string/pref_list_hideNotif_none
51 | - @string/pref_list_hideNotif_inventory
52 | - @string/pref_list_hideNotif_download
53 | - @string/pref_list_hideNotif_all
54 |
55 |
56 | - 0
57 | - 1
58 | - 2
59 | - 3
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
23 |
24 | #ff97187f
25 |
26 | #D3D3D3
27 |
28 | #FFFFFF
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
23 |
24 | Configuration
25 | Import settings
26 | Export settings
27 | About
28 | Ready
29 | Send inventory
30 | Show inventory
31 | Store inventory
32 | Settings
33 | OCSInventory\nNG
34 | Inventory
35 | Inventory recorded on sdcard
36 | Sending prolog to server
37 | Sending inventory to server
38 | Inventory sent
39 | Transmission Error
40 | Transmission
41 | Inventory in progress
42 | Inventory sent to OCS server
43 | Downloaded packages availables
44 |
45 | OCS-NG notification
46 | Settings exported
47 | Settings imported
48 | hours
49 | minutes
50 | Installation
51 | Unable to connect to :
52 | Start package update service
53 | You must accept all permissions
54 |
55 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings_nt.xml:
--------------------------------------------------------------------------------
1 |
23 |
24 |
25 | OCS-NG Agent
26 |
27 | 24
28 | 10
29 | 900000
30 |
31 | OCS-NG_Android_agent_v2.2
32 | OCS-NG_Android_agent_v2.7
33 | .
34 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings_prefs.xml:
--------------------------------------------------------------------------------
1 |
23 |
24 |
25 | General
26 | Debug
27 | Make a trace file on sdcard
28 | TAG
29 | Category TAG in OCS
30 | Mobile
31 | Automatic
32 | Automatic inventory
33 |
34 | Depending on network status
35 | Data or WIFI, no roaming
36 | Data or WIFI, any network
37 | WIFI only
38 |
39 | Inventory frequency
40 | Delay in hours
41 | Delay between two inventory sent
42 | Wake frequency
43 | Interval between verifications
44 | Delay in minutes
45 |
46 | Server
47 | Server URL
48 | OCS server address
49 | http://ocsinventory-ng.org/ocsinventory
50 | ON
51 | OFF
52 | SSL Control
53 |
54 | Proxy http
55 | Address
56 | Proxy IP address
57 | Port
58 | Proxy TCP port
59 |
60 | Basic authentication
61 | Login
62 | Password
63 |
64 | Cache
65 | Inventory cache on device
66 |
67 | Cache lifetime
68 | Cache live time
69 | 5 minutes
70 | 15 minutes
71 | 30 minutes
72 | one hour
73 |
74 | System software
75 | Exclude system softwares of inventory
76 | Excluded of inventory
77 | Included in inventory
78 |
79 | Useragent compatibility
80 | Useragent 2.0 for compatibility
81 | User agent 2.0
82 | Current useragent
83 |
84 | Hide notifications
85 | None
86 | Inventories
87 | Downloads
88 | All
89 |
90 |
91 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/preferences.xml:
--------------------------------------------------------------------------------
1 |
23 |
24 |
25 |
31 |
36 |
40 |
47 |
54 |
61 |
66 |
74 |
81 |
88 |
94 |
95 |
96 |
97 |
104 |
110 |
111 |
115 |
119 |
124 |
125 |
129 |
134 |
139 |
140 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | buildscript {
3 | repositories {
4 | google()
5 | jcenter()
6 | mavenCentral()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:3.6.3'
10 | }
11 | }
12 |
13 | allprojects {
14 | repositories {
15 | google()
16 | jcenter()
17 |
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OCSInventory-NG/AndroidAgent/d63507d6a3de3e7e91ec109a3cf0bb9be92b4b9b/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 01 09:40:31 CEST 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------