Compare commits

..

3 commits

Author SHA1 Message Date
Peter Cai bb281ab7e0 do not use Dialer UI for incoming calls if audio permission is not granted
We cannot request new permissions when Dialer UI is shown. For incoming
calls, if the Dialer UI is displayed over keyguard, then the user may
not even be able to see the permission notifications that we use for
outgoing calls.

If we just do not use the Dialer UI when the permission is not granted,
it is at most a minor annoyance for the first time. After the user has
accepted an incoming call even just once, the permission will be
granted, and the Dialer integration will start to work just fine.
2022-03-11 22:04:58 -05:00
Peter Cai 729b86a2fc ConnectionService: miscellaneous fixes
* Fix a few potential errors due to the use of newer APIs (minSDK is
  still only 24)
* Fix one remaining case of raw usage of generic types.
2022-03-11 22:04:32 -05:00
Peter Cai 0cd0678921 ConnectionService: Dialer UI integration for incoming calls 2022-03-11 22:04:29 -05:00
2 changed files with 10 additions and 12 deletions

View file

@ -68,17 +68,8 @@ public class ConnectionService extends android.telecom.ConnectionService {
}
};
private PermissionManager mPermissionManager;
@Override
public void onCreate() {
mPermissionManager = PermissionManager.getInstance(this);
mPermissionManager.setNotificationSettings(
new NotificationSettings.Builder()
.withMessage(R.string.microphone_permission_for_call)
.withSmallIcon(R.drawable.ic_notification).build()
);
// From XmppActivity.connectToBackend
Intent intent = new Intent(this, XmppConnectionService.class);
intent.setAction("ui");
@ -124,9 +115,16 @@ public class ConnectionService extends android.telecom.ConnectionService {
Jid with = Jid.ofLocalAndDomain(tel, gateway[1]);
CheogramConnection connection = new CheogramConnection(account, with, postDial);
PermissionManager permissionManager = PermissionManager.getInstance(this);
permissionManager.setNotificationSettings(
new NotificationSettings.Builder()
.withMessage(R.string.microphone_permission_for_call)
.withSmallIcon(R.drawable.ic_notification).build()
);
Set<String> permissions = new HashSet<>();
permissions.add(Manifest.permission.RECORD_AUDIO);
mPermissionManager.checkPermissions(permissions, new PermissionManager.PermissionRequestListener() {
permissionManager.checkPermissions(permissions, new PermissionManager.PermissionRequestListener() {
@Override
public void onPermissionGranted() {
connection.setSessionId(xmppConnectionService.getJingleConnectionManager().proposeJingleRtpSession(

View file

@ -467,8 +467,8 @@ public class NotificationService {
try {
telecomManager.addNewIncomingCall(handle, callInfo);
} catch (SecurityException e) {
// There *could* be race conditions where the account is not registered yet
// when an incoming call is already received
// If the account is not registered or enabled, it could result in a security exception
// Just fall back to the built-in UI in this case.
Log.w(Config.LOGTAG, e);
return false;
}