Ask for record audio permission when calibrating echo canceller from the settings
This commit is contained in:
parent
ee19177a0c
commit
e5baec4d20
2 changed files with 60 additions and 30 deletions
|
@ -104,6 +104,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
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 final int PERMISSIONS_REQUEST_CONTACTS = 208;
|
||||||
|
private static final int PERMISSIONS_RECORD_AUDIO_ECHO_CANCELLER = 209;
|
||||||
|
|
||||||
private static LinphoneActivity instance;
|
private static LinphoneActivity instance;
|
||||||
|
|
||||||
|
@ -114,6 +115,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
private RelativeLayout mTopBar;
|
private RelativeLayout mTopBar;
|
||||||
private ImageView cancel;
|
private ImageView cancel;
|
||||||
private FragmentsAvailable pendingFragmentTransaction, currentFragment, nextFragment;
|
private FragmentsAvailable pendingFragmentTransaction, currentFragment, nextFragment;
|
||||||
|
private Fragment fragment;
|
||||||
private List<FragmentsAvailable> fragmentsHistory;
|
private List<FragmentsAvailable> fragmentsHistory;
|
||||||
private Fragment.SavedState dialerSavedState;
|
private Fragment.SavedState dialerSavedState;
|
||||||
private boolean newProxyConfig;
|
private boolean newProxyConfig;
|
||||||
|
@ -346,69 +348,69 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Fragment newFragment = null;
|
fragment = null;
|
||||||
|
|
||||||
switch (newFragmentType) {
|
switch (newFragmentType) {
|
||||||
case HISTORY_LIST:
|
case HISTORY_LIST:
|
||||||
newFragment = new HistoryListFragment();
|
fragment = new HistoryListFragment();
|
||||||
if (isTablet()) {
|
if (isTablet()) {
|
||||||
((HistoryListFragment) newFragment).displayFirstLog();
|
((HistoryListFragment) fragment).displayFirstLog();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HISTORY_DETAIL:
|
case HISTORY_DETAIL:
|
||||||
newFragment = new HistoryDetailFragment();
|
fragment = new HistoryDetailFragment();
|
||||||
break;
|
break;
|
||||||
case CONTACTS_LIST:
|
case CONTACTS_LIST:
|
||||||
checkAndRequestReadContactsPermission();
|
checkAndRequestReadContactsPermission();
|
||||||
newFragment = new ContactsListFragment();
|
fragment = new ContactsListFragment();
|
||||||
if (isTablet()) {
|
if (isTablet()) {
|
||||||
((ContactsListFragment) newFragment).displayFirstContact();
|
((ContactsListFragment) fragment).displayFirstContact();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CONTACT_DETAIL:
|
case CONTACT_DETAIL:
|
||||||
newFragment = new ContactDetailsFragment();
|
fragment = new ContactDetailsFragment();
|
||||||
break;
|
break;
|
||||||
case CONTACT_EDITOR:
|
case CONTACT_EDITOR:
|
||||||
newFragment = new ContactEditorFragment();
|
fragment = new ContactEditorFragment();
|
||||||
break;
|
break;
|
||||||
case DIALER:
|
case DIALER:
|
||||||
newFragment = new DialerFragment();
|
fragment = new DialerFragment();
|
||||||
if (extras == null) {
|
if (extras == null) {
|
||||||
newFragment.setInitialSavedState(dialerSavedState);
|
fragment.setInitialSavedState(dialerSavedState);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SETTINGS:
|
case SETTINGS:
|
||||||
newFragment = new SettingsFragment();
|
fragment = new SettingsFragment();
|
||||||
break;
|
break;
|
||||||
case ACCOUNT_SETTINGS:
|
case ACCOUNT_SETTINGS:
|
||||||
newFragment = new AccountPreferencesFragment();
|
fragment = new AccountPreferencesFragment();
|
||||||
break;
|
break;
|
||||||
case ABOUT:
|
case ABOUT:
|
||||||
newFragment = new AboutFragment();
|
fragment = new AboutFragment();
|
||||||
break;
|
break;
|
||||||
case EMPTY:
|
case EMPTY:
|
||||||
newFragment = new EmptyFragment();
|
fragment = new EmptyFragment();
|
||||||
break;
|
break;
|
||||||
case CHAT_LIST:
|
case CHAT_LIST:
|
||||||
newFragment = new ChatListFragment();
|
fragment = new ChatListFragment();
|
||||||
if (isTablet()) {
|
if (isTablet()) {
|
||||||
((ChatListFragment) newFragment).displayFirstChat();
|
((ChatListFragment) fragment).displayFirstChat();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CHAT:
|
case CHAT:
|
||||||
newFragment = new ChatFragment();
|
fragment = new ChatFragment();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newFragment != null) {
|
if (fragment != null) {
|
||||||
newFragment.setArguments(extras);
|
fragment.setArguments(extras);
|
||||||
if (isTablet()) {
|
if (isTablet()) {
|
||||||
changeFragmentForTablets(newFragment, newFragmentType, withoutAnimation);
|
changeFragmentForTablets(fragment, newFragmentType, withoutAnimation);
|
||||||
} else {
|
} else {
|
||||||
changeFragment(newFragment, newFragmentType, withoutAnimation);
|
changeFragment(fragment, newFragmentType, withoutAnimation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1186,6 +1188,10 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
checkAndRequestPermission(Manifest.permission.WRITE_CONTACTS, 0);
|
checkAndRequestPermission(Manifest.permission.WRITE_CONTACTS, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkAndRequestRecordAudioPermissionForEchoCanceller() {
|
||||||
|
checkAndRequestPermission(Manifest.permission.RECORD_AUDIO, PERMISSIONS_RECORD_AUDIO_ECHO_CANCELLER);
|
||||||
|
}
|
||||||
|
|
||||||
public void checkAndRequestPermissionsToSendImage() {
|
public void checkAndRequestPermissionsToSendImage() {
|
||||||
ArrayList<String> permissionsList = new ArrayList<String>();
|
ArrayList<String> permissionsList = new ArrayList<String>();
|
||||||
|
|
||||||
|
@ -1250,6 +1256,13 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
fetchedContactsOnce = true;
|
fetchedContactsOnce = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case PERMISSIONS_RECORD_AUDIO_ECHO_CANCELLER:
|
||||||
|
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
((SettingsFragment) fragment).startEchoCancellerCalibration();
|
||||||
|
} else {
|
||||||
|
((SettingsFragment) fragment).echoCalibrationFail();
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,9 @@ import org.linphone.purchase.InAppPurchaseActivity;
|
||||||
import org.linphone.ui.LedPreference;
|
import org.linphone.ui.LedPreference;
|
||||||
import org.linphone.ui.PreferencesListFragment;
|
import org.linphone.ui.PreferencesListFragment;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
|
@ -73,7 +75,7 @@ public class SettingsFragment extends PreferencesListFragment {
|
||||||
setListeners();
|
setListeners();
|
||||||
hideSettings();
|
hideSettings();
|
||||||
|
|
||||||
mListener = new LinphoneCoreListenerBase(){
|
mListener = new LinphoneCoreListenerBase() {
|
||||||
@Override
|
@Override
|
||||||
public void ecCalibrationStatus(LinphoneCore lc, final EcCalibratorStatus status, final int delayMs, Object data) {
|
public void ecCalibrationStatus(LinphoneCore lc, final EcCalibratorStatus status, final int delayMs, Object data) {
|
||||||
LinphoneManager.getInstance().routeAudioToReceiver();
|
LinphoneManager.getInstance().routeAudioToReceiver();
|
||||||
|
@ -99,7 +101,7 @@ public class SettingsFragment extends PreferencesListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removePreviousPreferencesFile() {
|
private void removePreviousPreferencesFile() {
|
||||||
File dir = new File(LinphoneActivity.instance().getFilesDir().getAbsolutePath() + "shared_prefs");
|
File dir = new File(getContext().getFilesDir().getAbsolutePath() + "shared_prefs");
|
||||||
dir.delete();
|
dir.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,17 +575,32 @@ public class SettingsFragment extends PreferencesListFragment {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
synchronized (SettingsFragment.this) {
|
synchronized (SettingsFragment.this) {
|
||||||
try {
|
preference.setSummary(R.string.ec_calibrating);
|
||||||
LinphoneManager.getInstance().startEcCalibration(mListener);
|
|
||||||
preference.setSummary(R.string.ec_calibrating);
|
int recordAudio = getContext().getPackageManager().checkPermission(Manifest.permission.RECORD_AUDIO, getContext().getPackageName());
|
||||||
} catch (LinphoneCoreException e) {
|
if (recordAudio == PackageManager.PERMISSION_GRANTED) {
|
||||||
Log.w(e, "Cannot calibrate EC");
|
startEchoCancellerCalibration();
|
||||||
|
} else {
|
||||||
|
LinphoneActivity.instance().checkAndRequestRecordAudioPermissionForEchoCanceller();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void startEchoCancellerCalibration() {
|
||||||
|
try {
|
||||||
|
LinphoneManager.getInstance().startEcCalibration(mListener);
|
||||||
|
} catch (LinphoneCoreException e) {
|
||||||
|
Log.e(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void echoCalibrationFail() {
|
||||||
|
Preference echoCancellerCalibration = findPreference(getString(R.string.pref_echo_canceller_calibration_key));
|
||||||
|
echoCancellerCalibration.setSummary(R.string.failed);
|
||||||
|
}
|
||||||
|
|
||||||
private void initVideoSettings() {
|
private void initVideoSettings() {
|
||||||
initializePreferredVideoSizePreferences((ListPreference) findPreference(getString(R.string.pref_preferred_video_size_key)));
|
initializePreferredVideoSizePreferences((ListPreference) findPreference(getString(R.string.pref_preferred_video_size_key)));
|
||||||
|
|
Loading…
Reference in a new issue