mirror of
https://github.com/etesync/android
synced 2024-11-22 07:58:09 +00:00
Remote Service - Add query journal enteries
This commit is contained in:
parent
835d2c833c
commit
84f98b5699
@ -2,10 +2,13 @@
|
|||||||
package com.etesync.syncadapter;
|
package com.etesync.syncadapter;
|
||||||
|
|
||||||
// Declare any non-default types here with import statements
|
// Declare any non-default types here with import statements
|
||||||
|
import com.etesync.syncadapter.model.CollectionInfo;
|
||||||
|
|
||||||
interface IEteSyncService {
|
interface IEteSyncService {
|
||||||
boolean hasPermission(String journalType);
|
boolean hasPermission(String journalType);
|
||||||
|
|
||||||
void requestPermission(String journalType);
|
void requestPermission(String journalType);
|
||||||
|
|
||||||
|
CollectionInfo[] getJournalEntries(String journalType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
package com.etesync.syncadapter.model;
|
package com.etesync.syncadapter.model;
|
||||||
|
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
|
||||||
import com.etesync.syncadapter.journalmanager.Constants;
|
import com.etesync.syncadapter.journalmanager.Constants;
|
||||||
import com.etesync.syncadapter.journalmanager.JournalManager;
|
import com.etesync.syncadapter.journalmanager.JournalManager;
|
||||||
@ -23,7 +25,7 @@ import io.requery.sql.EntityDataStore;
|
|||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
@ToString(exclude = {"id"})
|
@ToString(exclude = {"id"})
|
||||||
public class CollectionInfo implements Serializable {
|
public class CollectionInfo implements Parcelable, Serializable {
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public long id;
|
public long id;
|
||||||
|
|
||||||
@ -58,6 +60,17 @@ public class CollectionInfo implements Serializable {
|
|||||||
version = Constants.CURRENT_VERSION;
|
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) {
|
public static CollectionInfo defaultForServiceType(Type service) {
|
||||||
CollectionInfo info = new CollectionInfo();
|
CollectionInfo info = new CollectionInfo();
|
||||||
info.displayName = "Default";
|
info.displayName = "Default";
|
||||||
@ -110,4 +123,33 @@ public class CollectionInfo implements Serializable {
|
|||||||
return (i == null) ? null : (i != 0);
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,6 +122,8 @@ public class ApiPermissionHelper {
|
|||||||
|
|
||||||
String[] callingPackages = mPackageManager.getPackagesForUid(uid);
|
String[] callingPackages = mPackageManager.getPackagesForUid(uid);
|
||||||
|
|
||||||
|
if (callingPackages == null) return false;
|
||||||
|
|
||||||
// is calling package allowed to use this service?
|
// is calling package allowed to use this service?
|
||||||
for (String currentPkg : callingPackages) {
|
for (String currentPkg : callingPackages) {
|
||||||
if (isPackageAllowed(currentPkg, journalType)) {
|
if (isPackageAllowed(currentPkg, journalType)) {
|
||||||
@ -144,7 +146,7 @@ public class ApiPermissionHelper {
|
|||||||
App.log.warning("Package is NOT allowed! packageName: " + packageName + " for journal type " + journalType);
|
App.log.warning("Package is NOT allowed! packageName: " + packageName + " for journal type " + journalType);
|
||||||
return false;
|
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;
|
byte[] currentPackageCert;
|
||||||
try {
|
try {
|
||||||
|
@ -14,6 +14,7 @@ import android.os.IBinder;
|
|||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
|
||||||
import com.etesync.syncadapter.IEteSyncService;
|
import com.etesync.syncadapter.IEteSyncService;
|
||||||
|
import com.etesync.syncadapter.model.CollectionInfo;
|
||||||
|
|
||||||
public class RemoteService extends Service {
|
public class RemoteService extends Service {
|
||||||
|
|
||||||
@ -34,6 +35,12 @@ public class RemoteService extends Service {
|
|||||||
RemoteRegisterActivity.startActivity(RemoteService.this,
|
RemoteRegisterActivity.startActivity(RemoteService.this,
|
||||||
mApiPermissionHelper.getCurrentCallingPackage(), journalType);
|
mApiPermissionHelper.getCurrentCallingPackage(), journalType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CollectionInfo[] getJournalEntries(String journalType) throws RemoteException {
|
||||||
|
if (!mApiPermissionHelper.isAllowedIgnoreErrors(journalType)) return null;
|
||||||
|
|
||||||
|
return new CollectionInfo[0]; //todo implement
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -5,6 +5,7 @@ import android.content.Context;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Parcelable;
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
@ -19,6 +20,8 @@ import com.etesync.syncadapter.model.CollectionInfo;
|
|||||||
import com.etesync.syncadapter.model.JournalEntity;
|
import com.etesync.syncadapter.model.JournalEntity;
|
||||||
import com.etesync.syncadapter.resource.LocalCalendar;
|
import com.etesync.syncadapter.resource.LocalCalendar;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
import io.requery.Persistable;
|
import io.requery.Persistable;
|
||||||
import io.requery.sql.EntityDataStore;
|
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) {
|
public static Intent newIntent(Context context, Account account, CollectionInfo info) {
|
||||||
Intent intent = new Intent(context, CollectionMembersActivity.class);
|
Intent intent = new Intent(context, CollectionMembersActivity.class);
|
||||||
intent.putExtra(CollectionMembersActivity.EXTRA_ACCOUNT, account);
|
intent.putExtra(CollectionMembersActivity.EXTRA_ACCOUNT, account);
|
||||||
intent.putExtra(CollectionMembersActivity.EXTRA_COLLECTION_INFO, info);
|
intent.putExtra(CollectionMembersActivity.EXTRA_COLLECTION_INFO, (Serializable) info);
|
||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,11 +25,13 @@ import com.etesync.syncadapter.model.CollectionInfo;
|
|||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
import yuku.ambilwarna.AmbilWarnaDialog;
|
import yuku.ambilwarna.AmbilWarnaDialog;
|
||||||
|
|
||||||
public class CreateCollectionActivity extends BaseActivity {
|
public class CreateCollectionActivity extends BaseActivity {
|
||||||
static final String EXTRA_ACCOUNT = "account",
|
static final String EXTRA_ACCOUNT = "account",
|
||||||
EXTRA_COLLECTION_INFO = "collectionInfo";
|
EXTRA_COLLECTION_INFO = "collectionInfo";
|
||||||
|
|
||||||
protected Account account;
|
protected Account account;
|
||||||
protected CollectionInfo info;
|
protected CollectionInfo info;
|
||||||
@ -37,7 +39,7 @@ public class CreateCollectionActivity extends BaseActivity {
|
|||||||
public static Intent newIntent(Context context, Account account, CollectionInfo info) {
|
public static Intent newIntent(Context context, Account account, CollectionInfo info) {
|
||||||
Intent intent = new Intent(context, CreateCollectionActivity.class);
|
Intent intent = new Intent(context, CreateCollectionActivity.class);
|
||||||
intent.putExtra(CreateCollectionActivity.EXTRA_ACCOUNT, account);
|
intent.putExtra(CreateCollectionActivity.EXTRA_ACCOUNT, account);
|
||||||
intent.putExtra(CreateCollectionActivity.EXTRA_COLLECTION_INFO, info);
|
intent.putExtra(CreateCollectionActivity.EXTRA_COLLECTION_INFO, (Serializable) info);
|
||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@ import com.etesync.syncadapter.model.CollectionInfo;
|
|||||||
import com.etesync.syncadapter.model.JournalEntity;
|
import com.etesync.syncadapter.model.JournalEntity;
|
||||||
import com.etesync.syncadapter.resource.LocalCalendar;
|
import com.etesync.syncadapter.resource.LocalCalendar;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
import io.requery.Persistable;
|
import io.requery.Persistable;
|
||||||
import io.requery.sql.EntityDataStore;
|
import io.requery.sql.EntityDataStore;
|
||||||
|
|
||||||
@ -31,7 +33,7 @@ public class EditCollectionActivity extends CreateCollectionActivity {
|
|||||||
public static Intent newIntent(Context context, Account account, CollectionInfo info) {
|
public static Intent newIntent(Context context, Account account, CollectionInfo info) {
|
||||||
Intent intent = new Intent(context, EditCollectionActivity.class);
|
Intent intent = new Intent(context, EditCollectionActivity.class);
|
||||||
intent.putExtra(CreateCollectionActivity.EXTRA_ACCOUNT, account);
|
intent.putExtra(CreateCollectionActivity.EXTRA_ACCOUNT, account);
|
||||||
intent.putExtra(CreateCollectionActivity.EXTRA_COLLECTION_INFO, info);
|
intent.putExtra(CreateCollectionActivity.EXTRA_COLLECTION_INFO, (Serializable) info);
|
||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ import com.etesync.syncadapter.utils.HintManager;
|
|||||||
import com.etesync.syncadapter.utils.ShowcaseBuilder;
|
import com.etesync.syncadapter.utils.ShowcaseBuilder;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import at.bitfire.ical4android.CalendarStorageException;
|
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) {
|
public static Intent newIntent(Context context, Account account, CollectionInfo info) {
|
||||||
Intent intent = new Intent(context, ViewCollectionActivity.class);
|
Intent intent = new Intent(context, ViewCollectionActivity.class);
|
||||||
intent.putExtra(ViewCollectionActivity.EXTRA_ACCOUNT, account);
|
intent.putExtra(ViewCollectionActivity.EXTRA_ACCOUNT, account);
|
||||||
intent.putExtra(ViewCollectionActivity.EXTRA_COLLECTION_INFO, info);
|
intent.putExtra(ViewCollectionActivity.EXTRA_COLLECTION_INFO, (Serializable) info);
|
||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,8 +18,11 @@ import android.widget.TextView;
|
|||||||
import com.etesync.syncadapter.R;
|
import com.etesync.syncadapter.R;
|
||||||
import com.etesync.syncadapter.model.CollectionInfo;
|
import com.etesync.syncadapter.model.CollectionInfo;
|
||||||
import com.etesync.syncadapter.ui.BaseActivity;
|
import com.etesync.syncadapter.ui.BaseActivity;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
|
||||||
public class ImportActivity extends BaseActivity implements SelectImportMethod, ResultFragment.OnImportCallback, DialogInterface {
|
public class ImportActivity extends BaseActivity implements SelectImportMethod, ResultFragment.OnImportCallback, DialogInterface {
|
||||||
|
|
||||||
public final static String EXTRA_ACCOUNT = "account",
|
public final static String EXTRA_ACCOUNT = "account",
|
||||||
EXTRA_COLLECTION_INFO = "collectionInfo";
|
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) {
|
public static Intent newIntent(Context context, Account account, CollectionInfo info) {
|
||||||
Intent intent = new Intent(context, ImportActivity.class);
|
Intent intent = new Intent(context, ImportActivity.class);
|
||||||
intent.putExtra(ImportActivity.EXTRA_ACCOUNT, account);
|
intent.putExtra(ImportActivity.EXTRA_ACCOUNT, account);
|
||||||
intent.putExtra(ImportActivity.EXTRA_COLLECTION_INFO, info);
|
intent.putExtra(ImportActivity.EXTRA_COLLECTION_INFO, (Serializable) info);
|
||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user