mirror of
https://github.com/TeamVanced/VancedMicroG
synced 2024-12-13 06:07:44 +01:00
Add some wearable APIs
This commit is contained in:
parent
b852fefd86
commit
704199355e
@ -24,16 +24,23 @@ public class DataHolder extends AutoSafeParcelable {
|
||||
private int versionCode = 1;
|
||||
|
||||
@SafeParceled(1)
|
||||
private String[] columns;
|
||||
public final String[] columns;
|
||||
|
||||
@SafeParceled(2)
|
||||
private CursorWindow[] windows;
|
||||
public final CursorWindow[] windows;
|
||||
|
||||
@SafeParceled(3)
|
||||
private int statusCode;
|
||||
public final int statusCode;
|
||||
|
||||
@SafeParceled(4)
|
||||
private Bundle metadata;
|
||||
public final Bundle metadata;
|
||||
|
||||
private DataHolder() {
|
||||
columns = null;
|
||||
windows = null;
|
||||
statusCode = 0;
|
||||
metadata = null;
|
||||
}
|
||||
|
||||
public DataHolder(String[] columns, CursorWindow[] windows, int statusCode, Bundle metadata) {
|
||||
this.columns = columns;
|
||||
@ -48,6 +55,7 @@ public class DataHolder extends AutoSafeParcelable {
|
||||
protected static final int FIELD_TYPE_NULL = 0;
|
||||
protected static final int FIELD_TYPE_STRING = 3;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@SuppressLint("NewApi")
|
||||
static int getCursorType(Cursor cursor, int i) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
@ -113,6 +121,17 @@ public class DataHolder extends AutoSafeParcelable {
|
||||
return dataHolder;
|
||||
}
|
||||
|
||||
|
||||
public int getCount() {
|
||||
int c = 0;
|
||||
if (windows != null) {
|
||||
for (CursorWindow window : windows) {
|
||||
c += window.getNumRows();
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DataHolder{" +
|
||||
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2013-2015 µg 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.common.data;
|
||||
|
||||
public interface Freezable<T> {
|
||||
/**
|
||||
* Freeze a volatile representation into an immutable representation. Objects returned from
|
||||
* this call are safe to cache.
|
||||
* <p/>
|
||||
* Note that the output of {@link #freeze} may not be identical to the parent object, but
|
||||
* should be equal.
|
||||
*
|
||||
* @return A concrete implementation of the data object.
|
||||
*/
|
||||
T freeze();
|
||||
|
||||
/**
|
||||
* Check to see if this object is valid for use. If the object is still volatile, this method
|
||||
* will indicate whether or not the object can be safely used.
|
||||
* The output of a call to {@link #freeze()} will always be valid.
|
||||
*
|
||||
* @return whether or not the object is valid for use.
|
||||
*/
|
||||
boolean isDataValid();
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright 2013-2015 µg 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 android.net.Uri;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
|
||||
import org.microg.gms.common.PublicApi;
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
||||
/**
|
||||
* An asset is a binary blob shared between data items that is replicated across the wearable
|
||||
* network on demand.
|
||||
* <p/>
|
||||
* It may represent an asset not yet added with the Android Wear network. DataItemAssets
|
||||
* are representations of an asset after it has been added to the network through a
|
||||
* {@link PutDataRequest}.
|
||||
*/
|
||||
@PublicApi
|
||||
public class Asset extends AutoSafeParcelable {
|
||||
|
||||
/**
|
||||
* Creates an Asset using a byte array.
|
||||
*/
|
||||
public static Asset createFromBytes(byte[] assetData) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an Asset using a file descriptor. The FD should be closed after being successfully
|
||||
* sent in a putDataItem request.
|
||||
*/
|
||||
public static Asset createFromFd(ParcelFileDescriptor fd) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an Asset using an existing Asset's digest.
|
||||
*/
|
||||
public static Asset createFromRef(String digest) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an Asset using a content URI. Google Play services must have permission to read this
|
||||
* Uri.
|
||||
*/
|
||||
public static Asset createFromUri(Uri uri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the digest associated with the asset data. A digest is a content identifier used to
|
||||
* identify the asset across devices.
|
||||
*/
|
||||
public String getDigest() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the file descriptor referencing the asset.
|
||||
*/
|
||||
public ParcelFileDescriptor getFd() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the uri referencing the asset data.
|
||||
*/
|
||||
public Uri getUri() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final Creator<Asset> CREATOR = new AutoCreator<>(Asset.class);
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2013-2015 µg 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 android.net.Uri;
|
||||
|
||||
import com.google.android.gms.common.data.Freezable;
|
||||
|
||||
import org.microg.gms.common.PublicApi;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The base object of data stored in the Android Wear network. {@link DataItem} are replicated
|
||||
* across all devices in the network. It contains a small blob of data and associated assets.
|
||||
* <p/>
|
||||
* A {@link DataItem} is identified by its Uri, which contains its creator and a path.
|
||||
*/
|
||||
@PublicApi
|
||||
public interface DataItem extends Freezable<DataItem> {
|
||||
/**
|
||||
* A map of assets associated with this data item.
|
||||
*/
|
||||
Map<String, DataItemAsset> getAssets();
|
||||
|
||||
/**
|
||||
* An array of data stored at the specified {@link Uri}.
|
||||
*/
|
||||
byte[] getData();
|
||||
|
||||
/**
|
||||
* Returns the DataItem's Uri. {@link Uri#getHost()} returns the id of the node that created it.
|
||||
*/
|
||||
Uri getUri();
|
||||
|
||||
/**
|
||||
* Sets the data in a data item.
|
||||
* <p/>
|
||||
* The current maximum data item size limit is approximately 100k. Data items should generally be much smaller than this limit.
|
||||
*/
|
||||
DataItem setData(byte[] data);
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2013-2015 µg 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.data.Freezable;
|
||||
|
||||
/**
|
||||
* A reference to an asset stored in a data item. Used to fetch file descriptors using
|
||||
* DataApi#getFdForAsset(GoogleApiClient, DataItemAsset).
|
||||
*/
|
||||
public interface DataItemAsset extends Freezable<DataItemAsset> {
|
||||
/**
|
||||
* @return the identifier used to address this asset in the context of an existing
|
||||
* {@link DataItem}.
|
||||
*/
|
||||
String getDataItemKey();
|
||||
|
||||
/**
|
||||
* @return the Android Wear-wide unique identifier for a particular asset.
|
||||
*/
|
||||
String getId();
|
||||
}
|
@ -27,10 +27,10 @@ public interface Node {
|
||||
* Returns a human readable description of the node. Sometimes generated from the Bluetooth
|
||||
* device name
|
||||
*/
|
||||
public abstract String getDisplayName();
|
||||
String getDisplayName();
|
||||
|
||||
/**
|
||||
* Returns an opaque string that represents a node in the Android Wear network.
|
||||
*/
|
||||
public abstract String getId();
|
||||
String getId();
|
||||
}
|
||||
|
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright 2013-2015 µg 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 android.net.Uri;
|
||||
|
||||
import org.microg.gms.common.PublicApi;
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* {@link PutDataRequest} is used to create new data items in the Android Wear network.
|
||||
*/
|
||||
@PublicApi
|
||||
public class PutDataRequest extends AutoSafeParcelable {
|
||||
public static final String WEAR_URI_SCHEME = "wear";
|
||||
|
||||
private DataItem dataItem;
|
||||
|
||||
private PutDataRequest(DataItem dataItem) {
|
||||
this.dataItem = dataItem;
|
||||
}
|
||||
|
||||
public static PutDataRequest create(String path) {
|
||||
// TODO
|
||||
return new PutDataRequest(null);
|
||||
}
|
||||
|
||||
public static PutDataRequest createFromDataItem(DataItem source) {
|
||||
return new PutDataRequest(source);
|
||||
}
|
||||
|
||||
public static PutDataRequest createWithAutoAppendedId(String pathPrefix) {
|
||||
return new PutDataRequest(null);
|
||||
}
|
||||
|
||||
public Asset getAsset(String key) {
|
||||
// TODO
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map<String, Asset> getAssets() {
|
||||
// TODO
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
public byte[] getData() {
|
||||
return dataItem.getData();
|
||||
}
|
||||
|
||||
public Uri getUri() {
|
||||
return dataItem.getUri();
|
||||
}
|
||||
|
||||
public boolean hasAsset(String key) {
|
||||
return dataItem.getAssets().containsKey(key);
|
||||
}
|
||||
|
||||
public PutDataRequest putAsset(String key, Asset value) {
|
||||
// TODO
|
||||
return this;
|
||||
}
|
||||
|
||||
public PutDataRequest removeAsset(String key) {
|
||||
// TODO
|
||||
return this;
|
||||
}
|
||||
|
||||
public PutDataRequest setData(byte[] data) {
|
||||
// TODO
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toString(false);
|
||||
}
|
||||
|
||||
public String toString(boolean verbose) {
|
||||
return "PutDataRequest{data=" + dataItem + "}";
|
||||
}
|
||||
|
||||
public static final Creator<PutDataRequest> CREATOR = new AutoCreator<>(PutDataRequest.class);
|
||||
}
|
@ -39,8 +39,10 @@ public @interface PublicApi {
|
||||
String until() default "latest";
|
||||
|
||||
/**
|
||||
* @return used on a method or field to exclude it from the public api if the corresponding
|
||||
* class was marked as public api
|
||||
* Used on a method or field to exclude it from the public api if the corresponding class was
|
||||
* marked as public api.
|
||||
*
|
||||
* @return true if the method or field is not part of the public api
|
||||
*/
|
||||
boolean exclude() default false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user