Improve uninstallers

This commit is contained in:
Rahul Kumar Patel
2021-03-06 17:29:58 +05:30
parent 1a858977ab
commit 9c4fc5109c
4 changed files with 37 additions and 12 deletions

View File

@@ -51,17 +51,40 @@ class RootInstaller(context: Context) : InstallerBase(context) {
xInstallLegacy(packageName, it)
}
} else {
val event = InstallerEvent.Failed(
postError(
packageName,
context.getString(R.string.installer_status_failure),
context.getString(R.string.installer_root_unavailable)
)
EventBus.getDefault().post(event)
Log.e(" >>>>>>>>>>>>>>>>>>>>>>>>>> NO ROOT ACCESS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
}
}
}
override fun uninstall(packageName: String) {
if (Shell.getShell().isRoot) {
val result: Shell.Result =
Shell.su("pm uninstall --user 0 $packageName")
.exec()
val response = result.out
if (response[0] != "Success") {
postError(
packageName,
context.getString(R.string.installer_status_failure),
parseError(result)
)
}
} else {
postError(
packageName,
context.getString(R.string.installer_status_failure),
context.getString(R.string.installer_root_unavailable)
)
Log.e(" >>>>>>>>>>>>>>>>>>>>>>>>>> NO ROOT ACCESS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
}
}
private fun xInstall(packageName: String, files: List<File>) {
var totalSize = 0
@@ -99,21 +122,19 @@ class RootInstaller(context: Context) : InstallerBase(context) {
}
} else {
removeFromInstallQueue(packageName)
val event = InstallerEvent.Failed(
postError(
packageName,
context.getString(R.string.installer_status_failure),
context.getString(R.string.installer_root_unavailable)
)
EventBus.getDefault().post(event)
}
} else {
removeFromInstallQueue(packageName)
val event = InstallerEvent.Failed(
postError(
packageName,
context.getString(R.string.installer_status_failure),
context.getString(R.string.installer_status_failure_session)
)
EventBus.getDefault().post(event)
}
}

View File

@@ -272,9 +272,11 @@ class AppDetailsActivity : BaseDetailsActivity() {
@Synchronized
private fun uninstallApp() {
AppInstaller(this)
.getPreferredInstaller()
.uninstall(app.packageName)
task {
AppInstaller(this)
.getPreferredInstaller()
.uninstall(app.packageName)
}
}
private fun attachWhiteListStatus() {

View File

@@ -107,8 +107,10 @@ class AppMenuSheet : BaseBottomSheet() {
}
R.id.action_uninstall -> {
AppInstaller(requireContext())
.getPreferredInstaller().uninstall(app.packageName)
task {
AppInstaller(requireContext())
.getPreferredInstaller().uninstall(app.packageName)
}
}
R.id.action_info -> {

View File

@@ -46,7 +46,7 @@
android:fragment="com.aurora.store.view.ui.preferences.DownloadPreference"
app:icon="@drawable/ic_download_manager"
app:iconSpaceReserved="false"
app:key="pref_ui"
app:key="pref_download"
app:layout="@layout/item_preference"
app:title="@string/pref_app_download" />
</PreferenceScreen>