From c1f66a6b3b462c53f0d67345cc9ca2c7c6bdab74 Mon Sep 17 00:00:00 2001 From: mar-v-in Date: Thu, 15 Jan 2015 20:16:15 +0100 Subject: [PATCH] Add api stuff --- build.gradle | 2 +- .../google/android/gms/common/api/Result.java | 8 ++ .../google/android/gms/common/api/Status.java | 79 +++++++++++++++++++ src/org/microg/gms/Constants.java | 1 + 4 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 src/com/google/android/gms/common/api/Result.java create mode 100644 src/com/google/android/gms/common/api/Status.java diff --git a/build.gradle b/build.gradle index f433729e..dd90597a 100644 --- a/build.gradle +++ b/build.gradle @@ -15,7 +15,7 @@ dependencies { android { compileSdkVersion 21 - buildToolsVersion "21.0.2" + buildToolsVersion "21.1.2" lintOptions.abortOnError false sourceSets { diff --git a/src/com/google/android/gms/common/api/Result.java b/src/com/google/android/gms/common/api/Result.java new file mode 100644 index 00000000..d8408112 --- /dev/null +++ b/src/com/google/android/gms/common/api/Result.java @@ -0,0 +1,8 @@ +package com.google.android.gms.common.api; + +/** + * Represents the final result of invoking an API method in Google Play Services. + */ +public interface Result { + public Status getStatus(); +} diff --git a/src/com/google/android/gms/common/api/Status.java b/src/com/google/android/gms/common/api/Status.java new file mode 100644 index 00000000..1431f98c --- /dev/null +++ b/src/com/google/android/gms/common/api/Status.java @@ -0,0 +1,79 @@ +package com.google.android.gms.common.api; + +import android.app.PendingIntent; +import org.microg.safeparcel.AutoSafeParcelable; + +/** + * Represents the results of work. + *

+ * TODO: Docs + */ +public final class Status extends AutoSafeParcelable implements Result { + private static final int STATUS_CODE_INTERRUPTED = 14; + private static final int STATUS_CODE_CANCELED = 16; + + public static final Status INTERRUPTED = new Status(STATUS_CODE_INTERRUPTED); + public static final Status CANCELED = new Status(STATUS_CODE_CANCELED); + + private final int versionCode; + private final int statusCode; + private final String statusMessage; + private final PendingIntent resolution; + + private Status() { + versionCode = 1; + statusCode = 0; + statusMessage = null; + resolution = null; + } + + public Status(int statusCode) { + this(statusCode, null); + } + + public Status(int statusCode, String statusMessage) { + this(statusCode, statusMessage, null); + } + + public Status(int statusCode, String statusMessage, PendingIntent resolution) { + this.versionCode = 1; + this.statusCode = statusCode; + this.statusMessage = statusMessage; + this.resolution = resolution; + } + + public PendingIntent getResolution() { + return resolution; + } + + public int getStatusCode() { + return statusCode; + } + + public String getStatusMessage() { + return statusMessage; + } + + public boolean hasResolution() { + return resolution != null; + } + + public boolean isCanceled() { + return statusCode == STATUS_CODE_CANCELED; + } + + public boolean isInterrupted() { + return statusCode == STATUS_CODE_INTERRUPTED; + } + + public boolean isSuccess() { + return statusCode <= 0; + } + + @Override + public Status getStatus() { + return this; + } + + public static final Creator CREATOR = new AutoCreator<>(Status.class); +} diff --git a/src/org/microg/gms/Constants.java b/src/org/microg/gms/Constants.java index a855bbc5..8e6c6844 100644 --- a/src/org/microg/gms/Constants.java +++ b/src/org/microg/gms/Constants.java @@ -9,6 +9,7 @@ public class Constants { public static final String ACTION_GMS_LOCATION_MANAGER_SERVICE_START = "com.google.android.location.internal.GoogleLocationManagerService.START"; public static final String KEY_MOCK_LOCATION = "mockLocation"; public static final String DEFAULT_ACCOUNT = "<>"; + public static final String GMS_PACKAGE_NAME = "com.google.android.gms"; /** * No base map tiles.