From a223d9591290172fc58266173f9ce1c8b98cef12 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Fri, 22 Jan 2016 03:44:27 +0100 Subject: [PATCH] Split constant-pool, add some components for gcm --- extern/SafeParcel | 2 +- play-services-api/build.gradle | 18 ++- .../android/gms/iid/IMessengerCompat.aidl | 7 ++ .../android/gms/gcm/PendingCallback.java | 59 ++++++++++ .../android/gms/iid/MessengerCompat.java | 106 ++++++++++++++++++ .../org/microg/gms/auth/AuthConstants.java | 22 ++++ .../java/org/microg/gms/common/Constants.java | 28 +---- .../java/org/microg/gms/gcm/GcmConstants.java | 71 ++++++++++++ .../gms/location/LocationConstants.java | 21 ++++ .../org/microg/gms/maps/MapsConstants.java | 40 +++++++ 10 files changed, 344 insertions(+), 30 deletions(-) create mode 100644 play-services-api/src/main/aidl/com/google/android/gms/iid/IMessengerCompat.aidl create mode 100644 play-services-api/src/main/java/com/google/android/gms/gcm/PendingCallback.java create mode 100644 play-services-api/src/main/java/com/google/android/gms/iid/MessengerCompat.java create mode 100644 play-services-api/src/main/java/org/microg/gms/auth/AuthConstants.java create mode 100644 play-services-api/src/main/java/org/microg/gms/gcm/GcmConstants.java create mode 100644 play-services-api/src/main/java/org/microg/gms/location/LocationConstants.java create mode 100644 play-services-api/src/main/java/org/microg/gms/maps/MapsConstants.java diff --git a/extern/SafeParcel b/extern/SafeParcel index 4579b940..e7051668 160000 --- a/extern/SafeParcel +++ b/extern/SafeParcel @@ -1 +1 @@ -Subproject commit 4579b940f2aab6bc4be8607b20e0bbb70ab4002d +Subproject commit e70516688482e667a22b8d485d1131e5af11c188 diff --git a/play-services-api/build.gradle b/play-services-api/build.gradle index d7c9bc7b..28a98c26 100644 --- a/play-services-api/build.gradle +++ b/play-services-api/build.gradle @@ -19,7 +19,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.3.0' + classpath 'com.android.tools.build:gradle:1.5.0' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' } } @@ -27,12 +27,26 @@ buildscript { apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' +String getMyVersionName() { + def stdout = new ByteArrayOutputStream() + exec { + commandLine 'git', 'describe', '--tags', '--always', '--dirty' + standardOutput = stdout + } + return stdout.toString().trim() +} + group = 'org.microg' -version = '1.0-SNAPSHOT' +version = getMyVersionName().substring(1) android { compileSdkVersion 23 buildToolsVersion "23.0.2" + + defaultConfig { + versionName getMyVersionName() + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_6 } diff --git a/play-services-api/src/main/aidl/com/google/android/gms/iid/IMessengerCompat.aidl b/play-services-api/src/main/aidl/com/google/android/gms/iid/IMessengerCompat.aidl new file mode 100644 index 00000000..3ebf38c1 --- /dev/null +++ b/play-services-api/src/main/aidl/com/google/android/gms/iid/IMessengerCompat.aidl @@ -0,0 +1,7 @@ +package com.google.android.gms.iid; + +import android.os.Message; + +interface IMessengerCompat { + void send(in Message message); +} diff --git a/play-services-api/src/main/java/com/google/android/gms/gcm/PendingCallback.java b/play-services-api/src/main/java/com/google/android/gms/gcm/PendingCallback.java new file mode 100644 index 00000000..6eed3e3d --- /dev/null +++ b/play-services-api/src/main/java/com/google/android/gms/gcm/PendingCallback.java @@ -0,0 +1,59 @@ +/* + * Copyright 2013-2016 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.gcm; + +import android.os.IBinder; +import android.os.Parcel; +import android.os.Parcelable; + +public class PendingCallback implements Parcelable { + private final IBinder binder; + + public PendingCallback(IBinder binder) { + this.binder = binder; + } + + private PendingCallback(Parcel in) { + this.binder = in.readStrongBinder(); + } + + public IBinder getBinder() { + return binder; + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeStrongBinder(binder); + } + + public static final Creator CREATOR = new Creator() { + @Override + public PendingCallback createFromParcel(Parcel source) { + return new PendingCallback(source); + } + + @Override + public PendingCallback[] newArray(int size) { + return new PendingCallback[size]; + } + }; +} diff --git a/play-services-api/src/main/java/com/google/android/gms/iid/MessengerCompat.java b/play-services-api/src/main/java/com/google/android/gms/iid/MessengerCompat.java new file mode 100644 index 00000000..d06fc263 --- /dev/null +++ b/play-services-api/src/main/java/com/google/android/gms/iid/MessengerCompat.java @@ -0,0 +1,106 @@ +/* + * Copyright 2013-2016 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.iid; + +import android.os.Binder; +import android.os.Handler; +import android.os.IBinder; +import android.os.Message; +import android.os.Messenger; +import android.os.Parcel; +import android.os.Parcelable; +import android.os.RemoteException; + +import static android.os.Build.VERSION.SDK_INT; +import static android.os.Build.VERSION_CODES.LOLLIPOP; + +public class MessengerCompat implements Parcelable { + private Messenger messenger; + private IMessengerCompat messengerCompat; + + public MessengerCompat(IBinder binder) { + if (SDK_INT >= LOLLIPOP) { + messenger = new Messenger(binder); + } else { + messengerCompat = IMessengerCompat.Stub.asInterface(binder); + } + } + + public MessengerCompat(Handler handler) { + if (SDK_INT >= LOLLIPOP) { + messenger = new Messenger(handler); + } else { + messengerCompat = new IMessengerCompatImpl(handler); + } + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public boolean equals(Object o) { + return o instanceof MessengerCompat && ((MessengerCompat) o).getBinder().equals(getBinder()); + } + + public IBinder getBinder() { + return messenger != null ? messenger.getBinder() : messengerCompat.asBinder(); + } + + @Override + public int hashCode() { + return getBinder().hashCode(); + } + + public void send(Message message) throws RemoteException { + if (messenger != null) messenger.send(message); + else messengerCompat.send(message); + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeStrongBinder(getBinder()); + } + + public static final Creator CREATOR = new Creator() { + @Override + public MessengerCompat createFromParcel(Parcel source) { + IBinder binder = source.readStrongBinder(); + return binder != null ? new MessengerCompat(binder) : null; + } + + @Override + public MessengerCompat[] newArray(int size) { + return new MessengerCompat[size]; + } + }; + + private static class IMessengerCompatImpl extends IMessengerCompat.Stub { + private final Handler handler; + + public IMessengerCompatImpl(Handler handler) { + this.handler = handler; + } + + @Override + public void send(Message message) throws RemoteException { + message.arg2 = Binder.getCallingUid(); + handler.dispatchMessage(message); + } + } +} diff --git a/play-services-api/src/main/java/org/microg/gms/auth/AuthConstants.java b/play-services-api/src/main/java/org/microg/gms/auth/AuthConstants.java new file mode 100644 index 00000000..70ce7126 --- /dev/null +++ b/play-services-api/src/main/java/org/microg/gms/auth/AuthConstants.java @@ -0,0 +1,22 @@ +/* + * Copyright 2013-2016 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.auth; + +public class AuthConstants { + public static final String DEFAULT_ACCOUNT = "<>"; + public static final String SCOPE_GET_ACCOUNT_ID = "^^_account_id_^^"; +} 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 6f0589bc..d838c0b0 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 @@ -22,34 +22,8 @@ public class Constants { * Does not necessarily mean anything. */ public static final int MAX_REFERENCE_VERSION = 8489000; - 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"; + public static final String GSF_PACKAGE_NAME = "com.google.android.gsf"; public static final String GMS_PACKAGE_SIGNATURE_SHA1 = "38918a453d07199354f8b19af05ec6562ced5788"; - public static final String SCOPE_GET_ACCOUNT_ID = "^^_account_id_^^"; - /** - * No base map tiles. - */ - public static final int MAP_TYPE_NONE = 0; - - /** - * Basic maps. - */ - public static final int MAP_TYPE_NORMAL = 1; - - /** - * Satellite maps with no labels. - */ - public static final int MAP_TYPE_SATELLITE = 2; - - /** - * Terrain maps. - */ - public static final int MAP_TYPE_TERRAIN = 3; - - /** - * Satellite maps with a transparent layer of major streets. - */ - public static final int MAP_TYPE_HYBRID = 4; } diff --git a/play-services-api/src/main/java/org/microg/gms/gcm/GcmConstants.java b/play-services-api/src/main/java/org/microg/gms/gcm/GcmConstants.java new file mode 100644 index 00000000..d387b56c --- /dev/null +++ b/play-services-api/src/main/java/org/microg/gms/gcm/GcmConstants.java @@ -0,0 +1,71 @@ +/* + * Copyright 2013-2016 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.gcm; + +public final class GcmConstants { + public static final String ACTION_C2DM_RECEIVE = "com.google.android.c2dm.intent.RECEIVE"; + public static final String ACTION_C2DM_REGISTER = "com.google.android.c2dm.intent.REGISTER"; + public static final String ACTION_C2DM_REGISTRATION = "com.google.android.c2dm.intent.REGISTRATION"; + public static final String ACTION_C2DM_UNREGISTER = "com.google.android.c2dm.intent.UNREGISTER"; + public static final String ACTION_GCM_SEND = "com.google.android.gcm.intent.SEND"; + public static final String ACTION_NOTIFICATION_OPEN = "com.google.android.gms.gcm.NOTIFICATION_OPEN"; + public static final String ACTION_NOTIFICATION_DISMISS = "com.google.android.gms.gcm.NOTIFICATION_DISMISS"; + public static final String ACTION_SCHEDULE = "com.google.android.gms.gcm.ACTION_SCHEDULE"; + public static final String ACTION_TASK_READY = "com.google.android.gms.gcm.ACTION_TASK_READY"; + public static final String ACTION_TASK_INITIALZE = "com.google.android.gms.gcm.SERVICE_ACTION_INITIALIZE"; + public static final String ACTION_INSTANCE_ID = "com.google.android.gms.iid.InstanceID"; + + public static final String EXTRA_APP = "app"; + public static final String EXTRA_COMPONENT = "component"; + public static final String EXTRA_DELAY = "google.delay"; + public static final String EXTRA_ERROR = "error"; + public static final String EXTRA_FROM = "from"; + public static final String EXTRA_GSF_INTENT = "GSF"; + public static final String EXTRA_PENDING_INTENT = "com.google.android.gms.gcm.PENDING_INTENT"; + public static final String EXTRA_MESSENGER = "google.messenger"; + public static final String EXTRA_MESSAGE_TYPE = "message_type"; + public static final String EXTRA_MESSAGE_ID = "google.message_id"; + public static final String EXTRA_REGISTRATION_ID = "registration_id"; + public static final String EXTRA_RETRY_AFTER = "Retry-After"; + public static final String EXTRA_SCHEDULER_ACTION = "scheduler_action"; + public static final String EXTRA_SENDER = "sender"; + public static final String EXTRA_SENDER_LEGACY = "legacy.sender"; + public static final String EXTRA_SEND_TO = "google.to"; + public static final String EXTRA_SEND_FROM = "google.from"; + public static final String EXTRA_TAG = "tag"; + public static final String EXTRA_TOPIC = "gcm.topic"; + public static final String EXTRA_TTL = "google.ttl"; + public static final String EXTRA_UNREGISTERED = "unregistered"; + + public static final String MESSAGE_TYPE_GCM = "gcm"; + public static final String MESSAGE_TYPE_DELETED_MESSAGE = "deleted_message"; + public static final String MESSAGE_TYPE_SEND_ERROR = "send_error"; + public static final String MESSAGE_TYPE_SEND_EVENT = "send_event"; + + public static final String SCHEDULER_ACTION_CANCEL = "CANCEL_TASK"; + public static final String SCHEDULER_ACTION_CANCEL_ALL = "CANCEL_ALL"; + public static final String SCHEDULER_ACTION_SCHEDULE = "SCHEDULE_TASK"; + + public static final String PERMISSION_GTALK = "com.google.android.gtalkservice.permission.GTALK_SERVICE"; + public static final String PERMISSION_NETWORK_TASK = "com.google.android.gms.permission.BIND_NETWORK_TASK_SERVICE"; + public static final String PERMISSION_RECEIVE = "com.google.android.c2dm.permission.RECEIVE"; + public static final String PERMISSION_SEND = "com.google.android.c2dm.permission.SEND"; + + public static final String ERROR_SERVICE_NOT_AVAILABLE = "SERVICE_NOT_AVAILABLE"; + + public static final String INSTANCE_ID_SCOPE_GCM = "GCM"; +} diff --git a/play-services-api/src/main/java/org/microg/gms/location/LocationConstants.java b/play-services-api/src/main/java/org/microg/gms/location/LocationConstants.java new file mode 100644 index 00000000..378c5c73 --- /dev/null +++ b/play-services-api/src/main/java/org/microg/gms/location/LocationConstants.java @@ -0,0 +1,21 @@ +/* + * Copyright 2013-2016 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.location; + +public class LocationConstants { + public static final String KEY_MOCK_LOCATION = "mockLocation"; +} diff --git a/play-services-api/src/main/java/org/microg/gms/maps/MapsConstants.java b/play-services-api/src/main/java/org/microg/gms/maps/MapsConstants.java new file mode 100644 index 00000000..b54649e0 --- /dev/null +++ b/play-services-api/src/main/java/org/microg/gms/maps/MapsConstants.java @@ -0,0 +1,40 @@ +/* + * Copyright 2013-2016 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.maps; + +public class MapsConstants { + /** + * No base map tiles. + */ + public static final int MAP_TYPE_NONE = 0; + /** + * Basic maps. + */ + public static final int MAP_TYPE_NORMAL = 1; + /** + * Satellite maps with no labels. + */ + public static final int MAP_TYPE_SATELLITE = 2; + /** + * Terrain maps. + */ + public static final int MAP_TYPE_TERRAIN = 3; + /** + * Satellite maps with a transparent layer of major streets. + */ + public static final int MAP_TYPE_HYBRID = 4; +}