mirror of
https://github.com/YTVanced/VancedMicroG
synced 2024-11-27 21:53:00 +00:00
First snapshot
This commit is contained in:
commit
31184fd03e
9 changed files with 767 additions and 0 deletions
4
AndroidManifest.xml
Normal file
4
AndroidManifest.xml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest package="com.google.android.gms">
|
||||||
|
<uses-sdk minSdkVersion="5" />
|
||||||
|
</manifest>
|
29
build.gradle
Normal file
29
build.gradle
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:1.0.0'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'com.android.library'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile 'com.android.support:support-v4:21.0.3'
|
||||||
|
compile project(':GmsApi')
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 21
|
||||||
|
buildToolsVersion "21.1.2"
|
||||||
|
lintOptions.abortOnError false
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main {
|
||||||
|
manifest.srcFile 'AndroidManifest.xml'
|
||||||
|
java.srcDirs = ['src']
|
||||||
|
aidl.srcDirs = ['src']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
185
src/com/google/android/gms/common/ConnectionResult.java
Normal file
185
src/com/google/android/gms/common/ConnectionResult.java
Normal file
|
@ -0,0 +1,185 @@
|
||||||
|
package com.google.android.gms.common;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.content.IntentSender;
|
||||||
|
import com.google.android.gms.common.api.GoogleApiClient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains all possible error codes for when a client fails to connect to Google Play services.
|
||||||
|
* These error codes are used by {@link GoogleApiClient.OnConnectionFailedListener}.
|
||||||
|
*/
|
||||||
|
public class ConnectionResult {
|
||||||
|
/**
|
||||||
|
* The connection was successful.
|
||||||
|
*/
|
||||||
|
public static final int SUCCESS = 0;
|
||||||
|
/**
|
||||||
|
* Google Play services is missing on this device. The calling activity should pass this error
|
||||||
|
* code to {@link GooglePlayServicesUtil#getErrorDialog(int, Activity, int)} to get a localized
|
||||||
|
* error dialog that will resolve the error when shown.
|
||||||
|
*/
|
||||||
|
public static final int SERVICE_MISSING = 1;
|
||||||
|
/**
|
||||||
|
* The installed version of Google Play services is out of date. The calling activity should
|
||||||
|
* pass this error code to {@link GooglePlayServicesUtil#getErrorDialog(int, Activity, int)} to
|
||||||
|
* get a localized error dialog that will resolve the error when shown.
|
||||||
|
*/
|
||||||
|
public static final int SERVICE_VERSION_UPDATE_REQUIRED = 2;
|
||||||
|
/**
|
||||||
|
* The installed version of Google Play services has been disabled on this device. The calling
|
||||||
|
* activity should pass this error code to
|
||||||
|
* {@link GooglePlayServicesUtil#getErrorDialog(int, Activity, int)} to get a localized error
|
||||||
|
* dialog that will resolve the error when shown.
|
||||||
|
*/
|
||||||
|
public static final int SERVICE_DISABLED = 3;
|
||||||
|
/**
|
||||||
|
* The client attempted to connect to the service but the user is not signed in. The client may
|
||||||
|
* choose to continue without using the API or it may call
|
||||||
|
* {@link #startResolutionForResult(Activity, int)} to prompt the user to sign in. After the
|
||||||
|
* sign in activity returns with {@link Activity#RESULT_OK} further attempts to connect should
|
||||||
|
* succeed.
|
||||||
|
*/
|
||||||
|
public static final int SIGN_IN_REQUIRED = 4;
|
||||||
|
/**
|
||||||
|
* The client attempted to connect to the service with an invalid account name specified.
|
||||||
|
*/
|
||||||
|
public static final int INVALID_ACCOUNT = 5;
|
||||||
|
/**
|
||||||
|
* Completing the connection requires some form of resolution. A resolution will be available
|
||||||
|
* to be started with {@link #startResolutionForResult(Activity, int)}. If the result returned
|
||||||
|
* is {@link Activity#RESULT_OK}, then further attempts to connect should either complete or
|
||||||
|
* continue on to the next issue that needs to be resolved.
|
||||||
|
*/
|
||||||
|
public static final int RESOLUTION_REQUIRED = 6;
|
||||||
|
/**
|
||||||
|
* A network error occurred. Retrying should resolve the problem.
|
||||||
|
*/
|
||||||
|
public static final int NETWORK_ERROR = 7;
|
||||||
|
/**
|
||||||
|
* An internal error occurred. Retrying should resolve the problem.
|
||||||
|
*/
|
||||||
|
public static final int INTERNAL_ERROR = 8;
|
||||||
|
/**
|
||||||
|
* The version of the Google Play services installed on this device is not authentic.
|
||||||
|
*/
|
||||||
|
public static final int SERVICE_INVALID = 9;
|
||||||
|
/**
|
||||||
|
* The application is misconfigured. This error is not recoverable and will be treated as
|
||||||
|
* fatal. The developer should look at the logs after this to determine more actionable
|
||||||
|
* information.
|
||||||
|
*/
|
||||||
|
public static final int DEVELOPER_ERROR = 10;
|
||||||
|
/**
|
||||||
|
* The application is not licensed to the user. This error is not recoverable and will be
|
||||||
|
* treated as fatal.
|
||||||
|
*/
|
||||||
|
public static final int LICENSE_CHECK_FAILED = 11;
|
||||||
|
/**
|
||||||
|
* The client canceled the connection by calling {@link GoogleApiClient#disconnect()}.
|
||||||
|
* Only returned by {@link GoogleApiClient#blockingConnect()}.
|
||||||
|
*/
|
||||||
|
public static final int CANCELED = 13;
|
||||||
|
/**
|
||||||
|
* The timeout was exceeded while waiting for the connection to complete. Only returned by
|
||||||
|
* {@link GoogleApiClient#blockingConnect()}.
|
||||||
|
*/
|
||||||
|
public static final int TIMEOUT = 14;
|
||||||
|
/**
|
||||||
|
* An interrupt occurred while waiting for the connection complete. Only returned by
|
||||||
|
* {@link GoogleApiClient#blockingConnect()}.
|
||||||
|
*/
|
||||||
|
public static final int INTERRUPTED = 15;
|
||||||
|
/**
|
||||||
|
* One of the API components you attempted to connect to is not available. The API will not
|
||||||
|
* work on this device, and updating Google Play services will not likely solve the problem.
|
||||||
|
* Using the API on the device should be avoided.
|
||||||
|
*/
|
||||||
|
public static final int API_UNAVAILABLE = 16;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Drive API requires external storage (such as an SD card), but no external storage is
|
||||||
|
* mounted. This error is recoverable if the user installs external storage (if none is
|
||||||
|
* present) and ensures that it is mounted (which may involve disabling USB storage mode,
|
||||||
|
* formatting the storage, or other initialization as required by the device).
|
||||||
|
* <p/>
|
||||||
|
* This error should never be returned on a device with emulated external storage. On devices
|
||||||
|
* with emulated external storage, the emulated "external storage" is always present regardless
|
||||||
|
* of whether the device also has removable storage.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static final int DRIVE_EXTERNAL_STORAGE_REQUIRED = 1500;
|
||||||
|
|
||||||
|
private final PendingIntent pendingIntent;
|
||||||
|
private final int statusCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a connection result.
|
||||||
|
*
|
||||||
|
* @param statusCode The status code.
|
||||||
|
* @param pendingIntent A pending intent that will resolve the issue when started, or null.
|
||||||
|
*/
|
||||||
|
public ConnectionResult(int statusCode, PendingIntent pendingIntent) {
|
||||||
|
this.statusCode = statusCode;
|
||||||
|
this.pendingIntent = pendingIntent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates the type of error that interrupted connection.
|
||||||
|
*
|
||||||
|
* @return the error code, or {@link #SUCCESS} if no error occurred.
|
||||||
|
*/
|
||||||
|
public int getErrorCode() {
|
||||||
|
return this.statusCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A pending intent to resolve the connection failure. This intent can be started with
|
||||||
|
* {@link Activity#startIntentSenderForResult(IntentSender, int, Intent, int, int, int)} to
|
||||||
|
* present UI to solve the issue.
|
||||||
|
*
|
||||||
|
* @return The pending intent to resolve the connection failure.
|
||||||
|
*/
|
||||||
|
public PendingIntent getResolution() {
|
||||||
|
return this.pendingIntent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns {@code true} if calling {@link #startResolutionForResult(Activity, int)} will start
|
||||||
|
* any intents requiring user interaction.
|
||||||
|
*
|
||||||
|
* @return {@code true} if there is a resolution that can be started.
|
||||||
|
*/
|
||||||
|
public boolean hasResolution() {
|
||||||
|
return statusCode != 0 && pendingIntent != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns {@code true} if the connection was successful.
|
||||||
|
*
|
||||||
|
* @return {@code true} if the connection was successful, {@code false} if there was an error.
|
||||||
|
*/
|
||||||
|
public boolean isSuccess() {
|
||||||
|
return this.statusCode == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolves an error by starting any intents requiring user interaction. See
|
||||||
|
* {@link #SIGN_IN_REQUIRED}, and {@link #RESOLUTION_REQUIRED}.
|
||||||
|
*
|
||||||
|
* @param activity An Activity context to use to resolve the issue. The activity's
|
||||||
|
* {@link Activity#onActivityResult} method will be invoked after the user
|
||||||
|
* is done. If the resultCode is {@link Activity#RESULT_OK}, the application
|
||||||
|
* should try to connect again.
|
||||||
|
* @param requestCode The request code to pass to {@link Activity#onActivityResult}.
|
||||||
|
* @throws IntentSender.SendIntentException If the resolution intent has been canceled or is no
|
||||||
|
* longer able to execute the request.
|
||||||
|
*/
|
||||||
|
public void startResolutionForResult(Activity activity, int requestCode) throws
|
||||||
|
IntentSender.SendIntentException {
|
||||||
|
if (hasResolution()) {
|
||||||
|
activity.startIntentSenderForResult(pendingIntent.getIntentSender(), requestCode, null,
|
||||||
|
0, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
package com.google.android.gms.common;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.app.Fragment;
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import org.microg.gms.Constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility class for verifying that the Google Play services APK is available and up-to-date on
|
||||||
|
* this device. The same checks are performed if one uses {@link AdvertisingIdClient} or
|
||||||
|
* {@link GoogleAuthUtil} to connect to the service.
|
||||||
|
* <p/>
|
||||||
|
* TODO: methods :)
|
||||||
|
*/
|
||||||
|
public class GooglePlayServicesUtil {
|
||||||
|
public static final String GMS_ERROR_DIALOG = "GooglePlayServicesErrorDialog";
|
||||||
|
public static final String GOOGLE_PLAY_SERVICES_PACKAGE = "com.google.android.gms";
|
||||||
|
public static final int GOOGLE_PLAY_SERVICES_VERSION_CODE = Constants.MAX_REFERENCE_VERSION;
|
||||||
|
public static final String GOOGLE_PLAY_STORE_PACKAGE = "com.android.vending";
|
||||||
|
|
||||||
|
public static Dialog getErrorDialog(int errorCode, Activity activity, int requestCode) {
|
||||||
|
return null; // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Dialog getErrorDialog(int errorCode, Activity activity, int requestCode,
|
||||||
|
DialogInterface.OnCancelListener cancelListener) {
|
||||||
|
return null; // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PendingIntent getErrorPendingIntent(int errorCode, Activity activity,
|
||||||
|
int requestCode) {
|
||||||
|
return null; // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getErrorString(int errorCode) {
|
||||||
|
return null; // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getOpenSourceSoftwareLicenseInfo(Context context) {
|
||||||
|
return null; // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Context getRemoteContext(Context context) {
|
||||||
|
return null; // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int isGooglePlayServicesAvailable(Context context) {
|
||||||
|
return 0; // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isGoogleSignedUid(PackageManager packageManager, int uid) {
|
||||||
|
return false; // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isUserRecoverableError(int errorCode) {
|
||||||
|
return false; // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean showErrorDialogFragment(int errorCode, Activity activity,
|
||||||
|
int requestCode) {
|
||||||
|
return false; // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean showErrorDialogFragment(int errorCode, Activity activity,
|
||||||
|
Fragment fragment, int requestCode, DialogInterface.OnCancelListener cancelListener) {
|
||||||
|
return false; // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean showErrorDialogFragment(int errorCode, Activity activity, int requestCode,
|
||||||
|
DialogInterface.OnCancelListener cancelListener) {
|
||||||
|
return false; // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void showErrorNotification(int errorCode, Context context) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
13
src/com/google/android/gms/common/api/Api.java
Normal file
13
src/com/google/android/gms/common/api/Api.java
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
package com.google.android.gms.common.api;
|
||||||
|
|
||||||
|
public class Api<O extends Api.ApiOptions> {
|
||||||
|
|
||||||
|
public interface ApiOptions {
|
||||||
|
public interface HasOptions extends ApiOptions {
|
||||||
|
|
||||||
|
}
|
||||||
|
public interface NotRequiredOptions extends ApiOptions {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
443
src/com/google/android/gms/common/api/GoogleApiClient.java
Normal file
443
src/com/google/android/gms/common/api/GoogleApiClient.java
Normal file
|
@ -0,0 +1,443 @@
|
||||||
|
package com.google.android.gms.common.api;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.FragmentActivity;
|
||||||
|
import android.view.View;
|
||||||
|
import com.google.android.gms.common.ConnectionResult;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.logging.Handler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The main entry point for Google Play services integration.
|
||||||
|
* <p/>
|
||||||
|
* GoogleApiClient is used with a variety of static methods. Some of these methods require that
|
||||||
|
* GoogleApiClient be connected, some will queue up calls before GoogleApiClient is connected;
|
||||||
|
* check the specific API documentation to determine whether you need to be connected.
|
||||||
|
* <p/>
|
||||||
|
* Before any operation is executed, the GoogleApiClient must be connected using the
|
||||||
|
* {@link #connect()} method. The client is not considered connected until the
|
||||||
|
* {@link ConnectionCallbacks#onConnected(Bundle)} callback has been called.
|
||||||
|
* <p/>
|
||||||
|
* When your app is done using this client, call {@link #disconnect()}, even if the async result
|
||||||
|
* from {@link #connect()} has not yet been delivered.
|
||||||
|
* <p/>
|
||||||
|
* You should instantiate a client object in your Activity's {@link Activity#onCreate(Bundle)}
|
||||||
|
* method and then call {@link #connect()} in {@link Activity#onStart()} and {@link #disconnect()}
|
||||||
|
* in {@link Activity#onStop()}, regardless of the state.
|
||||||
|
*/
|
||||||
|
public interface GoogleApiClient {
|
||||||
|
/**
|
||||||
|
* Connects the client to Google Play services. Blocks until the connection either succeeds or
|
||||||
|
* fails. This is not allowed on the UI thread.
|
||||||
|
*
|
||||||
|
* @return the result of the connection
|
||||||
|
*/
|
||||||
|
public ConnectionResult blockingConnect();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connects the client to Google Play services. Blocks until the connection is set or failed or
|
||||||
|
* has timed out. This is not allowed on the UI thread.
|
||||||
|
*
|
||||||
|
* @param timeout the maximum time to wait
|
||||||
|
* @param unit the time unit of the {@code timeout} argument
|
||||||
|
* @return the result of the connection
|
||||||
|
*/
|
||||||
|
public ConnectionResult blockingConnect(long timeout, TimeUnit unit);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the account selected by the user and reconnects the client asking the user to pick an
|
||||||
|
* account again if {@link Builder#useDefaultAccount()} was set.
|
||||||
|
*
|
||||||
|
* @return the pending result is fired once the default account has been cleared, but before
|
||||||
|
* the client is reconnected - for that {@link ConnectionCallbacks} can be used.
|
||||||
|
*/
|
||||||
|
public PendingResult<Status> clearDefaultAccountAndReconnect();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connects the client to Google Play services. This method returns immediately, and connects
|
||||||
|
* to the service in the background. If the connection is successful,
|
||||||
|
* {@link ConnectionCallbacks#onConnected(Bundle)} is called and enqueued items are executed.
|
||||||
|
* On a failure, {@link OnConnectionFailedListener#onConnectionFailed(ConnectionResult)} is
|
||||||
|
* called.
|
||||||
|
*/
|
||||||
|
public void connect();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes the connection to Google Play services. No calls can be made using this client after
|
||||||
|
* calling this method. Any method calls that haven't executed yet will be canceled. That is
|
||||||
|
* {@link ResultCallback#onResult(Result)} won't be called, if connection to the service hasn't
|
||||||
|
* been established yet all calls already made will be canceled.
|
||||||
|
*
|
||||||
|
* @see #connect()
|
||||||
|
*/
|
||||||
|
public void disconnect();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the client is currently connected to the service, so that requests to other
|
||||||
|
* methods will succeed. Applications should guard client actions caused by the user with a
|
||||||
|
* call to this method.
|
||||||
|
*
|
||||||
|
* @return {@code true} if the client is connected to the service.
|
||||||
|
*/
|
||||||
|
public boolean isConnected();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the client is attempting to connect to the service.
|
||||||
|
*
|
||||||
|
* @return {@code true} if the client is attempting to connect to the service.
|
||||||
|
*/
|
||||||
|
public boolean isConnecting();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns {@code true} if the specified listener is currently registered to receive connection
|
||||||
|
* events.
|
||||||
|
*
|
||||||
|
* @param listener The listener to check for.
|
||||||
|
* @return {@code true} if the specified listener is currently registered to receive connection
|
||||||
|
* events.
|
||||||
|
* @see #registerConnectionCallbacks(ConnectionCallbacks)
|
||||||
|
* @see #unregisterConnectionCallbacks(ConnectionCallbacks)
|
||||||
|
*/
|
||||||
|
public boolean isConnectionCallbacksRegistered(ConnectionCallbacks listener);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns {@code true} if the specified listener is currently registered to receive connection
|
||||||
|
* failed events.
|
||||||
|
*
|
||||||
|
* @param listener The listener to check for.
|
||||||
|
* @return {@code true} if the specified listener is currently registered to receive connection
|
||||||
|
* failed events.
|
||||||
|
* @see #registerConnectionFailedListener(OnConnectionFailedListener)
|
||||||
|
* @see #unregisterConnectionFailedListener(OnConnectionFailedListener)
|
||||||
|
*/
|
||||||
|
public boolean isConnectionFailedListenerRegistered(OnConnectionFailedListener listener);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes the current connection to Google Play services and creates a new connection.
|
||||||
|
* <p/>
|
||||||
|
* This method closes the current connection then returns immediately and reconnects to the
|
||||||
|
* service in the background.
|
||||||
|
* <p/>
|
||||||
|
* After calling this method, your application will receive
|
||||||
|
* {@link ConnectionCallbacks#onConnected(Bundle)} if the connection is successful, or
|
||||||
|
* {@link OnConnectionFailedListener#onConnectionFailed(ConnectionResult)} if the connection
|
||||||
|
* failed.
|
||||||
|
*
|
||||||
|
* @see #connect()
|
||||||
|
* @see #disconnect()
|
||||||
|
*/
|
||||||
|
public void reconnect();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a listener to receive connection events from this {@link GoogleApiClient}. If the
|
||||||
|
* service is already connected, the listener's {@link ConnectionCallbacks#onConnected(Bundle)}
|
||||||
|
* method will be called immediately. Applications should balance calls to this method with
|
||||||
|
* calls to {@link #unregisterConnectionCallbacks(ConnectionCallbacks)} to avoid leaking
|
||||||
|
* resources.
|
||||||
|
* <p/>
|
||||||
|
* If the specified listener is already registered to receive connection events, this method
|
||||||
|
* will not add a duplicate entry for the same listener, but will still call the listener's
|
||||||
|
* {@link ConnectionCallbacks#onConnected(Bundle)} method if currently connected.
|
||||||
|
* <p/>
|
||||||
|
* Note that the order of messages received here may not be stable, so clients should not rely
|
||||||
|
* on the order that multiple listeners receive events in.
|
||||||
|
*
|
||||||
|
* @param listener the listener where the results of the asynchronous {@link #connect()} call
|
||||||
|
* are delivered.
|
||||||
|
*/
|
||||||
|
public void registerConnectionCallbacks(ConnectionCallbacks listener);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a listener to receive connection failed events from this {@link GoogleApiClient}.
|
||||||
|
* Unlike {@link #registerConnectionCallbacks(ConnectionCallbacks)}, if the service is not
|
||||||
|
* already connected, the listener's
|
||||||
|
* {@link OnConnectionFailedListener#onConnectionFailed(ConnectionResult)} method will not be
|
||||||
|
* called immediately. Applications should balance calls to this method with calls to
|
||||||
|
* {@link #unregisterConnectionFailedListener(OnConnectionFailedListener)} to avoid leaking
|
||||||
|
* resources.
|
||||||
|
* <p/>
|
||||||
|
* If the specified listener is already registered to receive connection failed events, this
|
||||||
|
* method will not add a duplicate entry for the same listener.
|
||||||
|
* <p/>
|
||||||
|
* Note that the order of messages received here may not be stable, so clients should not rely
|
||||||
|
* on the order that multiple listeners receive events in.
|
||||||
|
*
|
||||||
|
* @param listener the listener where the results of the asynchronous {@link #connect()} call
|
||||||
|
* are delivered.
|
||||||
|
*/
|
||||||
|
public void registerConnectionFailedListener(OnConnectionFailedListener listener);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disconnects the client and stops automatic lifecycle management. Use this before creating a
|
||||||
|
* new client (which might be necessary when switching accounts, changing the set of used APIs
|
||||||
|
* etc.).
|
||||||
|
* <p/>
|
||||||
|
* This method must be called from the main thread.
|
||||||
|
*
|
||||||
|
* @param lifecycleActivity the activity managing the client's lifecycle.
|
||||||
|
* @throws IllegalStateException if called from outside of the main thread.
|
||||||
|
* @see Builder#enableAutoManage(FragmentActivity, int, OnConnectionFailedListener)
|
||||||
|
*/
|
||||||
|
public void stopAutoManager(FragmentActivity lifecycleActivity) throws IllegalStateException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a connection listener from this {@link GoogleApiClient}. Note that removing a
|
||||||
|
* listener does not generate any callbacks.
|
||||||
|
* <p/>
|
||||||
|
* If the specified listener is not currently registered to receive connection events, this
|
||||||
|
* method will have no effect.
|
||||||
|
*
|
||||||
|
* @param listener the listener to unregister.
|
||||||
|
*/
|
||||||
|
public void unregisterConnectionCallbacks(ConnectionCallbacks listener);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a connection failed listener from the {@link GoogleApiClient}. Note that removing a
|
||||||
|
* listener does not generate any callbacks.
|
||||||
|
* <p/>
|
||||||
|
* If the specified listener is not currently registered to receive connection failed events,
|
||||||
|
* this method will have no effect.
|
||||||
|
*
|
||||||
|
* @param listener the listener to unregister.
|
||||||
|
*/
|
||||||
|
public void unregisterConnectionFailedListener(OnConnectionFailedListener listener);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builder to configure a {@link GoogleApiClient}.
|
||||||
|
*/
|
||||||
|
public class Builder {
|
||||||
|
/**
|
||||||
|
* Builder to help construct the {@link GoogleApiClient} object.
|
||||||
|
*
|
||||||
|
* @param context The context to use for the connection.
|
||||||
|
*/
|
||||||
|
public Builder(Context context) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builder to help construct the {@link GoogleApiClient} object.
|
||||||
|
*
|
||||||
|
* @param context The context to use for the connection.
|
||||||
|
* @param connectedListener The listener where the results of the asynchronous
|
||||||
|
* {@link #connect()} call are delivered.
|
||||||
|
* @param connectionFailedListener The listener which will be notified if the connection
|
||||||
|
* attempt fails.
|
||||||
|
*/
|
||||||
|
public Builder(Context context, ConnectionCallbacks connectedListener,
|
||||||
|
OnConnectionFailedListener connectionFailedListener) {
|
||||||
|
this(context);
|
||||||
|
addConnectionCallbacks(connectedListener);
|
||||||
|
addOnConnectionFailedListener(connectionFailedListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify which Apis are requested by your app. See {@link Api} for more information.
|
||||||
|
*
|
||||||
|
* @param api The Api requested by your app.
|
||||||
|
* @param options Any additional parameters required for the specific AP
|
||||||
|
* @see Api
|
||||||
|
*/
|
||||||
|
public <O extends Api.ApiOptions.HasOptions> Builder addApi(Api<O> api, O options) {
|
||||||
|
// TODO
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify which Apis are requested by your app. See {@link Api} for more information.
|
||||||
|
*
|
||||||
|
* @param api The Api requested by your app.
|
||||||
|
* @see Api
|
||||||
|
*/
|
||||||
|
public Builder addApi(Api<? extends Api.ApiOptions.NotRequiredOptions> api) {
|
||||||
|
// TODO
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a listener to receive connection events from this {@link GoogleApiClient}.
|
||||||
|
* Applications should balance calls to this method with calls to
|
||||||
|
* {@link #unregisterConnectionCallbacks(ConnectionCallbacks)} to avoid
|
||||||
|
* leaking resources.
|
||||||
|
* <p/>
|
||||||
|
* If the specified listener is already registered to receive connection events, this
|
||||||
|
* method will not add a duplicate entry for the same listener.
|
||||||
|
* <p/>
|
||||||
|
* Note that the order of messages received here may not be stable, so clients should not
|
||||||
|
* rely on the order that multiple listeners receive events in.
|
||||||
|
*
|
||||||
|
* @param listener the listener where the results of the asynchronous {@link #connect()}
|
||||||
|
* call are delivered.
|
||||||
|
*/
|
||||||
|
public Builder addConnectionCallbacks(ConnectionCallbacks listener) {
|
||||||
|
// TODO
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a listener to register to receive connection failed events from this
|
||||||
|
* {@link GoogleApiClient}. Applications should balance calls to this method with calls to
|
||||||
|
* {@link #unregisterConnectionFailedListener(OnConnectionFailedListener)} to avoid
|
||||||
|
* leaking resources.
|
||||||
|
* <p/>
|
||||||
|
* If the specified listener is already registered to receive connection failed events,
|
||||||
|
* this method will not add a duplicate entry for the same listener.
|
||||||
|
* <p/>
|
||||||
|
* Note that the order of messages received here may not be stable, so clients should not
|
||||||
|
* rely on the order that multiple listeners receive events in.
|
||||||
|
*
|
||||||
|
* @param listener the listener where the results of the asynchronous {@link #connect()}
|
||||||
|
* call are delivered.
|
||||||
|
*/
|
||||||
|
public Builder addOnConnectionFailedListener(OnConnectionFailedListener listener) {
|
||||||
|
// TODO
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify the OAuth 2.0 scopes requested by your app. See
|
||||||
|
* {@link com.google.android.gms.common.Scopes} for more information.
|
||||||
|
*
|
||||||
|
* @param scope The OAuth 2.0 scopes requested by your app.
|
||||||
|
* @see com.google.android.gms.common.Scopes
|
||||||
|
*/
|
||||||
|
public Builder addScope(Scope scope) {
|
||||||
|
// TODO
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds a new {@link GoogleApiClient} object for communicating with the Google APIs.
|
||||||
|
*
|
||||||
|
* @return The {@link GoogleApiClient} object.
|
||||||
|
*/
|
||||||
|
public GoogleApiClient build() {
|
||||||
|
return null; // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder enableAutoManage(FragmentActivity fragmentActivity, int cliendId,
|
||||||
|
OnConnectionFailedListener unresolvedConnectionFailedListener)
|
||||||
|
throws NullPointerException, IllegalArgumentException, IllegalStateException {
|
||||||
|
// TODO
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify an account name on the device that should be used. If this is never called, the
|
||||||
|
* client will use the current default account for Google Play services for this
|
||||||
|
* application.
|
||||||
|
*
|
||||||
|
* @param accountName The account name on the device that should be used by
|
||||||
|
* {@link GoogleApiClient}.
|
||||||
|
*/
|
||||||
|
public Builder setAccountName(String accountName) {
|
||||||
|
// TODO
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the part of the screen at which games service popups (for example,
|
||||||
|
* "welcome back" or "achievement unlocked" popups) will be displayed using gravity.
|
||||||
|
*
|
||||||
|
* @param gravityForPopups The gravity which controls the placement of games service popups.
|
||||||
|
*/
|
||||||
|
public Builder setGravityForPopups(int gravityForPopups) {
|
||||||
|
// TODO
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a {@link Handler} to indicate which thread to use when invoking callbacks. Will not
|
||||||
|
* be used directly to handle callbacks. If this is not called then the application's main
|
||||||
|
* thread will be used.
|
||||||
|
*/
|
||||||
|
public Builder setHandler(Handler handler) {
|
||||||
|
// TODO
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the {@link View} to use as a content view for popups.
|
||||||
|
*
|
||||||
|
* @param viewForPopups The view to use as a content view for popups. View cannot be null.
|
||||||
|
*/
|
||||||
|
public Builder setViewForPopups(View viewForPopups) {
|
||||||
|
// TODO
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify that the default account should be used when connecting to services.
|
||||||
|
*/
|
||||||
|
public Builder useDefaultAccount() {
|
||||||
|
// TODO
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides callbacks that are called when the client is connected or disconnected from the
|
||||||
|
* service. Most applications implement {@link #onConnected(Bundle)} to start making requests.
|
||||||
|
*/
|
||||||
|
public interface ConnectionCallbacks {
|
||||||
|
/**
|
||||||
|
* A suspension cause informing that the service has been killed.
|
||||||
|
*/
|
||||||
|
int CAUSE_SERVICE_DISCONNECTED = 1;
|
||||||
|
/**
|
||||||
|
* A suspension cause informing you that a peer device connection was lost.
|
||||||
|
*/
|
||||||
|
int CAUSE_NETWORK_LOST = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* After calling {@link #connect()}, this method will be invoked asynchronously when the
|
||||||
|
* connect request has successfully completed. After this callback, the application can
|
||||||
|
* make requests on other methods provided by the client and expect that no user
|
||||||
|
* intervention is required to call methods that use account and scopes provided to the
|
||||||
|
* client constructor.
|
||||||
|
* <p/>
|
||||||
|
* Note that the contents of the {@code connectionHint} Bundle are defined by the specific
|
||||||
|
* services. Please see the documentation of the specific implementation of
|
||||||
|
* {@link GoogleApiClient} you are using for more information.
|
||||||
|
*
|
||||||
|
* @param connectionHint Bundle of data provided to clients by Google Play services. May
|
||||||
|
* be null if no content is provided by the service.
|
||||||
|
*/
|
||||||
|
void onConnected(Bundle connectionHint);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the client is temporarily in a disconnected state. This can happen if there
|
||||||
|
* is a problem with the remote service (e.g. a crash or resource problem causes it to be
|
||||||
|
* killed by the system). When called, all requests have been canceled and no outstanding
|
||||||
|
* listeners will be executed. GoogleApiClient will automatically attempt to restore the
|
||||||
|
* connection. Applications should disable UI components that require the service, and wait
|
||||||
|
* for a call to {@link #onConnected(Bundle)} to re-enable them.
|
||||||
|
*
|
||||||
|
* @param cause The reason for the disconnection. Defined by constants {@code CAUSE_*}.
|
||||||
|
*/
|
||||||
|
void onConnectionSuspended(int cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides callbacks for scenarios that result in a failed attempt to connect the client to
|
||||||
|
* the service. See {@link ConnectionResult} for a list of error codes and suggestions for
|
||||||
|
* resolution.
|
||||||
|
*/
|
||||||
|
public interface OnConnectionFailedListener {
|
||||||
|
/**
|
||||||
|
* Called when there was an error connecting the client to the service.
|
||||||
|
*
|
||||||
|
* @param result A {@link ConnectionResult} that can be used for resolving the error, and
|
||||||
|
* deciding what sort of error occurred. To resolve the error, the resolution
|
||||||
|
* must be started from an activity with a non-negative {@code requestCode}
|
||||||
|
* passed to {@link ConnectionResult#startResolutionForResult(Activity, int)}.
|
||||||
|
* Applications should implement {@link Activity#onActivityResult} in their
|
||||||
|
* Activity to call {@link #connect()} again if the user has resolved the
|
||||||
|
* issue (resultCode is {@link Activity#RESULT_OK}).
|
||||||
|
*/
|
||||||
|
void onConnectionFailed(ConnectionResult result);
|
||||||
|
}
|
||||||
|
}
|
4
src/com/google/android/gms/common/api/PendingResult.java
Normal file
4
src/com/google/android/gms/common/api/PendingResult.java
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
package com.google.android.gms.common.api;
|
||||||
|
|
||||||
|
public class PendingResult<T> {
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
package com.google.android.gms.common.api;
|
||||||
|
|
||||||
|
public class ResultCallback {
|
||||||
|
}
|
4
src/com/google/android/gms/common/api/Status.java
Normal file
4
src/com/google/android/gms/common/api/Status.java
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
package com.google.android.gms.common.api;
|
||||||
|
|
||||||
|
public class Status {
|
||||||
|
}
|
Loading…
Reference in a new issue