-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Play Search: Search only works for package names. Install will work for some apps. Very alpha.
- Loading branch information
Showing
17 changed files
with
568 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
app/src/main/kotlin/com/apkupdater/repository/PlayRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.apkupdater.repository | ||
|
||
import android.content.Context | ||
import android.net.Uri | ||
import android.util.Log | ||
import com.apkupdater.data.ui.AppUpdate | ||
import com.apkupdater.data.ui.PlaySource | ||
import com.apkupdater.prefs.Prefs | ||
import com.apkupdater.util.play.NativeDeviceInfoProvider | ||
import com.apkupdater.util.play.PlayHttpClient | ||
import com.aurora.gplayapi.data.models.AuthData | ||
import com.aurora.gplayapi.helpers.AppDetailsHelper | ||
import com.aurora.gplayapi.helpers.PurchaseHelper | ||
import com.google.gson.Gson | ||
import kotlinx.coroutines.flow.catch | ||
import kotlinx.coroutines.flow.flow | ||
|
||
|
||
class PlayRepository( | ||
private val context: Context, | ||
private val gson: Gson, | ||
private val prefs: Prefs | ||
) { | ||
private suspend fun auth(): AuthData { | ||
val savedData = prefs.playAuthData.get() | ||
if (savedData.email.isEmpty()) { | ||
val properties = NativeDeviceInfoProvider(context).getNativeDeviceProperties() | ||
val playResponse = PlayHttpClient.postAuth( | ||
"https://auroraoss.com/api/auth", | ||
gson.toJson(properties).toByteArray() | ||
) | ||
if (playResponse.isSuccessful) { | ||
val authData = gson.fromJson(String(playResponse.responseBytes), AuthData::class.java) | ||
prefs.playAuthData.put(authData) | ||
return authData | ||
} | ||
throw IllegalStateException("Auth not successful.") | ||
} | ||
return savedData | ||
} | ||
|
||
suspend fun search(text: String) = flow { | ||
if (text.contains(" ") || !text.contains(".")) { | ||
emit(Result.success(emptyList())) | ||
return@flow | ||
} | ||
val authData = auth() | ||
val details = AppDetailsHelper(authData).using(PlayHttpClient) | ||
val app = details.getAppByPackageName(text) | ||
val files = PurchaseHelper(authData).purchase(app.packageName, app.versionCode, app.offerType) | ||
val link = files.joinToString(separator = ",") { it.url } | ||
val update = AppUpdate( | ||
app.displayName, | ||
app.packageName, | ||
app.versionName, | ||
"", | ||
app.versionCode.toLong(), | ||
0L, | ||
PlaySource, | ||
Uri.parse(app.iconArtwork.url), | ||
link, | ||
whatsNew = app.changes | ||
) | ||
emit(Result.success(listOf(update))) | ||
}.catch { | ||
emit(Result.failure(it)) | ||
Log.e("PlayRepository", "Error searching.", it) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
app/src/main/kotlin/com/apkupdater/util/play/EglExtensionProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.apkupdater.util.play | ||
|
||
import android.opengl.GLES10 | ||
import android.text.TextUtils | ||
import javax.microedition.khronos.egl.EGL10 | ||
import javax.microedition.khronos.egl.EGLConfig | ||
import javax.microedition.khronos.egl.EGLContext | ||
import javax.microedition.khronos.egl.EGLDisplay | ||
|
||
|
||
object EglExtensionProvider { | ||
@JvmStatic | ||
val eglExtensions: List<String> | ||
get() { | ||
val glExtensions: MutableSet<String> = HashSet() | ||
val egl10 = EGLContext.getEGL() as EGL10 | ||
val display = egl10.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY) | ||
egl10.eglInitialize(display, IntArray(2)) | ||
val cf = IntArray(1) | ||
if (egl10.eglGetConfigs(display, null, 0, cf)) { | ||
val configs = arrayOfNulls<EGLConfig>(cf[0]) | ||
if (egl10.eglGetConfigs(display, configs, cf[0], cf)) { | ||
val a1 = intArrayOf(EGL10.EGL_WIDTH, EGL10.EGL_PBUFFER_BIT, EGL10.EGL_HEIGHT, EGL10.EGL_PBUFFER_BIT, EGL10.EGL_NONE) | ||
val a2 = intArrayOf(12440, EGL10.EGL_PIXMAP_BIT, EGL10.EGL_NONE) | ||
val a3 = IntArray(1) | ||
for (i in 0 until cf[0]) { | ||
egl10.eglGetConfigAttrib(display, configs[i], EGL10.EGL_CONFIG_CAVEAT, a3) | ||
if (a3[0] != EGL10.EGL_SLOW_CONFIG) { | ||
egl10.eglGetConfigAttrib(display, configs[i], EGL10.EGL_SURFACE_TYPE, a3) | ||
if (1 and a3[0] != 0) { | ||
egl10.eglGetConfigAttrib(display, configs[i], EGL10.EGL_RENDERABLE_TYPE, a3) | ||
if (1 and a3[0] != 0) { | ||
addExtensionsForConfig(egl10, display, configs[i], a1, null, glExtensions) | ||
} | ||
if (4 and a3[0] != 0) { | ||
addExtensionsForConfig(egl10, display, configs[i], a1, a2, glExtensions) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
egl10.eglTerminate(display) | ||
return ArrayList(glExtensions).sorted() | ||
} | ||
|
||
private fun addExtensionsForConfig( | ||
egl10: EGL10, | ||
eglDisplay: EGLDisplay, | ||
eglConfig: EGLConfig?, | ||
ai: IntArray, | ||
ai1: IntArray?, | ||
set: MutableSet<String> | ||
) { | ||
val eglContext = egl10.eglCreateContext(eglDisplay, eglConfig, EGL10.EGL_NO_CONTEXT, ai1) | ||
if (eglContext === EGL10.EGL_NO_CONTEXT) { | ||
return | ||
} | ||
val eglSurface = egl10.eglCreatePbufferSurface(eglDisplay, eglConfig, ai) | ||
if (eglSurface === EGL10.EGL_NO_SURFACE) { | ||
egl10.eglDestroyContext(eglDisplay, eglContext) | ||
} else { | ||
egl10.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext) | ||
val s = GLES10.glGetString(7939) | ||
if (!TextUtils.isEmpty(s)) { | ||
val split = s.split(" ".toRegex()).toTypedArray() | ||
val i = split.size | ||
set.addAll(listOf(*split).subList(0, i)) | ||
} | ||
egl10.eglMakeCurrent( | ||
eglDisplay, | ||
EGL10.EGL_NO_SURFACE, | ||
EGL10.EGL_NO_SURFACE, | ||
EGL10.EGL_NO_CONTEXT | ||
) | ||
egl10.eglDestroySurface(eglDisplay, eglSurface) | ||
egl10.eglDestroyContext(eglDisplay, eglContext) | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
app/src/main/kotlin/com/apkupdater/util/play/IProxyHttpClient.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.apkupdater.util.play | ||
|
||
import com.aurora.gplayapi.network.IHttpClient | ||
|
||
|
||
interface IProxyHttpClient : IHttpClient { | ||
@Throws(UnsupportedOperationException::class) | ||
fun setProxy(proxyInfo: ProxyInfo): IHttpClient | ||
} |
Oops, something went wrong.