Fix permissions loops when asking for record audio, camera or contacts
This commit is contained in:
parent
4b00bfcb55
commit
bb070b3665
3 changed files with 27 additions and 12 deletions
|
@ -97,7 +97,6 @@
|
||||||
|
|
||||||
<activity android:name=".CallIncomingActivity"
|
<activity android:name=".CallIncomingActivity"
|
||||||
android:theme="@style/NoTitle"
|
android:theme="@style/NoTitle"
|
||||||
android:noHistory="true"
|
|
||||||
android:launchMode="singleTop"
|
android:launchMode="singleTop"
|
||||||
android:screenOrientation="behind">
|
android:screenOrientation="behind">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
@ -107,7 +106,6 @@
|
||||||
|
|
||||||
<activity android:name=".CallOutgoingActivity"
|
<activity android:name=".CallOutgoingActivity"
|
||||||
android:theme="@style/NoTitle"
|
android:theme="@style/NoTitle"
|
||||||
android:noHistory="true"
|
|
||||||
android:launchMode="singleTop"
|
android:launchMode="singleTop"
|
||||||
android:screenOrientation="behind">
|
android:screenOrientation="behind">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
|
|
@ -236,7 +236,7 @@ public class ContactsManager extends ContentObserver {
|
||||||
public List<LinphoneContact> fetchContactsAsync() {
|
public List<LinphoneContact> fetchContactsAsync() {
|
||||||
List<LinphoneContact> contacts = new ArrayList<LinphoneContact>();
|
List<LinphoneContact> contacts = new ArrayList<LinphoneContact>();
|
||||||
|
|
||||||
if (mAccount != null && hasContactsAccess()) {
|
if (hasContactsAccess()) {
|
||||||
Cursor c = Compatibility.getContactsCursor(contentResolver, null);
|
Cursor c = Compatibility.getContactsCursor(contentResolver, null);
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
while (c.moveToNext()) {
|
while (c.moveToNext()) {
|
||||||
|
|
|
@ -105,6 +105,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
private static final int CALL_ACTIVITY = 19;
|
private static final int CALL_ACTIVITY = 19;
|
||||||
private static final int PERMISSIONS_REQUEST_OVERLAY = 206;
|
private static final int PERMISSIONS_REQUEST_OVERLAY = 206;
|
||||||
private static final int PERMISSIONS_REQUEST_SYNC = 207;
|
private static final int PERMISSIONS_REQUEST_SYNC = 207;
|
||||||
|
private static final int PERMISSIONS_REQUEST_CONTACTS = 208;
|
||||||
|
|
||||||
private static LinphoneActivity instance;
|
private static LinphoneActivity instance;
|
||||||
|
|
||||||
|
@ -353,6 +354,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
newFragment = new HistoryDetailFragment();
|
newFragment = new HistoryDetailFragment();
|
||||||
break;
|
break;
|
||||||
case CONTACTS_LIST:
|
case CONTACTS_LIST:
|
||||||
|
checkAndRequestReadContactsPermission();
|
||||||
newFragment = new ContactsListFragment();
|
newFragment = new ContactsListFragment();
|
||||||
if (isTablet()) {
|
if (isTablet()) {
|
||||||
((ContactsListFragment) newFragment).displayFirstContact();
|
((ContactsListFragment) newFragment).displayFirstContact();
|
||||||
|
@ -1171,7 +1173,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkAndRequestReadContactsPermission() {
|
public void checkAndRequestReadContactsPermission() {
|
||||||
checkAndRequestPermission(Manifest.permission.READ_CONTACTS, 0);
|
checkAndRequestPermission(Manifest.permission.READ_CONTACTS, PERMISSIONS_REQUEST_CONTACTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkAndRequestWriteContactsPermission() {
|
public void checkAndRequestWriteContactsPermission() {
|
||||||
|
@ -1235,6 +1237,29 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
ContactsManager.getInstance().initializeContactManager(getApplicationContext(), getContentResolver());
|
ContactsManager.getInstance().initializeContactManager(getApplicationContext(), getContentResolver());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case PERMISSIONS_REQUEST_CONTACTS:
|
||||||
|
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
ContactsManager.getInstance().enableContactsAccess();
|
||||||
|
ContactsManager.getInstance().fetchContacts();
|
||||||
|
fetchedContactsOnce = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
|
||||||
|
int contacts = getPackageManager().checkPermission(Manifest.permission.READ_CONTACTS, getPackageName());
|
||||||
|
Log.i("[Permission] Contacts permission is " + (contacts == PackageManager.PERMISSION_GRANTED ? "granted" : "denied"));
|
||||||
|
|
||||||
|
if (contacts == PackageManager.PERMISSION_GRANTED && !fetchedContactsOnce) {
|
||||||
|
ContactsManager.getInstance().enableContactsAccess();
|
||||||
|
ContactsManager.getInstance().fetchContacts();
|
||||||
|
fetchedContactsOnce = true;
|
||||||
|
} else {
|
||||||
|
checkAndRequestReadContactsPermission();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1251,14 +1276,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
lc.addListener(mListener);
|
lc.addListener(mListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getPackageManager().checkPermission(Manifest.permission.READ_CONTACTS, getPackageName()) == PackageManager.PERMISSION_GRANTED && !fetchedContactsOnce) {
|
|
||||||
ContactsManager.getInstance().enableContactsAccess();
|
|
||||||
ContactsManager.getInstance().fetchContacts();
|
|
||||||
fetchedContactsOnce = true;
|
|
||||||
} else {
|
|
||||||
checkAndRequestReadContactsPermission();
|
|
||||||
}
|
|
||||||
|
|
||||||
refreshAccounts();
|
refreshAccounts();
|
||||||
|
|
||||||
updateMissedChatCount();
|
updateMissedChatCount();
|
||||||
|
|
Loading…
Reference in a new issue