Loading src/java/com/android/internal/telephony/InboundSmsHandler.java +2 −3 Original line number Diff line number Diff line Loading @@ -1151,15 +1151,14 @@ public abstract class InboundSmsHandler extends StateMachine { // Deliver the broadcast only to those running users that are permitted // by user policy. for (int i = users.length - 1; i >= 0; i--) { UserHandle targetUser = new UserHandle(users[i]); UserHandle targetUser = UserHandle.of(users[i]); if (users[i] != UserHandle.USER_SYSTEM) { // Is the user not allowed to use SMS? if (mUserManager.hasUserRestriction(UserManager.DISALLOW_SMS, targetUser)) { continue; } // Skip unknown users and managed profiles as well UserInfo info = mUserManager.getUserInfo(users[i]); if (info == null || info.isManagedProfile()) { if (mUserManager.isManagedProfile(users[i])) { continue; } } Loading src/java/com/android/internal/telephony/SMSDispatcher.java +2 −2 Original line number Diff line number Diff line Loading @@ -1785,7 +1785,7 @@ public abstract class SMSDispatcher extends Handler { PackageManager pm = mContext.getPackageManager(); // Get package info via packagemanager final int userId = UserHandle.getCallingUserId(); final int userId = UserHandle.getUserHandleForUid(Binder.getCallingUid()).getIdentifier(); PackageInfo appInfo = null; try { appInfo = pm.getPackageInfoAsUser( Loading Loading @@ -2001,7 +2001,7 @@ public abstract class SMSDispatcher extends Handler { try { PackageManager pm = mContext.getPackageManager(); ApplicationInfo ai = pm.getApplicationInfo(getCarrierAppPackageName(), 0); if (!UserHandle.isSameApp(ai.uid, Binder.getCallingUid())) { if (UserHandle.getAppId(ai.uid) != UserHandle.getAppId(Binder.getCallingUid())) { throw new SecurityException("Caller is not phone or carrier app!"); } } catch (PackageManager.NameNotFoundException re) { Loading src/java/com/android/internal/telephony/SmsUsageMonitor.java +8 −6 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.app.AppGlobals; import android.content.ContentResolver; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.XmlResourceParser; import android.database.ContentObserver; import android.os.Binder; Loading Loading @@ -571,21 +572,22 @@ public class SmsUsageMonitor { }).start(); } private static void checkCallerIsSystemOrPhoneOrSameApp(String pkg) { private void checkCallerIsSystemOrPhoneOrSameApp(String pkg) { int uid = Binder.getCallingUid(); int appId = UserHandle.getAppId(uid); if (appId == Process.SYSTEM_UID || appId == Process.PHONE_UID || uid == 0) { return; } try { ApplicationInfo ai = AppGlobals.getPackageManager().getApplicationInfo( pkg, 0, UserHandle.getCallingUserId()); if (!UserHandle.isSameApp(ai.uid, uid)) { ApplicationInfo ai = mContext.getPackageManager().getApplicationInfoAsUser( pkg, 0, UserHandle.getUserHandleForUid(uid)); if (UserHandle.getAppId(ai.uid) != UserHandle.getAppId(uid)) { throw new SecurityException("Calling uid " + uid + " gave package" + pkg + " which is owned by uid " + ai.uid); } } catch (RemoteException re) { throw new SecurityException("Unknown package " + pkg + "\n" + re); } catch (NameNotFoundException ex) { throw new SecurityException("Unknown package " + pkg + "\n" + ex); } } Loading src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java +3 −1 Original line number Diff line number Diff line Loading @@ -186,7 +186,9 @@ public class SubscriptionInfoUpdater extends Handler { } } }, LOG_TAG); mCurrentlyActiveUserId = ActivityManager.getService().getCurrentUser().id; ActivityManager am = (ActivityManager) mContext.getSystemService( Context.ACTIVITY_SERVICE); mCurrentlyActiveUserId = am.getCurrentUser(); } catch (RemoteException e) { logd("Couldn't get current user ID; guessing it's 0: " + e.getMessage()); } Loading tests/telephonytests/src/com/android/internal/telephony/mocks/TelephonyRegistryMock.java +2 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.internal.telephony.mocks; import android.net.LinkProperties; import android.net.NetworkCapabilities; import android.os.Binder; import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; Loading Loading @@ -181,7 +182,7 @@ public class TelephonyRegistryMock extends ITelephonyRegistry.Stub { r.onOpportunisticSubscriptionsChangedListenerCallback = callback; r.callingPackage = callingPackage; r.callerUserId = UserHandle.getCallingUserId(); r.callerUserId = UserHandle.getUserHandleForUid(Binder.getCallingUid()).getIdentifier(); r.events = 0; r.canReadPhoneState = true; // permission has been enforced above // Always notify when registration occurs if there has been a notification. Loading Loading
src/java/com/android/internal/telephony/InboundSmsHandler.java +2 −3 Original line number Diff line number Diff line Loading @@ -1151,15 +1151,14 @@ public abstract class InboundSmsHandler extends StateMachine { // Deliver the broadcast only to those running users that are permitted // by user policy. for (int i = users.length - 1; i >= 0; i--) { UserHandle targetUser = new UserHandle(users[i]); UserHandle targetUser = UserHandle.of(users[i]); if (users[i] != UserHandle.USER_SYSTEM) { // Is the user not allowed to use SMS? if (mUserManager.hasUserRestriction(UserManager.DISALLOW_SMS, targetUser)) { continue; } // Skip unknown users and managed profiles as well UserInfo info = mUserManager.getUserInfo(users[i]); if (info == null || info.isManagedProfile()) { if (mUserManager.isManagedProfile(users[i])) { continue; } } Loading
src/java/com/android/internal/telephony/SMSDispatcher.java +2 −2 Original line number Diff line number Diff line Loading @@ -1785,7 +1785,7 @@ public abstract class SMSDispatcher extends Handler { PackageManager pm = mContext.getPackageManager(); // Get package info via packagemanager final int userId = UserHandle.getCallingUserId(); final int userId = UserHandle.getUserHandleForUid(Binder.getCallingUid()).getIdentifier(); PackageInfo appInfo = null; try { appInfo = pm.getPackageInfoAsUser( Loading Loading @@ -2001,7 +2001,7 @@ public abstract class SMSDispatcher extends Handler { try { PackageManager pm = mContext.getPackageManager(); ApplicationInfo ai = pm.getApplicationInfo(getCarrierAppPackageName(), 0); if (!UserHandle.isSameApp(ai.uid, Binder.getCallingUid())) { if (UserHandle.getAppId(ai.uid) != UserHandle.getAppId(Binder.getCallingUid())) { throw new SecurityException("Caller is not phone or carrier app!"); } } catch (PackageManager.NameNotFoundException re) { Loading
src/java/com/android/internal/telephony/SmsUsageMonitor.java +8 −6 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.app.AppGlobals; import android.content.ContentResolver; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.XmlResourceParser; import android.database.ContentObserver; import android.os.Binder; Loading Loading @@ -571,21 +572,22 @@ public class SmsUsageMonitor { }).start(); } private static void checkCallerIsSystemOrPhoneOrSameApp(String pkg) { private void checkCallerIsSystemOrPhoneOrSameApp(String pkg) { int uid = Binder.getCallingUid(); int appId = UserHandle.getAppId(uid); if (appId == Process.SYSTEM_UID || appId == Process.PHONE_UID || uid == 0) { return; } try { ApplicationInfo ai = AppGlobals.getPackageManager().getApplicationInfo( pkg, 0, UserHandle.getCallingUserId()); if (!UserHandle.isSameApp(ai.uid, uid)) { ApplicationInfo ai = mContext.getPackageManager().getApplicationInfoAsUser( pkg, 0, UserHandle.getUserHandleForUid(uid)); if (UserHandle.getAppId(ai.uid) != UserHandle.getAppId(uid)) { throw new SecurityException("Calling uid " + uid + " gave package" + pkg + " which is owned by uid " + ai.uid); } } catch (RemoteException re) { throw new SecurityException("Unknown package " + pkg + "\n" + re); } catch (NameNotFoundException ex) { throw new SecurityException("Unknown package " + pkg + "\n" + ex); } } Loading
src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java +3 −1 Original line number Diff line number Diff line Loading @@ -186,7 +186,9 @@ public class SubscriptionInfoUpdater extends Handler { } } }, LOG_TAG); mCurrentlyActiveUserId = ActivityManager.getService().getCurrentUser().id; ActivityManager am = (ActivityManager) mContext.getSystemService( Context.ACTIVITY_SERVICE); mCurrentlyActiveUserId = am.getCurrentUser(); } catch (RemoteException e) { logd("Couldn't get current user ID; guessing it's 0: " + e.getMessage()); } Loading
tests/telephonytests/src/com/android/internal/telephony/mocks/TelephonyRegistryMock.java +2 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.internal.telephony.mocks; import android.net.LinkProperties; import android.net.NetworkCapabilities; import android.os.Binder; import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; Loading Loading @@ -181,7 +182,7 @@ public class TelephonyRegistryMock extends ITelephonyRegistry.Stub { r.onOpportunisticSubscriptionsChangedListenerCallback = callback; r.callingPackage = callingPackage; r.callerUserId = UserHandle.getCallingUserId(); r.callerUserId = UserHandle.getUserHandleForUid(Binder.getCallingUid()).getIdentifier(); r.events = 0; r.canReadPhoneState = true; // permission has been enforced above // Always notify when registration occurs if there has been a notification. Loading