Fixed the incorrect uid check for HSUM mode
In the HSUM mode, the uid is pre-fixed with user id. Fixed by
using the correct method to check uid.
Fix: 367402314
Flag: EXEMPT bug fix
Test: Basic telephony functionality tests
Test: atest FrameworksTelephonyTests TeleServicesTest
Change-Id: I1ecf9c7ac6bf3515b15f7ba7bcc23b603608f19a
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index ae0cc3f..d5ae671 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -9597,7 +9597,7 @@
private WorkSource getWorkSource(int uid) {
String packageName = mApp.getPackageManager().getNameForUid(uid);
- if (uid == Process.ROOT_UID && packageName == null) {
+ if (UserHandle.isSameApp(uid, Process.ROOT_UID) && packageName == null) {
// Downstream WorkSource attribution inside the RIL requires both a UID and package name
// to be set for wakelock tracking, otherwise RIL requests fail with a runtime
// exception. ROOT_UID seems not to have a valid package name returned by
@@ -11319,7 +11319,7 @@
// In fact, the current code acquires way too many,
// and probably has lurking deadlocks.
- if (Binder.getCallingUid() != Process.SYSTEM_UID) {
+ if (!UserHandle.isSameApp(Binder.getCallingUid(), Process.SYSTEM_UID)) {
throw new SecurityException("Only the OS may call notifyUserActivity()");
}
diff --git a/src/com/android/phone/TelephonyShellCommand.java b/src/com/android/phone/TelephonyShellCommand.java
index 08b041b..bfc93e0 100644
--- a/src/com/android/phone/TelephonyShellCommand.java
+++ b/src/com/android/phone/TelephonyShellCommand.java
@@ -34,6 +34,7 @@
import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceSpecificException;
+import android.os.UserHandle;
import android.provider.BlockedNumberContract;
import android.telephony.BarringInfo;
import android.telephony.CarrierConfigManager;
@@ -1119,7 +1120,8 @@
}
// Verify that the user is allowed to run the command. Only allowed in rooted device in a
// non user build.
- if (Binder.getCallingUid() != Process.ROOT_UID || TelephonyUtils.IS_USER) {
+ if (!UserHandle.isSameApp(Binder.getCallingUid(), Process.ROOT_UID)
+ || TelephonyUtils.IS_USER) {
errPw.println("cc: Permission denied.");
return -1;
}
@@ -1685,14 +1687,15 @@
private boolean checkShellUid() {
// adb can run as root or as shell, depending on whether the device is rooted.
- return Binder.getCallingUid() == Process.SHELL_UID
- || Binder.getCallingUid() == Process.ROOT_UID;
+ return UserHandle.isSameApp(Binder.getCallingUid(), Process.SHELL_UID)
+ || UserHandle.isSameApp(Binder.getCallingUid(), Process.ROOT_UID);
}
private int handleCcCommand() {
// Verify that the user is allowed to run the command. Only allowed in rooted device in a
// non user build.
- if (Binder.getCallingUid() != Process.ROOT_UID || TelephonyUtils.IS_USER) {
+ if (!UserHandle.isSameApp(Binder.getCallingUid(), Process.ROOT_UID)
+ || TelephonyUtils.IS_USER) {
getErrPrintWriter().println("cc: Permission denied.");
return -1;
}
@@ -2248,7 +2251,8 @@
private int handleRestartModemCommand() {
// Verify that the user is allowed to run the command. Only allowed in rooted device in a
// non user build.
- if (Binder.getCallingUid() != Process.ROOT_UID || TelephonyUtils.IS_USER) {
+ if (!UserHandle.isSameApp(Binder.getCallingUid(), Process.ROOT_UID)
+ || TelephonyUtils.IS_USER) {
getErrPrintWriter().println("RestartModem: Permission denied.");
return -1;
}
@@ -2262,7 +2266,8 @@
private int handleGetImei() {
// Verify that the user is allowed to run the command. Only allowed in rooted device in a
// non user build.
- if (Binder.getCallingUid() != Process.ROOT_UID || TelephonyUtils.IS_USER) {
+ if (!UserHandle.isSameApp(Binder.getCallingUid(), Process.ROOT_UID)
+ || TelephonyUtils.IS_USER) {
getErrPrintWriter().println("Device IMEI: Permission denied.");
return -1;
}
@@ -2293,7 +2298,8 @@
private int handleUnattendedReboot() {
// Verify that the user is allowed to run the command. Only allowed in rooted device in a
// non user build.
- if (Binder.getCallingUid() != Process.ROOT_UID || TelephonyUtils.IS_USER) {
+ if (!UserHandle.isSameApp(Binder.getCallingUid(), Process.ROOT_UID)
+ || TelephonyUtils.IS_USER) {
getErrPrintWriter().println("UnattendedReboot: Permission denied.");
return -1;
}
@@ -2307,7 +2313,8 @@
private int handleGetSimSlotsMapping() {
// Verify that the user is allowed to run the command. Only allowed in rooted device in a
// non user build.
- if (Binder.getCallingUid() != Process.ROOT_UID || TelephonyUtils.IS_USER) {
+ if (!UserHandle.isSameApp(Binder.getCallingUid(), Process.ROOT_UID)
+ || TelephonyUtils.IS_USER) {
getErrPrintWriter().println("GetSimSlotsMapping: Permission denied.");
return -1;
}