mirror of
https://github.com/TeamVanced/VancedMicroG
synced 2024-12-26 04:35:50 +01:00
Move certain wearable classes
This commit is contained in:
parent
289a346315
commit
b9cb95d39b
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.gms.wearable.internal;
|
||||
package com.google.android.gms.wearable;
|
||||
|
||||
public interface AmsEntityUpdate {
|
||||
}
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.gms.wearable.internal;
|
||||
package com.google.android.gms.wearable;
|
||||
|
||||
public interface AncsNotification {
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2013-2016 microG Project Team
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.gms.wearable;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Information about a Capability on the network and where it is available.
|
||||
*/
|
||||
public interface CapabilityInfo {
|
||||
/**
|
||||
* Returns the name of the capability.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Returns the set of nodes for the capability. Disconnected nodes may or may not be included in the set.
|
||||
*/
|
||||
Set<Node> getNodes();
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright 2013-2015 microG Project Team
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.gms.wearable;
|
||||
|
||||
import com.google.android.gms.common.api.GoogleApiClient;
|
||||
import com.google.android.gms.common.api.PendingResult;
|
||||
import com.google.android.gms.common.api.Result;
|
||||
import com.google.android.gms.common.api.Status;
|
||||
|
||||
import org.microg.gms.common.PublicApi;
|
||||
|
||||
@PublicApi
|
||||
public interface MessageApi {
|
||||
|
||||
/**
|
||||
* A value returned by {@link SendMessageResult#getRequestId()} when
|
||||
* {@link #sendMessage(GoogleApiClient, String, String, byte[])} fails.
|
||||
*/
|
||||
int UNKNOWN_REQUEST_ID = -1;
|
||||
|
||||
/**
|
||||
* Registers a listener to be notified of received messages. Calls to this method should
|
||||
* balanced with {@link #removeListener(GoogleApiClient, MessageListener)} to avoid leaking
|
||||
* resources.
|
||||
* <p/>
|
||||
* Callers wishing to be notified of events in the background should use {@link WearableListenerService}.
|
||||
*/
|
||||
PendingResult<Status> addListener(GoogleApiClient client, MessageListener listener);
|
||||
|
||||
/**
|
||||
* Removes a message listener which was previously added through
|
||||
* {@link #addListener(GoogleApiClient, MessageListener)}.
|
||||
*/
|
||||
PendingResult<Status> removeListener(GoogleApiClient client, MessageListener listener);
|
||||
|
||||
/**
|
||||
* Sends {@code byte[]} data to the specified node.
|
||||
*
|
||||
* @param nodeId identifier for a particular node on the Android Wear network. Valid targets
|
||||
* may be obtained through {@link NodeApi#getConnectedNodes(GoogleApiClient)}
|
||||
* or from the host in {@link DataItem#getUri()}.
|
||||
* @param path identifier used to specify a particular endpoint at the receiving node
|
||||
* @param data small array of information to pass to the target node. Generally not larger
|
||||
* than 100k
|
||||
*/
|
||||
PendingResult<SendMessageResult> sendMessage(GoogleApiClient client, String nodeId,
|
||||
String path, byte[] data);
|
||||
|
||||
/**
|
||||
* Used with {@link MessageApi#addListener(GoogleApiClient, MessageListener)} to receive
|
||||
* message events.
|
||||
* <p/>
|
||||
* Callers wishing to be notified of events in the background should use
|
||||
* {@link WearableListenerService}.
|
||||
*/
|
||||
interface MessageListener {
|
||||
/**
|
||||
* Notification that a message has been received.
|
||||
*/
|
||||
void onMessageReceived(MessageEvent messageEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains the request id assigned to the message. On failure, the id will be
|
||||
* {@link MessageApi#UNKNOWN_REQUEST_ID} and the status will be unsuccessful.
|
||||
*/
|
||||
interface SendMessageResult extends Result {
|
||||
/**
|
||||
* @return an ID used to identify the sent message. If {@link #getStatus()} is not
|
||||
* successful, this value will be {@link MessageApi#UNKNOWN_REQUEST_ID}.
|
||||
*/
|
||||
int getRequestId();
|
||||
}
|
||||
}
|
@ -16,6 +16,8 @@
|
||||
|
||||
package com.google.android.gms.wearable.internal;
|
||||
|
||||
import com.google.android.gms.wearable.AmsEntityUpdate;
|
||||
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
||||
public class AmsEntityUpdateParcelable extends AutoSafeParcelable implements AmsEntityUpdate {
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
package com.google.android.gms.wearable.internal;
|
||||
|
||||
import com.google.android.gms.wearable.AncsNotification;
|
||||
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
||||
public class AncsNotificationParcelable extends AutoSafeParcelable implements AncsNotification {
|
||||
|
@ -16,8 +16,75 @@
|
||||
|
||||
package com.google.android.gms.wearable.internal;
|
||||
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
import com.google.android.gms.wearable.CapabilityInfo;
|
||||
import com.google.android.gms.wearable.Node;
|
||||
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
import org.microg.safeparcel.SafeParceled;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class CapabilityInfoParcelable extends AutoSafeParcelable implements CapabilityInfo {
|
||||
@SafeParceled(1)
|
||||
private int versionCode = 1;
|
||||
|
||||
@SafeParceled(2)
|
||||
private String name;
|
||||
|
||||
@SafeParceled(value = 3, subClass = NodeParcelable.class)
|
||||
private List<NodeParcelable> nodeParcelables;
|
||||
|
||||
private Set<Node> nodes;
|
||||
private Object lock = new Object();
|
||||
|
||||
private CapabilityInfoParcelable() {
|
||||
}
|
||||
|
||||
public CapabilityInfoParcelable(String name, List<NodeParcelable> nodeParcelables) {
|
||||
this.name = name;
|
||||
this.nodeParcelables = nodeParcelables;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Set<Node> getNodes() {
|
||||
if (nodes == null) {
|
||||
nodes = new HashSet<Node>(nodeParcelables);
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) return true;
|
||||
if (other == null || getClass() != other.getClass()) return false;
|
||||
|
||||
CapabilityInfoParcelable that = (CapabilityInfoParcelable) other;
|
||||
|
||||
if (versionCode != that.versionCode) return false;
|
||||
if (name != null ? !name.equals(that.name) : that.name != null) return false;
|
||||
return nodeParcelables != null ? nodeParcelables.equals(that.nodeParcelables) : that.nodeParcelables == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = versionCode;
|
||||
result = 31 * result + (name != null ? name.hashCode() : 0);
|
||||
result = 31 * result + (nodeParcelables != null ? nodeParcelables.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CapabilityInfo{" + name + ", " + nodeParcelables + "}";
|
||||
}
|
||||
|
||||
public static final Creator<CapabilityInfoParcelable> CREATOR = new AutoCreator<CapabilityInfoParcelable>(CapabilityInfoParcelable.class);
|
||||
|
||||
public class CapabilityInfoParcelable extends AutoSafeParcelable {
|
||||
public static final Creator<CapabilityInfoParcelable> CREATOR = new AutoCreator<CapabilityInfoParcelable>(CapabilityInfoParcelable.class);
|
||||
}
|
||||
|
@ -16,17 +16,15 @@
|
||||
|
||||
package com.google.android.gms.wearable.internal;
|
||||
|
||||
import com.google.android.gms.wearable.Channel;
|
||||
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
import org.microg.safeparcel.SafeParceled;
|
||||
|
||||
public class ChannelEventParcelable extends AutoSafeParcelable {
|
||||
|
||||
@SafeParceled(1)
|
||||
private int versionCode;
|
||||
private int versionCode = 1;
|
||||
@SafeParceled(2)
|
||||
public Channel channel; // TODO: ChannelImpl needed!
|
||||
public ChannelImpl channel;
|
||||
@SafeParceled(3)
|
||||
public int eventType;
|
||||
@SafeParceled(4)
|
||||
|
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright 2013-2016 microG Project Team
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.gms.wearable.internal;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.android.gms.common.api.GoogleApiClient;
|
||||
import com.google.android.gms.common.api.PendingResult;
|
||||
import com.google.android.gms.common.api.Status;
|
||||
import com.google.android.gms.wearable.Channel;
|
||||
import com.google.android.gms.wearable.ChannelApi;
|
||||
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
import org.microg.safeparcel.SafeParceled;
|
||||
|
||||
public class ChannelImpl extends AutoSafeParcelable implements Channel {
|
||||
private static final String TAG = "GmsWearChannelImpl";
|
||||
|
||||
@SafeParceled(1)
|
||||
private int versionCode = 1;
|
||||
@SafeParceled(2)
|
||||
private String token;
|
||||
@SafeParceled(3)
|
||||
private String nodeId;
|
||||
@SafeParceled(4)
|
||||
private String path;
|
||||
|
||||
private ChannelImpl() {
|
||||
}
|
||||
|
||||
public ChannelImpl(String token, String nodeId, String path) {
|
||||
this.token = token;
|
||||
this.nodeId = nodeId;
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PendingResult<Status> addListener(GoogleApiClient client, ChannelApi.ChannelListener listener) {
|
||||
Log.d(TAG, "unimplemented Method: addListener");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PendingResult<Status> close(GoogleApiClient client, int errorCode) {
|
||||
Log.d(TAG, "unimplemented Method: close");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PendingResult<Status> close(GoogleApiClient client) {
|
||||
Log.d(TAG, "unimplemented Method: close");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PendingResult<GetInputStreamResult> getInputStream(GoogleApiClient client) {
|
||||
Log.d(TAG, "unimplemented Method: getInputStream");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PendingResult<GetOutputStreamResult> getOutputStream(GoogleApiClient client) {
|
||||
Log.d(TAG, "unimplemented Method: getOutputStream");
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getNodeId() {
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PendingResult<Status> receiveFile(GoogleApiClient client, Uri uri, boolean append) {
|
||||
Log.d(TAG, "unimplemented Method: receiveFile");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PendingResult<Status> removeListener(GoogleApiClient client, ChannelApi.ChannelListener listener) {
|
||||
Log.d(TAG, "unimplemented Method: removeListener");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PendingResult<Status> sendFile(GoogleApiClient client, Uri uri) {
|
||||
Log.d(TAG, "unimplemented Method: sendFile");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PendingResult<Status> sendFile(GoogleApiClient client, Uri uri, long startOffset, long length) {
|
||||
Log.d(TAG, "unimplemented Method: sendFile");
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final Creator<ChannelImpl> CREATOR = new AutoCreator<ChannelImpl>(ChannelImpl.class);
|
||||
}
|
@ -16,10 +16,13 @@
|
||||
|
||||
package com.google.android.gms.wearable.internal;
|
||||
|
||||
import com.google.android.gms.common.api.Status;
|
||||
import com.google.android.gms.wearable.MessageApi;
|
||||
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
import org.microg.safeparcel.SafeParceled;
|
||||
|
||||
public class SendMessageResponse extends AutoSafeParcelable {
|
||||
public class SendMessageResponse extends AutoSafeParcelable implements MessageApi.SendMessageResult {
|
||||
|
||||
@SafeParceled(1)
|
||||
private int versionCode = 1;
|
||||
@ -28,7 +31,17 @@ public class SendMessageResponse extends AutoSafeParcelable {
|
||||
public int statusCode;
|
||||
|
||||
@SafeParceled(3)
|
||||
public int resultId = -1;
|
||||
public int requestId = -1;
|
||||
|
||||
@Override
|
||||
public int getRequestId() {
|
||||
return requestId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status getStatus() {
|
||||
return new Status(statusCode);
|
||||
}
|
||||
|
||||
public static final Creator<SendMessageResponse> CREATOR = new AutoCreator<SendMessageResponse>(SendMessageResponse.class);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user