From 643e2b23ea885ff52d9eaf5c0b5ba1caf17042af Mon Sep 17 00:00:00 2001 From: Ricki Hirner Date: Thu, 27 Apr 2017 13:35:14 +0200 Subject: [PATCH] Use UUIDs for newly generated event/task UIDs (RFC 7986 5.3 UID Property) --- app/src/main/java/com/etesync/syncadapter/App.java | 7 ------- .../java/com/etesync/syncadapter/resource/LocalEvent.java | 3 ++- .../java/com/etesync/syncadapter/resource/LocalTask.java | 3 ++- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/etesync/syncadapter/App.java b/app/src/main/java/com/etesync/syncadapter/App.java index 11d599ab..6e88e631 100644 --- a/app/src/main/java/com/etesync/syncadapter/App.java +++ b/app/src/main/java/com/etesync/syncadapter/App.java @@ -49,8 +49,6 @@ import com.etesync.syncadapter.resource.LocalCalendar; import com.etesync.syncadapter.ui.AccountsActivity; import com.etesync.syncadapter.utils.HintManager; -import net.fortuna.ical4j.util.UidGenerator; - import org.apache.commons.lang3.time.DateFormatUtils; import java.io.File; @@ -100,9 +98,6 @@ public class App extends Application { @Getter private static HostnameVerifier hostnameVerifier; - @Getter - private static UidGenerator uidGenerator; - public final static Logger log = Logger.getLogger("syncadapter"); static { at.bitfire.cert4android.Constants.log = Logger.getLogger("syncadapter.cert4android"); @@ -124,8 +119,6 @@ public class App extends Application { StrictMode.enableDefaults(); initPrefVersion(); - uidGenerator = new UidGenerator(null, android.provider.Settings.Secure.getString(getContentResolver(), android.provider.Settings.Secure.ANDROID_ID)); - appName = getString(R.string.app_name); accountType = getString(R.string.account_type); addressBookAccountType = getString(R.string.account_type_address_book); diff --git a/app/src/main/java/com/etesync/syncadapter/resource/LocalEvent.java b/app/src/main/java/com/etesync/syncadapter/resource/LocalEvent.java index a4ff658a..b0933f1c 100644 --- a/app/src/main/java/com/etesync/syncadapter/resource/LocalEvent.java +++ b/app/src/main/java/com/etesync/syncadapter/resource/LocalEvent.java @@ -27,6 +27,7 @@ import net.fortuna.ical4j.model.property.ProdId; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.util.UUID; import java.util.logging.Level; import at.bitfire.ical4android.AndroidCalendar; @@ -150,7 +151,7 @@ public class LocalEvent extends AndroidEvent implements LocalResource { if (c.moveToNext()) uid = c.getString(0); if (uid == null) - uid = App.getUidGenerator().generateUid().getValue(); + uid = UUID.randomUUID().toString(); final String newFileName = uid; diff --git a/app/src/main/java/com/etesync/syncadapter/resource/LocalTask.java b/app/src/main/java/com/etesync/syncadapter/resource/LocalTask.java index 101fa8a2..71b93696 100644 --- a/app/src/main/java/com/etesync/syncadapter/resource/LocalTask.java +++ b/app/src/main/java/com/etesync/syncadapter/resource/LocalTask.java @@ -24,6 +24,7 @@ import org.dmfs.provider.tasks.TaskContract.Tasks; import java.io.FileNotFoundException; import java.io.IOException; import java.text.ParseException; +import java.util.UUID; import at.bitfire.ical4android.AndroidTask; import at.bitfire.ical4android.AndroidTaskFactory; @@ -100,7 +101,7 @@ public class LocalTask extends AndroidTask implements LocalResource { public void prepareForUpload() throws CalendarStorageException { try { - final String uid = App.getUidGenerator().generateUid().getValue(); + final String uid = UUID.randomUUID().toString(); final String newFileName = uid + ".ics"; ContentValues values = new ContentValues(2);