Ask for READ_PHONE_STATE permission when starting LinphoneActivity (used to detect GSM calls and pause SIP calls)
This commit is contained in:
parent
0425c1bc33
commit
ca4f078b9e
3 changed files with 24 additions and 10 deletions
|
@ -24,7 +24,6 @@ import java.util.List;
|
||||||
import org.linphone.core.LinphoneAddress;
|
import org.linphone.core.LinphoneAddress;
|
||||||
import org.linphone.core.LinphoneCall;
|
import org.linphone.core.LinphoneCall;
|
||||||
import org.linphone.core.LinphoneCall.State;
|
import org.linphone.core.LinphoneCall.State;
|
||||||
import org.linphone.core.LinphoneCallParams;
|
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCoreListenerBase;
|
import org.linphone.core.LinphoneCoreListenerBase;
|
||||||
import org.linphone.core.Reason;
|
import org.linphone.core.Reason;
|
||||||
|
|
|
@ -1140,6 +1140,10 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkAndRequestReadPhoneStatePermission() {
|
||||||
|
checkAndRequestPermission(Manifest.permission.READ_PHONE_STATE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
public void checkAndRequestReadExternalStoragePermission() {
|
public void checkAndRequestReadExternalStoragePermission() {
|
||||||
checkAndRequestPermission(Manifest.permission.READ_EXTERNAL_STORAGE, 0);
|
checkAndRequestPermission(Manifest.permission.READ_EXTERNAL_STORAGE, 0);
|
||||||
}
|
}
|
||||||
|
@ -1237,6 +1241,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
ContactsManager.getInstance().enableContactsAccess();
|
ContactsManager.getInstance().enableContactsAccess();
|
||||||
}
|
}
|
||||||
|
checkAndRequestReadPhoneStatePermission();
|
||||||
ContactsManager.getInstance().fetchContactsAsync();
|
ContactsManager.getInstance().fetchContactsAsync();
|
||||||
fetchedContactsOnce = true;
|
fetchedContactsOnce = true;
|
||||||
break;
|
break;
|
||||||
|
@ -1264,15 +1269,26 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
int contacts = getPackageManager().checkPermission(Manifest.permission.READ_CONTACTS, getPackageName());
|
int contacts = getPackageManager().checkPermission(Manifest.permission.READ_CONTACTS, getPackageName());
|
||||||
Log.i("[Permission] Contacts permission is " + (contacts == PackageManager.PERMISSION_GRANTED ? "granted" : "denied"));
|
Log.i("[Permission] Contacts permission is " + (contacts == PackageManager.PERMISSION_GRANTED ? "granted" : "denied"));
|
||||||
|
|
||||||
if (contacts == PackageManager.PERMISSION_GRANTED && !fetchedContactsOnce) {
|
int readPhone = getPackageManager().checkPermission(Manifest.permission.READ_PHONE_STATE, getPackageName());
|
||||||
ContactsManager.getInstance().enableContactsAccess();
|
Log.i("[Permission] Read phone state permission is " + (readPhone == PackageManager.PERMISSION_GRANTED ? "granted" : "denied"));
|
||||||
ContactsManager.getInstance().fetchContactsAsync();
|
|
||||||
fetchedContactsOnce = true;
|
if (contacts == PackageManager.PERMISSION_GRANTED) {
|
||||||
} else if (contacts != PackageManager.PERMISSION_GRANTED && !willContactsPermissionBeAsked()) {
|
if (readPhone == PackageManager.PERMISSION_DENIED) {
|
||||||
ContactsManager.getInstance().fetchContactsAsync();
|
checkAndRequestReadPhoneStatePermission();
|
||||||
fetchedContactsOnce = true;
|
}
|
||||||
|
if (!fetchedContactsOnce) {
|
||||||
|
ContactsManager.getInstance().enableContactsAccess();
|
||||||
|
ContactsManager.getInstance().fetchContactsAsync();
|
||||||
|
fetchedContactsOnce = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
checkAndRequestReadContactsPermission();
|
if (!willContactsPermissionBeAsked()) {
|
||||||
|
ContactsManager.getInstance().fetchContactsAsync();
|
||||||
|
fetchedContactsOnce = true;
|
||||||
|
checkAndRequestReadPhoneStatePermission();
|
||||||
|
} else {
|
||||||
|
checkAndRequestReadContactsPermission(); // This will ask for Read_Phone_State permission on it's cb
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,6 @@ import org.linphone.core.PublishState;
|
||||||
import org.linphone.core.SubscriptionState;
|
import org.linphone.core.SubscriptionState;
|
||||||
import org.linphone.core.TunnelConfig;
|
import org.linphone.core.TunnelConfig;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
import org.linphone.mediastream.MediastreamerAndroidContext;
|
|
||||||
import org.linphone.mediastream.Version;
|
import org.linphone.mediastream.Version;
|
||||||
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
||||||
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration.AndroidCamera;
|
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration.AndroidCamera;
|
||||||
|
|
Loading…
Reference in a new issue