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);
}
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;
}
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 "";
}
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;
}
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;
}
Aggregations