MCS: Fix reconnect

This commit is contained in:
mar-v-in 2015-04-04 00:21:47 +02:00
parent 7b3e490d55
commit 39c957cda8
2 changed files with 23 additions and 5 deletions

View File

@ -86,6 +86,7 @@
<action android:name="com.google.android.location.internal.GoogleLocationManagerService.START" />
</intent-filter>
</service>
<service android:name="org.microg.gms.location.ReportingAndroidService">
<intent-filter>
<action android:name="com.google.android.location.reporting.service.START" />
@ -101,10 +102,12 @@
android:name="org.microg.gms.gservices.GServicesProvider"
android:authorities="com.google.android.gsf.gservices"
android:exported="true" />
<provider
android:name="org.microg.gms.settings.GoogleSettingsProvider"
android:authorities="com.google.settings"
android:exported="true" />
<provider
android:name="org.microg.gms.feeds.SubscribedFeedsProvider"
android:authorities="subscribedfeeds"
@ -151,6 +154,7 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</service>
<service
android:name="org.microg.gms.gcm.McsService"
android:exported="true" />
@ -159,6 +163,18 @@
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
<intent-filter>
<action android:name="org.microg.gms.gcm.RECONNECT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<data
android:scheme="package"
android:path="com.google.android.gms" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
</intent-filter>
<intent-filter>
<action android:name="android.provider.Telephony.SECRET_CODE" />
@ -232,6 +248,7 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="org.microg.gms.auth.login.LoginActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
@ -243,6 +260,7 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="org.microg.gms.auth.AskPermissionActivity"
android:excludeFromRecents="true"

View File

@ -20,6 +20,7 @@ import android.app.IntentService;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.text.TextUtils;
import android.util.Log;
import com.squareup.wire.Message;
@ -163,6 +164,7 @@ public class McsService extends IntentService {
heartbeatThread = null;
}
Log.d(TAG, "Connection closed");
sendBroadcast(new Intent("org.microg.gms.gcm.RECONNECT"), "org.microg.gms.STATUS_BROADCAST");
}
private void handleClose(Close close) throws IOException {
@ -170,7 +172,7 @@ public class McsService extends IntentService {
}
private void handleLoginresponse(LoginResponse loginResponse) throws IOException {
getSharedPreferences().edit().putString(PREF_LAST_PERSISTENT_ID, null);
getSharedPreferences().edit().putString(PREF_LAST_PERSISTENT_ID, "").apply();
if (loginResponse.error == null) {
Log.d(TAG, "Logged in");
} else {
@ -189,10 +191,8 @@ public class McsService extends IntentService {
private void handleMessage(DataMessageStanza message) throws IOException {
if (message.persistent_id != null) {
String old = getSharedPreferences().getString(PREF_LAST_PERSISTENT_ID, null);
if (old == null) {
old = "";
} else {
String old = getSharedPreferences().getString(PREF_LAST_PERSISTENT_ID, "");
if (!old.isEmpty()) {
old += "|";
}
getSharedPreferences().edit()