From a181a0f3b98c682d9d1e0b522c5ada9e749433f3 Mon Sep 17 00:00:00 2001 From: mar-v-in Date: Wed, 8 Apr 2015 02:48:25 +0200 Subject: [PATCH] Add some Logging APIs, fix services list --- .../common/internal/IGmsServiceBroker.aidl | 12 +-- .../gms/playlog/internal/IPlayLogService.aidl | 4 + .../gms/playlog/internal/LogEvent.aidl | 3 + .../playlog/internal/PlayLoggerContext.aidl | 3 + .../common/internal/GetServiceRequest.java | 23 +++++- .../gms/maps/model/TileOverlayOptions.java | 3 +- .../gms/playlog/internal/LogEvent.java | 55 ++++++++++++++ .../playlog/internal/PlayLoggerContext.java | 75 +++++++++++++++++++ .../java/org/microg/gms/common/Constants.java | 2 +- .../java/org/microg/gms/common/Services.java | 48 +++++++++++- 10 files changed, 216 insertions(+), 12 deletions(-) create mode 100644 play-services-api/src/main/aidl/com/google/android/gms/playlog/internal/LogEvent.aidl create mode 100644 play-services-api/src/main/aidl/com/google/android/gms/playlog/internal/PlayLoggerContext.aidl create mode 100644 play-services-api/src/main/java/com/google/android/gms/playlog/internal/LogEvent.java create mode 100644 play-services-api/src/main/java/com/google/android/gms/playlog/internal/PlayLoggerContext.java diff --git a/play-services-api/src/main/aidl/com/google/android/gms/common/internal/IGmsServiceBroker.aidl b/play-services-api/src/main/aidl/com/google/android/gms/common/internal/IGmsServiceBroker.aidl index 2074e4aa..9649150d 100644 --- a/play-services-api/src/main/aidl/com/google/android/gms/common/internal/IGmsServiceBroker.aidl +++ b/play-services-api/src/main/aidl/com/google/android/gms/common/internal/IGmsServiceBroker.aidl @@ -7,16 +7,16 @@ import com.google.android.gms.common.internal.GetServiceRequest; import com.google.android.gms.common.internal.ValidateAccountRequest; interface IGmsServiceBroker { - void getPlusService(IGmsCallbacks callback, int code, String str1, String str2, in String[] paramArrayOfString, String str3, in Bundle params) = 0; - void getPanoramaService(IGmsCallbacks callback, int code, String str, in Bundle params) = 1; - void getAppDataSearchService(IGmsCallbacks callback, int code, String str) = 2; + void getPlusService(IGmsCallbacks callback, int code, String packageName, String authPackage, in String[] scopes, String accountName, in Bundle params) = 0; + void getPanoramaService(IGmsCallbacks callback, int code, String packageName, in Bundle params) = 1; + void getAppDataSearchService(IGmsCallbacks callback, int code, String packageName) = 2; void getWalletService(IGmsCallbacks callback, int code) = 3; void getPeopleService(IGmsCallbacks callback, int code, String str, in Bundle params) = 4; void getReportingService(IGmsCallbacks callback, int code, String str, in Bundle params) = 5; void getLocationService(IGmsCallbacks callback, int code, String str, in Bundle params) = 6; void getGoogleLocationManagerService(IGmsCallbacks callback, int code, String str, in Bundle params) = 7; - void getGamesService(IGmsCallbacks callback, int code, String str1, String str2, in String[] args, String str3, IBinder binder, String str4, in Bundle params) = 8; - void getAppStateService(IGmsCallbacks callback, int code, String str1, String str2, in String[] args) = 9; + void getGamesService(IGmsCallbacks callback, int code, String packageName, String accountName, in String[] scopes, String gamePackageName, IBinder popupWindowToken, String desiredLocale, in Bundle params) = 8; + void getAppStateService(IGmsCallbacks callback, int code, String packageName, String accountName, in String[] scopes) = 9; void getPlayLogService(IGmsCallbacks callback, int code, String str, in Bundle params) = 10; void getAdMobService(IGmsCallbacks callback, int code, String str, in Bundle params) = 11; void getDroidGuardService(IGmsCallbacks callback, int code, String str, in Bundle params) = 12; @@ -32,6 +32,8 @@ interface IGmsServiceBroker { void getAutoBackupService(IGmsCallbacks callback, int code, String str, in Bundle params) = 22; void getAddressService(IGmsCallbacks callback, int code, String str) = 23; + void getWalletServiceWithPackageName(IGmsCallbacks callback, int code, String packageName) = 41; + void getService(IGmsCallbacks callback, in GetServiceRequest request) = 45; void validateAccount(IGmsCallbacks callback, in ValidateAccountRequest request) = 46; } diff --git a/play-services-api/src/main/aidl/com/google/android/gms/playlog/internal/IPlayLogService.aidl b/play-services-api/src/main/aidl/com/google/android/gms/playlog/internal/IPlayLogService.aidl index 38e620ea..521df957 100644 --- a/play-services-api/src/main/aidl/com/google/android/gms/playlog/internal/IPlayLogService.aidl +++ b/play-services-api/src/main/aidl/com/google/android/gms/playlog/internal/IPlayLogService.aidl @@ -1,4 +1,8 @@ package com.google.android.gms.playlog.internal; +import com.google.android.gms.playlog.internal.LogEvent; +import com.google.android.gms.playlog.internal.PlayLoggerContext; + interface IPlayLogService { + void event(String packageName, in PlayLoggerContext context, in LogEvent event) = 1; } diff --git a/play-services-api/src/main/aidl/com/google/android/gms/playlog/internal/LogEvent.aidl b/play-services-api/src/main/aidl/com/google/android/gms/playlog/internal/LogEvent.aidl new file mode 100644 index 00000000..6e7bed53 --- /dev/null +++ b/play-services-api/src/main/aidl/com/google/android/gms/playlog/internal/LogEvent.aidl @@ -0,0 +1,3 @@ +package com.google.android.gms.playlog.internal; + +parcelable LogEvent; diff --git a/play-services-api/src/main/aidl/com/google/android/gms/playlog/internal/PlayLoggerContext.aidl b/play-services-api/src/main/aidl/com/google/android/gms/playlog/internal/PlayLoggerContext.aidl new file mode 100644 index 00000000..9cc0e0e4 --- /dev/null +++ b/play-services-api/src/main/aidl/com/google/android/gms/playlog/internal/PlayLoggerContext.aidl @@ -0,0 +1,3 @@ +package com.google.android.gms.playlog.internal; + +parcelable PlayLoggerContext; diff --git a/play-services-api/src/main/java/com/google/android/gms/common/internal/GetServiceRequest.java b/play-services-api/src/main/java/com/google/android/gms/common/internal/GetServiceRequest.java index ecaa97ff..29660700 100644 --- a/play-services-api/src/main/java/com/google/android/gms/common/internal/GetServiceRequest.java +++ b/play-services-api/src/main/java/com/google/android/gms/common/internal/GetServiceRequest.java @@ -23,18 +23,21 @@ import android.os.IBinder; import com.google.android.gms.common.api.Scope; import org.microg.gms.common.Constants; +import org.microg.gms.common.Services; import org.microg.safeparcel.AutoSafeParcelable; import org.microg.safeparcel.SafeParceled; +import java.util.Arrays; + public class GetServiceRequest extends AutoSafeParcelable { @SafeParceled(1) - private final int versionCode = 2; + private final int versionCode; @SafeParceled(2) public final int serviceId; @SafeParceled(3) - public int gmsVersion = Constants.MAX_REFERENCE_VERSION; + public int gmsVersion; @SafeParceled(4) public String packageName; @@ -52,11 +55,27 @@ public class GetServiceRequest extends AutoSafeParcelable { public Account account; private GetServiceRequest() { + versionCode = 2; serviceId = -1; + gmsVersion = Constants.MAX_REFERENCE_VERSION; } public GetServiceRequest(int serviceId) { + this.versionCode = 2; this.serviceId = serviceId; + this.gmsVersion = Constants.MAX_REFERENCE_VERSION; + } + + @Override + public String toString() { + return "GetServiceRequest{" + + "serviceId=" + Services.nameFromServiceId(serviceId) + + ", gmsVersion=" + gmsVersion + + ", packageName='" + packageName + '\'' + + (scopes == null || scopes.length == 0 ? "" : (", scopes=" + Arrays.toString(scopes))) + + (extras == null ? "" : (", extras=" + extras)) + + (account == null ? "" : (", account=" + account)) + + '}'; } public static Creator CREATOR = new AutoCreator<>(GetServiceRequest.class); diff --git a/play-services-api/src/main/java/com/google/android/gms/maps/model/TileOverlayOptions.java b/play-services-api/src/main/java/com/google/android/gms/maps/model/TileOverlayOptions.java index 85ab38f0..7f2df331 100644 --- a/play-services-api/src/main/java/com/google/android/gms/maps/model/TileOverlayOptions.java +++ b/play-services-api/src/main/java/com/google/android/gms/maps/model/TileOverlayOptions.java @@ -31,7 +31,7 @@ import org.microg.safeparcel.SafeParceled; public class TileOverlayOptions extends AutoSafeParcelable { @SafeParceled(1) - private final int versionCode = 1; + private final int versionCode; /** * This is a IBinder to the {@link #tileProvider}, built using {@link ITileProviderDelegate}. */ @@ -49,6 +49,7 @@ public class TileOverlayOptions extends AutoSafeParcelable { * Creates a new set of tile overlay options. */ public TileOverlayOptions() { + versionCode = 1; } /** diff --git a/play-services-api/src/main/java/com/google/android/gms/playlog/internal/LogEvent.java b/play-services-api/src/main/java/com/google/android/gms/playlog/internal/LogEvent.java new file mode 100644 index 00000000..3f2469f9 --- /dev/null +++ b/play-services-api/src/main/java/com/google/android/gms/playlog/internal/LogEvent.java @@ -0,0 +1,55 @@ +/* + * 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.playlog.internal; + +import org.microg.safeparcel.AutoSafeParcelable; +import org.microg.safeparcel.SafeParceled; + +import java.util.Date; + +public class LogEvent extends AutoSafeParcelable { + + @SafeParceled(1) + public final int versionCode; + + @SafeParceled(2) + public final long eventTime; + + @SafeParceled(3) + public final String tag; + + @SafeParceled(4) + public final byte[] data; + + private LogEvent() { + versionCode = 1; + eventTime = -1; + tag = null; + data = null; + } + + @Override + public String toString() { + return "LogEvent{" + + "eventTime=" + new Date(eventTime) + + ", tag='" + tag + '\'' + + ", data='" + new String(data) + '\'' + + '}'; + } + + public static Creator CREATOR = new AutoCreator<>(LogEvent.class); +} diff --git a/play-services-api/src/main/java/com/google/android/gms/playlog/internal/PlayLoggerContext.java b/play-services-api/src/main/java/com/google/android/gms/playlog/internal/PlayLoggerContext.java new file mode 100644 index 00000000..3dcd4f92 --- /dev/null +++ b/play-services-api/src/main/java/com/google/android/gms/playlog/internal/PlayLoggerContext.java @@ -0,0 +1,75 @@ +/* + * 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.playlog.internal; + +import org.microg.safeparcel.AutoSafeParcelable; +import org.microg.safeparcel.SafeParceled; + +public class PlayLoggerContext extends AutoSafeParcelable { + + @SafeParceled(1) + public final int versionCode; + + @SafeParceled(2) + public final String packageName; + + @SafeParceled(4) + public final int logSource; + + @SafeParceled(5) + public final String uploadAccount; + + @SafeParceled(6) + public final int loggingId; + + @SafeParceled(7) + public final boolean logAndroidId; + + @SafeParceled(8) + public final String logSourceName; + + private PlayLoggerContext() { + this.versionCode = 1; + packageName = uploadAccount = logSourceName = null; + logSource = loggingId = -1; + logAndroidId = false; + } + + public PlayLoggerContext(String packageName, int logSource, String uploadAccount, int loggingId, String logSourceName) { + this.versionCode = 1; + this.packageName = packageName; + this.logSource = logSource; + this.uploadAccount = uploadAccount; + this.loggingId = loggingId; + this.logSourceName = logSourceName; + this.logAndroidId = true; + } + + @Override + public String toString() { + return "PlayLoggerContext{" + + "packageName='" + packageName + '\'' + + ", logSource=" + logSource + + ", uploadAccount='" + uploadAccount + '\'' + + ", loggingId=" + loggingId + + ", logAndroidId=" + logAndroidId + + ", logSourceName='" + logSourceName + '\'' + + '}'; + } + + public static Creator CREATOR = new AutoCreator<>(PlayLoggerContext.class); +} diff --git a/play-services-api/src/main/java/org/microg/gms/common/Constants.java b/play-services-api/src/main/java/org/microg/gms/common/Constants.java index 097d36ef..7e53ce71 100644 --- a/play-services-api/src/main/java/org/microg/gms/common/Constants.java +++ b/play-services-api/src/main/java/org/microg/gms/common/Constants.java @@ -5,7 +5,7 @@ public class Constants { * This is the highest version that was looked at during development. * Does not necessarily mean anything. */ - public static final int MAX_REFERENCE_VERSION = 6599436; + public static final int MAX_REFERENCE_VERSION = 7099448; 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"; diff --git a/play-services-api/src/main/java/org/microg/gms/common/Services.java b/play-services-api/src/main/java/org/microg/gms/common/Services.java index 9d717e7d..f4a73ea6 100644 --- a/play-services-api/src/main/java/org/microg/gms/common/Services.java +++ b/play-services-api/src/main/java/org/microg/gms/common/Services.java @@ -16,6 +16,8 @@ package org.microg.gms.common; +import java.lang.reflect.Field; + public final class Services { public static final class GAMES { public static final int SERVICE_ID = 1; @@ -43,9 +45,8 @@ public final class Services { public static final String ACTION = "com.google.android.gms.people.service.START"; } - @Deprecated public static final class LOCATION { - public static final int SERVICE_ID = 5; + public static final int SERVICE_ID = 6; } public static final class APPSTATE { @@ -128,6 +129,10 @@ public final class Services { public static final String ACTION = "com.google.android.location.internal.GoogleLocationManagerService.START"; } + public static final class PLAY_LOG { + public static final int SERVICE_ID = 24; + } + public static final class DROIDGUARD { public static final int SERVICE_ID = 25; public static final String ACTION = "com.google.android.gms.droidguard.service.START"; @@ -143,7 +148,6 @@ public final class Services { public static final String ACTION = "com.google.android.gms.cast_mirroring.service.START"; } - @Deprecated public static final class NETWORK_QUALITY { public static final int SERVICE_ID = 28; public static final String ACTION = "com.google.android.gms.mdm.services.START"; @@ -154,16 +158,32 @@ public final class Services { public static final String ACTION = "com.google.android.gms.feedback.internal.IFeedbackService"; } + public static final class SEARCH_ADMINISTRATION { + public static final int SERVICE_ID = 30; + } + public static final class PHOTO_AUTO_BACKUP { public static final int SERVICE_ID = 31; public static final String ACTION = "com.google.android.gms.photos.autobackup.service.START"; } + public static final class SEARCH_QUERIES { + public static final int SERVICE_ID = 32; + } + + public static final class SEARCH_GLOBAL { + public static final int SERVICE_ID = 33; + } + public static final class UDC { public static final int SERVICE_ID = 35; public static final String ACTION = "com.google.android.gms.udc.service.START"; } + public static final class SEARCH_CORPORA { + public static final int SERVICE_ID = 36; + } + public static final class DEVICE_MANAGER { public static final int SERVICE_ID = 37; public static final String ACTION = "com.google.android.gms.mdm.services.DeviceManagerApiService.START"; @@ -302,9 +322,31 @@ public final class Services { public static final String ACTION = "com.google.android.gms.config.START"; } + public static final class GEODATA { + public static final int SERVICE_ID = 65; + } + + public static final class SEARCH_IME { + public static final int SERVICE_ID = 66; + } + + public static final class PLACE_DETECTION { + public static final int SERVICE_ID = 67; + } + public static final class CREDENTIALS { public static final int SERVICE_ID = 68; public static final String ACTION = "com.google.android.gms.auth.api.credentials.service.START"; } + public static String nameFromServiceId(int serviceId) { + for (Class cls : Services.class.getDeclaredClasses()) { + try { + Field serviceIdField = cls.getDeclaredField("SERVICE_ID"); + if ((Integer) serviceIdField.get(null) == serviceId) return cls.getSimpleName(); + } catch (Exception e) { + } + } + return "UNKNOWN(" + serviceId + ")"; + } }