|
@@ -1,10 +1,13 @@
|
|
|
package com.vpn.fastestvpnservice.retrofit;
|
|
|
|
|
|
+import android.content.pm.PackageInfo;
|
|
|
+
|
|
|
import com.stealthcopter.networktools.Ping;
|
|
|
import de.blinkt.openvpn.core.App;
|
|
|
import com.vpn.fastestvpnservice.constants.AppConstant;
|
|
|
import com.vpn.fastestvpnservice.helpers.BasePreferenceHelper;
|
|
|
import com.vpn.fastestvpnservice.retrofit.entities.GsonFactory;
|
|
|
+import com.vpn.fastestvpnservice.utils.StaticMethods;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
@@ -25,6 +28,8 @@ public class WebServiceFactory {
|
|
|
private static final String X_PLATFORM = "X-PLATFORM";
|
|
|
private static final String X_PLATFORM_TOKEN = "X-PLATFORM-TOKEN";
|
|
|
private static final String X_LOCALE = "Content-Language";
|
|
|
+ private static final String X_APPLICATION_BUILD_NUMBER = "X-Application-Build-Number";
|
|
|
+ private static final String X_PLATFORM_BUILD_NUMBER = "X-PLATFORM-Build-Number";
|
|
|
private static final String PLATFORM = "platform";
|
|
|
private static final String VERSION = "version";
|
|
|
|
|
@@ -38,9 +43,22 @@ public class WebServiceFactory {
|
|
|
httpClient.connectTimeout(120, TimeUnit.SECONDS);
|
|
|
httpClient.readTimeout(120, TimeUnit.SECONDS);
|
|
|
|
|
|
+ boolean isTV = StaticMethods.isTV(App.getContext().getApplicationContext());
|
|
|
+ String platform = "";
|
|
|
+ if (isTV) { platform = "TV"; } else { platform = "android"; }
|
|
|
+ String finalPlatform = platform;
|
|
|
+
|
|
|
+ String versionName = "";
|
|
|
+ try {
|
|
|
+ PackageInfo pInfo = App.getContext().getApplicationContext().getPackageManager().getPackageInfo(App.getContext().getApplicationContext().getPackageName(), 0);
|
|
|
+ versionName = pInfo.versionName;
|
|
|
+ } catch (Exception ex) {}
|
|
|
+
|
|
|
+ String finalVersionName = versionName;
|
|
|
+ String osVersion = android.os.Build.VERSION.RELEASE;
|
|
|
+
|
|
|
if (instance == null) {
|
|
|
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
|
|
- // TODO uncomment_this_JC
|
|
|
// if (BuildConfig.DEBUG) {
|
|
|
// logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
|
|
// }
|
|
@@ -53,10 +71,12 @@ public class WebServiceFactory {
|
|
|
Request.Builder requestBuilder;
|
|
|
prefHelper.getXPlatformToken();
|
|
|
requestBuilder = original.newBuilder()
|
|
|
- .header(X_PLATFORM, "android")
|
|
|
+ .header(X_PLATFORM, finalPlatform)
|
|
|
.header(KEY_HEADER_AUTHORIZATION, (prefHelper.getUser() != null) ? "Bearer " + prefHelper.getUser().getToken() : "")
|
|
|
.header(X_PLATFORM_TOKEN, prefHelper.getXPlatformToken())
|
|
|
- .header(X_LOCALE, prefHelper.getLanguage());
|
|
|
+ .header(X_LOCALE, prefHelper.getLanguage())
|
|
|
+ .header(X_APPLICATION_BUILD_NUMBER, finalVersionName)
|
|
|
+ .header(X_PLATFORM_BUILD_NUMBER, osVersion);
|
|
|
|
|
|
return chain.proceed(requestBuilder.build());
|
|
|
}
|