diff --git a/app/src/main/aidl/com/etesync/syncadapter/IEteSyncService.aidl b/app/src/main/aidl/com/etesync/syncadapter/IEteSyncService.aidl index 4a2e6ec4..cbf08a07 100644 --- a/app/src/main/aidl/com/etesync/syncadapter/IEteSyncService.aidl +++ b/app/src/main/aidl/com/etesync/syncadapter/IEteSyncService.aidl @@ -2,10 +2,13 @@ package com.etesync.syncadapter; // Declare any non-default types here with import statements +import com.etesync.syncadapter.model.CollectionInfo; interface IEteSyncService { boolean hasPermission(String journalType); void requestPermission(String journalType); + + CollectionInfo[] getJournalEntries(String journalType); } diff --git a/app/src/main/java/com/etesync/syncadapter/model/CollectionInfo.java b/app/src/main/java/com/etesync/syncadapter/model/CollectionInfo.java index f1f99c48..691d1d79 100644 --- a/app/src/main/java/com/etesync/syncadapter/model/CollectionInfo.java +++ b/app/src/main/java/com/etesync/syncadapter/model/CollectionInfo.java @@ -9,6 +9,8 @@ package com.etesync.syncadapter.model; import android.content.ContentValues; +import android.os.Parcel; +import android.os.Parcelable; import com.etesync.syncadapter.journalmanager.Constants; import com.etesync.syncadapter.journalmanager.JournalManager; @@ -23,7 +25,7 @@ import io.requery.sql.EntityDataStore; import lombok.ToString; @ToString(exclude = {"id"}) -public class CollectionInfo implements Serializable { +public class CollectionInfo implements Parcelable, Serializable { @Deprecated public long id; @@ -58,6 +60,17 @@ public class CollectionInfo implements Serializable { version = Constants.CURRENT_VERSION; } + protected CollectionInfo(Parcel in) { + id = in.readLong(); + serviceID = in.readInt(); + version = in.readInt(); + uid = in.readString(); + displayName = in.readString(); + description = in.readString(); + timeZone = in.readString(); + selected = in.readByte() != 0; + } + public static CollectionInfo defaultForServiceType(Type service) { CollectionInfo info = new CollectionInfo(); info.displayName = "Default"; @@ -110,4 +123,33 @@ public class CollectionInfo implements Serializable { return (i == null) ? null : (i != 0); } + + public static final Creator CREATOR = new Creator() { + @Override + public CollectionInfo createFromParcel(Parcel in) { + return new CollectionInfo(in); + } + + @Override + public CollectionInfo[] newArray(int size) { + return new CollectionInfo[size]; + } + }; + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel aParcel, int aI) { + aParcel.writeLong(id); + aParcel.writeInt(serviceID); + aParcel.writeInt(version); + aParcel.writeString(uid); + aParcel.writeString(displayName); + aParcel.writeString(description); + aParcel.writeString(timeZone); + aParcel.writeByte((byte) (selected ? 1 : 0)); + } } diff --git a/app/src/main/java/com/etesync/syncadapter/remote/ApiPermissionHelper.java b/app/src/main/java/com/etesync/syncadapter/remote/ApiPermissionHelper.java index a3441d38..524521fe 100644 --- a/app/src/main/java/com/etesync/syncadapter/remote/ApiPermissionHelper.java +++ b/app/src/main/java/com/etesync/syncadapter/remote/ApiPermissionHelper.java @@ -122,6 +122,8 @@ public class ApiPermissionHelper { String[] callingPackages = mPackageManager.getPackagesForUid(uid); + if (callingPackages == null) return false; + // is calling package allowed to use this service? for (String currentPkg : callingPackages) { if (isPackageAllowed(currentPkg, journalType)) { @@ -144,7 +146,7 @@ public class ApiPermissionHelper { App.log.warning("Package is NOT allowed! packageName: " + packageName + " for journal type " + journalType); return false; } - App.log.info("Package is allowed! packageName: " + packageName + " for journal type " + journalType); + App.log.info("Package is allowed. packageName: " + packageName + " for journal type " + journalType); byte[] currentPackageCert; try { diff --git a/app/src/main/java/com/etesync/syncadapter/remote/RemoteService.java b/app/src/main/java/com/etesync/syncadapter/remote/RemoteService.java index 39e6b24c..44854e87 100644 --- a/app/src/main/java/com/etesync/syncadapter/remote/RemoteService.java +++ b/app/src/main/java/com/etesync/syncadapter/remote/RemoteService.java @@ -14,6 +14,7 @@ import android.os.IBinder; import android.os.RemoteException; import com.etesync.syncadapter.IEteSyncService; +import com.etesync.syncadapter.model.CollectionInfo; public class RemoteService extends Service { @@ -34,6 +35,12 @@ public class RemoteService extends Service { RemoteRegisterActivity.startActivity(RemoteService.this, mApiPermissionHelper.getCurrentCallingPackage(), journalType); } + + public CollectionInfo[] getJournalEntries(String journalType) throws RemoteException { + if (!mApiPermissionHelper.isAllowedIgnoreErrors(journalType)) return null; + + return new CollectionInfo[0]; //todo implement + } }; @Override diff --git a/app/src/main/java/com/etesync/syncadapter/ui/CollectionMembersActivity.java b/app/src/main/java/com/etesync/syncadapter/ui/CollectionMembersActivity.java index 42661b12..042c9ed5 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/CollectionMembersActivity.java +++ b/app/src/main/java/com/etesync/syncadapter/ui/CollectionMembersActivity.java @@ -5,6 +5,7 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; +import android.os.Parcelable; import android.support.v4.app.DialogFragment; import android.support.v7.app.AlertDialog; import android.text.InputType; @@ -19,6 +20,8 @@ import com.etesync.syncadapter.model.CollectionInfo; import com.etesync.syncadapter.model.JournalEntity; import com.etesync.syncadapter.resource.LocalCalendar; +import java.io.Serializable; + import io.requery.Persistable; import io.requery.sql.EntityDataStore; @@ -34,7 +37,7 @@ public class CollectionMembersActivity extends BaseActivity implements Refreshab public static Intent newIntent(Context context, Account account, CollectionInfo info) { Intent intent = new Intent(context, CollectionMembersActivity.class); intent.putExtra(CollectionMembersActivity.EXTRA_ACCOUNT, account); - intent.putExtra(CollectionMembersActivity.EXTRA_COLLECTION_INFO, info); + intent.putExtra(CollectionMembersActivity.EXTRA_COLLECTION_INFO, (Serializable) info); return intent; } diff --git a/app/src/main/java/com/etesync/syncadapter/ui/CreateCollectionActivity.java b/app/src/main/java/com/etesync/syncadapter/ui/CreateCollectionActivity.java index 808fc26f..1280f505 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/CreateCollectionActivity.java +++ b/app/src/main/java/com/etesync/syncadapter/ui/CreateCollectionActivity.java @@ -25,11 +25,13 @@ import com.etesync.syncadapter.model.CollectionInfo; import org.apache.commons.lang3.StringUtils; +import java.io.Serializable; + import yuku.ambilwarna.AmbilWarnaDialog; public class CreateCollectionActivity extends BaseActivity { static final String EXTRA_ACCOUNT = "account", - EXTRA_COLLECTION_INFO = "collectionInfo"; + EXTRA_COLLECTION_INFO = "collectionInfo"; protected Account account; protected CollectionInfo info; @@ -37,7 +39,7 @@ public class CreateCollectionActivity extends BaseActivity { public static Intent newIntent(Context context, Account account, CollectionInfo info) { Intent intent = new Intent(context, CreateCollectionActivity.class); intent.putExtra(CreateCollectionActivity.EXTRA_ACCOUNT, account); - intent.putExtra(CreateCollectionActivity.EXTRA_COLLECTION_INFO, info); + intent.putExtra(CreateCollectionActivity.EXTRA_COLLECTION_INFO, (Serializable) info); return intent; } diff --git a/app/src/main/java/com/etesync/syncadapter/ui/EditCollectionActivity.java b/app/src/main/java/com/etesync/syncadapter/ui/EditCollectionActivity.java index 9bc3a4bb..cd37fae0 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/EditCollectionActivity.java +++ b/app/src/main/java/com/etesync/syncadapter/ui/EditCollectionActivity.java @@ -24,6 +24,8 @@ import com.etesync.syncadapter.model.CollectionInfo; import com.etesync.syncadapter.model.JournalEntity; import com.etesync.syncadapter.resource.LocalCalendar; +import java.io.Serializable; + import io.requery.Persistable; import io.requery.sql.EntityDataStore; @@ -31,7 +33,7 @@ public class EditCollectionActivity extends CreateCollectionActivity { public static Intent newIntent(Context context, Account account, CollectionInfo info) { Intent intent = new Intent(context, EditCollectionActivity.class); intent.putExtra(CreateCollectionActivity.EXTRA_ACCOUNT, account); - intent.putExtra(CreateCollectionActivity.EXTRA_COLLECTION_INFO, info); + intent.putExtra(CreateCollectionActivity.EXTRA_COLLECTION_INFO, (Serializable) info); return intent; } diff --git a/app/src/main/java/com/etesync/syncadapter/ui/ViewCollectionActivity.java b/app/src/main/java/com/etesync/syncadapter/ui/ViewCollectionActivity.java index 604599e9..bc3f3354 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/ViewCollectionActivity.java +++ b/app/src/main/java/com/etesync/syncadapter/ui/ViewCollectionActivity.java @@ -36,6 +36,7 @@ import com.etesync.syncadapter.utils.HintManager; import com.etesync.syncadapter.utils.ShowcaseBuilder; import java.io.FileNotFoundException; +import java.io.Serializable; import java.util.Locale; import at.bitfire.ical4android.CalendarStorageException; @@ -58,7 +59,7 @@ public class ViewCollectionActivity extends BaseActivity implements Refreshable public static Intent newIntent(Context context, Account account, CollectionInfo info) { Intent intent = new Intent(context, ViewCollectionActivity.class); intent.putExtra(ViewCollectionActivity.EXTRA_ACCOUNT, account); - intent.putExtra(ViewCollectionActivity.EXTRA_COLLECTION_INFO, info); + intent.putExtra(ViewCollectionActivity.EXTRA_COLLECTION_INFO, (Serializable) info); return intent; } diff --git a/app/src/main/java/com/etesync/syncadapter/ui/importlocal/ImportActivity.java b/app/src/main/java/com/etesync/syncadapter/ui/importlocal/ImportActivity.java index a13e4fdc..2ae514b8 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/importlocal/ImportActivity.java +++ b/app/src/main/java/com/etesync/syncadapter/ui/importlocal/ImportActivity.java @@ -18,8 +18,11 @@ import android.widget.TextView; import com.etesync.syncadapter.R; import com.etesync.syncadapter.model.CollectionInfo; import com.etesync.syncadapter.ui.BaseActivity; +import java.io.Serializable; + public class ImportActivity extends BaseActivity implements SelectImportMethod, ResultFragment.OnImportCallback, DialogInterface { + public final static String EXTRA_ACCOUNT = "account", EXTRA_COLLECTION_INFO = "collectionInfo"; @@ -29,7 +32,7 @@ public class ImportActivity extends BaseActivity implements SelectImportMethod, public static Intent newIntent(Context context, Account account, CollectionInfo info) { Intent intent = new Intent(context, ImportActivity.class); intent.putExtra(ImportActivity.EXTRA_ACCOUNT, account); - intent.putExtra(ImportActivity.EXTRA_COLLECTION_INFO, info); + intent.putExtra(ImportActivity.EXTRA_COLLECTION_INFO, (Serializable) info); return intent; }