Minor usecase improvements
This commit is contained in:
@@ -20,9 +20,21 @@
|
|||||||
package com.aurora.store.data.event
|
package com.aurora.store.data.event
|
||||||
|
|
||||||
sealed class BusEvent {
|
sealed class BusEvent {
|
||||||
data class InstallEvent(var packageName: String, var error: String = String()) : BusEvent()
|
data class InstallEvent(
|
||||||
data class UninstallEvent(var packageName: String, var error: String = String()) : BusEvent()
|
var packageName: String,
|
||||||
data class Blacklisted(var packageName: String, var error: String = String()) : BusEvent()
|
var extra: String? = ""
|
||||||
|
) : BusEvent()
|
||||||
|
|
||||||
|
data class UninstallEvent(
|
||||||
|
var packageName: String,
|
||||||
|
var extra: String? = ""
|
||||||
|
) : BusEvent()
|
||||||
|
|
||||||
|
data class Blacklisted(
|
||||||
|
var packageName: String,
|
||||||
|
var error: String? = ""
|
||||||
|
) : BusEvent()
|
||||||
|
|
||||||
data class GoogleAAS(
|
data class GoogleAAS(
|
||||||
var success: Boolean,
|
var success: Boolean,
|
||||||
var email: String = String(),
|
var email: String = String(),
|
||||||
@@ -30,15 +42,15 @@ sealed class BusEvent {
|
|||||||
) : BusEvent()
|
) : BusEvent()
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class SessionEvent {
|
sealed class InstallerEvent {
|
||||||
data class Success(
|
data class Success(
|
||||||
var packageName: String? = "",
|
var packageName: String? = "",
|
||||||
var extra: String? = ""
|
var extra: String? = ""
|
||||||
) : SessionEvent()
|
) : InstallerEvent()
|
||||||
|
|
||||||
data class Failed(
|
data class Failed(
|
||||||
var packageName: String? = "",
|
var packageName: String? = "",
|
||||||
var error: String? = "",
|
var error: String? = "",
|
||||||
var extra: String? = ""
|
var extra: String? = ""
|
||||||
) : SessionEvent()
|
) : InstallerEvent()
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,7 @@ import android.os.Build
|
|||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import com.aurora.store.R
|
import com.aurora.store.R
|
||||||
import com.aurora.store.data.event.SessionEvent
|
import com.aurora.store.data.event.InstallerEvent
|
||||||
import com.aurora.store.util.Log
|
import com.aurora.store.util.Log
|
||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
|
|
||||||
@@ -65,12 +65,12 @@ class InstallerService : Service() {
|
|||||||
private fun postStatus(status: Int, packageName: String?, extra: String?) {
|
private fun postStatus(status: Int, packageName: String?, extra: String?) {
|
||||||
when (status) {
|
when (status) {
|
||||||
PackageInstaller.STATUS_SUCCESS -> {
|
PackageInstaller.STATUS_SUCCESS -> {
|
||||||
EventBus.getDefault().post(SessionEvent.Success(packageName, "Success"))
|
EventBus.getDefault().post(InstallerEvent.Success(packageName, "Success"))
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
val errorString = getErrorString(status)
|
val errorString = getErrorString(status)
|
||||||
Log.e("$packageName : $errorString")
|
Log.e("$packageName : $errorString")
|
||||||
EventBus.getDefault().post(SessionEvent.Failed(packageName, errorString, extra))
|
EventBus.getDefault().post(InstallerEvent.Failed(packageName, errorString, extra))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,9 +21,8 @@ package com.aurora.store.data.installer
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.aurora.extensions.isLAndAbove
|
import com.aurora.extensions.isLAndAbove
|
||||||
import com.aurora.extensions.toast
|
|
||||||
import com.aurora.store.R
|
import com.aurora.store.R
|
||||||
import com.aurora.store.data.event.SessionEvent
|
import com.aurora.store.data.event.InstallerEvent
|
||||||
import com.aurora.store.util.Log
|
import com.aurora.store.util.Log
|
||||||
import com.topjohnwu.superuser.Shell
|
import com.topjohnwu.superuser.Shell
|
||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
@@ -52,7 +51,7 @@ class RootInstaller(context: Context) : InstallerBase(context) {
|
|||||||
xInstallLegacy(packageName, it)
|
xInstallLegacy(packageName, it)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val event = SessionEvent.Failed(
|
val event = InstallerEvent.Failed(
|
||||||
packageName,
|
packageName,
|
||||||
context.getString(R.string.installer_status_failure),
|
context.getString(R.string.installer_status_failure),
|
||||||
context.getString(R.string.installer_root_unavailable)
|
context.getString(R.string.installer_root_unavailable)
|
||||||
@@ -91,7 +90,7 @@ class RootInstaller(context: Context) : InstallerBase(context) {
|
|||||||
|
|
||||||
if (!shellResult.isSuccess) {
|
if (!shellResult.isSuccess) {
|
||||||
removeFromInstallQueue(packageName)
|
removeFromInstallQueue(packageName)
|
||||||
val event = SessionEvent.Failed(
|
val event = InstallerEvent.Failed(
|
||||||
packageName,
|
packageName,
|
||||||
context.getString(R.string.installer_status_failure),
|
context.getString(R.string.installer_status_failure),
|
||||||
parseError(shellResult)
|
parseError(shellResult)
|
||||||
@@ -100,7 +99,7 @@ class RootInstaller(context: Context) : InstallerBase(context) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
removeFromInstallQueue(packageName)
|
removeFromInstallQueue(packageName)
|
||||||
val event = SessionEvent.Failed(
|
val event = InstallerEvent.Failed(
|
||||||
packageName,
|
packageName,
|
||||||
context.getString(R.string.installer_status_failure),
|
context.getString(R.string.installer_status_failure),
|
||||||
context.getString(R.string.installer_root_unavailable)
|
context.getString(R.string.installer_root_unavailable)
|
||||||
@@ -109,7 +108,7 @@ class RootInstaller(context: Context) : InstallerBase(context) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
removeFromInstallQueue(packageName)
|
removeFromInstallQueue(packageName)
|
||||||
val event = SessionEvent.Failed(
|
val event = InstallerEvent.Failed(
|
||||||
packageName,
|
packageName,
|
||||||
context.getString(R.string.installer_status_failure),
|
context.getString(R.string.installer_status_failure),
|
||||||
context.getString(R.string.installer_status_failure_session)
|
context.getString(R.string.installer_status_failure_session)
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import com.aurora.services.IPrivilegedCallback
|
|||||||
import com.aurora.services.IPrivilegedService
|
import com.aurora.services.IPrivilegedService
|
||||||
import com.aurora.store.BuildConfig
|
import com.aurora.store.BuildConfig
|
||||||
import com.aurora.store.R
|
import com.aurora.store.R
|
||||||
import com.aurora.store.data.event.SessionEvent
|
import com.aurora.store.data.event.InstallerEvent
|
||||||
import com.aurora.store.util.Log
|
import com.aurora.store.util.Log
|
||||||
import com.aurora.store.util.PackageUtil
|
import com.aurora.store.util.PackageUtil
|
||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
@@ -70,7 +70,7 @@ class ServiceInstaller(context: Context) : InstallerBase(context) {
|
|||||||
xInstall(packageName, uriList)
|
xInstall(packageName, uriList)
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
val event = SessionEvent.Failed(
|
val event = InstallerEvent.Failed(
|
||||||
packageName,
|
packageName,
|
||||||
context.getString(R.string.installer_status_failure),
|
context.getString(R.string.installer_status_failure),
|
||||||
context.getString(R.string.installer_service_unavailable)
|
context.getString(R.string.installer_service_unavailable)
|
||||||
@@ -108,7 +108,7 @@ class ServiceInstaller(context: Context) : InstallerBase(context) {
|
|||||||
EventBus
|
EventBus
|
||||||
.getDefault()
|
.getDefault()
|
||||||
.post(
|
.post(
|
||||||
SessionEvent.Failed(
|
InstallerEvent.Failed(
|
||||||
packageName,
|
packageName,
|
||||||
e.localizedMessage,
|
e.localizedMessage,
|
||||||
e.stackTraceToString()
|
e.stackTraceToString()
|
||||||
@@ -118,7 +118,7 @@ class ServiceInstaller(context: Context) : InstallerBase(context) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.e(context.getString(R.string.installer_service_misconfigured))
|
Log.e(context.getString(R.string.installer_service_misconfigured))
|
||||||
val event = SessionEvent.Failed(
|
val event = InstallerEvent.Failed(
|
||||||
packageName,
|
packageName,
|
||||||
context.getString(R.string.installer_status_failure),
|
context.getString(R.string.installer_status_failure),
|
||||||
context.getString(R.string.installer_service_misconfigured)
|
context.getString(R.string.installer_service_misconfigured)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import androidx.annotation.RequiresApi
|
|||||||
import androidx.core.content.FileProvider
|
import androidx.core.content.FileProvider
|
||||||
import com.aurora.extensions.isNAndAbove
|
import com.aurora.extensions.isNAndAbove
|
||||||
import com.aurora.store.BuildConfig
|
import com.aurora.store.BuildConfig
|
||||||
import com.aurora.store.data.event.SessionEvent
|
import com.aurora.store.data.event.InstallerEvent
|
||||||
import com.aurora.store.util.Log
|
import com.aurora.store.util.Log
|
||||||
import org.apache.commons.io.IOUtils
|
import org.apache.commons.io.IOUtils
|
||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
@@ -102,7 +102,7 @@ class SessionInstaller(context: Context) : InstallerBase(context) {
|
|||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
session.abandon()
|
session.abandon()
|
||||||
removeFromInstallQueue(packageName)
|
removeFromInstallQueue(packageName)
|
||||||
val event = SessionEvent.Failed(
|
val event = InstallerEvent.Failed(
|
||||||
packageName,
|
packageName,
|
||||||
e.localizedMessage,
|
e.localizedMessage,
|
||||||
e.stackTraceToString()
|
e.stackTraceToString()
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import com.aurora.store.data.event.BusEvent.UninstallEvent
|
|||||||
import com.aurora.store.data.installer.AppInstaller
|
import com.aurora.store.data.installer.AppInstaller
|
||||||
import com.aurora.store.util.PathUtil
|
import com.aurora.store.util.PathUtil
|
||||||
import com.aurora.store.util.Preferences
|
import com.aurora.store.util.Preferences
|
||||||
|
import com.aurora.store.util.isExternalStorageEnable
|
||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@@ -39,19 +40,20 @@ open class PackageManagerReceiver : BroadcastReceiver() {
|
|||||||
|
|
||||||
when (intent.action) {
|
when (intent.action) {
|
||||||
Intent.ACTION_PACKAGE_ADDED -> {
|
Intent.ACTION_PACKAGE_ADDED -> {
|
||||||
EventBus.getDefault()
|
EventBus.getDefault().post(InstallEvent(packageName, ""))
|
||||||
.post(InstallEvent(packageName, ""))
|
}
|
||||||
|
|
||||||
//Clear installation queue
|
Intent.ACTION_PACKAGE_REMOVED -> {
|
||||||
AppInstaller(context)
|
EventBus.getDefault().post(UninstallEvent(packageName, ""))
|
||||||
.getPreferredInstaller()
|
|
||||||
.removeFromInstallQueue(packageName)
|
|
||||||
}
|
}
|
||||||
Intent.ACTION_PACKAGE_REMOVED -> EventBus.getDefault()
|
|
||||||
.post(UninstallEvent(packageName, ""))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
clearNotification(context, packageName)
|
//Clear installation queue
|
||||||
|
AppInstaller(context)
|
||||||
|
.getPreferredInstaller()
|
||||||
|
.removeFromInstallQueue(packageName)
|
||||||
|
|
||||||
|
//clearNotification(context, packageName)
|
||||||
|
|
||||||
val isAutoDeleteAPKEnabled = Preferences.getBoolean(
|
val isAutoDeleteAPKEnabled = Preferences.getBoolean(
|
||||||
context,
|
context,
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import com.aurora.extensions.isLAndAbove
|
|||||||
import com.aurora.gplayapi.data.models.App
|
import com.aurora.gplayapi.data.models.App
|
||||||
import com.aurora.store.R
|
import com.aurora.store.R
|
||||||
import com.aurora.store.data.downloader.DownloadManager
|
import com.aurora.store.data.downloader.DownloadManager
|
||||||
import com.aurora.store.data.event.SessionEvent
|
import com.aurora.store.data.event.InstallerEvent
|
||||||
import com.aurora.store.data.installer.AppInstaller
|
import com.aurora.store.data.installer.AppInstaller
|
||||||
import com.aurora.store.data.receiver.DownloadCancelReceiver
|
import com.aurora.store.data.receiver.DownloadCancelReceiver
|
||||||
import com.aurora.store.data.receiver.DownloadPauseReceiver
|
import com.aurora.store.data.receiver.DownloadPauseReceiver
|
||||||
@@ -361,12 +361,12 @@ class NotificationService : Service() {
|
|||||||
@Subscribe()
|
@Subscribe()
|
||||||
fun onEventMainThread(event: Any) {
|
fun onEventMainThread(event: Any) {
|
||||||
when (event) {
|
when (event) {
|
||||||
is SessionEvent.Success -> {
|
is InstallerEvent.Success -> {
|
||||||
val app = appMap[event.packageName.hashCode()]
|
val app = appMap[event.packageName.hashCode()]
|
||||||
if (app != null)
|
if (app != null)
|
||||||
notifyInstallationStatus(app, event.extra)
|
notifyInstallationStatus(app, event.extra)
|
||||||
}
|
}
|
||||||
is SessionEvent.Failed -> {
|
is InstallerEvent.Failed -> {
|
||||||
val app = appMap[event.packageName.hashCode()]
|
val app = appMap[event.packageName.hashCode()]
|
||||||
if (app != null)
|
if (app != null)
|
||||||
notifyInstallationStatus(app, event.error)
|
notifyInstallationStatus(app, event.error)
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ package com.aurora.store.util
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
|
import com.aurora.extensions.isLAndAbove
|
||||||
import com.aurora.gplayapi.data.models.App
|
import com.aurora.gplayapi.data.models.App
|
||||||
import com.aurora.gplayapi.data.models.File
|
import com.aurora.gplayapi.data.models.File
|
||||||
import com.aurora.extensions.isLAndAbove
|
|
||||||
|
|
||||||
fun Context.getInternalBaseDirectory(): String {
|
fun Context.getInternalBaseDirectory(): String {
|
||||||
return filesDir.path
|
return filesDir.path
|
||||||
@@ -33,7 +33,7 @@ object PathUtil {
|
|||||||
|
|
||||||
private fun getDownloadDirectory(context: Context): String {
|
private fun getDownloadDirectory(context: Context): String {
|
||||||
return if (isLAndAbove()) {
|
return if (isLAndAbove()) {
|
||||||
if (Preferences.getBoolean(context, Preferences.PREFERENCE_DOWNLOAD_EXTERNAL))
|
if (context.isExternalStorageEnable())
|
||||||
getExternalPath()
|
getExternalPath()
|
||||||
else
|
else
|
||||||
context.getInternalBaseDirectory() + "/Downloads"
|
context.getInternalBaseDirectory() + "/Downloads"
|
||||||
@@ -79,4 +79,8 @@ object PathUtil {
|
|||||||
val obbDir = getObbDownloadPath(context, app)
|
val obbDir = getObbDownloadPath(context, app)
|
||||||
return "$obbDir/${file.name}"
|
return "$obbDir/${file.name}"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Context.isExternalStorageEnable(): Boolean {
|
||||||
|
return Preferences.getBoolean(this, Preferences.PREFERENCE_DOWNLOAD_EXTERNAL)
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,7 @@ import com.aurora.store.R
|
|||||||
import com.aurora.store.data.downloader.DownloadManager
|
import com.aurora.store.data.downloader.DownloadManager
|
||||||
import com.aurora.store.data.downloader.RequestBuilder
|
import com.aurora.store.data.downloader.RequestBuilder
|
||||||
import com.aurora.store.data.event.BusEvent
|
import com.aurora.store.data.event.BusEvent
|
||||||
import com.aurora.store.data.event.SessionEvent
|
import com.aurora.store.data.event.InstallerEvent
|
||||||
import com.aurora.store.data.installer.AppInstaller
|
import com.aurora.store.data.installer.AppInstaller
|
||||||
import com.aurora.store.data.network.HttpClient
|
import com.aurora.store.data.network.HttpClient
|
||||||
import com.aurora.store.data.providers.AuthProvider
|
import com.aurora.store.data.providers.AuthProvider
|
||||||
@@ -114,7 +114,7 @@ class AppDetailsActivity : BaseDetailsActivity() {
|
|||||||
attachActions()
|
attachActions()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is SessionEvent.Failed -> {
|
is InstallerEvent.Failed -> {
|
||||||
if (app.packageName == event.packageName) {
|
if (app.packageName == event.packageName) {
|
||||||
InstallErrorDialogSheet.newInstance(
|
InstallErrorDialogSheet.newInstance(
|
||||||
app,
|
app,
|
||||||
|
|||||||
@@ -20,12 +20,44 @@
|
|||||||
package com.aurora.store.view.ui.preferences
|
package com.aurora.store.view.ui.preferences
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.view.View
|
||||||
|
import androidx.preference.Preference
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
|
import androidx.preference.SwitchPreferenceCompat
|
||||||
import com.aurora.store.R
|
import com.aurora.store.R
|
||||||
|
import com.aurora.store.util.Preferences
|
||||||
|
|
||||||
|
|
||||||
class DownloadPreference : PreferenceFragmentCompat() {
|
class DownloadPreference : PreferenceFragmentCompat() {
|
||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
setPreferencesFromResource(R.xml.preferences_download, rootKey)
|
setPreferencesFromResource(R.xml.preferences_download, rootKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
val downloadExternalPreference: SwitchPreferenceCompat? =
|
||||||
|
findPreference(Preferences.PREFERENCE_DOWNLOAD_EXTERNAL)
|
||||||
|
|
||||||
|
val autoDeletePreference: SwitchPreferenceCompat? =
|
||||||
|
findPreference(Preferences.PREFERENCE_AUTO_DELETE)
|
||||||
|
|
||||||
|
|
||||||
|
downloadExternalPreference?.let { switchPreferenceCompat ->
|
||||||
|
switchPreferenceCompat.onPreferenceChangeListener =
|
||||||
|
Preference.OnPreferenceChangeListener { _, newValue ->
|
||||||
|
val checked = newValue.toString().toBoolean()
|
||||||
|
autoDeletePreference?.let {
|
||||||
|
if (checked) {
|
||||||
|
it.isEnabled = true
|
||||||
|
} else {
|
||||||
|
it.isEnabled = false
|
||||||
|
it.isChecked = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -27,6 +27,13 @@
|
|||||||
app:summary="@string/pref_downloader_external_desc"
|
app:summary="@string/pref_downloader_external_desc"
|
||||||
app:title="@string/pref_downloader_external" />
|
app:title="@string/pref_downloader_external" />
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
app:defaultValue="true"
|
||||||
|
app:iconSpaceReserved="false"
|
||||||
|
app:key="PREFERENCE_AUTO_DELETE"
|
||||||
|
app:summary="@string/pref_install_delete_summary"
|
||||||
|
app:title="@string/pref_install_delete_title" />
|
||||||
|
|
||||||
<SeekBarPreference
|
<SeekBarPreference
|
||||||
android:defaultValue="3"
|
android:defaultValue="3"
|
||||||
android:key="PREFERENCE_DOWNLOAD_ACTIVE"
|
android:key="PREFERENCE_DOWNLOAD_ACTIVE"
|
||||||
|
|||||||
@@ -26,13 +26,6 @@
|
|||||||
app:summary="@string/pref_install_auto_summary"
|
app:summary="@string/pref_install_auto_summary"
|
||||||
app:title="@string/pref_install_auto_title" />
|
app:title="@string/pref_install_auto_title" />
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
|
||||||
app:defaultValue="true"
|
|
||||||
app:iconSpaceReserved="false"
|
|
||||||
app:key="PREFERENCE_AUTO_DELETE"
|
|
||||||
app:summary="@string/pref_install_delete_summary"
|
|
||||||
app:title="@string/pref_install_delete_title" />
|
|
||||||
|
|
||||||
<com.aurora.store.view.custom.preference.AuroraListPreference
|
<com.aurora.store.view.custom.preference.AuroraListPreference
|
||||||
app:defaultValue="0"
|
app:defaultValue="0"
|
||||||
app:entries="@array/pref_installation_method"
|
app:entries="@array/pref_installation_method"
|
||||||
|
|||||||
Reference in New Issue
Block a user