From f88a6d0cde9c338b06800dd119f415771647579c Mon Sep 17 00:00:00 2001 From: mar-v-in Date: Sat, 28 Feb 2015 20:56:05 +0100 Subject: [PATCH] Checkin can be used ... but resulting android id is probably unusable as it's not providing features :) --- AndroidManifest.xml | 18 +++++++++++ src/org/microg/gms/checkin/CheckinClient.java | 13 +++++--- .../microg/gms/checkin/CheckinManager.java | 5 ++- .../microg/gms/checkin/CheckinService.java | 16 ++++------ .../microg/gms/checkin/TriggerReceiver.java | 32 +++++++++++++++++++ 5 files changed, 70 insertions(+), 14 deletions(-) create mode 100644 src/org/microg/gms/checkin/TriggerReceiver.java diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 1781f833..fccd82d3 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -84,6 +84,24 @@ + + + + + + + + + + + + + + + + ) TODO) .serial((String) TODO) @@ -138,7 +136,14 @@ public class CheckinClient { .userName((String) TODO) .userSerialNumber((Integer) TODO) .version(3); - if (checkinInfo.securityToken != 0) builder.securityToken(checkinInfo.securityToken); + if (deviceIdent.wifiMac != null) { + builder.macAddress(Arrays.asList(deviceIdent.wifiMac)) + .macAddressType(Arrays.asList("wifi")); + } + if (checkinInfo.securityToken != 0) { + builder.securityToken(checkinInfo.securityToken) + .fragment(1); + } return builder.build(); } diff --git a/src/org/microg/gms/checkin/CheckinManager.java b/src/org/microg/gms/checkin/CheckinManager.java index 6c38646e..4fed159d 100644 --- a/src/org/microg/gms/checkin/CheckinManager.java +++ b/src/org/microg/gms/checkin/CheckinManager.java @@ -19,6 +19,9 @@ package org.microg.gms.checkin; import android.content.ContentResolver; import android.content.Context; +import org.microg.gms.common.DeviceConfiguration; +import org.microg.gms.common.DeviceIdentifier; +import org.microg.gms.common.PhoneInfo; import org.microg.gms.common.Utils; import org.microg.gms.gservices.GServices; @@ -30,7 +33,7 @@ public class CheckinManager { public static synchronized LastCheckinInfo checkin(Context context) throws IOException { LastCheckinInfo info = LastCheckinInfo.read(context); if (info.lastCheckin > System.currentTimeMillis() - MIN_CHECKIN_INTERVAL) return null; - CheckinRequest request = CheckinClient.makeRequest(Utils.getBuild(context), null, null, null, info); // TODO + CheckinRequest request = CheckinClient.makeRequest(Utils.getBuild(context), new DeviceConfiguration(), new DeviceIdentifier(), new PhoneInfo(), info); // TODO return handleResponse(context, CheckinClient.request(request)); } diff --git a/src/org/microg/gms/checkin/CheckinService.java b/src/org/microg/gms/checkin/CheckinService.java index 95d17d34..2b0a0426 100644 --- a/src/org/microg/gms/checkin/CheckinService.java +++ b/src/org/microg/gms/checkin/CheckinService.java @@ -24,7 +24,6 @@ import java.io.IOException; public class CheckinService extends IntentService { private static final String TAG = "GmsCheckinService"; - public static final String CHECKIN_ACTION = "com.google.android.gsf.checkin.CHECKIN"; public CheckinService() { super(TAG); @@ -32,15 +31,14 @@ public class CheckinService extends IntentService { @Override protected void onHandleIntent(Intent intent) { - if (CHECKIN_ACTION.equals(intent.getAction())) { - try { - LastCheckinInfo info = CheckinManager.checkin(this); - if (info != null) { - Log.d(TAG, "Checked in as " + Long.toHexString(info.androidId)); - } - } catch (IOException e) { - Log.w(TAG, e); + try { + LastCheckinInfo info = CheckinManager.checkin(this); + if (info != null) { + Log.d(TAG, "Checked in as " + Long.toHexString(info.androidId)); } + } catch (Exception e) { + Log.w(TAG, e); } + stopSelf(); } } diff --git a/src/org/microg/gms/checkin/TriggerReceiver.java b/src/org/microg/gms/checkin/TriggerReceiver.java new file mode 100644 index 00000000..363c6aea --- /dev/null +++ b/src/org/microg/gms/checkin/TriggerReceiver.java @@ -0,0 +1,32 @@ +/* + * 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.checkin; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.util.Log; + +public class TriggerReceiver extends BroadcastReceiver { + private static final String TAG = "GmsCheckinTrigger"; + + @Override + public void onReceive(Context context, Intent intent) { + Log.d(TAG, "Trigger checkin: " + intent); + context.startService(new Intent(context, CheckinService.class)); + } +}