mirror of
https://github.com/awfixers-stuff/OwnDroid.git
synced 2026-03-23 19:15:58 +00:00
fix unable to uninstall app in Dhizuku mode
fix unable to push CI builds to Telegram
This commit is contained in:
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@@ -91,6 +91,6 @@ jobs:
|
|||||||
mv ./$RELEASE_SIGNED_PWD/app-release.apk ./$RELEASE_SIGNED_PWD.apk && rm -rf ./$RELEASE_SIGNED_PWD
|
mv ./$RELEASE_SIGNED_PWD/app-release.apk ./$RELEASE_SIGNED_PWD.apk && rm -rf ./$RELEASE_SIGNED_PWD
|
||||||
../binaries/telegram-bot-api --api-id=${{ secrets.TELEGRAM_API_APP_ID }} --api-hash=${{ secrets.TELEGRAM_API_HASH }} --local 2>&1 > /dev/null &
|
../binaries/telegram-bot-api --api-id=${{ secrets.TELEGRAM_API_APP_ID }} --api-hash=${{ secrets.TELEGRAM_API_HASH }} --local 2>&1 > /dev/null &
|
||||||
export token=${{ secrets.TELEGRAM_BOT_KEY }}
|
export token=${{ secrets.TELEGRAM_BOT_KEY }}
|
||||||
curl -v "http://127.0.0.1:8081/bot$token/sendMediaGroup?chat_id=-1002216379163&media=%5B%7B%22type%22%3A%22document%22%2C%22media%22%3A%22attach%3A%2F%2FdebugTest%22%7D%2C%7B%22type%22%3A%22document%22%2C%22media%22%3A%22attach%3A%2F%2FreleaseTest%22%7D%2C%7B%22type%22%3A%22document%22%2C%22media%22%3A%22attach%3A%2F%2FdebugSigned%22%7D%2C%7B%22type%22%3A%22document%22%2C%22media%22%3A%22attach%3A%2F%2FreleaseSigned%22%2C%22parse_mode%22%3A%22MarkdownV2%22%2C%22caption%22%3A${ESCAPED}%7D%5D" \
|
curl -v "http://127.0.0.1:8081/bot$token/sendMediaGroup?chat_id=-1002216379163&media=%5B%7B%22type%22%3A%22document%22%2C%22media%22%3A%22attach%3A%2F%2FreleaseTest%22%7D%2C%7B%22type%22%3A%22document%22%2C%22media%22%3A%22attach%3A%2F%2FreleaseSigned%22%2C%22parse_mode%22%3A%22MarkdownV2%22%2C%22caption%22%3A${ESCAPED}%7D%5D" \
|
||||||
-F releaseTest="@$RELEASE_TEST_PWD.apk" \
|
-F releaseTest="@$RELEASE_TEST_PWD.apk" \
|
||||||
-F releaseSigned="@$RELEASE_SIGNED_PWD.apk"
|
-F releaseSigned="@$RELEASE_SIGNED_PWD.apk"
|
||||||
|
|||||||
17
app/src/main/java/android/content/pm/IPackageInstaller.java
Normal file
17
app/src/main/java/android/content/pm/IPackageInstaller.java
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package android.content.pm;
|
||||||
|
|
||||||
|
import android.os.Binder;
|
||||||
|
import android.os.IBinder;
|
||||||
|
import android.os.IInterface;
|
||||||
|
|
||||||
|
import androidx.annotation.Keep;
|
||||||
|
|
||||||
|
@Keep
|
||||||
|
public interface IPackageInstaller extends IInterface {
|
||||||
|
@Keep
|
||||||
|
abstract class Stub extends Binder implements IPackageInstaller {
|
||||||
|
public static IPackageInstaller asInterface(IBinder obj) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -58,7 +58,7 @@ class InstallAppActivity: FragmentActivity() {
|
|||||||
)
|
)
|
||||||
fd?.close()
|
fd?.close()
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
status = "waiting"
|
status = "pending"
|
||||||
apkInfoText = "${context.getString(R.string.package_name)}: ${apkInfo.packageName}\n"
|
apkInfoText = "${context.getString(R.string.package_name)}: ${apkInfo.packageName}\n"
|
||||||
apkInfoText += "${context.getString(R.string.version_name)}: ${apkInfo.versionName}\n"
|
apkInfoText += "${context.getString(R.string.version_name)}: ${apkInfo.versionName}\n"
|
||||||
apkInfoText += "${context.getString(R.string.version_code)}: ${apkInfo.versionCode}"
|
apkInfoText += "${context.getString(R.string.version_code)}: ${apkInfo.versionCode}"
|
||||||
@@ -79,7 +79,7 @@ class InstallAppActivity: FragmentActivity() {
|
|||||||
},
|
},
|
||||||
text = {
|
text = {
|
||||||
Column {
|
Column {
|
||||||
AnimatedVisibility(status != "waiting") {
|
AnimatedVisibility(status != "pending") {
|
||||||
LinearProgressIndicator(modifier = Modifier.fillMaxWidth())
|
LinearProgressIndicator(modifier = Modifier.fillMaxWidth())
|
||||||
}
|
}
|
||||||
Text(text = apkInfoText, modifier = Modifier.padding(top = 4.dp))
|
Text(text = apkInfoText, modifier = Modifier.padding(top = 4.dp))
|
||||||
|
|||||||
@@ -942,7 +942,7 @@ private fun UninstallApp(pkgName: String) {
|
|||||||
onClick = {
|
onClick = {
|
||||||
val intent = Intent(context, PackageInstallerReceiver::class.java)
|
val intent = Intent(context, PackageInstallerReceiver::class.java)
|
||||||
val intentSender = PendingIntent.getBroadcast(context, 8, intent, PendingIntent.FLAG_IMMUTABLE).intentSender
|
val intentSender = PendingIntent.getBroadcast(context, 8, intent, PendingIntent.FLAG_IMMUTABLE).intentSender
|
||||||
val pkgInstaller = context.packageManager.packageInstaller
|
val pkgInstaller = context.getPI()
|
||||||
pkgInstaller.uninstall(pkgName, intentSender)
|
pkgInstaller.uninstall(pkgName, intentSender)
|
||||||
},
|
},
|
||||||
modifier = Modifier.fillMaxWidth()
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import android.app.admin.SystemUpdatePolicy
|
|||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.pm.IPackageInstaller
|
||||||
import android.content.pm.PackageInstaller
|
import android.content.pm.PackageInstaller
|
||||||
import android.os.Build.VERSION
|
import android.os.Build.VERSION
|
||||||
import androidx.activity.result.ActivityResultLauncher
|
import androidx.activity.result.ActivityResultLauncher
|
||||||
@@ -86,7 +87,7 @@ fun installPackage(context: Context, inputStream: InputStream) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("PrivateApi")
|
@SuppressLint("PrivateApi")
|
||||||
fun binderWrapperDevicePolicyManager(appContext: Context): DevicePolicyManager? {
|
private fun binderWrapperDevicePolicyManager(appContext: Context): DevicePolicyManager? {
|
||||||
try {
|
try {
|
||||||
val context = appContext.createPackageContext(Dhizuku.getOwnerComponent().packageName, Context.CONTEXT_IGNORE_SECURITY)
|
val context = appContext.createPackageContext(Dhizuku.getOwnerComponent().packageName, Context.CONTEXT_IGNORE_SECURITY)
|
||||||
val manager = context.getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager
|
val manager = context.getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager
|
||||||
@@ -105,6 +106,40 @@ fun binderWrapperDevicePolicyManager(appContext: Context): DevicePolicyManager?
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("PrivateApi")
|
||||||
|
private fun binderWrapperPackageInstaller(appContext: Context): PackageInstaller? {
|
||||||
|
try {
|
||||||
|
val context = appContext.createPackageContext(Dhizuku.getOwnerComponent().packageName, Context.CONTEXT_IGNORE_SECURITY)
|
||||||
|
val installer = context.packageManager.packageInstaller
|
||||||
|
val field = installer.javaClass.getDeclaredField("mInstaller")
|
||||||
|
field.isAccessible = true
|
||||||
|
val oldInterface = field[installer] as IPackageInstaller
|
||||||
|
if (oldInterface is DhizukuBinderWrapper) return installer
|
||||||
|
val oldBinder = oldInterface.asBinder()
|
||||||
|
val newBinder = binderWrapper(oldBinder)
|
||||||
|
val newInterface = IPackageInstaller.Stub.asInterface(newBinder)
|
||||||
|
field[installer] = newInterface
|
||||||
|
return installer
|
||||||
|
} catch (e: Exception) {
|
||||||
|
dhizukuErrorStatus.value = 1
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Context.getPI(): PackageInstaller {
|
||||||
|
val sharedPref = this.getSharedPreferences("data", Context.MODE_PRIVATE)
|
||||||
|
if(sharedPref.getBoolean("dhizuku", false)) {
|
||||||
|
if (!Dhizuku.isPermissionGranted()) {
|
||||||
|
dhizukuErrorStatus.value = 2
|
||||||
|
backToHomeStateFlow.value = true
|
||||||
|
return this.packageManager.packageInstaller
|
||||||
|
}
|
||||||
|
return binderWrapperPackageInstaller(this) ?: this.packageManager.packageInstaller
|
||||||
|
} else {
|
||||||
|
return this.packageManager.packageInstaller
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun Context.getDPM(): DevicePolicyManager {
|
fun Context.getDPM(): DevicePolicyManager {
|
||||||
val sharedPref = this.getSharedPreferences("data", Context.MODE_PRIVATE)
|
val sharedPref = this.getSharedPreferences("data", Context.MODE_PRIVATE)
|
||||||
if(sharedPref.getBoolean("dhizuku", false)) {
|
if(sharedPref.getBoolean("dhizuku", false)) {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import androidx.compose.foundation.layout.Column
|
|||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.offset
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.text.KeyboardActions
|
import androidx.compose.foundation.text.KeyboardActions
|
||||||
@@ -101,7 +102,7 @@ private fun Home(navCtrl: NavHostController) {
|
|||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.work_profile),
|
text = stringResource(R.string.work_profile),
|
||||||
style = typography.headlineLarge,
|
style = typography.headlineLarge,
|
||||||
modifier = Modifier.padding(top = 8.dp, bottom = 5.dp, start = 15.dp)
|
modifier = Modifier.padding(top = 8.dp, bottom = 5.dp).offset(x = (-8).dp)
|
||||||
)
|
)
|
||||||
if(VERSION.SDK_INT >= 30 && context.isProfileOwner && dpm.isManagedProfile(receiver)) {
|
if(VERSION.SDK_INT >= 30 && context.isProfileOwner && dpm.isManagedProfile(receiver)) {
|
||||||
SubPageItem(R.string.org_owned_work_profile, "", R.drawable.corporate_fare_fill0) { navCtrl.navigate("OrgOwnedWorkProfile") }
|
SubPageItem(R.string.org_owned_work_profile, "", R.drawable.corporate_fare_fill0) { navCtrl.navigate("OrgOwnedWorkProfile") }
|
||||||
|
|||||||
@@ -327,6 +327,7 @@ private fun DeviceOwner() {
|
|||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val dpm = context.getDPM()
|
val dpm = context.getDPM()
|
||||||
var deactivateDialog by remember { mutableStateOf(false) }
|
var deactivateDialog by remember { mutableStateOf(false) }
|
||||||
|
var resetPolicy by remember { mutableStateOf(true) }
|
||||||
Column(modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState()).padding(horizontal = 8.dp)) {
|
Column(modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState()).padding(horizontal = 8.dp)) {
|
||||||
Spacer(Modifier.padding(vertical = 10.dp))
|
Spacer(Modifier.padding(vertical = 10.dp))
|
||||||
Text(text = stringResource(R.string.device_owner), style = typography.headlineLarge)
|
Text(text = stringResource(R.string.device_owner), style = typography.headlineLarge)
|
||||||
@@ -357,7 +358,8 @@ private fun DeviceOwner() {
|
|||||||
text = {
|
text = {
|
||||||
Column {
|
Column {
|
||||||
if(sharedPref.getBoolean("dhizuku", false)) Text(stringResource(R.string.dhizuku_will_be_deactivated))
|
if(sharedPref.getBoolean("dhizuku", false)) Text(stringResource(R.string.dhizuku_will_be_deactivated))
|
||||||
Text(stringResource(R.string.will_reset_policy))
|
Spacer(Modifier.padding(vertical = 4.dp))
|
||||||
|
CheckBoxItem(text = R.string.reset_device_policy, checked = resetPolicy, operation = { resetPolicy = it })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onDismissRequest = { deactivateDialog = false },
|
onDismissRequest = { deactivateDialog = false },
|
||||||
@@ -372,7 +374,7 @@ private fun DeviceOwner() {
|
|||||||
TextButton(
|
TextButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
coroutine.launch {
|
coroutine.launch {
|
||||||
context.resetDevicePolicy()
|
if(resetPolicy) context.resetDevicePolicy()
|
||||||
dpm.clearDeviceOwnerApp(context.dpcPackageName)
|
dpm.clearDeviceOwnerApp(context.dpcPackageName)
|
||||||
if(sharedPref.getBoolean("dhizuku", false)) {
|
if(sharedPref.getBoolean("dhizuku", false)) {
|
||||||
if (!Dhizuku.init(context)) {
|
if (!Dhizuku.init(context)) {
|
||||||
|
|||||||
@@ -64,7 +64,7 @@
|
|||||||
<string name="profile_owner">Profil Sahibi</string>
|
<string name="profile_owner">Profil Sahibi</string>
|
||||||
<string name="device_owner">Cihaz Sahibi</string>
|
<string name="device_owner">Cihaz Sahibi</string>
|
||||||
<string name="dhizuku_will_be_deactivated">Dhizuku will be deactivated</string> <!--TODO-->
|
<string name="dhizuku_will_be_deactivated">Dhizuku will be deactivated</string> <!--TODO-->
|
||||||
<string name="will_reset_policy">All device policies set by OwnDroid will be cleared</string> <!--TODO-->
|
<string name="reset_device_policy">Reset device policy</string> <!--TODO-->
|
||||||
<string name="activate_device_admin">Cihaz Yöneticisini Etkinleştir</string>
|
<string name="activate_device_admin">Cihaz Yöneticisini Etkinleştir</string>
|
||||||
<string name="device_info">Cihaz Bilgisi</string>
|
<string name="device_info">Cihaz Bilgisi</string>
|
||||||
<string name="support_device_id_attestation">Cihaz Kimliği Doğrulama Desteği: </string>
|
<string name="support_device_id_attestation">Cihaz Kimliği Doğrulama Desteği: </string>
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
<string name="activate_jump" tools:ignore="TypographyEllipsis">激活...</string>
|
<string name="activate_jump" tools:ignore="TypographyEllipsis">激活...</string>
|
||||||
<string name="profile_owner">Profile owner</string>
|
<string name="profile_owner">Profile owner</string>
|
||||||
<string name="device_owner">Device owner</string>
|
<string name="device_owner">Device owner</string>
|
||||||
<string name="will_reset_policy">所有由OwnDroid设置的设备策略将被清除</string>
|
<string name="reset_device_policy">重置设备策略</string>
|
||||||
<string name="dhizuku_will_be_deactivated">Dhizuku将被停用</string>
|
<string name="dhizuku_will_be_deactivated">Dhizuku将被停用</string>
|
||||||
<string name="activate_device_admin">激活Device admin</string>
|
<string name="activate_device_admin">激活Device admin</string>
|
||||||
<string name="device_info">设备信息</string>
|
<string name="device_info">设备信息</string>
|
||||||
|
|||||||
@@ -64,7 +64,7 @@
|
|||||||
<string name="profile_owner">Profile owner</string>
|
<string name="profile_owner">Profile owner</string>
|
||||||
<string name="device_owner">Device owner</string>
|
<string name="device_owner">Device owner</string>
|
||||||
<string name="dhizuku_will_be_deactivated">Dhizuku will be deactivated</string>
|
<string name="dhizuku_will_be_deactivated">Dhizuku will be deactivated</string>
|
||||||
<string name="will_reset_policy">All device policies set by OwnDroid will be cleared</string>
|
<string name="reset_device_policy">Reset device policy</string>
|
||||||
<string name="activate_device_admin">Activate Device admin</string>
|
<string name="activate_device_admin">Activate Device admin</string>
|
||||||
<string name="activate_device_admin_command" translatable="false">dpm set-active-admin com.bintianqi.owndroid/com.bintianqi.owndroid.Receiver</string>
|
<string name="activate_device_admin_command" translatable="false">dpm set-active-admin com.bintianqi.owndroid/com.bintianqi.owndroid.Receiver</string>
|
||||||
<string name="activate_device_owner_command" translatable="false">dpm set-device-owner com.bintianqi.owndroid/com.bintianqi.owndroid.Receiver</string>
|
<string name="activate_device_owner_command" translatable="false">dpm set-device-owner com.bintianqi.owndroid/com.bintianqi.owndroid.Receiver</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user