public override void finishSync(bool refresh)
        {
            // delete leftover local notes
            NoteManager.purgeDeletedNotes(activity);

            Time now = new Time();
            now.SetToNow();
            string nowstring = now.Format3339(false);
            Preferences.putstring(Preferences.Key.LATEST_SYNC_DATE, nowstring);

            setSyncProgress(100);
            if (refresh)
                SendMessage(PARSING_COMPLETE);
        }
Beispiel #2
0
        protected void onChooseNote(string title, string content, bool choseLocal)
        {
            title = NoteManager.validateNoteTitle(this, title, localNote.getGuid());

            Time now = new Time();
            now.SetToNow();
            string time = now.Format3339(false);

            localNote.setTitle(title);
            localNote.setXmlContent(content);
            localNote.setLastChangeDate(time);

            // doing a title difference

            if(differentNotes) {
                if(choseLocal) { // chose to keep local, delete remote, push local
                    pullNote(localNote);
                    remoteNote.addTag("system:deleted");

                    if(noRemote) {
                        finishForResult(new Intent());
                        return;
                    }

                    pushNote(localNote); // add for pushing
                    pushNote(remoteNote); // add for deletion

                }
                else { // chose to keep remote, delete local, add remote, push remote back
                    deleteNote(localNote);
                    remoteNote.setTitle(title);
                    remoteNote.setXmlContent(content);
                    remoteNote.setLastChangeDate(time);
                    pullNote(remoteNote);

                    if(!noRemote)
                        pushNote(remoteNote);
                }
            }
            else { // just readd and push modified localNote
                pullNote(localNote);

                if(!noRemote)
                    pushNote(localNote);
            }
            finishForResult(new Intent());
        }
        /// <summary>
        /// Collects crash data.
        /// </summary>
        /// <param name="context"><see cref="Context"/> for the application being reported.</param>
        /// <param name="reportFields"><see cref="Array"/> of <see cref="ReportField"/> to include in report</param>
        /// <param name="appStartDate"><see cref="Time"/> of application start</param>
        /// <param name="initialConfiguration">Application initial configuration</param>
        /// <param name="th"><see cref="Java.Lang.Throwable"/> that caused the crash.</param>
        /// <param name="isSilentReport">Whether to report this report as being sent silently.</param>
        /// <returns>Builded report data</returns>
        public static ReportData BuildReportData(Context context, ReportField[] reportFields, Time appStartDate, string initialConfiguration, Java.Lang.Throwable th, bool isSilentReport)
        {
            var crashReportData = new ReportData();
            try
            {
                crashReportData.Add(ReportField.StackTrace, th.StackTrace);
                crashReportData.Add(ReportField.UserAppStartDate, appStartDate.Format3339(false));

                if (isSilentReport)
                {
                    crashReportData.Add(ReportField.IsSilent, "true");
                }

                if (reportFields.Contains(ReportField.ReportID))
                {
                    crashReportData.Add(ReportField.ReportID, Guid.NewGuid().ToString());
                }

                if (reportFields.Contains(ReportField.InstallationID))
                {
                    crashReportData.Add(ReportField.InstallationID, Installation.Id(context));
                }

                if (reportFields.Contains(ReportField.InitialConfiguration))
                {
                    crashReportData.Add(ReportField.InitialConfiguration, initialConfiguration);
                }

                if (reportFields.Contains(ReportField.CrashConfiguration))
                {
                    crashReportData.Add(ReportField.CrashConfiguration, ReportUtils.GetCrashConfiguration(context));
                }

                if (reportFields.Contains(ReportField.DumpsysMeminfo))
                {
                    crashReportData.Add(ReportField.DumpsysMeminfo, DumpSysCollector.CollectMemInfo());
                }

                if (reportFields.Contains(ReportField.PackageName))
                {
                    crashReportData.Add(ReportField.PackageName, context.PackageName);
                }

                if (reportFields.Contains(ReportField.Build))
                {
                    crashReportData.Add(ReportField.Build, ReflectionCollector.CollectStaticProperties(typeof(Build)));
                }

                if (reportFields.Contains(ReportField.PhoneModel))
                {
                    crashReportData.Add(ReportField.PhoneModel, Build.Model);
                }

                if (reportFields.Contains(ReportField.AndroidVersion))
                {
                    crashReportData.Add(ReportField.AndroidVersion, Build.VERSION.Release);
                }

                if (reportFields.Contains(ReportField.Brand))
                {
                    crashReportData.Add(ReportField.Brand, Build.Brand);
                }

                if (reportFields.Contains(ReportField.Product))
                {
                    crashReportData.Add(ReportField.Product, Build.Product);
                }

                if (reportFields.Contains(ReportField.TotalMemSize))
                {
                    crashReportData.Add(ReportField.TotalMemSize, ReportUtils.TotalInternalMemorySize.ToString());
                }

                if (reportFields.Contains(ReportField.AvailableMemSize))
                {
                    crashReportData.Add(ReportField.AvailableMemSize, ReportUtils.AvailableInternalMemorySize.ToString());
                }

                if (reportFields.Contains(ReportField.FilePath))
                {
                    crashReportData.Add(ReportField.FilePath, ReportUtils.GetApplicationFilePath(context));
                }

                if (reportFields.Contains(ReportField.Display))
                {
                    crashReportData.Add(ReportField.Display, ReportUtils.GetDisplayDetails(context));
                }

                if (reportFields.Contains(ReportField.UserCrashDate))
                {
                    var curDate = new Time();
                    curDate.SetToNow();
                    crashReportData.Add(ReportField.UserCrashDate, curDate.Format3339(false));
                }

                if (reportFields.Contains(ReportField.DeviceFeatures))
                {
                    crashReportData.Add(ReportField.DeviceFeatures, DeviceFeaturesCollector.GetFeatures(context));
                }

                if (reportFields.Contains(ReportField.Environment))
                {
                    crashReportData.Add(ReportField.Environment, ReflectionCollector.CollectStaticProperties(typeof(Environment)));
                }

                if (reportFields.Contains(ReportField.SettingsSystem))
                {
                    crashReportData.Add(ReportField.SettingsSystem, SettingsCollector.CollectSystemSettings(context));
                }

                if (reportFields.Contains(ReportField.SettingsSecure))
                {
                    crashReportData.Add(ReportField.SettingsSecure, SettingsCollector.CollectSecureSettings(context));
                }

                if (reportFields.Contains(ReportField.SharedPreferences))
                {
                    crashReportData.Add(ReportField.SharedPreferences, SharedPreferencesCollector.Collect(context));
                }

                var pm = new PackageManagerWrapper(context);
                var pi = pm.GetPackageInfo();
                if (pi != null)
                {
                    if (reportFields.Contains(ReportField.AppVersionCode))
                    {
                        crashReportData.Add(ReportField.AppVersionCode, pi.VersionCode.ToString());
                    }
                    if (reportFields.Contains(ReportField.AppVersionName))
                    {
                        crashReportData.Add(ReportField.AppVersionName, pi.VersionName ?? "not set");
                    }
                }
                else
                {
                    crashReportData.Add(ReportField.AppVersionName, "Package info unavailable");
                }

                if (reportFields.Contains(ReportField.DeviceID) && pm.HasPermission(Manifest.Permission.ReadPhoneState))
                {
                    var deviceId = ReportUtils.GetDeviceId(context);
                    if (deviceId != null)
                    {
                        crashReportData.Add(ReportField.DeviceID, deviceId);
                    }
                }

                if (pm.HasPermission(Manifest.Permission.ReadLogs))
                {
                    Log.Info(Constants.LOG_TAG, "READ_LOGS granted! Crasher can include LogCat and DropBox data.");
                    if (reportFields.Contains(ReportField.Logcat))
                    {
                        crashReportData.Add(ReportField.Logcat, LogCatCollector.CollectLogCat(null));
                    }
                    if (reportFields.Contains(ReportField.Eventslog))
                    {
                        crashReportData.Add(ReportField.Eventslog, LogCatCollector.CollectLogCat("events"));
                    }
                    if (reportFields.Contains(ReportField.Radiolog))
                    {
                        crashReportData.Add(ReportField.Radiolog, LogCatCollector.CollectLogCat("radio"));
                    }
                }
                else
                {
                    Log.Info(Constants.LOG_TAG, "READ_LOGS not allowed. Crasher will not include LogCat and DropBox data.");
                }

            }
            catch (Java.Lang.RuntimeException e)
            {
                Log.Error(Constants.LOG_TAG, e, "Error while retrieving crash data");
            }
            return crashReportData;
        }
Beispiel #4
0
        private void saveNote()
        {
            TLog.v(TAG, "saving note");

            bool updated = updateNoteContent(xmlOn);
            if(!updated) {
                Toast.MakeText(this, Resources.GetString(Resource.String.messageErrorParsingXML),ToastLength.Short).Show();
                return;
            }

            string validTitle = NoteManager.validateNoteTitle(this, title.Text, note.getGuid());
            title.SetText(validTitle);
            note.setTitle(validTitle);

            Time now = new Time();
            now.SetToNow();
            string time = now.Format3339(false);
            note.setLastChangeDate(time);
            NoteManager.putNote( this, note);
            if(!SyncManager.getInstance().getCurrentService().needsLocation() && Preferences.GetBoolean(Preferences.Key.AUTO_BACKUP_NOTES)) {
                TLog.v(TAG, "backing note up");
                SdCardSyncService.backupNote(note);
            }
            textChanged = false;
            NewNote.neverSaved = false;

            Toast.MakeText(this, Resources.GetString(Resource.String.messageNoteSaved), ToastLength.Short).Show();
            TLog.v(TAG, "note saved");
        }
Beispiel #5
0
 public void setLastChangeDate(Time lastChangeDateTime)
 {
     this.lastChangeDate = lastChangeDateTime.Format3339(false);
 }
Beispiel #6
0
 // sets change date to now
 public void setLastChangeDate()
 {
     Time now = new Time();
     now.SetToNow();
     String time = now.Format3339(false);
     setLastChangeDate(time);
 }