1
0
mirror of https://github.com/etesync/android synced 2024-12-23 07:08:16 +00:00

Remote Service - Add query journal enteries

This commit is contained in:
Tal Hacohen 2017-05-09 21:12:13 +03:00
parent 835d2c833c
commit 84f98b5699
9 changed files with 73 additions and 8 deletions

View File

@ -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);
}

View File

@ -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<CollectionInfo> CREATOR = new Creator<CollectionInfo>() {
@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));
}
}

View File

@ -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 {

View File

@ -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

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}