Merge cherrypicks of ['googleplex-android-review.googlesource.com/31143841'] into 25Q1-release.
Change-Id: I043506f035f6d3f6257d1563b59eba4843782a11
diff --git a/src/com/android/server/telecom/TelecomServiceImpl.java b/src/com/android/server/telecom/TelecomServiceImpl.java
index 488524f..a25a4cc 100644
--- a/src/com/android/server/telecom/TelecomServiceImpl.java
+++ b/src/com/android/server/telecom/TelecomServiceImpl.java
@@ -27,8 +27,6 @@
import static android.Manifest.permission.READ_SMS;
import static android.Manifest.permission.REGISTER_SIM_SUBSCRIPTION;
import static android.Manifest.permission.WRITE_SECURE_SETTINGS;
-import static android.telecom.CallAttributes.DIRECTION_INCOMING;
-import static android.telecom.CallAttributes.DIRECTION_OUTGOING;
import static android.telecom.CallException.CODE_ERROR_UNKNOWN;
import static android.telecom.TelecomManager.TELECOM_TRANSACTION_SUCCESS;
@@ -66,6 +64,7 @@
import android.telecom.Log;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
+import android.telecom.StatusHints;
import android.telecom.TelecomAnalytics;
import android.telecom.TelecomManager;
import android.telecom.VideoProfile;
@@ -86,8 +85,6 @@
import com.android.server.telecom.metrics.ApiStats;
import com.android.server.telecom.metrics.TelecomMetricsController;
import com.android.server.telecom.settings.BlockedNumbersActivity;
-import com.android.server.telecom.callsequencing.voip.IncomingCallTransaction;
-import com.android.server.telecom.callsequencing.voip.OutgoingCallTransaction;
import com.android.server.telecom.callsequencing.TransactionManager;
import com.android.server.telecom.callsequencing.CallTransaction;
import com.android.server.telecom.callsequencing.CallTransactionResult;
@@ -3705,15 +3702,13 @@
// incompatible types.
if (icon != null && (icon.getType() == Icon.TYPE_URI
|| icon.getType() == Icon.TYPE_URI_ADAPTIVE_BITMAP)) {
- String encodedUser = icon.getUri().getEncodedUserInfo();
- // If there is no encoded user, the URI is calling into the calling user space
- if (encodedUser != null) {
- int userId = Integer.parseInt(encodedUser);
- if (userId != UserHandle.getUserId(Binder.getCallingUid())) {
- // If we are transcending the profile boundary, throw an error.
- throw new IllegalArgumentException("Attempting to register a phone account with"
- + " an image icon belonging to another user.");
- }
+ int callingUserId = UserHandle.getCallingUserId();
+ int requestingUserId = StatusHints.getUserIdFromAuthority(
+ icon.getUri().getAuthority(), callingUserId);
+ if(callingUserId != requestingUserId) {
+ // If we are transcending the profile boundary, throw an error.
+ throw new IllegalArgumentException("Attempting to register a phone account with"
+ + " an image icon belonging to another user.");
}
}
}
diff --git a/tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java b/tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java
index 6b0555c..96bf05a 100644
--- a/tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java
+++ b/tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java
@@ -1095,6 +1095,20 @@
// This should fail; security exception will be thrown.
registerPhoneAccountTestHelper(phoneAccount, false);
+ icon = Icon.createWithContentUri(
+ new Uri.Builder().scheme("content")
+ .encodedAuthority("10%40media")
+ .path("external/images/media/${mediaId.text}".trim())
+ .build());
+ phoneAccount = makePhoneAccount(phHandle).setIcon(icon).build();
+ // This should fail; security exception will be thrown
+ registerPhoneAccountTestHelper(phoneAccount, false);
+
+ icon = Icon.createWithContentUri( Uri.parse("content://10%40play.ground"));
+ phoneAccount = makePhoneAccount(phHandle).setIcon(icon).build();
+ // This should fail; security exception will be thrown
+ registerPhoneAccountTestHelper(phoneAccount, false);
+
icon = Icon.createWithContentUri("content://0@media/external/images/media/");
phoneAccount = makePhoneAccount(phHandle).setIcon(icon).build();
// This should succeed.