Loading src/com/android/server/telecom/Call.java +22 −1 Original line number Diff line number Diff line Loading @@ -130,6 +130,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, void onExtrasRemoved(Call c, int source, List<String> keys); void onHandleChanged(Call call); void onCallerDisplayNameChanged(Call call); void onCallDirectionChanged(Call call); void onVideoStateChanged(Call call, int previousVideoState, int newVideoState); void onTargetPhoneAccountChanged(Call call); void onConnectionManagerPhoneAccountChanged(Call call); Loading Loading @@ -197,6 +198,8 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, @Override public void onCallerDisplayNameChanged(Call call) {} @Override public void onCallDirectionChanged(Call call) {} @Override public void onVideoStateChanged(Call call, int previousVideoState, int newVideoState) {} @Override public void onTargetPhoneAccountChanged(Call call) {} Loading Loading @@ -258,7 +261,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, /** * One of CALL_DIRECTION_INCOMING, CALL_DIRECTION_OUTGOING, or CALL_DIRECTION_UNKNOWN */ private final int mCallDirection; private int mCallDirection; /** * The post-dial digits that were dialed after the network portion of the number Loading Loading @@ -3631,6 +3634,24 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, } } /** * Change the call direction. This is useful if it was not previously defined (for example in * single caller emulation mode). * @param callDirection The new direction of this call. */ // Make sure the callDirection has been mapped to the Call definition correctly! public void setCallDirection(int callDirection) { if (mCallDirection != callDirection) { Log.addEvent(this, LogUtils.Events.CALL_DIRECTION_CHANGED, "callDirection=" + callDirection); mCallDirection = callDirection; for (Listener l : mListeners) { // Update InCallService directly, do not notify CallsManager. l.onCallDirectionChanged(this); } } } /** * Sets the video history based on the state and state transitions of the call. Always add the * current video state to the video state history during a call transition except for the Loading src/com/android/server/telecom/ConnectionServiceWrapper.java +30 −0 Original line number Diff line number Diff line Loading @@ -1084,6 +1084,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements if (mContext.checkCallingOrSelfPermission(MODIFY_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) { Log.w(this, "setConferenceState from caller without permission."); Log.endSession(); return; } Loading @@ -1103,6 +1104,35 @@ public class ConnectionServiceWrapper extends ServiceBinder implements Log.endSession(); } } @Override public void setCallDirection(String callId, int direction, Session.Info sessionInfo) { Log.startSession(sessionInfo, "CSW.sCD"); if (mContext.checkCallingOrSelfPermission(MODIFY_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) { Log.w(this, "setCallDirection from caller without permission."); Log.endSession(); return; } long token = Binder.clearCallingIdentity(); try { synchronized (mLock) { logIncoming("setCallDirection %s %d", callId, direction); Call call = mCallIdMapper.getCall(callId); if (call != null) { call.setCallDirection(Call.getRemappedCallDirection(direction)); } } } catch (Throwable t) { Log.e(ConnectionServiceWrapper.this, t, ""); throw t; } finally { Binder.restoreCallingIdentity(token); Log.endSession(); } } } private final Adapter mAdapter = new Adapter(); Loading src/com/android/server/telecom/InCallController.java +5 −0 Original line number Diff line number Diff line Loading @@ -801,6 +801,11 @@ public class InCallController extends CallsManagerListenerBase { updateCall(call); } @Override public void onCallDirectionChanged(Call call) { updateCall(call); } @Override public void onVideoStateChanged(Call call, int previousVideoState, int newVideoState) { updateCall(call); Loading src/com/android/server/telecom/LogUtils.java +1 −0 Original line number Diff line number Diff line Loading @@ -136,6 +136,7 @@ public class LogUtils { public static final String REMOVE_CHILD = "REMOVE_CHILD"; public static final String SET_PARENT = "SET_PARENT"; public static final String CONF_STATE_CHANGED = "CONF_STATE_CHANGED"; public static final String CALL_DIRECTION_CHANGED = "CALL_DIRECTION_CHANGED"; public static final String MUTE = "MUTE"; public static final String UNMUTE = "UNMUTE"; public static final String AUDIO_ROUTE = "AUDIO_ROUTE"; Loading src/com/android/server/telecom/TelecomServiceImpl.java +57 −1 Original line number Diff line number Diff line Loading @@ -20,8 +20,10 @@ import static android.Manifest.permission.CALL_PHONE; import static android.Manifest.permission.CALL_PRIVILEGED; import static android.Manifest.permission.DUMP; import static android.Manifest.permission.MODIFY_PHONE_STATE; import static android.Manifest.permission.READ_PHONE_NUMBERS; import static android.Manifest.permission.READ_PHONE_STATE; import static android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE; import static android.Manifest.permission.READ_SMS; import static android.Manifest.permission.REGISTER_SIM_SUBSCRIPTION; import static android.Manifest.permission.WRITE_SECURE_SETTINGS; Loading Loading @@ -54,6 +56,7 @@ import android.text.TextUtils; import android.util.EventLog; import com.android.internal.telecom.ITelecomService; import com.android.internal.telephony.TelephonyPermissions; import com.android.internal.util.IndentingPrintWriter; import com.android.server.telecom.components.UserCallIntentProcessorFactory; import com.android.server.telecom.settings.BlockedNumbersActivity; Loading Loading @@ -643,7 +646,7 @@ public class TelecomServiceImpl { String callingFeatureId) { try { Log.startSession("getL1N"); if (!canReadPhoneState(callingPackage, callingFeatureId, "getLine1Number")) { if (!canReadPhoneNumbers(callingPackage, callingFeatureId, "getLine1Number")) { return null; } Loading Loading @@ -2125,6 +2128,59 @@ public class TelecomServiceImpl { } } private boolean canReadPhoneNumbers(String callingPackage, String callingFeatureId, String message) { boolean targetSdkPreR = false; int uid = Binder.getCallingUid(); try { ApplicationInfo applicationInfo = mPackageManager.getApplicationInfoAsUser( callingPackage, 0, UserHandle.getUserHandleForUid(Binder.getCallingUid())); targetSdkPreR = applicationInfo != null && applicationInfo.targetSdkVersion < Build.VERSION_CODES.R; } catch (PackageManager.NameNotFoundException e) { // In the case that the PackageManager cannot find the specified calling package apply // the more restrictive target R+ requirements. } // Apps targeting pre-R can access phone numbers via READ_PHONE_STATE if (targetSdkPreR) { try { return canReadPhoneState(callingPackage, callingFeatureId, message); } catch (SecurityException e) { // Apps targeting pre-R can still access phone numbers via the additional checks // below. } } else { // The system/default dialer can always read phone state - so that emergency calls will // still work. if (isPrivilegedDialerCalling(callingPackage)) { return true; } if (mContext.checkCallingOrSelfPermission(READ_PRIVILEGED_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) { return true; } } if (mContext.checkCallingOrSelfPermission(READ_PHONE_NUMBERS) == PackageManager.PERMISSION_GRANTED && mAppOpsManager.noteOpNoThrow( AppOpsManager.OPSTR_READ_PHONE_NUMBERS, uid, callingPackage, callingFeatureId, message) == AppOpsManager.MODE_ALLOWED) { return true; } if (mContext.checkCallingOrSelfPermission(READ_SMS) == PackageManager.PERMISSION_GRANTED && mAppOpsManager.noteOpNoThrow(AppOpsManager.OPSTR_READ_SMS, uid, callingPackage, callingFeatureId, message) == AppOpsManager.MODE_ALLOWED) { return true; } // The default SMS app with the WRITE_SMS appop granted can access phone numbers. if (mAppOpsManager.noteOpNoThrow(AppOpsManager.OPSTR_WRITE_SMS, uid, callingPackage, callingFeatureId, message) == AppOpsManager.MODE_ALLOWED) { return true; } throw new SecurityException("Package " + callingPackage + " does not meet the requirements to access the phone number"); } private boolean canReadPrivilegedPhoneState(String callingPackage, String message) { // The system/default dialer can always read phone state - so that emergency calls will // still work. Loading Loading
src/com/android/server/telecom/Call.java +22 −1 Original line number Diff line number Diff line Loading @@ -130,6 +130,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, void onExtrasRemoved(Call c, int source, List<String> keys); void onHandleChanged(Call call); void onCallerDisplayNameChanged(Call call); void onCallDirectionChanged(Call call); void onVideoStateChanged(Call call, int previousVideoState, int newVideoState); void onTargetPhoneAccountChanged(Call call); void onConnectionManagerPhoneAccountChanged(Call call); Loading Loading @@ -197,6 +198,8 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, @Override public void onCallerDisplayNameChanged(Call call) {} @Override public void onCallDirectionChanged(Call call) {} @Override public void onVideoStateChanged(Call call, int previousVideoState, int newVideoState) {} @Override public void onTargetPhoneAccountChanged(Call call) {} Loading Loading @@ -258,7 +261,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, /** * One of CALL_DIRECTION_INCOMING, CALL_DIRECTION_OUTGOING, or CALL_DIRECTION_UNKNOWN */ private final int mCallDirection; private int mCallDirection; /** * The post-dial digits that were dialed after the network portion of the number Loading Loading @@ -3631,6 +3634,24 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, } } /** * Change the call direction. This is useful if it was not previously defined (for example in * single caller emulation mode). * @param callDirection The new direction of this call. */ // Make sure the callDirection has been mapped to the Call definition correctly! public void setCallDirection(int callDirection) { if (mCallDirection != callDirection) { Log.addEvent(this, LogUtils.Events.CALL_DIRECTION_CHANGED, "callDirection=" + callDirection); mCallDirection = callDirection; for (Listener l : mListeners) { // Update InCallService directly, do not notify CallsManager. l.onCallDirectionChanged(this); } } } /** * Sets the video history based on the state and state transitions of the call. Always add the * current video state to the video state history during a call transition except for the Loading
src/com/android/server/telecom/ConnectionServiceWrapper.java +30 −0 Original line number Diff line number Diff line Loading @@ -1084,6 +1084,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements if (mContext.checkCallingOrSelfPermission(MODIFY_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) { Log.w(this, "setConferenceState from caller without permission."); Log.endSession(); return; } Loading @@ -1103,6 +1104,35 @@ public class ConnectionServiceWrapper extends ServiceBinder implements Log.endSession(); } } @Override public void setCallDirection(String callId, int direction, Session.Info sessionInfo) { Log.startSession(sessionInfo, "CSW.sCD"); if (mContext.checkCallingOrSelfPermission(MODIFY_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) { Log.w(this, "setCallDirection from caller without permission."); Log.endSession(); return; } long token = Binder.clearCallingIdentity(); try { synchronized (mLock) { logIncoming("setCallDirection %s %d", callId, direction); Call call = mCallIdMapper.getCall(callId); if (call != null) { call.setCallDirection(Call.getRemappedCallDirection(direction)); } } } catch (Throwable t) { Log.e(ConnectionServiceWrapper.this, t, ""); throw t; } finally { Binder.restoreCallingIdentity(token); Log.endSession(); } } } private final Adapter mAdapter = new Adapter(); Loading
src/com/android/server/telecom/InCallController.java +5 −0 Original line number Diff line number Diff line Loading @@ -801,6 +801,11 @@ public class InCallController extends CallsManagerListenerBase { updateCall(call); } @Override public void onCallDirectionChanged(Call call) { updateCall(call); } @Override public void onVideoStateChanged(Call call, int previousVideoState, int newVideoState) { updateCall(call); Loading
src/com/android/server/telecom/LogUtils.java +1 −0 Original line number Diff line number Diff line Loading @@ -136,6 +136,7 @@ public class LogUtils { public static final String REMOVE_CHILD = "REMOVE_CHILD"; public static final String SET_PARENT = "SET_PARENT"; public static final String CONF_STATE_CHANGED = "CONF_STATE_CHANGED"; public static final String CALL_DIRECTION_CHANGED = "CALL_DIRECTION_CHANGED"; public static final String MUTE = "MUTE"; public static final String UNMUTE = "UNMUTE"; public static final String AUDIO_ROUTE = "AUDIO_ROUTE"; Loading
src/com/android/server/telecom/TelecomServiceImpl.java +57 −1 Original line number Diff line number Diff line Loading @@ -20,8 +20,10 @@ import static android.Manifest.permission.CALL_PHONE; import static android.Manifest.permission.CALL_PRIVILEGED; import static android.Manifest.permission.DUMP; import static android.Manifest.permission.MODIFY_PHONE_STATE; import static android.Manifest.permission.READ_PHONE_NUMBERS; import static android.Manifest.permission.READ_PHONE_STATE; import static android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE; import static android.Manifest.permission.READ_SMS; import static android.Manifest.permission.REGISTER_SIM_SUBSCRIPTION; import static android.Manifest.permission.WRITE_SECURE_SETTINGS; Loading Loading @@ -54,6 +56,7 @@ import android.text.TextUtils; import android.util.EventLog; import com.android.internal.telecom.ITelecomService; import com.android.internal.telephony.TelephonyPermissions; import com.android.internal.util.IndentingPrintWriter; import com.android.server.telecom.components.UserCallIntentProcessorFactory; import com.android.server.telecom.settings.BlockedNumbersActivity; Loading Loading @@ -643,7 +646,7 @@ public class TelecomServiceImpl { String callingFeatureId) { try { Log.startSession("getL1N"); if (!canReadPhoneState(callingPackage, callingFeatureId, "getLine1Number")) { if (!canReadPhoneNumbers(callingPackage, callingFeatureId, "getLine1Number")) { return null; } Loading Loading @@ -2125,6 +2128,59 @@ public class TelecomServiceImpl { } } private boolean canReadPhoneNumbers(String callingPackage, String callingFeatureId, String message) { boolean targetSdkPreR = false; int uid = Binder.getCallingUid(); try { ApplicationInfo applicationInfo = mPackageManager.getApplicationInfoAsUser( callingPackage, 0, UserHandle.getUserHandleForUid(Binder.getCallingUid())); targetSdkPreR = applicationInfo != null && applicationInfo.targetSdkVersion < Build.VERSION_CODES.R; } catch (PackageManager.NameNotFoundException e) { // In the case that the PackageManager cannot find the specified calling package apply // the more restrictive target R+ requirements. } // Apps targeting pre-R can access phone numbers via READ_PHONE_STATE if (targetSdkPreR) { try { return canReadPhoneState(callingPackage, callingFeatureId, message); } catch (SecurityException e) { // Apps targeting pre-R can still access phone numbers via the additional checks // below. } } else { // The system/default dialer can always read phone state - so that emergency calls will // still work. if (isPrivilegedDialerCalling(callingPackage)) { return true; } if (mContext.checkCallingOrSelfPermission(READ_PRIVILEGED_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) { return true; } } if (mContext.checkCallingOrSelfPermission(READ_PHONE_NUMBERS) == PackageManager.PERMISSION_GRANTED && mAppOpsManager.noteOpNoThrow( AppOpsManager.OPSTR_READ_PHONE_NUMBERS, uid, callingPackage, callingFeatureId, message) == AppOpsManager.MODE_ALLOWED) { return true; } if (mContext.checkCallingOrSelfPermission(READ_SMS) == PackageManager.PERMISSION_GRANTED && mAppOpsManager.noteOpNoThrow(AppOpsManager.OPSTR_READ_SMS, uid, callingPackage, callingFeatureId, message) == AppOpsManager.MODE_ALLOWED) { return true; } // The default SMS app with the WRITE_SMS appop granted can access phone numbers. if (mAppOpsManager.noteOpNoThrow(AppOpsManager.OPSTR_WRITE_SMS, uid, callingPackage, callingFeatureId, message) == AppOpsManager.MODE_ALLOWED) { return true; } throw new SecurityException("Package " + callingPackage + " does not meet the requirements to access the phone number"); } private boolean canReadPrivilegedPhoneState(String callingPackage, String message) { // The system/default dialer can always read phone state - so that emergency calls will // still work. Loading