Android Open Source - androiddevice.info Device Information






From Project

Back to project page androiddevice.info.

License

The source code is released under:

GNU General Public License

If you think the Android project androiddevice.info listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package info.androiddevice.deviceinventory;
/*  w  ww  .j a  v a 2 s . c om*/

import org.json.JSONException;
import org.json.JSONObject;

import info.androiddevice.deviceinventory.info.DirProperty;
import info.androiddevice.deviceinventory.info.NameProperty;
import info.androiddevice.deviceinventory.info.OtacertsProperty;
import info.androiddevice.deviceinventory.info.PackageSigProperty;
import info.androiddevice.deviceinventory.info.CpuinfoProperty;
import info.androiddevice.deviceinventory.info.DisplayProperty;
import info.androiddevice.deviceinventory.info.EnvironmentProperty;
import info.androiddevice.deviceinventory.info.FeaturesProperty;
import info.androiddevice.deviceinventory.info.GetPropProperty;
import info.androiddevice.deviceinventory.info.JavaSystemProperty;
import info.androiddevice.deviceinventory.info.MeminfoProperty;
import info.androiddevice.deviceinventory.info.MountsProperty;
import info.androiddevice.deviceinventory.info.Property;
import info.androiddevice.deviceinventory.info.SharedLibraryNamesProperty;
import info.androiddevice.deviceinventory.info.UsbProperty;
import info.androiddevice.deviceinventory.info.VersionProperty;

public class DeviceInformation {
    private static DeviceInformation singleton = null;

    public static DeviceInformation getInstance() {
        if(singleton==null)
            singleton = new DeviceInformation();
        return singleton;
    }

    private DeviceInformation() {
    }

    public JSONObject getDeviceInformation() {
        JSONObject jsonObject = new JSONObject();
        addProperty(jsonObject, new MeminfoProperty());
        addProperty(jsonObject, new MountsProperty());
        addProperty(jsonObject, new CpuinfoProperty());
        addProperty(jsonObject, new EnvironmentProperty());
        addProperty(jsonObject, new JavaSystemProperty());
        addProperty(jsonObject, new FeaturesProperty());
        addProperty(jsonObject, new DisplayProperty());
        addProperty(jsonObject, new UsbProperty());
        addProperty(jsonObject, new GetPropProperty());
        addProperty(jsonObject, new PackageSigProperty());
        addProperty(jsonObject, new OtacertsProperty());
        addProperty(jsonObject, new DirProperty());
        addProperty(jsonObject, new VersionProperty());
        addProperty(jsonObject, new SharedLibraryNamesProperty());
        addProperty(jsonObject, new NameProperty());

        return jsonObject;
    }

    private void addProperty(JSONObject jsonObject, Property property) {
        if(jsonObject.has(property.getName())) {
            throw new RuntimeException("property already exists");
        }
        try {
            jsonObject.put(property.getName(), property.getProperty());
        } catch (JSONException e) {
            try {
                jsonObject.put(property.getName(), JSONObject.NULL);
            } catch (JSONException e1) {
                e1.printStackTrace();
            }
        }

    }
}




Java Source Code List

android.system.ErrnoException.java
android.system.Os.java
android.system.StructStat.java
info.androiddevice.deviceinventory.Application.java
info.androiddevice.deviceinventory.DeviceInformation.java
info.androiddevice.deviceinventory.Error.java
info.androiddevice.deviceinventory.info.CpuinfoProperty.java
info.androiddevice.deviceinventory.info.DirProperty.java
info.androiddevice.deviceinventory.info.DisplayProperty.java
info.androiddevice.deviceinventory.info.EnvironmentProperty.java
info.androiddevice.deviceinventory.info.FeaturesProperty.java
info.androiddevice.deviceinventory.info.FileProperty.java
info.androiddevice.deviceinventory.info.GetPropProperty.java
info.androiddevice.deviceinventory.info.JavaSystemProperty.java
info.androiddevice.deviceinventory.info.MeminfoProperty.java
info.androiddevice.deviceinventory.info.MountsProperty.java
info.androiddevice.deviceinventory.info.NameProperty.java
info.androiddevice.deviceinventory.info.OtacertsProperty.java
info.androiddevice.deviceinventory.info.PackageSigProperty.java
info.androiddevice.deviceinventory.info.Property.java
info.androiddevice.deviceinventory.info.SharedLibraryNamesProperty.java
info.androiddevice.deviceinventory.info.UsbProperty.java
info.androiddevice.deviceinventory.info.Utils.java
info.androiddevice.deviceinventory.info.VersionProperty.java
info.androiddevice.deviceinventory.submission.DeviceInformationListAdapter.java
info.androiddevice.deviceinventory.submission.MainActivity.java
libcore.io.ErrnoException.java
libcore.io.Libcore.java
libcore.io.Os.java
libcore.io.StructStat.java
name.unused.android.utils.systemproperties.SystemProperty.java
name.unused.android.utils.systemproperties.exception.NoSuchPropertyException.java