Search in sources :

Example 56 with JSONArray

use of org.json.JSONArray in project platform_frameworks_base by android.

the class FingerprintService method dumpInternal.

private void dumpInternal(PrintWriter pw) {
    JSONObject dump = new JSONObject();
    try {
        dump.put("service", "Fingerprint Manager");
        JSONArray sets = new JSONArray();
        for (UserInfo user : UserManager.get(getContext()).getUsers()) {
            final int userId = user.getUserHandle().getIdentifier();
            final int N = mFingerprintUtils.getFingerprintsForUser(mContext, userId).size();
            PerformanceStats stats = mPerformanceMap.get(userId);
            PerformanceStats cryptoStats = mCryptoPerformanceMap.get(userId);
            JSONObject set = new JSONObject();
            set.put("id", userId);
            set.put("count", N);
            set.put("accept", (stats != null) ? stats.accept : 0);
            set.put("reject", (stats != null) ? stats.reject : 0);
            set.put("acquire", (stats != null) ? stats.acquire : 0);
            set.put("lockout", (stats != null) ? stats.lockout : 0);
            // cryptoStats measures statistics about secure fingerprint transactions
            // (e.g. to unlock password storage, make secure purchases, etc.)
            set.put("acceptCrypto", (cryptoStats != null) ? cryptoStats.accept : 0);
            set.put("rejectCrypto", (cryptoStats != null) ? cryptoStats.reject : 0);
            set.put("acquireCrypto", (cryptoStats != null) ? cryptoStats.acquire : 0);
            set.put("lockoutCrypto", (cryptoStats != null) ? cryptoStats.lockout : 0);
            sets.put(set);
        }
        dump.put("prints", sets);
    } catch (JSONException e) {
        Slog.e(TAG, "dump formatting failure", e);
    }
    pw.println(dump);
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) UserInfo(android.content.pm.UserInfo) Fingerprint(android.hardware.fingerprint.Fingerprint)

Example 57 with JSONArray

use of org.json.JSONArray in project chromeview by pwnall.

the class PerfTraceEvent method setEnabled.

/**
     * Enable or disable perf tracing.
     * Disabling of perf tracing will dump trace data to the system log.
     */
public static synchronized void setEnabled(boolean enabled) {
    if (sEnabled == enabled) {
        return;
    }
    if (enabled) {
        sBeginNanoTime = System.nanoTime();
        sPerfTraceStrings = new JSONArray();
    } else {
        dumpPerf();
        sPerfTraceStrings = null;
        sFilter = null;
    }
    sEnabled = enabled;
}
Also used : JSONArray(org.json.JSONArray)

Example 58 with JSONArray

use of org.json.JSONArray in project weiciyuan by qii.

the class LocationInfoDao method getInfo.

public String getInfo() {
    Map<String, String> map = new HashMap<String, String>();
    map.put("language", "zh-CN");
    map.put("sensor", "false");
    map.put("latlng", getLatlng());
    String url = URLHelper.GOOGLELOCATION;
    String jsonData = null;
    try {
        jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Get, url, map);
    } catch (WeiboException e) {
        AppLogger.e(e.getMessage());
    }
    try {
        JSONObject jsonObject = new JSONObject(jsonData);
        JSONArray results = jsonObject.optJSONArray("results");
        JSONObject jsonObject1 = results.getJSONObject(0);
        String formatAddress = jsonObject1.optString("formatted_address");
        int index = formatAddress.indexOf(" ");
        if (index > 0) {
            String location = formatAddress.substring(0, index);
            return location;
        } else {
            return formatAddress;
        }
    } catch (JSONException e) {
        AppLogger.e(e.getMessage());
    }
    return "";
}
Also used : WeiboException(org.qii.weiciyuan.support.error.WeiboException) JSONObject(org.json.JSONObject) HashMap(java.util.HashMap) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException)

Example 59 with JSONArray

use of org.json.JSONArray in project weiciyuan by qii.

the class MapDao method getMap.

public Bitmap getMap() throws WeiboException {
    String url = URLHelper.STATIC_MAP;
    Map<String, String> map = new HashMap<String, String>();
    map.put("access_token", access_token);
    String coordinates = String.valueOf(lat) + "," + String.valueOf(lan);
    map.put("center_coordinate", coordinates);
    map.put("zoom", "14");
    map.put("size", "600x380");
    String jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Get, url, map);
    String mapUrl = "";
    try {
        JSONObject jsonObject = new JSONObject(jsonData);
        JSONArray array = jsonObject.optJSONArray("map");
        jsonObject = array.getJSONObject(0);
        mapUrl = jsonObject.getString("image_url");
    } catch (JSONException e) {
    }
    if (TextUtils.isEmpty(mapUrl)) {
        return null;
    }
    String filePath = FileManager.getFilePathFromUrl(mapUrl, FileLocationMethod.map);
    boolean downloaded = TaskCache.waitForPictureDownload(mapUrl, null, filePath, FileLocationMethod.map);
    if (!downloaded) {
        return null;
    }
    Bitmap bitmap = ImageUtility.readNormalPic(FileManager.getFilePathFromUrl(mapUrl, FileLocationMethod.map), -1, -1);
    return bitmap;
}
Also used : Bitmap(android.graphics.Bitmap) JSONObject(org.json.JSONObject) HashMap(java.util.HashMap) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException)

Example 60 with JSONArray

use of org.json.JSONArray in project weiciyuan by qii.

the class FriendsTimeLineTagDao method getGSONMsgList.

public List<TagBean> getGSONMsgList() throws WeiboException {
    String json = getMsgListJson();
    List<TagBean> tagBeanList = new ArrayList<TagBean>();
    try {
        JSONArray array = new JSONArray(json);
        int size = array.length();
        for (int i = 0; i < size; i++) {
            TagBean bean = new TagBean();
            JSONObject jsonObject = array.getJSONObject(i);
            Iterator<String> iterator = jsonObject.keys();
            while (iterator.hasNext()) {
                String key = iterator.next();
                if (key.equalsIgnoreCase("weight")) {
                    String value = jsonObject.optString(key);
                    bean.setWeight(value);
                } else {
                    String value = jsonObject.optString(key);
                    bean.setId(Integer.valueOf(key));
                    bean.setName(value);
                }
            }
            tagBeanList.add(bean);
        }
    } catch (JSONException e) {
        AppLogger.e(e.getMessage());
    }
    return tagBeanList;
}
Also used : JSONObject(org.json.JSONObject) TagBean(org.qii.weiciyuan.bean.TagBean) ArrayList(java.util.ArrayList) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException)

Aggregations

JSONArray (org.json.JSONArray)1710 JSONObject (org.json.JSONObject)1191 JSONException (org.json.JSONException)738 ArrayList (java.util.ArrayList)323 IOException (java.io.IOException)243 Test (org.junit.Test)207 HashMap (java.util.HashMap)108 ClientException (edu.umass.cs.gnscommon.exceptions.client.ClientException)96 List (java.util.List)63 DefaultGNSTest (edu.umass.cs.gnsserver.utils.DefaultGNSTest)61 File (java.io.File)54 HashSet (java.util.HashSet)54 Date (java.util.Date)47 Query (org.b3log.latke.repository.Query)47 RandomString (edu.umass.cs.gnscommon.utils.RandomString)44 GraphObject (com.abewy.android.apps.klyph.core.graph.GraphObject)43 FileNotFoundException (java.io.FileNotFoundException)40 Map (java.util.Map)40 GuidEntry (edu.umass.cs.gnsclient.client.util.GuidEntry)36 VolleyError (com.android.volley.VolleyError)35