mirror of
https://github.com/TeamVanced/VancedMicroG
synced 2025-01-03 08:06:13 +01:00
Small updates to wearable
This commit is contained in:
parent
192a9073e4
commit
6d2eee71bb
2
extern/GmsApi
vendored
2
extern/GmsApi
vendored
@ -1 +1 @@
|
||||
Subproject commit 865b41664d6afabecddbd1a5d1b7c702d0bd821f
|
||||
Subproject commit 18582ce01a3ba70f1332524bba38a0b54ba6b13f
|
2
extern/Wearable
vendored
2
extern/Wearable
vendored
@ -1 +1 @@
|
||||
Subproject commit e6d59dc062def314cdebf64699b15bb8b6a5eede
|
||||
Subproject commit c12fe119c8f71b4e7b458f480270f686dae34343
|
@ -113,6 +113,7 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
libraries.add(new Library("org.microg.safeparcel", "microG SafeParcel", "Apache License 2.0, Copyright © microG Team"));
|
||||
libraries.add(new Library("org.microg.nlp", "microG UnifiedNlp", "Apache License 2.0, Copyright © microG Team"));
|
||||
libraries.add(new Library("org.microg.nlp.api", "microG UnifiedNlp Api", "Apache License 2.0, Copyright © microG Team"));
|
||||
libraries.add(new Library("org.microg.wearable", "microG Wearable", "Apache License 2.0, Copyright © microG Team"));
|
||||
libraries.add(new Library("de.hdodenhof.circleimageview", "CircleImageView", "Apache License 2.0, Copyright © Henning Dodenhof"));
|
||||
libraries.add(new Library("org.oscim.android", "<vector<tile>>map", "GNU LGPLv3, Copyright © Hannes Janetzek"));
|
||||
libraries.add(new Library("com.squareup.wire", "Wire Protocol Buffers", "Apache License 2.0, Copyright © Square Inc."));
|
||||
|
@ -26,10 +26,13 @@ import com.google.android.gms.wearable.ConnectionConfiguration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class ConfigurationDatabaseHelper extends SQLiteOpenHelper {
|
||||
|
||||
public static final String NULL_STRING = "NULL_STRING";
|
||||
public static final String TABLE_NAME = "connectionConfigurations";
|
||||
public static final String BY_NAME = "name=?";
|
||||
|
||||
public ConfigurationDatabaseHelper(Context context) {
|
||||
super(context, "connectionconfig.db", null, 2);
|
||||
@ -58,7 +61,7 @@ public class ConfigurationDatabaseHelper extends SQLiteOpenHelper {
|
||||
}
|
||||
|
||||
public ConnectionConfiguration getConfiguration(String name) {
|
||||
Cursor cursor = getReadableDatabase().query("connectionConfigurations", null, "name=?", new String[]{name}, null, null, null);
|
||||
Cursor cursor = getReadableDatabase().query(TABLE_NAME, null, BY_NAME, new String[]{name}, null, null, null);
|
||||
ConnectionConfiguration config = null;
|
||||
if (cursor != null) {
|
||||
if (cursor.moveToNext())
|
||||
@ -86,11 +89,11 @@ public class ConfigurationDatabaseHelper extends SQLiteOpenHelper {
|
||||
contentValues.put("role", config.role);
|
||||
contentValues.put("connectionEnabled", true);
|
||||
contentValues.put("nodeId", config.nodeId);
|
||||
getWritableDatabase().insert("connectionConfigurations", null, contentValues);
|
||||
getWritableDatabase().insert(TABLE_NAME, null, contentValues);
|
||||
}
|
||||
|
||||
public ConnectionConfiguration[] getAllConfigurations() {
|
||||
Cursor cursor = getReadableDatabase().query("connectionConfigurations", null, null, null, null, null, null);
|
||||
Cursor cursor = getReadableDatabase().query(TABLE_NAME, null, null, null, null, null, null);
|
||||
if (cursor != null) {
|
||||
List<ConnectionConfiguration> configurations = new ArrayList<ConnectionConfiguration>();
|
||||
while (cursor.moveToNext()) {
|
||||
@ -106,4 +109,8 @@ public class ConfigurationDatabaseHelper extends SQLiteOpenHelper {
|
||||
public void setEnabledState(String name, boolean enabled) {
|
||||
getWritableDatabase().execSQL("UPDATE connectionConfigurations SET connectionEnabled=? WHERE name=?", new String[]{enabled ? "1" : "0", name});
|
||||
}
|
||||
|
||||
public int deleteConfiguration(String name) {
|
||||
return getWritableDatabase().delete(TABLE_NAME, BY_NAME, new String[]{name});
|
||||
}
|
||||
}
|
||||
|
@ -104,11 +104,16 @@ public class MessageHandler extends ServerMessageListener {
|
||||
if (syncStart.version < 2) {
|
||||
Log.d(TAG, "Sync uses version " + syncStart.version + " which is not supported (yet)");
|
||||
}
|
||||
boolean hasLocalNode = false;
|
||||
if (syncStart.syncTable != null) {
|
||||
for (SyncTableEntry entry : syncStart.syncTable) {
|
||||
service.syncToPeer(getConnection(), entry.key, entry.value);
|
||||
if (service.getLocalNodeId().equals(entry.key)) hasLocalNode = true;
|
||||
}
|
||||
} else {
|
||||
Log.d(TAG, "No sync table given.");
|
||||
}
|
||||
if (!hasLocalNode) service.syncToPeer(getConnection(), service.getLocalNodeId(), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -137,8 +142,8 @@ public class MessageHandler extends ServerMessageListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHearbeat(Heartbeat heartbeat) {
|
||||
Log.d(TAG, "onHearbeat: " + heartbeat);
|
||||
public void onHeartbeat(Heartbeat heartbeat) {
|
||||
Log.d(TAG, "onHeartbeat: " + heartbeat);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,6 +21,7 @@ import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.android.gms.wearable.Asset;
|
||||
@ -188,7 +189,7 @@ public class NodeDatabaseHelper extends SQLiteOpenHelper {
|
||||
}
|
||||
|
||||
public Cursor getModifiedDataItems(final String nodeId, final long seqId, final boolean excludeDeleted) {
|
||||
String selection = "sourceNode =? AND seqId >?" + (excludeDeleted ? "AND deleted =0" : "");
|
||||
String selection = "sourceNode =? AND seqId >?" + (excludeDeleted ? " AND deleted =0" : "");
|
||||
return getReadableDatabase().query("dataItemsAndAssets", GDIBHAP_FIELDS, selection, new String[]{nodeId, Long.toString(seqId)}, null, null, "seqId", null);
|
||||
}
|
||||
|
||||
@ -211,6 +212,7 @@ public class NodeDatabaseHelper extends SQLiteOpenHelper {
|
||||
}
|
||||
|
||||
public long getCurrentSeqId(String sourceNode) {
|
||||
if (TextUtils.isEmpty(sourceNode)) return 1;
|
||||
SQLiteDatabase db = getReadableDatabase();
|
||||
Cursor cursor = db.query("dataItemsAndAssets", new String[]{"seqId"}, "sourceNode=?", new String[]{sourceNode}, null, null, "seqId DESC", "1");
|
||||
long res = 1;
|
||||
|
@ -99,7 +99,7 @@ public class WearableServiceImpl extends IWearableService.Stub implements IWeara
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
private String getLocalNodeId() {
|
||||
public String getLocalNodeId() {
|
||||
SharedPreferences preferences = context.getSharedPreferences(CLOCKWORK_NODE_PREFERENCES, Context.MODE_PRIVATE);
|
||||
String nodeId = preferences.getString(CLOCKWORK_NODE_PREFERENCE_NODE_ID, null);
|
||||
if (nodeId == null) {
|
||||
@ -276,12 +276,20 @@ public class WearableServiceImpl extends IWearableService.Stub implements IWeara
|
||||
|
||||
@Override
|
||||
public void putConfig(IWearableCallbacks callbacks, ConnectionConfiguration config) throws RemoteException {
|
||||
if (config.nodeId == null) config.nodeId = getLocalNodeId();
|
||||
Log.d(TAG, "putConfig[nyp]: " + config);
|
||||
configDatabase.putConfiguration(config);
|
||||
configurationsUpdated = true;
|
||||
callbacks.onStatus(Status.SUCCESS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteConfig(IWearableCallbacks callbacks, String name) throws RemoteException {
|
||||
configDatabase.deleteConfiguration(name);
|
||||
configurationsUpdated = true;
|
||||
callbacks.onStatus(Status.SUCCESS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getConfig(IWearableCallbacks callbacks) throws RemoteException {
|
||||
Log.d(TAG, "getConfig");
|
||||
@ -460,10 +468,12 @@ public class WearableServiceImpl extends IWearableService.Stub implements IWeara
|
||||
}
|
||||
|
||||
public void syncToPeer(WearableConnection connection, String nodeId, long seqId) {
|
||||
Log.d(TAG, "-- Start syncing over " + connection + ", nodeId " + nodeId + " starting with seqId " + seqId);
|
||||
Cursor cursor = nodeDatabase.getModifiedDataItems(nodeId, seqId, true);
|
||||
if (cursor != null) {
|
||||
while (cursor.moveToNext()) {
|
||||
DataItemRecord record = DataItemRecord.fromCursor(cursor);
|
||||
Log.d(TAG, "Sync over " + connection + ": " + record);
|
||||
SetDataItem.Builder builder = new SetDataItem.Builder()
|
||||
.packageName(record.packageName)
|
||||
.signatureDigest(record.signatureDigest)
|
||||
@ -493,6 +503,7 @@ public class WearableServiceImpl extends IWearableService.Stub implements IWeara
|
||||
}
|
||||
cursor.close();
|
||||
}
|
||||
Log.d(TAG, "-- Done syncing over " + connection + ", nodeId " + nodeId + " starting with seqId " + seqId);
|
||||
}
|
||||
|
||||
public long getCurrentSeqId(String nodeId) {
|
||||
|
Loading…
Reference in New Issue
Block a user