Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TermsOfServiceActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setResult(RESULT_CANCELED)
setResult(RESULT_OK)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I think there should be an option like "Auto accept TOS", so only the people that enable the option have it.

finish()
}
}
26 changes: 26 additions & 0 deletions play-services-wearable/core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,32 @@

<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application>

<service
android:name="org.microg.gms.wearable.WearableService"
android:exported="true">
<intent-filter>
<action android:name="com.google.android.gms.wearable.BIND" />
</intent-filter>
</service>

<service
android:name="org.microg.gms.wearable.location.WearableLocationService"
android:exported="true">
<intent-filter>
<action android:name="com.google.android.gms.wearable.MESSAGE_RECEIVED" />
<data
android:host="*"
android:pathPrefix="/com/google/android/location/fused/wearable"
android:scheme="wear" />
</intent-filter>
</service>

</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,22 @@ public synchronized Cursor getDataItemsByHostAndPath(String packageName, String
return getDataItemsByHostAndPath(getReadableDatabase(), packageName, signatureDigest, host, path);
}

/**
* Returns a cursor with columns (host, capability) for all non-deleted capability data items.
* Capabilities are stored as data items with path '/capabilities/&lt;pkg&gt;/&lt;sig&gt;/&lt;capabilityName&gt;'.
*/
public synchronized Cursor getAllCapabilityItems() {
// Extract the last path segment (capability name) using reverse string operations:
// instr(reverse(path), '/') finds the position of the first '/' from the end,
// then substr takes everything after that position (i.e. the last path segment).
return getReadableDatabase().rawQuery(
"SELECT DISTINCT host, " +
"substr(path, length(path) - instr(reverse(path), '/') + 2) AS capability " +
"FROM appKeyDataItems " +
"WHERE path LIKE '/capabilities/%' AND deleted=0",
null);
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if (oldVersion != VERSION) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.google.android.gms.wearable.Asset;
import com.google.android.gms.wearable.ConnectionConfiguration;
import com.google.android.gms.wearable.Node;
import com.google.android.gms.wearable.internal.CapabilityInfoParcelable;
import com.google.android.gms.wearable.internal.IWearableListener;
import com.google.android.gms.wearable.internal.MessageEventParcelable;
import com.google.android.gms.wearable.internal.NodeParcelable;
Expand Down Expand Up @@ -487,6 +488,32 @@ public DataHolder getDataItemsByUriAsHolder(Uri uri, String packageName) {
return dataHolder;
}

public List<CapabilityInfoParcelable> getAllCapabilityInfos() {
Map<String, List<NodeParcelable>> capabilityNodes = new HashMap<>();
Cursor cursor = nodeDatabase.getAllCapabilityItems();
if (cursor != null) {
try {
while (cursor.moveToNext()) {
String nodeId = cursor.getString(0);
String capability = cursor.getString(1);
if (capability != null && !capability.isEmpty()) {
if (!capabilityNodes.containsKey(capability)) {
capabilityNodes.put(capability, new ArrayList<>());
}
capabilityNodes.get(capability).add(new NodeParcelable(nodeId, nodeId));
}
}
} finally {
cursor.close();
}
}
List<CapabilityInfoParcelable> result = new ArrayList<>();
for (Map.Entry<String, List<NodeParcelable>> entry : capabilityNodes.entrySet()) {
result.add(new CapabilityInfoParcelable(entry.getKey(), entry.getValue()));
}
return result;
}

public synchronized void addListener(String packageName, IWearableListener listener, IntentFilter[] filters) {
if (!listeners.containsKey(packageName)) {
listeners.put(packageName, new ArrayList<ListenerInfo>());
Expand Down Expand Up @@ -581,7 +608,7 @@ private void closeConnection(String nodeId) {
} catch (IOException e1) {
Log.w(TAG, e1);
}
if (connection == sct.getWearableConnection()) {
if (sct != null && connection == sct.getWearableConnection()) {
sct.close();
sct = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,12 @@ public void optInCloudSync(IWearableCallbacks callbacks, boolean enable) throws
@Override
@Deprecated
public void getCloudSyncOptInDone(IWearableCallbacks callbacks) throws RemoteException {
Log.d(TAG, "unimplemented Method: getCloudSyncOptInDone");
callbacks.onGetCloudSyncOptInOutDoneResponse(new GetCloudSyncOptInOutDoneResponse());
}

@Override
public void setCloudSyncSetting(IWearableCallbacks callbacks, boolean enable) throws RemoteException {
Log.d(TAG, "unimplemented Method: setCloudSyncSetting");
callbacks.onStatus(Status.SUCCESS);
}

@Override
Expand All @@ -249,12 +249,12 @@ public void getCloudSyncSetting(IWearableCallbacks callbacks) throws RemoteExcep

@Override
public void getCloudSyncOptInStatus(IWearableCallbacks callbacks) throws RemoteException {
Log.d(TAG, "unimplemented Method: getCloudSyncOptInStatus");
callbacks.onGetCloudSyncOptInStatusResponse(new GetCloudSyncOptInStatusResponse());
}

@Override
public void sendRemoteCommand(IWearableCallbacks callbacks, byte b) throws RemoteException {
Log.d(TAG, "unimplemented Method: sendRemoteCommand: " + b);
callbacks.onStatus(Status.SUCCESS);
}

@Override
Expand All @@ -281,7 +281,7 @@ public void getConnectedNodes(IWearableCallbacks callbacks) throws RemoteExcepti

@Override
public void getConnectedCapability(IWearableCallbacks callbacks, String capability, int nodeFilter) throws RemoteException {
Log.d(TAG, "unimplemented Method: getConnectedCapability " + capability + ", " + nodeFilter);
Log.d(TAG, "getConnectedCapability: " + capability + ", " + nodeFilter);
postMain(callbacks, () -> {
List<NodeParcelable> nodes = new ArrayList<>();
for (String host : capabilities.getNodesForCapability(capability)) {
Expand All @@ -294,13 +294,18 @@ public void getConnectedCapability(IWearableCallbacks callbacks, String capabili

@Override
public void getAllCapabilities(IWearableCallbacks callbacks, int nodeFilter) throws RemoteException {
Log.d(TAG, "unimplemented Method: getConnectedCapaibilties: " + nodeFilter);
callbacks.onGetAllCapabilitiesResponse(new GetAllCapabilitiesResponse());
Log.d(TAG, "getAllCapabilities: " + nodeFilter);
postMain(callbacks, () -> {
GetAllCapabilitiesResponse response = new GetAllCapabilitiesResponse();
response.statusCode = 0;
response.capabilities = wearable.getAllCapabilityInfos();
callbacks.onGetAllCapabilitiesResponse(response);
});
}

@Override
public void addLocalCapability(IWearableCallbacks callbacks, String capability) throws RemoteException {
Log.d(TAG, "unimplemented Method: addLocalCapability: " + capability);
Log.d(TAG, "addLocalCapability: " + capability);
this.wearable.networkHandler.post(new CallbackRunnable(callbacks) {
@Override
public void run(IWearableCallbacks callbacks) throws RemoteException {
Expand All @@ -311,7 +316,7 @@ public void run(IWearableCallbacks callbacks) throws RemoteException {

@Override
public void removeLocalCapability(IWearableCallbacks callbacks, String capability) throws RemoteException {
Log.d(TAG, "unimplemented Method: removeLocalCapability: " + capability);
Log.d(TAG, "removeLocalCapability: " + capability);
this.wearable.networkHandler.post(new CallbackRunnable(callbacks) {
@Override
public void run(IWearableCallbacks callbacks) throws RemoteException {
Expand All @@ -336,27 +341,27 @@ public void removeListener(IWearableCallbacks callbacks, RemoveListenerRequest r

@Override
public void getStorageInformation(IWearableCallbacks callbacks) throws RemoteException {
Log.d(TAG, "unimplemented Method: getStorageInformation");
callbacks.onStorageInfoResponse(new StorageInfoResponse());
}

@Override
public void clearStorage(IWearableCallbacks callbacks) throws RemoteException {
Log.d(TAG, "unimplemented Method: clearStorage");
callbacks.onStatus(Status.SUCCESS);
}

@Override
public void endCall(IWearableCallbacks callbacks) throws RemoteException {
Log.d(TAG, "unimplemented Method: endCall");
callbacks.onStatus(Status.SUCCESS);
}

@Override
public void acceptRingingCall(IWearableCallbacks callbacks) throws RemoteException {
Log.d(TAG, "unimplemented Method: acceptRingingCall");
callbacks.onStatus(Status.SUCCESS);
}

@Override
public void silenceRinger(IWearableCallbacks callbacks) throws RemoteException {
Log.d(TAG, "unimplemented Method: silenceRinger");
callbacks.onStatus(Status.SUCCESS);
}

/*
Expand All @@ -365,22 +370,23 @@ public void silenceRinger(IWearableCallbacks callbacks) throws RemoteException {

@Override
public void injectAncsNotificationForTesting(IWearableCallbacks callbacks, AncsNotificationParcelable notification) throws RemoteException {
Log.d(TAG, "unimplemented Method: injectAncsNotificationForTesting: " + notification);
callbacks.onStatus(Status.SUCCESS);
}

@Override
public void doAncsPositiveAction(IWearableCallbacks callbacks, int i) throws RemoteException {
Log.d(TAG, "unimplemented Method: doAncsPositiveAction: " + i);
callbacks.onStatus(Status.SUCCESS);
}

@Override
public void doAncsNegativeAction(IWearableCallbacks callbacks, int i) throws RemoteException {
Log.d(TAG, "unimplemented Method: doAncsNegativeAction: " + i);
callbacks.onStatus(Status.SUCCESS);
}

@Override
public void openChannel(IWearableCallbacks callbacks, String s1, String s2) throws RemoteException {
Log.d(TAG, "unimplemented Method: openChannel; " + s1 + ", " + s2);
Log.d(TAG, "openChannel: " + s1 + ", " + s2);
callbacks.onOpenChannelResponse(new OpenChannelResponse());
}

/*
Expand All @@ -389,38 +395,43 @@ public void openChannel(IWearableCallbacks callbacks, String s1, String s2) thro

@Override
public void closeChannel(IWearableCallbacks callbacks, String s) throws RemoteException {
Log.d(TAG, "unimplemented Method: closeChannel: " + s);
Log.d(TAG, "closeChannel: " + s);
callbacks.onCloseChannelResponse(new CloseChannelResponse());
}

@Override
public void closeChannelWithError(IWearableCallbacks callbacks, String s, int errorCode) throws RemoteException {
Log.d(TAG, "unimplemented Method: closeChannelWithError:" + s + ", " + errorCode);

Log.d(TAG, "closeChannelWithError: " + s + ", " + errorCode);
callbacks.onCloseChannelResponse(new CloseChannelResponse());
}

@Override
public void getChannelInputStream(IWearableCallbacks callbacks, IChannelStreamCallbacks channelCallbacks, String s) throws RemoteException {
Log.d(TAG, "unimplemented Method: getChannelInputStream: " + s);
Log.d(TAG, "getChannelInputStream: " + s);
callbacks.onGetChannelInputStreamResponse(new GetChannelInputStreamResponse());
}

@Override
public void getChannelOutputStream(IWearableCallbacks callbacks, IChannelStreamCallbacks channelCallbacks, String s) throws RemoteException {
Log.d(TAG, "unimplemented Method: getChannelOutputStream: " + s);
Log.d(TAG, "getChannelOutputStream: " + s);
callbacks.onGetChannelOutputStreamResponse(new GetChannelOutputStreamResponse());
}

@Override
public void writeChannelInputToFd(IWearableCallbacks callbacks, String s, ParcelFileDescriptor fd) throws RemoteException {
Log.d(TAG, "unimplemented Method: writeChannelInputToFd: " + s);
Log.d(TAG, "writeChannelInputToFd: " + s);
callbacks.onChannelReceiveFileResponse(new ChannelReceiveFileResponse());
}

@Override
public void readChannelOutputFromFd(IWearableCallbacks callbacks, String s, ParcelFileDescriptor fd, long l1, long l2) throws RemoteException {
Log.d(TAG, "unimplemented Method: readChannelOutputFromFd: " + s + ", " + l1 + ", " + l2);
Log.d(TAG, "readChannelOutputFromFd: " + s + ", " + l1 + ", " + l2);
callbacks.onChannelSendFileResponse(new ChannelSendFileResponse());
}

@Override
public void syncWifiCredentials(IWearableCallbacks callbacks) throws RemoteException {
Log.d(TAG, "unimplemented Method: syncWifiCredentials");
callbacks.onStatus(Status.SUCCESS);
}

/*
Expand All @@ -430,7 +441,10 @@ public void syncWifiCredentials(IWearableCallbacks callbacks) throws RemoteExcep
@Override
@Deprecated
public void putConnection(IWearableCallbacks callbacks, ConnectionConfiguration config) throws RemoteException {
Log.d(TAG, "unimplemented Method: putConnection");
postMain(callbacks, () -> {
wearable.createConnection(config);
callbacks.onStatus(Status.SUCCESS);
});
}

@Override
Expand Down