mirror of
https://github.com/whyorean/AuroraStore.git
synced 2026-06-19 13:08:59 -04:00
Downloads : Fix app purchases
+ code cleanup & improvements
This commit is contained in:
@@ -26,7 +26,6 @@ package com.aurora.store.api;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.aurora.store.Constants;
|
||||
import com.aurora.store.adapter.OkHttpClientAdapter;
|
||||
@@ -36,12 +35,14 @@ import com.aurora.store.manager.SpoofManager;
|
||||
import com.aurora.store.model.LoginInfo;
|
||||
import com.aurora.store.provider.NativeDeviceInfoProvider;
|
||||
import com.aurora.store.utility.Accountant;
|
||||
import com.aurora.store.utility.Log;
|
||||
import com.aurora.store.utility.PrefUtil;
|
||||
import com.aurora.store.utility.Util;
|
||||
import com.dragons.aurora.playstoreapiv2.ApiBuilderException;
|
||||
import com.dragons.aurora.playstoreapiv2.AuthException;
|
||||
import com.dragons.aurora.playstoreapiv2.DeviceInfoProvider;
|
||||
import com.dragons.aurora.playstoreapiv2.GooglePlayAPI;
|
||||
import com.dragons.aurora.playstoreapiv2.PlayStoreApiBuilder;
|
||||
import com.dragons.aurora.playstoreapiv2.PropertiesDeviceInfoProvider;
|
||||
import com.dragons.aurora.playstoreapiv2.TokenDispenserException;
|
||||
|
||||
@@ -52,7 +53,7 @@ public class PlayStoreApiAuthenticator {
|
||||
|
||||
private static final int RETRIES = 5;
|
||||
private static final String tokenDispenserURL = "http://www.auroraoss.com:8080";
|
||||
private static GooglePlayAPI api;
|
||||
private volatile static GooglePlayAPI api;
|
||||
|
||||
private Context context;
|
||||
private SharedPreferences prefs;
|
||||
@@ -61,7 +62,7 @@ public class PlayStoreApiAuthenticator {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public GooglePlayAPI getApi() throws IOException {
|
||||
public synchronized GooglePlayAPI getApi() throws IOException {
|
||||
if (api == null) {
|
||||
api = buildFromPreferences();
|
||||
}
|
||||
@@ -150,7 +151,7 @@ public class PlayStoreApiAuthenticator {
|
||||
int tried = 0;
|
||||
while (tried < retries) {
|
||||
try {
|
||||
com.dragons.aurora.playstoreapiv2.PlayStoreApiBuilder builder = getBuilder(loginInfo);
|
||||
PlayStoreApiBuilder builder = getBuilder(loginInfo);
|
||||
GooglePlayAPI api = builder.build();
|
||||
loginInfo.setEmail(builder.getEmail());
|
||||
return api;
|
||||
@@ -170,15 +171,15 @@ public class PlayStoreApiAuthenticator {
|
||||
if (tried >= retries) {
|
||||
throw e;
|
||||
}
|
||||
Log.i(Constants.TAG, "Login retry : " + tried);
|
||||
Log.i("Login retry : " + tried);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private com.dragons.aurora.playstoreapiv2.PlayStoreApiBuilder getBuilder(LoginInfo loginInfo) {
|
||||
private PlayStoreApiBuilder getBuilder(LoginInfo loginInfo) {
|
||||
fill(loginInfo);
|
||||
return new com.dragons.aurora.playstoreapiv2.PlayStoreApiBuilder()
|
||||
return new PlayStoreApiBuilder()
|
||||
.setHttpClient(new OkHttpClientAdapter(context))
|
||||
.setDeviceInfoProvider(getDeviceInfoProvider())
|
||||
.setLocale(loginInfo.getLocale())
|
||||
@@ -208,7 +209,7 @@ public class PlayStoreApiAuthenticator {
|
||||
prefs = Util.getPrefs(context.getApplicationContext());
|
||||
String locale = prefs.getString(Constants.PREFERENCE_REQUESTED_LANGUAGE, "");
|
||||
loginInfo.setLocale(TextUtils.isEmpty(locale)
|
||||
? new LocaleManager(context).getLocale()
|
||||
? Locale.getDefault()
|
||||
: new Locale(locale));
|
||||
loginInfo.setGsfId(prefs.getString(Accountant.GSF_ID, ""));
|
||||
loginInfo.setToken(prefs.getString(Accountant.AUTH_TOKEN, ""));
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.opengl.GLES10;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -47,7 +48,7 @@ public class EglExtensionProvider {
|
||||
}
|
||||
EGLDisplay display = egl10.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
|
||||
egl10.eglInitialize(display, new int[2]);
|
||||
int cf[] = new int[1];
|
||||
int[] cf = new int[1];
|
||||
if (egl10.eglGetConfigs(display, null, 0, cf)) {
|
||||
EGLConfig[] configs = new EGLConfig[cf[0]];
|
||||
if (egl10.eglGetConfigs(display, configs, cf[0], cf)) {
|
||||
@@ -77,7 +78,7 @@ public class EglExtensionProvider {
|
||||
return sorted;
|
||||
}
|
||||
|
||||
private static void addExtensionsForConfig(EGL10 egl10, EGLDisplay egldisplay, EGLConfig eglconfig, int ai[], int ai1[], Set<String> set) {
|
||||
private static void addExtensionsForConfig(EGL10 egl10, EGLDisplay egldisplay, EGLConfig eglconfig, int[] ai, int[] ai1, Set<String> set) {
|
||||
EGLContext eglContext = egl10.eglCreateContext(egldisplay, eglconfig, EGL10.EGL_NO_CONTEXT, ai1);
|
||||
if (eglContext == EGL10.EGL_NO_CONTEXT) {
|
||||
return;
|
||||
@@ -89,11 +90,9 @@ public class EglExtensionProvider {
|
||||
egl10.eglMakeCurrent(egldisplay, eglSurface, eglSurface, eglContext);
|
||||
String s = GLES10.glGetString(7939);
|
||||
if (!TextUtils.isEmpty(s)) {
|
||||
String as[] = s.split(" ");
|
||||
String[] as = s.split(" ");
|
||||
int i = as.length;
|
||||
for (int j = 0; j < i; j++) {
|
||||
set.add(as[j]);
|
||||
}
|
||||
set.addAll(Arrays.asList(as).subList(0, i));
|
||||
}
|
||||
egl10.eglMakeCurrent(egldisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
|
||||
egl10.eglDestroySurface(egldisplay, eglSurface);
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.dragons.aurora.playstoreapiv2.AndroidCheckinRequest;
|
||||
import com.dragons.aurora.playstoreapiv2.DeviceConfigurationProto;
|
||||
import com.dragons.aurora.playstoreapiv2.DeviceInfoProvider;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -53,22 +54,11 @@ public class NativeDeviceInfoProvider implements DeviceInfoProvider {
|
||||
private String simOperator = "";
|
||||
private NativeGsfVersionProvider gsfVersionProvider;
|
||||
|
||||
static public List<String> getPlatforms() {
|
||||
List<String> platforms = new ArrayList<>();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
platforms = Arrays.asList(Build.SUPPORTED_ABIS);
|
||||
} else {
|
||||
if (!TextUtils.isEmpty(Build.CPU_ABI)) {
|
||||
platforms.add(Build.CPU_ABI);
|
||||
}
|
||||
if (!TextUtils.isEmpty(Build.CPU_ABI2)) {
|
||||
platforms.add(Build.CPU_ABI2);
|
||||
}
|
||||
}
|
||||
return platforms;
|
||||
private static List<String> getPlatforms() {
|
||||
return Arrays.asList(Build.SUPPORTED_ABIS);
|
||||
}
|
||||
|
||||
static public List<String> getFeatures(Context context) {
|
||||
static private List<String> getFeatures(Context context) {
|
||||
List<String> featureStringList = new ArrayList<>();
|
||||
for (FeatureInfo feature : context.getPackageManager().getSystemAvailableFeatures()) {
|
||||
if (!TextUtils.isEmpty(feature.name)) {
|
||||
@@ -79,7 +69,7 @@ public class NativeDeviceInfoProvider implements DeviceInfoProvider {
|
||||
return featureStringList;
|
||||
}
|
||||
|
||||
static public List<String> getLocales(Context context) {
|
||||
private static List<String> getLocales(Context context) {
|
||||
List<String> rawLocales = new ArrayList<>();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
rawLocales.addAll(Arrays.asList(context.getAssets().getLocales()));
|
||||
@@ -99,7 +89,7 @@ public class NativeDeviceInfoProvider implements DeviceInfoProvider {
|
||||
return locales;
|
||||
}
|
||||
|
||||
static public List<String> getSharedLibraries(Context context) {
|
||||
private static List<String> getSharedLibraries(Context context) {
|
||||
List<String> libraries = new ArrayList<>(Arrays.asList(context.getPackageManager().getSystemSharedLibraryNames()));
|
||||
Collections.sort(libraries);
|
||||
return libraries;
|
||||
@@ -136,35 +126,36 @@ public class NativeDeviceInfoProvider implements DeviceInfoProvider {
|
||||
}
|
||||
|
||||
public String getUserAgentString() {
|
||||
return "Android-Finsky/" + gsfVersionProvider.getVendingVersionString(true) +
|
||||
" (" + "api=3" +
|
||||
",versionCode=" + gsfVersionProvider.getVendingVersionCode(true) +
|
||||
",sdk=" + Build.VERSION.SDK_INT +
|
||||
",device=" + Build.DEVICE +
|
||||
",hardware=" + Build.HARDWARE +
|
||||
",product=" + Build.PRODUCT +
|
||||
",platformVersionRelease=" + Build.VERSION.RELEASE +
|
||||
",model=" + Build.MODEL +
|
||||
",buildId=" + Build.ID +
|
||||
",isWideScreen=" + (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? "1" : "0") +
|
||||
",supportedAbis=" + TextUtils.join(";", getPlatforms()) + ")";
|
||||
return "Android-Finsky/" + URLEncoder.encode(gsfVersionProvider.getVendingVersionString(true)).replace("+", "%20")
|
||||
+ " ("
|
||||
+ "api=3" + ","
|
||||
+ "versionCode=" + gsfVersionProvider.getVendingVersionCode(true) + ","
|
||||
+ "sdk=" + Build.VERSION.SDK_INT + ","
|
||||
+ "device=" + Build.DEVICE + ","
|
||||
+ "hardware=" + Build.HARDWARE + ","
|
||||
+ "product=" + Build.PRODUCT + ","
|
||||
+ "platformVersionRelease=" + Build.VERSION.RELEASE + ","
|
||||
+ "model=" + URLEncoder.encode(Build.MODEL).replace("+", "%20")
|
||||
+ "buildId=" + Build.ID + ","
|
||||
+ "isWideScreen=" + (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? "1" : "0") + ","
|
||||
+ "supportedAbis=" + TextUtils.join(";", getPlatforms())
|
||||
+ ")";
|
||||
}
|
||||
|
||||
public AndroidCheckinRequest generateAndroidCheckinRequest() {
|
||||
return AndroidCheckinRequest
|
||||
.newBuilder()
|
||||
.setId(0)
|
||||
.setCheckin(getCheckinProto())
|
||||
.setCheckin(getCheckInProto())
|
||||
.setLocale(this.localeString)
|
||||
.setTimeZone(TimeZone.getDefault().getID())
|
||||
.setVersion(3)
|
||||
.setDeviceConfiguration(getDeviceConfigurationProto())
|
||||
.setFragment(0)
|
||||
.build()
|
||||
;
|
||||
.build();
|
||||
}
|
||||
|
||||
private AndroidCheckinProto getCheckinProto() {
|
||||
private AndroidCheckinProto getCheckInProto() {
|
||||
return AndroidCheckinProto.newBuilder()
|
||||
.setBuild(getBuildProto())
|
||||
.setLastCheckinMsec(0)
|
||||
@@ -172,8 +163,7 @@ public class NativeDeviceInfoProvider implements DeviceInfoProvider {
|
||||
.setSimOperator(simOperator)
|
||||
.setRoaming("mobile-notroaming")
|
||||
.setUserNumber(0)
|
||||
.build()
|
||||
;
|
||||
.build();
|
||||
}
|
||||
|
||||
private AndroidBuildProto getBuildProto() {
|
||||
|
||||
@@ -27,14 +27,16 @@ import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
|
||||
import com.aurora.store.utility.Log;
|
||||
|
||||
public class NativeGsfVersionProvider {
|
||||
|
||||
static private final String GOOGLE_SERVICES_PACKAGE_ID = "com.google.android.gms";
|
||||
static private final String GOOGLE_VENDING_PACKAGE_ID = "com.android.vending";
|
||||
|
||||
static private final int GOOGLE_SERVICES_VERSION_CODE = 10548448;
|
||||
static private final int GOOGLE_VENDING_VERSION_CODE = 80798000;
|
||||
static private final String GOOGLE_VENDING_VERSION_STRING = "7.9.80";
|
||||
static private final int GOOGLE_SERVICES_VERSION_CODE = 16089037;
|
||||
static private final int GOOGLE_VENDING_VERSION_CODE = 81431900;
|
||||
static private final String GOOGLE_VENDING_VERSION_STRING = "14.3.19-all [0] [PR] 241809067";
|
||||
|
||||
private int gsfVersionCode = 0;
|
||||
private int vendingVersionCode = 0;
|
||||
@@ -47,9 +49,9 @@ public class NativeGsfVersionProvider {
|
||||
// com.google.android.gms not found
|
||||
}
|
||||
try {
|
||||
PackageInfo pi = context.getPackageManager().getPackageInfo(GOOGLE_VENDING_PACKAGE_ID, 0);
|
||||
vendingVersionCode = pi.versionCode;
|
||||
vendingVersionString = pi.versionName;
|
||||
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(GOOGLE_VENDING_PACKAGE_ID, 0);
|
||||
vendingVersionCode = packageInfo.versionCode;
|
||||
vendingVersionString = packageInfo.versionName;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
// com.android.vending not found
|
||||
}
|
||||
@@ -58,21 +60,18 @@ public class NativeGsfVersionProvider {
|
||||
public int getGsfVersionCode(boolean defaultIfNotFound) {
|
||||
return defaultIfNotFound && gsfVersionCode < GOOGLE_SERVICES_VERSION_CODE
|
||||
? GOOGLE_SERVICES_VERSION_CODE
|
||||
: gsfVersionCode
|
||||
;
|
||||
: gsfVersionCode;
|
||||
}
|
||||
|
||||
public int getVendingVersionCode(boolean defaultIfNotFound) {
|
||||
return defaultIfNotFound && vendingVersionCode < GOOGLE_VENDING_VERSION_CODE
|
||||
? GOOGLE_VENDING_VERSION_CODE
|
||||
: vendingVersionCode
|
||||
;
|
||||
: vendingVersionCode;
|
||||
}
|
||||
|
||||
public String getVendingVersionString(boolean defaultIfNotFound) {
|
||||
return defaultIfNotFound && vendingVersionCode < GOOGLE_VENDING_VERSION_CODE
|
||||
? GOOGLE_VENDING_VERSION_STRING
|
||||
: vendingVersionString
|
||||
;
|
||||
: vendingVersionString;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import com.aurora.store.exception.MalformedRequestException;
|
||||
import com.aurora.store.exception.NotPurchasedException;
|
||||
import com.aurora.store.model.App;
|
||||
import com.aurora.store.utility.Accountant;
|
||||
import com.aurora.store.utility.ContextUtil;
|
||||
import com.aurora.store.utility.Log;
|
||||
import com.aurora.store.utility.PrefUtil;
|
||||
import com.dragons.aurora.playstoreapiv2.AndroidAppDeliveryData;
|
||||
@@ -48,8 +47,11 @@ public class DeliveryData extends BaseTask {
|
||||
|
||||
public AndroidAppDeliveryData getDeliveryData(App app) throws IOException {
|
||||
GooglePlayAPI api = getApi();
|
||||
purchase(api, app);
|
||||
delivery(api, app);
|
||||
if (app.isFree()) {
|
||||
purchase(api, app);
|
||||
delivery(api, app);
|
||||
} else
|
||||
delivery(api, app);
|
||||
return deliveryData;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user