Skip to content

Commit f34975b

Browse files
committed
fix: #450
Change-Id: I3b526f3dc192a52572804700b7207c63b3a3090e
1 parent 7c405e2 commit f34975b

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

source/core/model/src/main/kotlin/com/xayah/core/model/database/PackageEntity.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ data class PackagePermission @JvmOverloads constructor(
2323
var name: String = "",
2424
var isGranted: Boolean = false, // Only for runtime permissions
2525
var op: Int = AppOpsManagerHidden.OP_NONE,
26-
var mode: Int = AppOpsManager.MODE_IGNORED,
26+
var mode: Int? = null,
2727
) : Parcelable {
2828
val isOpsAllowed: Boolean
2929
get() = run {
@@ -38,15 +38,19 @@ data class PackagePermission @JvmOverloads constructor(
3838
parcel.readString() ?: "",
3939
parcel.readByte() != 0.toByte(),
4040
parcel.readInt(),
41-
parcel.readInt()
42-
) {
43-
}
41+
if (parcel.readInt() == 1) parcel.readInt() else null
42+
)
4443

4544
override fun writeToParcel(parcel: Parcel, flags: Int) {
4645
parcel.writeString(name)
4746
parcel.writeByte(if (isGranted) 1 else 0)
4847
parcel.writeInt(op)
49-
parcel.writeInt(mode)
48+
if (mode == null) {
49+
parcel.writeInt(0)
50+
} else {
51+
parcel.writeInt(1)
52+
mode?.also { parcel.writeInt(it) }
53+
}
5054
}
5155

5256
override fun describeContents(): Int {

source/core/rootservice/src/main/kotlin/com/xayah/core/rootservice/impl/RemoteRootServiceImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ internal class RemoteRootServiceImpl(private val context: Context) : IRemoteRoot
500500
val protectionFlags = PermissionInfoCompat.getProtectionFlags(permissionInfo)
501501
val isGranted = (requestedPermissionsFlags[i] and PackageInfo.REQUESTED_PERMISSION_GRANTED) != 0
502502
val op = AppOpsManagerHidden.permissionToOpCode(name)
503-
val mode = ops?.get(op) ?: AppOpsManager.MODE_IGNORED
503+
val mode = ops?.get(op)
504504
if ((op != AppOpsManagerHidden.OP_NONE)
505505
|| (protection == PermissionInfo.PROTECTION_DANGEROUS || (protectionFlags and PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0)
506506
) {

source/core/service/src/main/kotlin/com/xayah/core/service/util/PackagesRestoreUtil.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,9 @@ class PackagesRestoreUtil @Inject constructor(
379379
rootService.revokeRuntimePermission(packageName, it.name, user!!)
380380
}
381381
if (it.op != AppOpsManagerHidden.OP_NONE) {
382-
rootService.setOpsMode(it.op, uid, packageName, it.mode)
382+
it.mode?.also { mode ->
383+
rootService.setOpsMode(it.op, uid, packageName, mode)
384+
}
383385
}
384386
}
385387
}

0 commit comments

Comments
 (0)