Add notification uris to ApiAppDao

This commit is contained in:
Vincent Breitmoser
2018-07-02 19:00:32 +02:00
parent 7ab2161cba
commit bf9179391b
4 changed files with 156 additions and 102 deletions

View File

@@ -78,12 +78,16 @@ public class ApiAppDao extends AbstractDao {
InsertApiApp statement = new ApiAppsModel.InsertApiApp(getWritableDb());
statement.bind(apiApp.package_name(), apiApp.package_signature());
statement.executeInsert();
getDatabaseNotifyManager().notifyApiAppChange(apiApp.package_name());
}
public void deleteApiApp(String packageName) {
DeleteByPackageName deleteByPackageName = new DeleteByPackageName(getWritableDb());
deleteByPackageName.bind(packageName);
deleteByPackageName.executeUpdateDelete();
getDatabaseNotifyManager().notifyApiAppChange(packageName);
}
public HashSet<Long> getAllowedKeyIdsForApp(String packageName) {
@@ -108,12 +112,16 @@ public class ApiAppDao extends AbstractDao {
statement.bind(packageName, keyId);
statement.execute();
}
getDatabaseNotifyManager().notifyApiAppChange(packageName);
}
public void addAllowedKeyIdForApp(String packageName, long allowedKeyId) {
InsertAllowedKey statement = new InsertAllowedKey(getWritableDb());
statement.bind(packageName, allowedKeyId);
statement.execute();
getDatabaseNotifyManager().notifyApiAppChange(packageName);
}
public List<ApiApp> getAllApiApps() {

View File

@@ -9,7 +9,8 @@ import org.sufficientlysecure.keychain.Constants;
public class DatabaseNotifyManager {
private static final Uri BASE_URI = Uri.parse("content://" + Constants.PROVIDER_AUTHORITY);
private static final Uri URI_KEYS = Uri.parse("content://" + Constants.PROVIDER_AUTHORITY + "/keys");
private static final Uri URI_APPS = Uri.parse("content://" + Constants.PROVIDER_AUTHORITY + "/apps");
private ContentResolver contentResolver;
@@ -42,11 +43,24 @@ public class DatabaseNotifyManager {
contentResolver.notifyChange(uri, null);
}
public void notifyApiAppChange(String apiApp) {
Uri uri = getNotifyUriPackageName(apiApp);
contentResolver.notifyChange(uri, null);
}
public static Uri getNotifyUriAllKeys() {
return BASE_URI;
return URI_KEYS;
}
public static Uri getNotifyUriMasterKeyId(long masterKeyId) {
return BASE_URI.buildUpon().appendPath(Long.toString(masterKeyId)).build();
return URI_KEYS.buildUpon().appendPath(Long.toString(masterKeyId)).build();
}
public static Uri getNotifyUriAllApps() {
return URI_APPS;
}
public static Uri getNotifyUriPackageName(String packageName) {
return URI_APPS.buildUpon().appendPath(packageName).build();
}
}