Update Cast API

This commit is contained in:
mar-v-in 2015-10-02 03:22:45 +02:00
parent 41a6ee844f
commit 2c18bafa4b
13 changed files with 517 additions and 72 deletions

2
extern/GmsApi vendored

@ -1 +1 @@
Subproject commit 607fb4ae5f7950223a957cd3b7d8406c8d019340
Subproject commit bb4037017c447d8129abf7c5cbaa73e527da5631

View File

@ -56,28 +56,28 @@ public final class Api<O extends Api.ApiOptions> {
* Base interface for {@link ApiOptions} in {@link Api}s that have options.
*/
@PublicApi
public interface HasOptions extends ApiOptions {
interface HasOptions extends ApiOptions {
}
/**
* Base interface for {@link ApiOptions} that are not required, don't exist.
*/
@PublicApi
public interface NotRequiredOptions extends ApiOptions {
interface NotRequiredOptions extends ApiOptions {
}
/**
* {@link ApiOptions} implementation for {@link Api}s that do not take any options.
*/
@PublicApi
public final class NoOptions implements NotRequiredOptions {
final class NoOptions implements NotRequiredOptions {
}
/**
* Base interface for {@link ApiOptions} that are optional.
*/
@PublicApi
public interface Optional extends HasOptions, NotRequiredOptions {
interface Optional extends HasOptions, NotRequiredOptions {
}
}

View File

@ -0,0 +1,43 @@
/*
* 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 org.microg.gms.common;
import org.microg.gms.common.api.ApiConnection;
public class DummyApiConnection implements ApiConnection {
private boolean connected = false;
@Override
public void connect() {
connected = true;
}
@Override
public void disconnect() {
connected = false;
}
@Override
public boolean isConnected() {
return connected;
}
@Override
public boolean isConnecting() {
return false;
}
}

View File

@ -16,18 +16,88 @@
package com.google.android.gms.cast;
import android.os.Bundle;
import com.google.android.gms.common.api.Api;
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.cast.CastApiBuilder;
import org.microg.gms.cast.CastApiImpl;
import org.microg.gms.common.PublicApi;
import java.io.IOException;
public class Cast {
@PublicApi
public final class Cast {
public static final Api<CastOptions> API = new Api<CastOptions>(null); // TODO
public static final Cast.CastApi CastApi = null; // TODO
/**
* A constant indicating that the Google Cast device is not the currently active video input.
*/
public static final int ACTIVE_INPUT_STATE_NO = 0;
/**
* A constant indicating that it is not known (and/or not possible to know) whether the Google Cast device is
* the currently active video input. Active input state can only be reported when the Google Cast device is
* connected to a TV or AVR with CEC support.
*/
public static final int ACTIVE_INPUT_STATE_UNKNOWN = -1;
/**
* A constant indicating that the Google Cast device is the currently active video input.
*/
public static final int ACTIVE_INPUT_STATE_YES = 1;
/**
* A boolean extra for the connection hint bundle passed to
* {@link GoogleApiClient.ConnectionCallbacks#onConnected(Bundle)} that indicates that the connection was
* re-established, but the receiver application that was in use at the time of the connection loss is no longer
* running on the receiver.
*/
public static final String EXTRA_APP_NO_LONGER_RUNNING = "com.google.android.gms.cast.EXTRA_APP_NO_LONGER_RUNNING";
/**
* The maximum raw message length (in bytes) that is supported by a Cast channel.
*/
public static final int MAX_MESSAGE_LENGTH = 65536;
/**
* The maximum length (in characters) of a namespace name.
*/
public static final int MAX_NAMESPACE_LENGTH = 128;
/**
* A constant indicating that the Google Cast device is not currently in standby.
*/
public static final int STANDBY_STATE_NO = 0;
/**
* A constant indicating that it is not known (and/or not possible to know) whether the Google Cast device is
* currently in standby. Standby state can only be reported when the Google Cast device is connected to a TV or
* AVR with CEC support.
*/
public static final int STANDBY_STATE_UNKNOWN = -1;
/**
* A constant indicating that the Google Cast device is currently in standby.
*/
public static final int STANDBY_STATE_YES = 1;
/**
* Token to pass to {@link GoogleApiClient.Builder#addApi(Api)} to enable the Cast features.
*/
public static final Api<CastOptions> API = new Api<CastOptions>(new CastApiBuilder());
/**
* An implementation of the CastApi interface. The interface is used to interact with a cast device.
*/
public static final Cast.CastApi CastApi = new CastApiImpl();
private Cast() {
}
public interface ApplicationConnectionResult extends Result {
ApplicationMetadata getApplicationMetadata();

View File

@ -1,64 +0,0 @@
/*
* 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.cast;
import java.util.Collection;
import java.util.Locale;
public class CastMediaControlIntent {
public static final String ACTION_SYNC_STATUS = "com.google.android.gms.cast.ACTION_SYNC_STATUS";
@Deprecated
public static final String CATEGORY_CAST = "com.google.android.gms.cast.CATEGORY_CAST";
public static final String EXTRA_CAST_APPLICATION_ID = "com.google.android.gms.cast.EXTRA_CAST_APPLICATION_ID";
public static final String EXTRA_CAST_LANGUAGE_CODE = "com.google.android.gms.cast.EXTRA_CAST_LANGUAGE_CODE";
public static final String EXTRA_CAST_RELAUNCH_APPLICATION = "com.google.android.gms.cast.EXTRA_CAST_RELAUNCH_APPLICATION";
public static final String EXTRA_CAST_STOP_APPLICATION_WHEN_SESSION_ENDS = "com.google.android.gms.cast.EXTRA_CAST_STOP_APPLICATION_WHEN_SESSION_ENDS";
public static final String EXTRA_CUSTOM_DATA = "com.google.android.gms.cast.EXTRA_CUSTOM_DATA";
public static final String EXTRA_DEBUG_LOGGING_ENABLED = "com.google.android.gms.cast.EXTRA_DEBUG_LOGGING_ENABLED";
public static final String EXTRA_ERROR_CODE = "com.google.android.gms.cast.EXTRA_ERROR_CODE";
public static final String DEFAULT_MEDIA_RECEIVER_APPLICATION_ID = "CC1AD845";
public static final int ERROR_CODE_REQUEST_FAILED = 1;
public static final int ERROR_CODE_SESSION_START_FAILED = 2;
public static final int ERROR_CODE_TEMPORARILY_DISCONNECTED = 3;
public static String categoryForCast(String applicationId) {
return CATEGORY_CAST; // TODO
}
public static String categoryForCast(String applicationId, Collection<String> namespaces) {
return CATEGORY_CAST; // TODO
}
public static String categoryForCast(Collection<String> namespaces) {
return CATEGORY_CAST; // TODO
}
public static String categoryForRemotePlayback(String applicationId) {
return CATEGORY_CAST; // TODO
}
public static String categoryForRemotePlayback() {
return CATEGORY_CAST; // TODO
}
public static String languageTagForLocale(Locale locale) {
return CATEGORY_CAST; // TODO
}
}

View File

@ -0,0 +1,76 @@
/*
* 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.cast;
import android.view.Display;
import com.google.android.gms.common.api.Api;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.Result;
import com.google.android.gms.common.api.Status;
import org.microg.gms.cast.CastRemoteDisplayApiBuilder;
import org.microg.gms.cast.CastRemoteDisplayApiImpl;
import org.microg.gms.common.PublicApi;
@PublicApi
public final class CastRemoteDisplay {
/**
* Token to pass to {@link GoogleApiClient.Builder#addApi(Api)} to enable the CastRemoteDisplay features.
*/
public static final Api<CastRemoteDisplayOptions> API = new Api<CastRemoteDisplayOptions>(new CastRemoteDisplayApiBuilder());
/**
* An implementation of the CastRemoteDisplayAPI interface. The interface is used to interact with a cast device.
*/
public static final CastRemoteDisplayApi CastApi = new CastRemoteDisplayApiImpl();
private CastRemoteDisplay() {
}
public static final class CastRemoteDisplayOptions implements Api.ApiOptions.HasOptions {
private CastDevice castDevice;
private CastRemoteDisplaySessionCallbacks callbacks;
private CastRemoteDisplayOptions(CastDevice castDevice, CastRemoteDisplaySessionCallbacks callbacks) {
this.castDevice = castDevice;
this.callbacks = callbacks;
}
public static final class Builder {
private CastDevice castDevice;
private CastRemoteDisplaySessionCallbacks callbacks;
public Builder(CastDevice castDevice, CastRemoteDisplaySessionCallbacks callbacks) {
this.castDevice = castDevice;
this.callbacks = callbacks;
}
public CastRemoteDisplayOptions build() {
return new CastRemoteDisplayOptions(castDevice, callbacks);
}
}
}
public interface CastRemoteDisplaySessionCallbacks {
void onRemoteDisplayEnded(Status status);
}
public interface CastRemoteDisplaySessionResult extends Result {
Display getPresentationDisplay();
}
}

View File

@ -0,0 +1,26 @@
/*
* 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.cast;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.PendingResult;
public interface CastRemoteDisplayApi {
PendingResult<CastRemoteDisplay.CastRemoteDisplaySessionResult> startRemoteDisplay(GoogleApiClient apiClient, String applicationId);
PendingResult<CastRemoteDisplay.CastRemoteDisplaySessionResult> stopRemoteDisplay(GoogleApiClient apiClient);
}

View File

@ -0,0 +1,28 @@
/*
* 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.cast;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
public class CastRemoteDisplayLocalService extends Service {
@Override
public IBinder onBind(Intent intent) {
return null;
}
}

View File

@ -0,0 +1,34 @@
/*
* 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 org.microg.gms.cast;
import android.content.Context;
import android.os.Looper;
import com.google.android.gms.cast.Cast;
import com.google.android.gms.common.api.AccountInfo;
import com.google.android.gms.common.api.GoogleApiClient;
import org.microg.gms.common.api.ApiBuilder;
import org.microg.gms.common.api.ApiConnection;
public class CastApiBuilder implements ApiBuilder<Cast.CastOptions>{
@Override
public ApiConnection build(Context context, Looper looper, Cast.CastOptions options, AccountInfo accountInfo, GoogleApiClient.ConnectionCallbacks callbacks, GoogleApiClient.OnConnectionFailedListener connectionFailedListener) {
return new CastClientImpl(context, options, callbacks, connectionFailedListener);
}
}

View File

@ -0,0 +1,134 @@
/*
* 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 org.microg.gms.cast;
import com.google.android.gms.cast.ApplicationMetadata;
import com.google.android.gms.cast.Cast;
import com.google.android.gms.cast.LaunchOptions;
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 java.io.IOException;
// TODO
public class CastApiImpl implements Cast.CastApi {
@Override
public int getActiveInputState(GoogleApiClient client) {
return 0;
}
@Override
public ApplicationMetadata getApplicationMetadata(GoogleApiClient client) {
return null;
}
@Override
public String getApplicationStatus(GoogleApiClient client) {
return null;
}
@Override
public int getStandbyState(GoogleApiClient client) {
return 0;
}
@Override
public double getVolume(GoogleApiClient client) {
return 0;
}
@Override
public boolean isMute(GoogleApiClient client) {
return false;
}
@Override
public PendingResult<Cast.ApplicationConnectionResult> joinApplication(GoogleApiClient client) {
return null;
}
@Override
public PendingResult<Cast.ApplicationConnectionResult> joinApplication(GoogleApiClient client, String applicationId, String sessionId) {
return null;
}
@Override
public PendingResult<Cast.ApplicationConnectionResult> joinApplication(GoogleApiClient client, String applicationId) {
return null;
}
@Override
public PendingResult<Cast.ApplicationConnectionResult> launchApplication(GoogleApiClient client, String applicationId, LaunchOptions launchOptions) {
return null;
}
@Override
public PendingResult<Cast.ApplicationConnectionResult> launchApplication(GoogleApiClient client, String applicationId) {
return null;
}
@Override
public PendingResult<Cast.ApplicationConnectionResult> launchApplication(GoogleApiClient client, String applicationId, boolean relaunchIfRunning) {
return null;
}
@Override
public PendingResult<Status> leaveApplication(GoogleApiClient client) {
return null;
}
@Override
public void removeMessageReceivedCallbacks(GoogleApiClient client, String namespace) throws IOException {
}
@Override
public void requestStatus(GoogleApiClient client) throws IOException {
}
@Override
public PendingResult<Status> sendMessage(GoogleApiClient client, String namespace, String message) {
return null;
}
@Override
public void setMessageReceivedCallbacks(GoogleApiClient client, String namespace, Cast.MessageReceivedCallback callbacks) throws IOException {
}
@Override
public void setMute(GoogleApiClient client, boolean mute) throws IOException {
}
@Override
public void setVolume(GoogleApiClient client, double volume) throws IOException {
}
@Override
public PendingResult<Status> stopApplication(GoogleApiClient client) {
return null;
}
@Override
public PendingResult<Status> stopApplication(GoogleApiClient client, String sessionId) {
return null;
}
}

View File

@ -0,0 +1,29 @@
/*
* 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 org.microg.gms.cast;
import android.content.Context;
import com.google.android.gms.cast.Cast;
import com.google.android.gms.common.api.GoogleApiClient;
import org.microg.gms.common.DummyApiConnection;
public class CastClientImpl extends DummyApiConnection {
public CastClientImpl(Context context, Cast.CastOptions options, GoogleApiClient.ConnectionCallbacks callbacks, GoogleApiClient.OnConnectionFailedListener connectionFailedListener) {
}
}

View File

@ -0,0 +1,35 @@
/*
* 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 org.microg.gms.cast;
import android.content.Context;
import android.os.Looper;
import com.google.android.gms.cast.CastRemoteDisplay;
import com.google.android.gms.common.api.AccountInfo;
import com.google.android.gms.common.api.GoogleApiClient;
import org.microg.gms.common.DummyApiConnection;
import org.microg.gms.common.api.ApiBuilder;
import org.microg.gms.common.api.ApiConnection;
public class CastRemoteDisplayApiBuilder implements ApiBuilder<CastRemoteDisplay.CastRemoteDisplayOptions> {
@Override
public ApiConnection build(Context context, Looper looper, CastRemoteDisplay.CastRemoteDisplayOptions options, AccountInfo accountInfo, GoogleApiClient.ConnectionCallbacks callbacks, GoogleApiClient.OnConnectionFailedListener connectionFailedListener) {
return new DummyApiConnection();
}
}

View File

@ -0,0 +1,34 @@
/*
* 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 org.microg.gms.cast;
import com.google.android.gms.cast.CastRemoteDisplay;
import com.google.android.gms.cast.CastRemoteDisplayApi;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.PendingResult;
public class CastRemoteDisplayApiImpl implements CastRemoteDisplayApi {
@Override
public PendingResult<CastRemoteDisplay.CastRemoteDisplaySessionResult> startRemoteDisplay(GoogleApiClient apiClient, String applicationId) {
return null;
}
@Override
public PendingResult<CastRemoteDisplay.CastRemoteDisplaySessionResult> stopRemoteDisplay(GoogleApiClient apiClient) {
return null;
}
}