Skip to content

Commit 72ee3bc

Browse files
committed
Combined changes:
- Adapt to GmsApi changes - Add GmsLib for play-services-wearable library - Increase version code (fixes microg#167) - Update wearable
1 parent 5aa68cc commit 72ee3bc

24 files changed

+115
-657
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@
77
[submodule "extern/Wearable"]
88
path = extern/Wearable
99
url = https://github.com/microg/android_external_Wearable.git
10+
[submodule "extern/GmsLib"]
11+
path = extern/GmsLib
12+
url = https://github.com/microg/android_external_GmsLib.git

build.gradle

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
subprojects {
2+
group = 'org.microg'
3+
repositories {
4+
jcenter()
5+
}
6+
}
7+

extern/GmsApi

Submodule GmsApi updated 62 files

extern/GmsLib

Submodule GmsLib added at 310127d

play-services-base

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extern/GmsLib/play-services-base

play-services-basement

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extern/GmsApi/play-services-basement

play-services-common-api

-1
This file was deleted.

play-services-core/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ dependencies {
3838

3939
compile project(":microg-ui-tools")
4040
compile project(':play-services-api')
41+
compile project(':play-services-wearable')
4142
compile project(':unifiednlp-base')
4243
compile project(':wearable-lib')
4344

@@ -80,8 +81,7 @@ android {
8081
versionName getMyVersionName()
8182
def x = getMyVersionCode()
8283
// We are not allowed to freely choose the hundreds column as it defines the device type
83-
// Update commit id to current when increasing gms version code
84-
versionCode(9256200 + x % 100 + ((int) (x / 100)) * 1000)
84+
versionCode(9450200 + x % 100 + ((int) (x / 100)) * 1000)
8585

8686
ndk {
8787
abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86"

play-services-core/src/main/AndroidManifest.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@
130130
</service>
131131

132132
<service
133-
android:name="org.microg.gms.wearable.WearableLocationService"
134-
android:exported="false">
133+
android:name="org.microg.gms.wearable.location.WearableLocationService">
135134
<intent-filter>
136135
<action android:name="com.google.android.gms.wearable.MESSAGE_RECEIVED"/>
136+
<data android:scheme="wear" android:host="*" android:pathPrefix="/com/google/android/location/fused/wearable" />
137137
</intent-filter>
138138
</service>
139139

play-services-core/src/main/java/org/microg/gms/common/RemoteListenerProxy.java

+3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ private boolean connect() {
6666
if (!connecting) Log.d(TAG, "Could not connect to: " + intent);
6767
return connecting;
6868
}
69+
Log.d(TAG, "Unable to resolve: " + searchIntent);
6970
return false;
7071
} catch (Exception e) {
7172
Log.w(TAG, e);
@@ -95,6 +96,8 @@ public void onServiceConnected(ComponentName name, IBinder service) {
9596
}
9697
waiting.clear();
9798
context.unbindService(RemoteListenerProxy.this);
99+
connecting = false;
100+
remote = null;
98101
}
99102
}
100103
}

play-services-core/src/main/java/org/microg/gms/wearable/NodeDatabaseHelper.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,20 @@ public synchronized Cursor getDataItemsForDataHolderByHostAndPath(String package
7575
if (path == null) {
7676
params = new String[]{packageName, signatureDigest};
7777
selection = "packageName = ? AND signatureDigest = ?";
78-
} else if (host == null) {
78+
} else if (TextUtils.isEmpty(host)) {
7979
if (path.endsWith("/")) path = path + "%";
80+
path = path.replace("*", "%");
8081
params = new String[]{packageName, signatureDigest, path};
8182
selection = "packageName = ? AND signatureDigest = ? AND path LIKE ?";
8283
} else {
8384
if (path.endsWith("/")) path = path + "%";
85+
path = path.replace("*", "%");
86+
host = host.replace("*", "%");
8487
params = new String[]{packageName, signatureDigest, host, path};
8588
selection = "packageName = ? AND signatureDigest = ? AND host = ? AND path LIKE ?";
8689
}
8790
selection += " AND deleted=0 AND assetsPresent !=0";
88-
return getReadableDatabase().rawQuery("SELECT host AS host,path AS path,data AS data,\'\' AS tags,assetname AS asset_key,assets_digest AS asset_id FROM dataItemsAndAssets WHERE " + selection, params);
91+
return getReadableDatabase().rawQuery("SELECT null AS host,printf(\"wear://%s%s\",host,path) AS path,data AS data,\'\' AS tags,assetname AS asset_key,assets_digest AS asset_id FROM dataItemsAndAssets WHERE " + selection, params);
8992
}
9093

9194
public synchronized Cursor getDataItemsByHostAndPath(String packageName, String signatureDigest, String host, String path) {

play-services-core/src/main/java/org/microg/gms/wearable/WearableImpl.java

+22-18
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,7 @@ public void onConnectedNodes(List<NodeParcelable> nodes) {
417417
}
418418

419419
public DataItemRecord putData(PutDataRequest request, String packageName) {
420-
String host = request.getUri().getHost();
421-
if (TextUtils.isEmpty(host)) host = getLocalNodeId();
422-
DataItemInternal dataItem = new DataItemInternal(host, request.getUri().getPath());
420+
DataItemInternal dataItem = new DataItemInternal(fixHost(request.getUri().getHost(), true), request.getUri().getPath());
423421
for (Map.Entry<String, Asset> assetEntry : request.getAssets().entrySet()) {
424422
Asset asset = prepareAsset(packageName, assetEntry.getValue());
425423
if (asset != null) {
@@ -443,30 +441,36 @@ public DataHolder getDataItemsAsHolder(String packageName) {
443441
return DataHolder.fromCursor(dataHolderItems, 0, null);
444442
}
445443

444+
private String fixHost(String host, boolean nothingToLocal) {
445+
if (TextUtils.isEmpty(host) && nothingToLocal) return getLocalNodeId();
446+
if (TextUtils.isEmpty(host)) return null;
447+
if (host.equals("local")) return getLocalNodeId();
448+
return host;
449+
}
450+
446451
public DataHolder getDataItemsByUriAsHolder(Uri uri, String packageName) {
447452
String firstSignature;
448453
try {
449454
firstSignature = PackageUtils.firstSignatureDigest(context, packageName);
450455
} catch (Exception e) {
451456
return null;
452457
}
453-
Cursor dataHolderItems = nodeDatabase.getDataItemsForDataHolderByHostAndPath(packageName, firstSignature, uri.getHost(), uri.getPath());
454-
while (dataHolderItems.moveToNext()) {
455-
Log.d(TAG, "getDataItems[]: path=" + Uri.parse(dataHolderItems.getString(1)).getPath());
456-
}
457-
dataHolderItems.moveToFirst();
458-
dataHolderItems.moveToPrevious();
459-
return new DataHolder(dataHolderItems, 0, null);
460-
}
461-
462-
public DataHolder getDataItemForRecordAsHolder(DataItemRecord record) {
463-
Cursor dataHolderItems = nodeDatabase.getDataItemsForDataHolderByHostAndPath(record.packageName, record.signatureDigest, record.dataItem.uri.getHost(), record.dataItem.uri.getPath());
458+
Cursor dataHolderItems = nodeDatabase.getDataItemsForDataHolderByHostAndPath(packageName, firstSignature, fixHost(uri.getHost(), false), uri.getPath());
459+
int j = 0;
464460
while (dataHolderItems.moveToNext()) {
465-
Log.d(TAG, "getDataItems[]: path=" + Uri.parse(dataHolderItems.getString(1)).getPath());
461+
for (int i = 0; i < dataHolderItems.getColumnCount(); i++) {
462+
if (dataHolderItems.getType(i) == Cursor.FIELD_TYPE_STRING) {
463+
Log.d(TAG, "getDataItems[" + j + "]: " + dataHolderItems.getColumnName(i) + "=" + dataHolderItems.getString(i));
464+
}
465+
if (dataHolderItems.getType(i) == Cursor.FIELD_TYPE_INTEGER)
466+
Log.d(TAG, "getDataItems[" + j + "]: " + dataHolderItems.getColumnName(i) + "=" + dataHolderItems.getLong(i));
467+
}
466468
}
467469
dataHolderItems.moveToFirst();
468470
dataHolderItems.moveToPrevious();
469-
return new DataHolder(dataHolderItems, 0, null);
471+
DataHolder dataHolder = new DataHolder(dataHolderItems, 0, null);
472+
Log.d(TAG, "Returning data holder of size " + dataHolder.getCount() + " for query " + uri);
473+
return dataHolder;
470474
}
471475

472476
public synchronized void addListener(String packageName, IWearableListener listener) {
@@ -515,7 +519,7 @@ public void createConnection(ConnectionConfiguration config) {
515519
}
516520

517521
public int deleteDataItems(Uri uri, String packageName) {
518-
List<DataItemRecord> records = nodeDatabase.deleteDataItems(packageName, PackageUtils.firstSignatureDigest(context, packageName), uri.getHost(), uri.getPath());
522+
List<DataItemRecord> records = nodeDatabase.deleteDataItems(packageName, PackageUtils.firstSignatureDigest(context, packageName), fixHost(uri.getHost(), false), uri.getPath());
519523
for (DataItemRecord record : records) {
520524
syncRecordToAll(record);
521525
}
@@ -533,7 +537,7 @@ public void sendMessageReceived(String packageName, MessageEventParcelable messa
533537
}
534538

535539
public DataItemRecord getDataItemByUri(Uri uri, String packageName) {
536-
Cursor cursor = nodeDatabase.getDataItemsByHostAndPath(packageName, PackageUtils.firstSignatureDigest(context, packageName), uri.getHost(), uri.getPath());
540+
Cursor cursor = nodeDatabase.getDataItemsByHostAndPath(packageName, PackageUtils.firstSignatureDigest(context, packageName), fixHost(uri.getHost(), true), uri.getPath());
537541
DataItemRecord record = null;
538542
if (cursor != null) {
539543
if (cursor.moveToNext()) {

play-services-core/src/main/java/org/microg/gms/wearable/WearableLocationService.java

-55
This file was deleted.

play-services-core/src/main/java/org/microg/gms/wearable/WearableServiceImpl.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import android.os.Parcel;
2222
import android.os.ParcelFileDescriptor;
2323
import android.os.RemoteException;
24+
import android.util.Base64;
2425
import android.util.Log;
2526

2627
import com.google.android.gms.common.api.Status;
@@ -154,11 +155,11 @@ public void deleteDataItemsWithFilter(IWearableCallbacks callbacks, Uri uri, int
154155

155156
@Override
156157
public void sendMessage(IWearableCallbacks callbacks, String targetNodeId, String path, byte[] data) throws RemoteException {
157-
Log.d(TAG, "sendMessage: " + targetNodeId + " / " + path);
158+
Log.d(TAG, "sendMessage: " + targetNodeId + " / " + path + ": " + (data == null ? null : Base64.encodeToString(data, Base64.NO_WRAP)));
158159
SendMessageResponse sendMessageResponse = new SendMessageResponse();
159160
try {
160-
sendMessageResponse.resultId = wearable.sendMessage(packageName, targetNodeId, path, data);
161-
if (sendMessageResponse.resultId == -1) {
161+
sendMessageResponse.requestId = wearable.sendMessage(packageName, targetNodeId, path, data);
162+
if (sendMessageResponse.requestId == -1) {
162163
sendMessageResponse.statusCode = 4000;
163164
}
164165
} catch (Exception e) {
@@ -262,8 +263,8 @@ public void removeListener(IWearableCallbacks callbacks, RemoveListenerRequest r
262263
}
263264

264265
@Override
265-
public void getStrorageInformation(IWearableCallbacks callbacks) throws RemoteException {
266-
Log.d(TAG, "unimplemented Method: getStrorageInformation");
266+
public void getStorageInformation(IWearableCallbacks callbacks) throws RemoteException {
267+
Log.d(TAG, "unimplemented Method: getStorageInformation");
267268
}
268269

269270
@Override

0 commit comments

Comments
 (0)