Android Open Source - androiddevice.info Get Prop Property






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.info;
// w w w  .  j ava  2  s  .c  o  m
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

import name.unused.android.utils.systemproperties.SystemProperty;
import name.unused.android.utils.systemproperties.exception.NoSuchPropertyException;
import info.androiddevice.deviceinventory.Application;

public class GetPropProperty implements Property {
    static List<String> whitelist = new ArrayList<String>() {{
        add("ro.product.device");
        add("ro.product.manufacturer");
        add("ro.product.model");
        add("ro.product.name");
        add("ro.board.platform");
        add("ro.boot.hardware");
        add("ro.build.description");
        add("ro.build.display.id");
        add("ro.build.fingerprint");
        add("ro.build.host");
        add("ro.build.id");
        add("ro.build.product");
        add("ro.build.tags");
        add("ro.build.type");
        add("ro.build.user");
        add("ro.build.version.codename");
        add("ro.build.version.incremental");
        add("ro.build.version.release");
        add("ro.build.version.sdk");
        add("ro.product.board");
        add("ro.product.brand");
        add("ro.product.cpu.abi2");
        add("ro.product.cpu.abi");
        add("ro.revision");
    }};


    @Override
    public Object getProperty() {
        JSONObject jsonObject = new JSONObject();
        SystemProperty property = new SystemProperty(Application.getContext());
        for(String key: whitelist) {
            try {
                String value = property.getOrThrow(key);
                jsonObject.put(key, value);
            } catch (NoSuchPropertyException e) {
                try {
                    jsonObject.put(key, JSONObject.NULL);
                } catch (JSONException e1) {}
            } catch (JSONException e) {
                try {
                    jsonObject.put(key, JSONObject.NULL);
                } catch (JSONException e1) {}
            }
        }
        return jsonObject;
    }

    @Override
    public String getName() {
        return "properties";
    }

}




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