private KISSmetricsAPI(String apiKey, Context context, boolean secure) { this._apiKey = apiKey; this._context = context; if (this._context == null) return; this.currentScheme = (secure) ? HTTPS : HTTP; SharedPreferences pref = this._context.getSharedPreferences(IDENTITY_PREF, Activity.MODE_PRIVATE); SharedPreferences.Editor prefEditor = null; this._identity = pref.getString("identity", null); if (this._identity == null) { TelephonyManager tm = (TelephonyManager) this._context.getSystemService(Context.TELEPHONY_SERVICE); this._identity = tm.getDeviceId(); prefEditor = pref.edit(); prefEditor.putString("identity", this._identity); prefEditor.commit(); } boolean shouldSendProps = true; pref = this._context.getSharedPreferences(PROPS_PREF, Activity.MODE_PRIVATE); propsToSend = new HashMap<String, String>(); for (String s : pref.getAll().keySet()) { propsToSend.put(s, pref.getString(s, null)); } if (!propsToSend.isEmpty()) { shouldSendProps = false; if (!android.os.Build.VERSION.RELEASE.equals(propsToSend.get("systemVersion"))) { shouldSendProps = true; } } if (shouldSendProps) { propsToSend.clear(); propsToSend.put("systemName", "android"); propsToSend.put("systemVersion", android.os.Build.VERSION.RELEASE); prefEditor = pref.edit(); for (String s : propsToSend.keySet()) { prefEditor.putString(s, propsToSend.get(s)); } prefEditor.commit(); } else { propsToSend = null; } this.unarchiveData(); this.setProperties(propsToSend); }
private boolean isMatching(ApplicationInfo appInfo, ClassChecker classChecker) { boolean havePackageMatch = false; for (String packageName : targetPackages()) { if (appInfo.packageName.equals(packageName)) havePackageMatch = true; } if (!havePackageMatch) return false; if (manufacturer() != ANY && !Util.containsManufacturer(manufacturer())) return false; if (release() != ANY && !Build.VERSION.RELEASE.equals(release())) return false; if (buildId() != ANY && !Build.ID.equals(buildId())) return false; try { if (md5Sum() != ANY && !XposedHelpers.getMD5Sum(appInfo.sourceDir).equals(md5Sum())) return false; } catch (IOException e) { log("Failed to get MD5 hash of " + appInfo.sourceDir); debug(e); return false; } if (apiLevel() != 0 && Build.VERSION.SDK_INT != apiLevel()) return false; if (!onMatch(appInfo, classChecker)) return false; final String[] classes = indicatorClasses(); if (classes == null || classes.length == 0) return true; debug("Checking " + classes.length + " indicator classes"); for (String className : classes) { if (classChecker.exists(className)) { debug(" OK: " + className); return true; } else { debug(" N/A: " + className); // continue } } return false; }