diff --git a/play-services-core/src/main/AndroidManifest.xml b/play-services-core/src/main/AndroidManifest.xml
index 4d2fdac9..1fc3dff0 100644
--- a/play-services-core/src/main/AndroidManifest.xml
+++ b/play-services-core/src/main/AndroidManifest.xml
@@ -12,56 +12,69 @@
~ 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.
- -->
-
+-->
+ android:versionCode="6772000"
+ android:versionName="1.0">
-
+
+ android:protectionLevel="dangerous"
+ android:label="@string/perm_c2dm_send_label" />
-
+
+ android:protectionLevel="dangerous"
+ android:description="@string/permission_service_local_description"
+ android:label="@string/permission_service_local_label" />
+ android:protectionLevel="dangerous"
+ android:description="@string/permission_service_mail_description"
+ android:label="@string/permission_service_mail_label" />
+ android:protectionLevel="dangerous"
+ android:description="@string/permission_service_writely_description"
+ android:label="@string/permission_service_writely_label" />
+
+
-
-
-
-
+
+
+
+ android:icon="@drawable/ic_microg_app"
+ android:label="@string/gms_app_name">
@@ -76,10 +89,6 @@
-
@@ -93,13 +102,13 @@
+ android:authorities="com.google.android.gsf.gservices"
+ android:exported="true" />
+ android:authorities="com.google.settings"
+ android:exported="true" />
+
+
@@ -136,29 +147,38 @@
android:permission="com.google.android.c2dm.permission.RECEIVE">
+
+
-
+
+
+
+
+
+
+
+ android:name="org.microg.gms.droidguard.DroidGuardService"
+ android:exported="true">
+
@@ -170,6 +190,7 @@
android:exported="true">
+
@@ -206,36 +227,39 @@
+ android:excludeFromRecents="true"
+ android:exported="true">
+
+ android:exported="true"
+ android:theme="@style/LoginBlueTheme">
+
+ android:theme="@style/Theme.AppCompat.Light.Dialog" />
+
@@ -245,6 +269,7 @@
android:exported="true">
+
@@ -280,5 +305,10 @@
+
+
+
diff --git a/play-services-core/src/main/java/org/microg/gms/checkin/TriggerReceiver.java b/play-services-core/src/main/java/org/microg/gms/checkin/TriggerReceiver.java
index 72265dc0..0c75a57a 100644
--- a/play-services-core/src/main/java/org/microg/gms/checkin/TriggerReceiver.java
+++ b/play-services-core/src/main/java/org/microg/gms/checkin/TriggerReceiver.java
@@ -27,6 +27,7 @@ public class TriggerReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "Trigger checkin: " + intent);
+
Intent subIntent = new Intent(context, CheckinService.class);
if ("android.provider.Telephony.SECRET_CODE".equals(intent.getAction())) {
subIntent.putExtra("force", true);
diff --git a/play-services-core/src/main/java/org/microg/gms/gcm/mcs/Constants.java b/play-services-core/src/main/java/org/microg/gms/gcm/Constants.java
similarity index 97%
rename from play-services-core/src/main/java/org/microg/gms/gcm/mcs/Constants.java
rename to play-services-core/src/main/java/org/microg/gms/gcm/Constants.java
index 4b3ac468..ea06c337 100644
--- a/play-services-core/src/main/java/org/microg/gms/gcm/mcs/Constants.java
+++ b/play-services-core/src/main/java/org/microg/gms/gcm/Constants.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.microg.gms.gcm.mcs;
+package org.microg.gms.gcm;
public class Constants {
public static final int MCS_HEARTBEAT_PING_TAG = 0;
diff --git a/play-services-core/src/main/java/org/microg/gms/gcm/mcs/McsInputStream.java b/play-services-core/src/main/java/org/microg/gms/gcm/McsInputStream.java
similarity index 82%
rename from play-services-core/src/main/java/org/microg/gms/gcm/mcs/McsInputStream.java
rename to play-services-core/src/main/java/org/microg/gms/gcm/McsInputStream.java
index 6b62d5f9..7b4b9224 100644
--- a/play-services-core/src/main/java/org/microg/gms/gcm/mcs/McsInputStream.java
+++ b/play-services-core/src/main/java/org/microg/gms/gcm/McsInputStream.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.microg.gms.gcm.mcs;
+package org.microg.gms.gcm;
import android.util.Base64;
import android.util.Log;
@@ -22,16 +22,24 @@ import android.util.Log;
import com.squareup.wire.Message;
import com.squareup.wire.Wire;
+import org.microg.gms.gcm.mcs.Close;
+import org.microg.gms.gcm.mcs.DataMessageStanza;
+import org.microg.gms.gcm.mcs.HeartbeatAck;
+import org.microg.gms.gcm.mcs.HeartbeatPing;
+import org.microg.gms.gcm.mcs.IqStanza;
+import org.microg.gms.gcm.mcs.LoginRequest;
+import org.microg.gms.gcm.mcs.LoginResponse;
+
import java.io.IOException;
import java.io.InputStream;
-import static org.microg.gms.gcm.mcs.Constants.MCS_CLOSE_TAG;
-import static org.microg.gms.gcm.mcs.Constants.MCS_DATA_MESSAGE_STANZA_TAG;
-import static org.microg.gms.gcm.mcs.Constants.MCS_HEARTBEAT_ACK_TAG;
-import static org.microg.gms.gcm.mcs.Constants.MCS_HEARTBEAT_PING_TAG;
-import static org.microg.gms.gcm.mcs.Constants.MCS_IQ_STANZA_TAG;
-import static org.microg.gms.gcm.mcs.Constants.MCS_LOGIN_REQUEST_TAG;
-import static org.microg.gms.gcm.mcs.Constants.MCS_LOGIN_RESPONSE_TAG;
+import static org.microg.gms.gcm.Constants.MCS_CLOSE_TAG;
+import static org.microg.gms.gcm.Constants.MCS_DATA_MESSAGE_STANZA_TAG;
+import static org.microg.gms.gcm.Constants.MCS_HEARTBEAT_ACK_TAG;
+import static org.microg.gms.gcm.Constants.MCS_HEARTBEAT_PING_TAG;
+import static org.microg.gms.gcm.Constants.MCS_IQ_STANZA_TAG;
+import static org.microg.gms.gcm.Constants.MCS_LOGIN_REQUEST_TAG;
+import static org.microg.gms.gcm.Constants.MCS_LOGIN_RESPONSE_TAG;
public class McsInputStream {
private static final String TAG = "GmsGcmMcsInput";
diff --git a/play-services-core/src/main/java/org/microg/gms/gcm/McsMessage.java b/play-services-core/src/main/java/org/microg/gms/gcm/McsMessage.java
new file mode 100644
index 00000000..03e2c0d1
--- /dev/null
+++ b/play-services-core/src/main/java/org/microg/gms/gcm/McsMessage.java
@@ -0,0 +1,4 @@
+package org.microg.gms.gcm;
+
+public class McsMessage {
+}
diff --git a/play-services-core/src/main/java/org/microg/gms/gcm/mcs/McsOutputStream.java b/play-services-core/src/main/java/org/microg/gms/gcm/McsOutputStream.java
similarity index 90%
rename from play-services-core/src/main/java/org/microg/gms/gcm/mcs/McsOutputStream.java
rename to play-services-core/src/main/java/org/microg/gms/gcm/McsOutputStream.java
index 68202aae..99992611 100644
--- a/play-services-core/src/main/java/org/microg/gms/gcm/mcs/McsOutputStream.java
+++ b/play-services-core/src/main/java/org/microg/gms/gcm/McsOutputStream.java
@@ -14,16 +14,21 @@
* limitations under the License.
*/
-package org.microg.gms.gcm.mcs;
+package org.microg.gms.gcm;
import android.util.Log;
import com.squareup.wire.Message;
+import org.microg.gms.gcm.mcs.DataMessageStanza;
+import org.microg.gms.gcm.mcs.HeartbeatAck;
+import org.microg.gms.gcm.mcs.HeartbeatPing;
+import org.microg.gms.gcm.mcs.LoginRequest;
+
import java.io.IOException;
import java.io.OutputStream;
-import static org.microg.gms.gcm.mcs.Constants.*;
+import static org.microg.gms.gcm.Constants.*;
public class McsOutputStream {
private static final String TAG = "GmsGcmMcsOutput";
diff --git a/play-services-core/src/main/java/org/microg/gms/gcm/mcs/McsService.java b/play-services-core/src/main/java/org/microg/gms/gcm/McsService.java
similarity index 93%
rename from play-services-core/src/main/java/org/microg/gms/gcm/mcs/McsService.java
rename to play-services-core/src/main/java/org/microg/gms/gcm/McsService.java
index e8379c71..d5e93117 100644
--- a/play-services-core/src/main/java/org/microg/gms/gcm/mcs/McsService.java
+++ b/play-services-core/src/main/java/org/microg/gms/gcm/McsService.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.microg.gms.gcm.mcs;
+package org.microg.gms.gcm;
import android.app.IntentService;
import android.content.Context;
@@ -25,6 +25,14 @@ import android.util.Log;
import com.squareup.wire.Message;
import org.microg.gms.checkin.LastCheckinInfo;
+import org.microg.gms.gcm.mcs.AppData;
+import org.microg.gms.gcm.mcs.Close;
+import org.microg.gms.gcm.mcs.DataMessageStanza;
+import org.microg.gms.gcm.mcs.HeartbeatAck;
+import org.microg.gms.gcm.mcs.HeartbeatPing;
+import org.microg.gms.gcm.mcs.LoginRequest;
+import org.microg.gms.gcm.mcs.LoginResponse;
+import org.microg.gms.gcm.mcs.Setting;
import java.io.IOException;
import java.net.Socket;
@@ -38,18 +46,20 @@ import static android.os.Build.VERSION.SDK_INT;
public class McsService extends IntentService {
private static final String TAG = "GmsGcmMcsSvc";
+
public static final String PREFERENCES_NAME = "mcs";
+ public static final String PREF_LAST_PERSISTENT_ID = "last_persistent_id";
public static final String SERVICE_HOST = "mtalk.google.com";
public static final int SERVICE_PORT = 5228;
- public static final String PREF_LAST_PERSISTENT_ID = "last_persistent_id";
+
public static final String SELF_CATEGORY = "com.google.android.gsf.gtalkservice";
public static final String IDLE_NOTIFICATION = "IdleNotification";
public static final String FROM_FIELD = "gcm@android.com";
+
public static final int HEARTBEAT_MS = 60000;
private static AtomicBoolean connected = new AtomicBoolean(false);
- private Socket socket;
private Socket sslSocket;
private McsInputStream inputStream;
private McsOutputStream outputStream;
@@ -76,6 +86,10 @@ public class McsService extends IntentService {
}
}
+ public static boolean isConnected() {
+ return connected.get();
+ }
+
private void heartbeatLoop() {
try {
while (!Thread.interrupted()) {
@@ -112,7 +126,7 @@ public class McsService extends IntentService {
try {
Log.d(TAG, "Starting MCS connection...");
LastCheckinInfo info = LastCheckinInfo.read(this);
- socket = new Socket(SERVICE_HOST, SERVICE_PORT);
+ Socket socket = new Socket(SERVICE_HOST, SERVICE_PORT);
Log.d(TAG, "Connected to " + SERVICE_HOST + ":" + SERVICE_PORT);
sslSocket = SSLContext.getDefault().getSocketFactory().createSocket(socket, "mtalk.google.com", 5228, true);
Log.d(TAG, "Activated SSL with " + SERVICE_HOST + ":" + SERVICE_PORT);
@@ -121,8 +135,7 @@ public class McsService extends IntentService {
LoginRequest loginRequest = buildLoginRequest(info);
Log.d(TAG, "Sending login request...");
outputStream.write(loginRequest);
- boolean close = false;
- while (!close) {
+ while (!Thread.interrupted()) {
Message o = inputStream.read();
lastMsgTime = System.currentTimeMillis();
if (o instanceof DataMessageStanza) {
@@ -211,7 +224,7 @@ public class McsService extends IntentService {
.resource(Long.toString(info.androidId))
.user(Long.toString(info.androidId))
.use_rmq2(true)
- .setting(Arrays.asList(new Setting("new_vc", "1")))
+ .setting(Collections.singletonList(new Setting("new_vc", "1")))
.received_persistent_id(Arrays.asList(getSharedPreferences().getString(PREF_LAST_PERSISTENT_ID, "").split("\\|")))
.build();
}
diff --git a/play-services-core/src/main/java/org/microg/gms/gcm/TriggerReceiver.java b/play-services-core/src/main/java/org/microg/gms/gcm/TriggerReceiver.java
new file mode 100644
index 00000000..ba1565f9
--- /dev/null
+++ b/play-services-core/src/main/java/org/microg/gms/gcm/TriggerReceiver.java
@@ -0,0 +1,36 @@
+/*
+ * 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 org.microg.gms.gcm;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.preference.PreferenceManager;
+
+public class TriggerReceiver extends BroadcastReceiver {
+ private static final String PREF_ENABLE_GCM = "gcm_enable_mcs_service";
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ boolean force = "android.provider.Telephony.SECRET_CODE".equals(intent.getAction());
+ if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean(PREF_ENABLE_GCM, false) || force) {
+ if (!McsService.isConnected() || force) {
+ context.startService(new Intent(context, McsService.class));
+ }
+ }
+ }
+}
diff --git a/play-services-core/src/main/java/org/microg/gms/gcm/mcs/McsMessage.java b/play-services-core/src/main/java/org/microg/gms/gcm/mcs/McsMessage.java
deleted file mode 100644
index bb326afa..00000000
--- a/play-services-core/src/main/java/org/microg/gms/gcm/mcs/McsMessage.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package org.microg.gms.gcm.mcs;
-
-public class McsMessage {
-}
diff --git a/play-services-core/src/main/java/org/microg/gms/maps/markup/InfoWindow.java b/play-services-core/src/main/java/org/microg/gms/maps/markup/InfoWindow.java
index 459b00ba..0b759ab2 100644
--- a/play-services-core/src/main/java/org/microg/gms/maps/markup/InfoWindow.java
+++ b/play-services-core/src/main/java/org/microg/gms/maps/markup/InfoWindow.java
@@ -133,6 +133,7 @@ public class InfoWindow {
*/
private class DefaultWindow extends FrameLayout {
+ @SuppressWarnings("deprecation")
public DefaultWindow(View view) {
super(context);
addView(view);
diff --git a/play-services-core/src/main/res/values/strings.xml b/play-services-core/src/main/res/values/strings.xml
index 3cbc3fc0..06cb7976 100644
--- a/play-services-core/src/main/res/values/strings.xml
+++ b/play-services-core/src/main/res/values/strings.xml
@@ -25,4 +25,8 @@
µg Google Account Manager
Allow
Deny
+
+ listen to internal status broadcasts
+ listen to C2DM messages
+ send C2DM messages to other apps