Loading play-services-core/src/main/java/org/microg/gms/common/HttpFormClient.java +19 −3 Original line number Diff line number Diff line Loading @@ -46,6 +46,13 @@ public class HttpFormClient { try { field.setAccessible(true); Object objVal = field.get(request); if (field.isAnnotationPresent(RequestContentDynamic.class)) { Map<String, String> contentParams = (Map<String, String>) objVal; for (Map.Entry<String, String> param : contentParams.entrySet()) { appendParam(content, param.getKey(), param.getValue()); } continue; } String value = objVal != null ? String.valueOf(objVal) : null; Boolean boolVal = null; if (field.getType().equals(boolean.class)) { Loading @@ -65,9 +72,7 @@ public class HttpFormClient { value = valueFromBoolVal(value, boolVal, annotation.truePresent(), annotation.falsePresent()); if (value != null || annotation.nullPresent()) { for (String key : annotation.value()) { if (content.length() > 0) content.append("&"); content.append(Uri.encode(key)).append("=").append(Uri.encode(String.valueOf(value))); appendParam(content, key, value); } } } Loading Loading @@ -109,6 +114,12 @@ public class HttpFormClient { } } private static void appendParam(StringBuilder content, String key, String value) { if (content.length() > 0) content.append("&"); content.append(Uri.encode(key)).append("=").append(Uri.encode(String.valueOf(value))); } private static <T> T parseResponse(Class<T> tClass, HttpURLConnection connection, String result) throws IOException { Map<String, List<String>> headerFields = connection.getHeaderFields(); T response; Loading Loading @@ -233,6 +244,11 @@ public class HttpFormClient { public String value(); } @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface RequestContentDynamic { } @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface ResponseHeader { Loading play-services-core/src/main/java/org/microg/gms/common/PackageUtils.java +8 −0 Original line number Diff line number Diff line Loading @@ -258,4 +258,12 @@ public class PackageUtils { return null; } } public static int targetSdkVersion(Context context, String packageName) { try { return context.getPackageManager().getApplicationInfo(packageName, 0).targetSdkVersion; } catch (PackageManager.NameNotFoundException e) { return -1; } } } play-services-core/src/main/java/org/microg/gms/gcm/PushRegisterHandler.java +1 −1 Original line number Diff line number Diff line Loading @@ -145,7 +145,7 @@ class PushRegisterHandler extends Handler { .checkin(LastCheckinInfo.read(context)) .app(packageName) .delete(delete) .appid(subdata.getString("appid"), subdata.getString("gmp_app_id")), .extraParams(subdata), bundle -> sendReply(what, id, replyTo, bundle)); } } play-services-core/src/main/java/org/microg/gms/gcm/PushRegisterManager.java +8 −4 Original line number Diff line number Diff line Loading @@ -70,12 +70,16 @@ public class PushRegisterManager { public static void completeRegisterRequest(Context context, GcmDatabase database, String requestId, RegisterRequest request, BundleCallback callback) { if (request.app != null) { if (request.appSignature == null) request.appSignature = PackageUtils.firstSignatureDigest(context, request.app); if (request.appVersion <= 0) request.appVersion = PackageUtils.versionCode(context, request.app); if (request.appVersionName == null) request.appVersionName = PackageUtils.versionName(context, request.app); if (!request.delete) { if (request.appSignature == null) { request.appSignature = PackageUtils.firstSignatureDigest(context, request.app); } request.sdkVersion = PackageUtils.targetSdkVersion(context, request.app); if (!request.hasExtraParam(GcmConstants.EXTRA_APP_VERSION_NAME)) request.extraParam(GcmConstants.EXTRA_APP_VERSION_NAME, PackageUtils.versionName(context, request.app)); } } GcmDatabase.App app = database.getApp(request.app); Loading play-services-core/src/main/java/org/microg/gms/gcm/PushRegisterService.java +4 −3 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import android.app.IntentService; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.os.IBinder; import android.os.Message; Loading Loading @@ -139,7 +138,8 @@ public class PushRegisterService extends IntentService { .build(Utils.getBuild(context)) .sender(intent.getStringExtra(EXTRA_SENDER)) .checkin(LastCheckinInfo.read(context)) .app(packageName), .app(packageName) .extraParams(intent.getExtras()), bundle -> { Intent outIntent = new Intent(ACTION_C2DM_REGISTRATION); outIntent.putExtras(bundle); Loading Loading @@ -175,7 +175,8 @@ public class PushRegisterService extends IntentService { .build(Utils.getBuild(this)) .sender(intent.getStringExtra(EXTRA_SENDER)) .checkin(LastCheckinInfo.read(this)) .app(packageName), .app(packageName) .extraParams(intent.getExtras()), bundle -> { Intent outIntent = new Intent(ACTION_C2DM_REGISTRATION); outIntent.putExtras(bundle); Loading Loading
play-services-core/src/main/java/org/microg/gms/common/HttpFormClient.java +19 −3 Original line number Diff line number Diff line Loading @@ -46,6 +46,13 @@ public class HttpFormClient { try { field.setAccessible(true); Object objVal = field.get(request); if (field.isAnnotationPresent(RequestContentDynamic.class)) { Map<String, String> contentParams = (Map<String, String>) objVal; for (Map.Entry<String, String> param : contentParams.entrySet()) { appendParam(content, param.getKey(), param.getValue()); } continue; } String value = objVal != null ? String.valueOf(objVal) : null; Boolean boolVal = null; if (field.getType().equals(boolean.class)) { Loading @@ -65,9 +72,7 @@ public class HttpFormClient { value = valueFromBoolVal(value, boolVal, annotation.truePresent(), annotation.falsePresent()); if (value != null || annotation.nullPresent()) { for (String key : annotation.value()) { if (content.length() > 0) content.append("&"); content.append(Uri.encode(key)).append("=").append(Uri.encode(String.valueOf(value))); appendParam(content, key, value); } } } Loading Loading @@ -109,6 +114,12 @@ public class HttpFormClient { } } private static void appendParam(StringBuilder content, String key, String value) { if (content.length() > 0) content.append("&"); content.append(Uri.encode(key)).append("=").append(Uri.encode(String.valueOf(value))); } private static <T> T parseResponse(Class<T> tClass, HttpURLConnection connection, String result) throws IOException { Map<String, List<String>> headerFields = connection.getHeaderFields(); T response; Loading Loading @@ -233,6 +244,11 @@ public class HttpFormClient { public String value(); } @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface RequestContentDynamic { } @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface ResponseHeader { Loading
play-services-core/src/main/java/org/microg/gms/common/PackageUtils.java +8 −0 Original line number Diff line number Diff line Loading @@ -258,4 +258,12 @@ public class PackageUtils { return null; } } public static int targetSdkVersion(Context context, String packageName) { try { return context.getPackageManager().getApplicationInfo(packageName, 0).targetSdkVersion; } catch (PackageManager.NameNotFoundException e) { return -1; } } }
play-services-core/src/main/java/org/microg/gms/gcm/PushRegisterHandler.java +1 −1 Original line number Diff line number Diff line Loading @@ -145,7 +145,7 @@ class PushRegisterHandler extends Handler { .checkin(LastCheckinInfo.read(context)) .app(packageName) .delete(delete) .appid(subdata.getString("appid"), subdata.getString("gmp_app_id")), .extraParams(subdata), bundle -> sendReply(what, id, replyTo, bundle)); } }
play-services-core/src/main/java/org/microg/gms/gcm/PushRegisterManager.java +8 −4 Original line number Diff line number Diff line Loading @@ -70,12 +70,16 @@ public class PushRegisterManager { public static void completeRegisterRequest(Context context, GcmDatabase database, String requestId, RegisterRequest request, BundleCallback callback) { if (request.app != null) { if (request.appSignature == null) request.appSignature = PackageUtils.firstSignatureDigest(context, request.app); if (request.appVersion <= 0) request.appVersion = PackageUtils.versionCode(context, request.app); if (request.appVersionName == null) request.appVersionName = PackageUtils.versionName(context, request.app); if (!request.delete) { if (request.appSignature == null) { request.appSignature = PackageUtils.firstSignatureDigest(context, request.app); } request.sdkVersion = PackageUtils.targetSdkVersion(context, request.app); if (!request.hasExtraParam(GcmConstants.EXTRA_APP_VERSION_NAME)) request.extraParam(GcmConstants.EXTRA_APP_VERSION_NAME, PackageUtils.versionName(context, request.app)); } } GcmDatabase.App app = database.getApp(request.app); Loading
play-services-core/src/main/java/org/microg/gms/gcm/PushRegisterService.java +4 −3 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import android.app.IntentService; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.os.IBinder; import android.os.Message; Loading Loading @@ -139,7 +138,8 @@ public class PushRegisterService extends IntentService { .build(Utils.getBuild(context)) .sender(intent.getStringExtra(EXTRA_SENDER)) .checkin(LastCheckinInfo.read(context)) .app(packageName), .app(packageName) .extraParams(intent.getExtras()), bundle -> { Intent outIntent = new Intent(ACTION_C2DM_REGISTRATION); outIntent.putExtras(bundle); Loading Loading @@ -175,7 +175,8 @@ public class PushRegisterService extends IntentService { .build(Utils.getBuild(this)) .sender(intent.getStringExtra(EXTRA_SENDER)) .checkin(LastCheckinInfo.read(this)) .app(packageName), .app(packageName) .extraParams(intent.getExtras()), bundle -> { Intent outIntent = new Intent(ACTION_C2DM_REGISTRATION); outIntent.putExtras(bundle); Loading