List of usage examples for android.os Build SERIAL
String SERIAL
To view the source code for android.os Build SERIAL.
Click Source Link
From source file:eu.faircode.netguard.ActivityPro.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.i(TAG, "Create"); Util.setTheme(this); super.onCreate(savedInstanceState); setContentView(R.layout.pro);/*from w w w . j a v a 2 s . c o m*/ getSupportActionBar().setTitle(R.string.title_pro); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); // Initial state updateState(); TextView tvLogTitle = findViewById(R.id.tvLogTitle); TextView tvFilterTitle = findViewById(R.id.tvFilterTitle); TextView tvNotifyTitle = findViewById(R.id.tvNotifyTitle); TextView tvSpeedTitle = findViewById(R.id.tvSpeedTitle); TextView tvThemeTitle = findViewById(R.id.tvThemeTitle); TextView tvAllTitle = findViewById(R.id.tvAllTitle); TextView tvDev1Title = findViewById(R.id.tvDev1Title); TextView tvDev2Title = findViewById(R.id.tvDev2Title); Linkify.TransformFilter filter = new Linkify.TransformFilter() { @Override public String transformUrl(Matcher match, String url) { return ""; } }; Linkify.addLinks(tvLogTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_LOG, null, filter); Linkify.addLinks(tvFilterTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_FILTER, null, filter); Linkify.addLinks(tvNotifyTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_NOTIFY, null, filter); Linkify.addLinks(tvSpeedTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_SPEED, null, filter); Linkify.addLinks(tvThemeTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_THEME, null, filter); Linkify.addLinks(tvAllTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_PRO1, null, filter); Linkify.addLinks(tvDev1Title, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_SUPPORT1, null, filter); Linkify.addLinks(tvDev2Title, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_SUPPORT2, null, filter); String android_id = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID); String challenge = (Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? Build.SERIAL : "O3" + android_id); String seed = (Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? "NetGuard2" : "NetGuard3"); // Challenge TextView tvChallenge = findViewById(R.id.tvChallenge); tvChallenge.setText(challenge); // Response try { final String response = Util.md5(challenge, seed); EditText etResponse = findViewById(R.id.etResponse); etResponse.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // Do nothing } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // Do nothing } @Override public void afterTextChanged(Editable editable) { if (response.equals(editable.toString().toUpperCase())) { IAB.setBought(SKU_DONATION, ActivityPro.this); updateState(); } } }); } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } try { iab = new IAB(new IAB.Delegate() { @Override public void onReady(final IAB iab) { Log.i(TAG, "IAB ready"); try { iab.updatePurchases(); updateState(); final Button btnLog = findViewById(R.id.btnLog); final Button btnFilter = findViewById(R.id.btnFilter); final Button btnNotify = findViewById(R.id.btnNotify); final Button btnSpeed = findViewById(R.id.btnSpeed); final Button btnTheme = findViewById(R.id.btnTheme); final Button btnAll = findViewById(R.id.btnAll); final Button btnDev1 = findViewById(R.id.btnDev1); final Button btnDev2 = findViewById(R.id.btnDev2); View.OnClickListener listener = new View.OnClickListener() { @Override public void onClick(View view) { try { int id = 0; PendingIntent pi = null; if (view == btnLog) { id = SKU_LOG_ID; pi = iab.getBuyIntent(SKU_LOG, false); } else if (view == btnFilter) { id = SKU_FILTER_ID; pi = iab.getBuyIntent(SKU_FILTER, false); } else if (view == btnNotify) { id = SKU_NOTIFY_ID; pi = iab.getBuyIntent(SKU_NOTIFY, false); } else if (view == btnSpeed) { id = SKU_SPEED_ID; pi = iab.getBuyIntent(SKU_SPEED, false); } else if (view == btnTheme) { id = SKU_THEME_ID; pi = iab.getBuyIntent(SKU_THEME, false); } else if (view == btnAll) { id = SKU_PRO1_ID; pi = iab.getBuyIntent(SKU_PRO1, false); } else if (view == btnDev1) { id = SKU_SUPPORT1_ID; pi = iab.getBuyIntent(SKU_SUPPORT1, true); } else if (view == btnDev2) { id = SKU_SUPPORT2_ID; pi = iab.getBuyIntent(SKU_SUPPORT2, true); } if (id > 0 && pi != null) startIntentSenderForResult(pi.getIntentSender(), id, new Intent(), 0, 0, 0); } catch (Throwable ex) { Log.i(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } } }; btnLog.setOnClickListener(listener); btnFilter.setOnClickListener(listener); btnNotify.setOnClickListener(listener); btnSpeed.setOnClickListener(listener); btnTheme.setOnClickListener(listener); btnAll.setOnClickListener(listener); btnDev1.setOnClickListener(listener); btnDev2.setOnClickListener(listener); btnLog.setEnabled(true); btnFilter.setEnabled(true); btnNotify.setEnabled(true); btnSpeed.setEnabled(true); btnTheme.setEnabled(true); btnAll.setEnabled(true); btnDev1.setEnabled(true); btnDev2.setEnabled(true); } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } } }, this); iab.bind(); } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } }
From source file:org.cook_e.cook_e.BugReportActivity.java
/** * Gathers information about the device running the application and returns it as a JSONObject * @return information about the system// ww w. j av a 2s .co m */ private JSONObject getSystemInformation() { final JSONObject json = new JSONObject(); try { final JSONObject build = new JSONObject(); build.put("version_name", BuildConfig.VERSION_NAME); build.put("version_code", BuildConfig.VERSION_CODE); build.put("build_type", BuildConfig.BUILD_TYPE); build.put("debug", BuildConfig.DEBUG); json.put("build", build); final JSONObject device = new JSONObject(); device.put("board", Build.BOARD); device.put("bootloader", Build.BOOTLOADER); device.put("brand", Build.BRAND); device.put("device", Build.DEVICE); device.put("display", Build.DISPLAY); device.put("fingerprint", Build.FINGERPRINT); device.put("hardware", Build.HARDWARE); device.put("host", Build.HOST); device.put("id", Build.ID); device.put("manufacturer", Build.MANUFACTURER); device.put("model", Build.MODEL); device.put("product", Build.PRODUCT); device.put("radio", Build.getRadioVersion()); device.put("serial", Build.SERIAL); device.put("tags", Build.TAGS); device.put("time", Build.TIME); device.put("type", Build.TYPE); device.put("user", Build.USER); json.put("device", device); } catch (JSONException e) { // Ignore } return json; }
From source file:at.jclehner.appopsxposed.BugReportBuilder.java
private String getDeviceId() { final String raw = Build.SERIAL + Build.FINGERPRINT; byte[] bytes; try {/* ww w .ja va 2 s. c om*/ final MessageDigest md = MessageDigest.getInstance("SHA1"); bytes = md.digest(raw.getBytes()); } catch (NoSuchAlgorithmException e) { bytes = raw.getBytes(); } final StringBuilder sb = new StringBuilder(bytes.length); for (byte b : bytes) sb.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1)); return sb.substring(0, 12); }
From source file:com.segment.analytics.internal.Utils.java
/** Creates a unique device id. */ public static String getDeviceId(Context context) { String androidId = getString(context.getContentResolver(), ANDROID_ID); if (!isNullOrEmpty(androidId) && !"9774d56d682e549c".equals(androidId) && !"unknown".equals(androidId) && !"000000000000000".equals(androidId)) { return androidId; }/*from ww w.j a v a 2 s. c om*/ // Serial number, guaranteed to be on all non phones in 2.3+ if (!isNullOrEmpty(Build.SERIAL)) { return Build.SERIAL; } // Telephony ID, guaranteed to be on all phones, requires READ_PHONE_STATE permission if (hasPermission(context, READ_PHONE_STATE) && hasFeature(context, FEATURE_TELEPHONY)) { TelephonyManager telephonyManager = getSystemService(context, TELEPHONY_SERVICE); String telephonyId = telephonyManager.getDeviceId(); if (!isNullOrEmpty(telephonyId)) { return telephonyId; } } // If this still fails, generate random identifier that does not persist across installations return UUID.randomUUID().toString(); }
From source file:com.framgia.android.emulator.EmulatorDetector.java
private boolean checkBasic() { boolean result = Build.FINGERPRINT.startsWith("generic") || Build.MODEL.contains("google_sdk") || Build.MODEL.toLowerCase().contains("droid4x") || Build.MODEL.contains("Emulator") || Build.MODEL.contains("Android SDK built for x86") || Build.MANUFACTURER.contains("Genymotion") || Build.HARDWARE.equals("goldfish") || Build.HARDWARE.equals("vbox86") || Build.PRODUCT.equals("sdk") || Build.PRODUCT.equals("google_sdk") || Build.PRODUCT.equals("sdk_x86") || Build.PRODUCT.equals("vbox86p") || Build.BOARD.toLowerCase().contains("nox") || Build.BOOTLOADER.toLowerCase().contains("nox") || Build.HARDWARE.toLowerCase().contains("nox") || Build.PRODUCT.toLowerCase().contains("nox") || Build.SERIAL.toLowerCase().contains("nox"); if (result)//w ww .j a v a 2s . c o m return true; result |= Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic"); if (result) return true; result |= "google_sdk".equals(Build.PRODUCT); return result; }
From source file:gcm.play.android.samples.com.gcmquickstart.MainActivity.java
public void validateLogin() { RequestQueue queue = Volley.newRequestQueue(this); String url = "http://www.entuizer.tech/administrators/suterm/webServices/validateLoginApp.php"; StringRequest putRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() { public void onResponse(String response) { // response try { progressDialog.dismiss(); Log.d("RESPONSE", response.toString()); JSONArray jsonArray = new JSONArray(response); JSONObject jsonObject = jsonArray.getJSONObject(0); int ERROR = jsonObject.getInt("ERROR"); //Validacin de la respuesta JSON if (ERROR == 0) { if (cbRecordar.isChecked()) UserData.setLogged(MainActivity.this, true); Intent intent = new Intent(MainActivity.this, NotificationsList.class); startActivity(intent); MainActivity.this.finish(); } else { Toast.makeText(MainActivity.this, getString(R.string.wrongValidation), Toast.LENGTH_SHORT) .show();/*from w w w . j a va 2s . c om*/ etPassword.requestFocus(); } } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { // error progressDialog.dismiss(); Log.d("Error.Response", error.toString()); } }) { @Override protected Map<String, String> getParams() { //Reg ID almacenando localmente String token = UserData.getRegId(MainActivity.this); Log.d("REGID:", token); //Obtener el nmero serial del dispositivo String numSerie = Build.SERIAL; //User ID almacenado localmente int userId = UserData.getUserId(MainActivity.this); //Verificamos si se desea mantener sesin abierta o no boolean isLogged = cbRecordar.isChecked(); String userIsLogged; if (isLogged) userIsLogged = "1"; else userIsLogged = "0"; Map<String, String> params = new HashMap<String, String>(); params.put("regisId", token.toString()); params.put("numSerie", numSerie); params.put("userId", "" + userId); params.put("userIsLogged", userIsLogged); params.put("userName", etUsername.getText().toString()); params.put("userPassword", etPassword.getText().toString()); return params; } }; queue.add(putRequest); }
From source file:com.juanojfp.gcmsample.MainActivity.java
public String registerInServer(String token) { String imei = Build.SERIAL; String model = Build.MANUFACTURER + ":" + Build.MODEL; String sdk = Build.VERSION.SDK + ":" + Build.VERSION.RELEASE; Log.e("RegisterInServer", "Imei: " + imei); HttpClient client = new DefaultHttpClient(); StringBuilder peticion = new StringBuilder(); peticion.append(URL_TO_SERVER).append(MODULE_DEVICE).append(COMMAND_REGISTER); Log.e("Peticion:", peticion.toString()); HttpPost method = new HttpPost(peticion.toString()); String msgServer;//w ww.jav a 2 s.c om try { List<NameValuePair> nvp = new ArrayList<NameValuePair>(); nvp.add(new BasicNameValuePair(PARAM_C2DM_DEVICE_TOKEN, token)); nvp.add(new BasicNameValuePair(PARAM_C2DM_DEVICE_IMEI, imei)); nvp.add(new BasicNameValuePair(PARAM_C2DM_DEVICE_MODEL, model)); nvp.add(new BasicNameValuePair(PARAM_C2DM_DEVICE_SDK, sdk)); for (NameValuePair v : nvp) Log.e("Parametro", v.getName() + ":" + v.getValue()); method.setEntity(new UrlEncodedFormEntity(nvp, HTTP.UTF_8)); HttpResponse response = client.execute(method); //Respuestas //{'message':'username', 'id':idUser, 'code':0} //{'message':'Token perdido', 'code':1} JSONObject json = new JSONObject(input2String(response.getEntity().getContent())); String msg = json.getString(PARAM_C2DM_DEVICE_MESSAGE); int id = json.getInt(PARAM_C2DM_DEVICE_MESSAGE_ID); int code = json.getInt(PARAM_C2DM_DEVICE_MESSAGE_CODE); msgServer = id + ":" + msg + ":" + code; } catch (ClientProtocolException e) { // TODO Auto-generated catch block msgServer = e.getMessage(); e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block msgServer = e.getMessage(); e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block msgServer = e.getMessage(); e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block msgServer = e.getMessage(); e.printStackTrace(); } Log.e("Serever Response", msgServer); return msgServer; }
From source file:com.flowzr.export.flowzr.FlowzrSyncEngine.java
public static String create(Context p_context, DatabaseAdapter p_dba, DefaultHttpClient p_http) { startTimestamp = System.currentTimeMillis(); if (isRunning == true) { isCanceled = true;// www.jav a 2 s . com isRunning = false; } isRunning = true; boolean recordSyncTime = true; dba = p_dba; db = dba.db(); em = dba.em(); http_client = p_http; context = p_context; last_sync_ts = MyPreferences.getFlowzrLastSync(context); FLOWZR_BASE_URL = "https://" + MyPreferences.getSyncApiUrl(context); FLOWZR_API_URL = FLOWZR_BASE_URL + "/financisto3/"; nsString = MyPreferences.getFlowzrAccount(context).replace("@", "_"); //urlsafe Log.i(TAG, "init sync engine, last sync was " + new Date(last_sync_ts).toLocaleString()); //if (true) { if (!checkSubscriptionFromWeb()) { Intent notificationIntent = new Intent(context, FlowzrSyncActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new NotificationCompat.Builder(context).setSmallIcon(R.drawable.icon) .setTicker(context.getString(R.string.flowzr_subscription_required)) .setContentTitle(context.getString(R.string.flowzr_sync_error)) .setContentText(context.getString(R.string.flowzr_subscription_required, MyPreferences.getFlowzrAccount(context))) .setContentIntent(pendingIntent).setAutoCancel(true).build(); notificationManager.notify(0, notification); Log.w("flowzr", "subscription rejected from web"); isCanceled = true; MyPreferences.unsetAutoSync(context); return null; } else { mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // Sets an ID for the notification, so it can be updated mNotifyBuilder = new NotificationCompat.Builder(context).setAutoCancel(true) .setContentTitle(context.getString(R.string.flowzr_sync)) .setContentText(context.getString(R.string.flowzr_sync_inprogress)) .setSmallIcon(R.drawable.icon); } if (!isCanceled) { notifyUser("fix created entities", 5); fixCreatedEntities(); } /** * pull delete */ if (!isCanceled) { notifyUser(context.getString(R.string.flowzr_sync_receiving) + " ...", 10); try { pullDelete(last_sync_ts); } catch (Exception e) { sendBackTrace(e); recordSyncTime = false; } } /** * push delete */ if (!isCanceled) { notifyUser(context.getString(R.string.flowzr_sync_sending) + " ...", 15); try { pushDelete(); } catch (Exception e) { sendBackTrace(e); recordSyncTime = false; } } /** * pull update */ if (!isCanceled && last_sync_ts == 0) { notifyUser(context.getString(R.string.flowzr_sync_receiving) + " ...", 20); try { pullUpdate(); } catch (IOException e) { sendBackTrace(e); recordSyncTime = false; } catch (JSONException e) { sendBackTrace(e); recordSyncTime = false; } catch (Exception e) { sendBackTrace(e); recordSyncTime = false; } } /** * push update */ if (!isCanceled) { notifyUser(context.getString(R.string.flowzr_sync_sending) + " ...", 35); try { pushUpdate(); } catch (ClientProtocolException e) { e.printStackTrace(); sendBackTrace(e); recordSyncTime = false; } catch (IOException e) { e.printStackTrace(); sendBackTrace(e); recordSyncTime = false; } catch (JSONException e) { e.printStackTrace(); sendBackTrace(e); recordSyncTime = false; } catch (Exception e) { e.printStackTrace(); recordSyncTime = false; } } /** * pull update */ if (!isCanceled && last_sync_ts > 0) { notifyUser(context.getString(R.string.flowzr_sync_receiving) + " ...", 20); try { pullUpdate(); } catch (IOException e) { sendBackTrace(e); recordSyncTime = false; } catch (JSONException e) { sendBackTrace(e); recordSyncTime = false; } catch (Exception e) { sendBackTrace(e); recordSyncTime = false; } } notifyUser(context.getString(R.string.integrity_fix), 80); new IntegrityFix(dba).fix(); /** * send account balances boundaries */ if (!isCanceled) { //if (true) { //will generate a Cloud Messaging request if prev. aborted notifyUser(context.getString(R.string.flowzr_sync_sending) + "...", 85); //nm.notify(NOTIFICATION_ID, mNotifyBuilder.build()); ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); nameValuePairs.add(new BasicNameValuePair("action", "balancesRecalc")); nameValuePairs.add(new BasicNameValuePair("last_sync_ts", String.valueOf(last_sync_ts))); String serialNumber = Build.SERIAL != Build.UNKNOWN ? Build.SERIAL : Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); nameValuePairs.add(new BasicNameValuePair("serialNumber", serialNumber)); List<Account> accountsList = em.getAllAccountsList(); for (Account account : accountsList) { nameValuePairs.add(new BasicNameValuePair(account.remoteKey, String.valueOf(account.totalAmount))); Log.i("flowzr", account.remoteKey + " " + String.valueOf(account.totalAmount)); } try { httpPush(nameValuePairs, "balances"); } catch (Exception e) { sendBackTrace(e); } } notifyUser("Widgets ...", 90); AccountWidget.updateWidgets(context); Handler refresh = new Handler(Looper.getMainLooper()); refresh.post(new Runnable() { public void run() { if (currentActivity != null) { //currentActivity.refreshCurrentTab(); } } }); if (!isCanceled && MyPreferences.doGoogleDriveUpload(context)) { notifyUser(context.getString(R.string.flowzr_sync_sending) + " Google Drive", 95); pushAllBlobs(); } else { Log.i("flowzr", "picture upload desactivated in prefs"); } notifyUser(context.getString(R.string.flowzr_sync_success), 100); if (isCanceled == false) { if (recordSyncTime == true) { last_sync_ts = System.currentTimeMillis(); SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit(); editor.putLong("PROPERTY_LAST_SYNC_TIMESTAMP", last_sync_ts); editor.commit(); } } // mNotificationManager.cancel(NOTIFICATION_ID); isRunning = false; isCanceled = false; if (context instanceof FlowzrSyncActivity) { ((FlowzrSyncActivity) context).setIsFinished(); } return FLOWZR_BASE_URL; }
From source file:org.feedhenry.welcome.fragments.NativeAppInfoFragment.java
private void getDeviceInformation() { manufactorurer.setText(Build.MANUFACTURER); model.setText(Build.MODEL);//w w w . ja v a 2s . c o m product.setText(Build.PRODUCT); serial.setText(Build.SERIAL); cpu.setText(Build.CPU_ABI); host.setText(Build.HOST); }
From source file:com.flowzr.budget.holo.export.flowzr.FlowzrSyncEngine.java
public static String create(Context p_context, DatabaseAdapter p_dba, DefaultHttpClient p_http) { startTimestamp = System.currentTimeMillis(); if (isRunning == true) { isCanceled = true;//from w w w . ja v a 2 s . c o m isRunning = false; } isRunning = true; boolean recordSyncTime = true; dba = p_dba; db = dba.db(); em = dba.em(); http_client = p_http; context = p_context; last_sync_ts = MyPreferences.getFlowzrLastSync(context); FLOWZR_BASE_URL = "https://" + MyPreferences.getSyncApiUrl(context); FLOWZR_API_URL = FLOWZR_BASE_URL + "/financisto3/"; nsString = MyPreferences.getFlowzrAccount(context).replace("@", "_"); //urlsafe Log.i(TAG, "init sync engine, last sync was " + new Date(last_sync_ts).toLocaleString()); //if (true) { if (!checkSubscriptionFromWeb()) { Intent notificationIntent = new Intent(context, FlowzrSyncActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new NotificationCompat.Builder(context).setSmallIcon(R.drawable.icon) .setTicker(context.getString(R.string.flowzr_subscription_required)) .setContentTitle(context.getString(R.string.flowzr_sync_error)) .setContentText(context.getString(R.string.flowzr_subscription_required, MyPreferences.getFlowzrAccount(context))) .setContentIntent(pendingIntent).setAutoCancel(true).build(); notificationManager.notify(0, notification); Log.w("flowzr", "subscription rejected from web"); isCanceled = true; MyPreferences.unsetAutoSync(context); return null; } else { mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // Sets an ID for the notification, so it can be updated mNotifyBuilder = new NotificationCompat.Builder(context).setAutoCancel(true) .setContentTitle(context.getString(R.string.flowzr_sync)) .setContentText(context.getString(R.string.flowzr_sync_inprogress)) .setSmallIcon(R.drawable.icon); } if (!isCanceled) { notifyUser("fix created entities", 5); fixCreatedEntities(); } /** * pull delete */ if (!isCanceled) { notifyUser(context.getString(R.string.flowzr_sync_receiving) + " ...", 10); try { pullDelete(last_sync_ts); } catch (Exception e) { sendBackTrace(e); recordSyncTime = false; } } /** * push delete */ if (!isCanceled) { notifyUser(context.getString(R.string.flowzr_sync_sending) + " ...", 15); try { pushDelete(); } catch (Exception e) { sendBackTrace(e); recordSyncTime = false; } } /** * pull update */ if (!isCanceled && last_sync_ts == 0) { notifyUser(context.getString(R.string.flowzr_sync_receiving) + " ...", 20); try { pullUpdate(); } catch (IOException e) { sendBackTrace(e); recordSyncTime = false; } catch (JSONException e) { sendBackTrace(e); recordSyncTime = false; } catch (Exception e) { sendBackTrace(e); recordSyncTime = false; } } /** * push update */ if (!isCanceled) { notifyUser(context.getString(R.string.flowzr_sync_sending) + " ...", 35); try { pushUpdate(); } catch (ClientProtocolException e) { e.printStackTrace(); sendBackTrace(e); recordSyncTime = false; } catch (IOException e) { e.printStackTrace(); sendBackTrace(e); recordSyncTime = false; } catch (JSONException e) { e.printStackTrace(); sendBackTrace(e); recordSyncTime = false; } catch (Exception e) { e.printStackTrace(); recordSyncTime = false; } } /** * pull update */ if (!isCanceled && last_sync_ts > 0) { notifyUser(context.getString(R.string.flowzr_sync_receiving) + " ...", 20); try { pullUpdate(); } catch (IOException e) { sendBackTrace(e); recordSyncTime = false; } catch (JSONException e) { sendBackTrace(e); recordSyncTime = false; } catch (Exception e) { sendBackTrace(e); recordSyncTime = false; } } notifyUser(context.getString(R.string.integrity_fix), 80); new IntegrityFix(dba).fix(); /** * send account balances boundaries */ if (!isCanceled) { //if (true) { //will generate a Cloud Messaging request if prev. aborted notifyUser(context.getString(R.string.flowzr_sync_sending) + "...", 85); //nm.notify(NOTIFICATION_ID, mNotifyBuilder.build()); ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); nameValuePairs.add(new BasicNameValuePair("action", "balancesRecalc")); nameValuePairs.add(new BasicNameValuePair("last_sync_ts", String.valueOf(last_sync_ts))); String serialNumber = Build.SERIAL != Build.UNKNOWN ? Build.SERIAL : Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); nameValuePairs.add(new BasicNameValuePair("serialNumber", serialNumber)); List<Account> accountsList = em.getAllAccountsList(); for (Account account : accountsList) { nameValuePairs.add(new BasicNameValuePair(account.remoteKey, String.valueOf(account.totalAmount))); Log.i("flowzr", account.remoteKey + " " + String.valueOf(account.totalAmount)); } try { httpPush(nameValuePairs, "balances"); } catch (Exception e) { sendBackTrace(e); } } notifyUser("Widgets ...", 90); AccountWidget.updateWidgets(context); Handler refresh = new Handler(Looper.getMainLooper()); refresh.post(new Runnable() { public void run() { if (currentActivity != null) { //currentActivity.refreshCurrentTab(); } } }); if (!isCanceled && MyPreferences.doGoogleDriveUpload(context)) { notifyUser(context.getString(R.string.flowzr_sync_sending) + " Google Drive", 95); pushAllBlobs(); } else { Log.i("flowzr", "picture upload desactivated in prefs"); } notifyUser(context.getString(R.string.flowzr_sync_success), 100); if (isCanceled == false) { if (recordSyncTime == true) { last_sync_ts = System.currentTimeMillis(); SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit(); editor.putLong("PROPERTY_LAST_SYNC_TIMESTAMP", last_sync_ts); editor.commit(); } } // mNotificationManager.cancel(NOTIFICATION_ID); isRunning = false; isCanceled = false; if (context instanceof FlowzrSyncActivity) { ((FlowzrSyncActivity) context).setIsFinished(); } return FLOWZR_BASE_URL; }