Ask for record audio permission in assistant only if going to calibrate echo canceller
This commit is contained in:
parent
271b444abc
commit
66877d552e
2 changed files with 24 additions and 17 deletions
|
@ -239,7 +239,7 @@ public class SettingsFragment extends PreferencesListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPreferenceDefaultValueAndSummary(int pref, String value) {
|
private void setPreferenceDefaultValueAndSummary(int pref, String value) {
|
||||||
if(value != null) {
|
if (value != null) {
|
||||||
EditTextPreference etPref = (EditTextPreference) findPreference(getString(pref));
|
EditTextPreference etPref = (EditTextPreference) findPreference(getString(pref));
|
||||||
etPref.setText(value);
|
etPref.setText(value);
|
||||||
etPref.setSummary(value);
|
etPref.setSummary(value);
|
||||||
|
|
|
@ -112,7 +112,7 @@ private static AssistantActivity instance;
|
||||||
if (state == RegistrationState.RegistrationOk) {
|
if (state == RegistrationState.RegistrationOk) {
|
||||||
if (progress != null) progress.dismiss();
|
if (progress != null) progress.dismiss();
|
||||||
if (LinphoneManager.getLc().getDefaultProxyConfig() != null) {
|
if (LinphoneManager.getLc().getDefaultProxyConfig() != null) {
|
||||||
launchEchoCancellerCalibration(true);
|
success();
|
||||||
}
|
}
|
||||||
} else if (state == RegistrationState.RegistrationFailed) {
|
} else if (state == RegistrationState.RegistrationFailed) {
|
||||||
if (progress != null) progress.dismiss();
|
if (progress != null) progress.dismiss();
|
||||||
|
@ -252,26 +252,24 @@ private static AssistantActivity instance;
|
||||||
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
launchEchoCancellerCalibration(true);
|
launchEchoCancellerCalibration(true);
|
||||||
} else {
|
} else {
|
||||||
success();
|
goToLinphoneActivity();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
success();
|
goToLinphoneActivity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void launchEchoCancellerCalibration(boolean sendEcCalibrationResult) {
|
private void launchEchoCancellerCalibration(boolean sendEcCalibrationResult) {
|
||||||
if (getPackageManager().checkPermission(Manifest.permission.RECORD_AUDIO, getPackageName()) == PackageManager.PERMISSION_GRANTED) {
|
int recordAudio = getPackageManager().checkPermission(Manifest.permission.RECORD_AUDIO, getPackageName());
|
||||||
boolean needsEchoCalibration = LinphoneManager.getLc().needsEchoCalibration();
|
Log.i("[Permission] Record audio permission is " + (recordAudio == PackageManager.PERMISSION_GRANTED ? "granted" : "denied"));
|
||||||
if (needsEchoCalibration && mPrefs.isFirstLaunch()) {
|
|
||||||
EchoCancellerCalibrationFragment fragment = new EchoCancellerCalibrationFragment();
|
if (recordAudio == PackageManager.PERMISSION_GRANTED) {
|
||||||
fragment.enableEcCalibrationResultSending(sendEcCalibrationResult);
|
EchoCancellerCalibrationFragment fragment = new EchoCancellerCalibrationFragment();
|
||||||
changeFragment(fragment);
|
fragment.enableEcCalibrationResultSending(sendEcCalibrationResult);
|
||||||
currentFragment = AssistantFragmentsEnum.ECHO_CANCELLER_CALIBRATION;
|
changeFragment(fragment);
|
||||||
back.setVisibility(View.VISIBLE);
|
currentFragment = AssistantFragmentsEnum.ECHO_CANCELLER_CALIBRATION;
|
||||||
cancel.setEnabled(false);
|
back.setVisibility(View.VISIBLE);
|
||||||
} else {
|
cancel.setEnabled(false);
|
||||||
success();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
checkAndRequestAudioPermission();
|
checkAndRequestAudioPermission();
|
||||||
}
|
}
|
||||||
|
@ -494,7 +492,7 @@ private static AssistantActivity instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void isEchoCalibrationFinished() {
|
public void isEchoCalibrationFinished() {
|
||||||
success();
|
goToLinphoneActivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dialog createErrorDialog(LinphoneProxyConfig proxy, String message){
|
public Dialog createErrorDialog(LinphoneProxyConfig proxy, String message){
|
||||||
|
@ -521,6 +519,15 @@ private static AssistantActivity instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void success() {
|
public void success() {
|
||||||
|
boolean needsEchoCalibration = LinphoneManager.getLc().needsEchoCalibration();
|
||||||
|
if (needsEchoCalibration && mPrefs.isFirstLaunch()) {
|
||||||
|
launchEchoCancellerCalibration(true);
|
||||||
|
} else {
|
||||||
|
goToLinphoneActivity();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void goToLinphoneActivity() {
|
||||||
mPrefs.firstLaunchSuccessful();
|
mPrefs.firstLaunchSuccessful();
|
||||||
startActivity(new Intent().setClass(this, LinphoneActivity.class).putExtra("isNewProxyConfig", true));
|
startActivity(new Intent().setClass(this, LinphoneActivity.class).putExtra("isNewProxyConfig", true));
|
||||||
finish();
|
finish();
|
||||||
|
|
Loading…
Reference in a new issue