Fixes from play store reported crashes
This commit is contained in:
parent
f88c3e3159
commit
937b9b8503
12 changed files with 66 additions and 29 deletions
|
@ -25,6 +25,7 @@ import android.app.Fragment;
|
|||
import android.app.FragmentManager;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.app.KeyguardManager;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
|
@ -550,9 +551,11 @@ public abstract class MainActivity extends LinphoneGenericActivity
|
|||
if (permissions[i].equals(Manifest.permission.READ_CONTACTS)
|
||||
|| permissions[i].equals(Manifest.permission.WRITE_CONTACTS)) {
|
||||
if (grantResults[i] == PackageManager.PERMISSION_GRANTED) {
|
||||
if (LinphoneContext.isReady()) {
|
||||
ContactsManager.getInstance().enableContactsAccess();
|
||||
ContactsManager.getInstance().initializeContactManager();
|
||||
}
|
||||
}
|
||||
} else if (permissions[i].equals(Manifest.permission.READ_EXTERNAL_STORAGE)) {
|
||||
boolean enableRingtone = grantResults[i] == PackageManager.PERMISSION_GRANTED;
|
||||
LinphonePreferences.instance().enableDeviceRingtone(enableRingtone);
|
||||
|
@ -778,8 +781,13 @@ public abstract class MainActivity extends LinphoneGenericActivity
|
|||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
try {
|
||||
startActivity(
|
||||
new Intent("android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS"));
|
||||
new Intent(
|
||||
"android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS"));
|
||||
} catch (ActivityNotFoundException anfe) {
|
||||
Log.e("[Main Activity] Activity not found exception: ", anfe);
|
||||
}
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -40,6 +40,7 @@ import android.view.KeyEvent;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.compatibility.Compatibility;
|
||||
|
@ -438,7 +439,7 @@ public class AndroidAudioManager {
|
|||
public synchronized void bluetoothHeadetConnectionChanged(boolean connected) {
|
||||
mIsBluetoothHeadsetConnected = connected;
|
||||
mAudioManager.setBluetoothScoOn(connected);
|
||||
LinphoneManager.getCallManager().refreshInCallActions();
|
||||
if (LinphoneContext.isReady()) LinphoneManager.getCallManager().refreshInCallActions();
|
||||
}
|
||||
|
||||
public synchronized void bluetoothHeadetAudioConnectionChanged(boolean connected) {
|
||||
|
@ -452,7 +453,7 @@ public class AndroidAudioManager {
|
|||
|
||||
public synchronized void bluetoothHeadetScoConnectionChanged(boolean connected) {
|
||||
mIsBluetoothHeadsetScoConnected = connected;
|
||||
LinphoneManager.getCallManager().refreshInCallActions();
|
||||
if (LinphoneContext.isReady()) LinphoneManager.getCallManager().refreshInCallActions();
|
||||
}
|
||||
|
||||
public synchronized boolean isUsingBluetoothAudioRoute() {
|
||||
|
|
|
@ -487,7 +487,7 @@ public class CallActivity extends LinphoneGenericActivity
|
|||
finish();
|
||||
}
|
||||
|
||||
LinphoneService.instance().destroyOverlay();
|
||||
if (LinphoneService.isReady()) LinphoneService.instance().destroyOverlay();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -502,7 +502,7 @@ public class CallActivity extends LinphoneGenericActivity
|
|||
Call call = core.getCurrentCall();
|
||||
if (call.getState() == Call.State.StreamsRunning) {
|
||||
// Prevent overlay creation if video call is paused by remote
|
||||
LinphoneService.instance().createOverlay();
|
||||
if (LinphoneService.isReady()) LinphoneService.instance().createOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -122,15 +122,8 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
|
|||
@Override
|
||||
public void onCallStateChanged(
|
||||
Core core, Call call, State state, String message) {
|
||||
if (call == mCall) {
|
||||
if (state == State.Connected) {
|
||||
// This is done by the LinphoneContext listener now
|
||||
// startActivity(new Intent(CallOutgoingActivity.this,
|
||||
// CallActivity.class));
|
||||
}
|
||||
}
|
||||
|
||||
if (state == State.End || state == State.Released) {
|
||||
mCall = null;
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
@ -176,7 +169,7 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
|
|||
mNumber.setText(address.asStringUriOnly());
|
||||
|
||||
if (LinphonePreferences.instance().acceptIncomingEarlyMedia()) {
|
||||
if (mCall.getCurrentParams().videoEnabled()) {
|
||||
if (mCall.getCurrentParams() != null && mCall.getCurrentParams().videoEnabled()) {
|
||||
findViewById(R.id.avatar_layout).setVisibility(View.GONE);
|
||||
mCall.getCore().setNativeVideoWindowId(mVideoDisplay);
|
||||
}
|
||||
|
@ -206,7 +199,8 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
|
|||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (LinphoneContext.isReady()
|
||||
&& (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME)) {
|
||||
&& (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME)
|
||||
&& mCall != null) {
|
||||
mCall.terminate();
|
||||
finish();
|
||||
}
|
||||
|
@ -231,7 +225,7 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
|
|||
}
|
||||
mAlreadyAcceptedOrDeniedCall = true;
|
||||
|
||||
mCall.terminate();
|
||||
if (mCall != null) mCall.terminate();
|
||||
finish();
|
||||
}
|
||||
|
||||
|
@ -281,6 +275,7 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
|
|||
}
|
||||
if (LinphonePreferences.instance().shouldAutomaticallyAcceptVideoRequests()
|
||||
&& mCall != null
|
||||
&& mCall.getRemoteParams() != null
|
||||
&& mCall.getRemoteParams().videoEnabled()) {
|
||||
if (camera != PackageManager.PERMISSION_GRANTED) {
|
||||
Log.i("[Permission] Asking for camera");
|
||||
|
|
|
@ -35,6 +35,7 @@ import android.widget.Button;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.core.Call;
|
||||
|
@ -184,10 +185,12 @@ public class CallStatusBarFragment extends Fragment {
|
|||
public void onPause() {
|
||||
super.onPause();
|
||||
|
||||
if (LinphoneContext.isReady()) {
|
||||
Core core = LinphoneManager.getCore();
|
||||
if (core != null) {
|
||||
core.removeListener(mListener);
|
||||
}
|
||||
}
|
||||
|
||||
if (mCallQualityUpdater != null) {
|
||||
LinphoneUtils.removeFromUIThreadDispatcher(mCallQualityUpdater);
|
||||
|
|
|
@ -43,7 +43,7 @@ class AndroidContact implements Serializable {
|
|||
String mAndroidId;
|
||||
private String mAndroidRawId;
|
||||
private boolean isAndroidRawIdLinphone;
|
||||
private final transient ArrayList<ContentProviderOperation> mChangesToCommit;
|
||||
private transient ArrayList<ContentProviderOperation> mChangesToCommit;
|
||||
private byte[] mTempPicture;
|
||||
|
||||
AndroidContact() {
|
||||
|
@ -66,6 +66,9 @@ class AndroidContact implements Serializable {
|
|||
|
||||
private void addChangesToCommit(ContentProviderOperation operation) {
|
||||
Log.i("[Contact] Added operation " + operation);
|
||||
if (mChangesToCommit == null) {
|
||||
mChangesToCommit = new ArrayList<>();
|
||||
}
|
||||
mChangesToCommit.add(operation);
|
||||
}
|
||||
|
||||
|
|
|
@ -222,7 +222,7 @@ public class ContactsManager extends ContentObserver
|
|||
}
|
||||
|
||||
public boolean hasReadContactsAccess() {
|
||||
if (mContext == null) {
|
||||
if (mContext == null || mContext.getPackageManager() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ import android.view.View.OnClickListener;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.core.Content;
|
||||
|
@ -162,11 +163,13 @@ public class StatusBarFragment extends Fragment {
|
|||
public void onPause() {
|
||||
super.onPause();
|
||||
|
||||
if (LinphoneContext.isReady()) {
|
||||
Core core = LinphoneManager.getCore();
|
||||
if (core != null) {
|
||||
core.removeListener(mListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setMenuListener(MenuClikedListener listener) {
|
||||
mMenuListener = listener;
|
||||
|
|
|
@ -36,6 +36,7 @@ import androidx.drawerlayout.widget.DrawerLayout;
|
|||
import androidx.fragment.app.Fragment;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.activities.AboutActivity;
|
||||
|
@ -182,6 +183,8 @@ public class SideMenuFragment extends Fragment {
|
|||
TextView address = mDefaultAccount.findViewById(R.id.main_account_address);
|
||||
TextView displayName = mDefaultAccount.findViewById(R.id.main_account_display_name);
|
||||
|
||||
if (!LinphoneContext.isReady() || LinphoneManager.getCore() == null) return;
|
||||
|
||||
ProxyConfig proxy = LinphoneManager.getCore().getDefaultProxyConfig();
|
||||
if (proxy == null) {
|
||||
displayName.setText(getString(R.string.no_account));
|
||||
|
|
|
@ -42,6 +42,11 @@ public class NotificationBroadcastReceiver extends BroadcastReceiver {
|
|||
final int notifId = intent.getIntExtra(Compatibility.INTENT_NOTIF_ID, 0);
|
||||
final String localyIdentity = intent.getStringExtra(Compatibility.INTENT_LOCAL_IDENTITY);
|
||||
|
||||
if (!LinphoneContext.isReady()) {
|
||||
Log.e("[Notification Broadcast Receiver] Context not ready, aborting...");
|
||||
return;
|
||||
}
|
||||
|
||||
if (intent.getAction().equals(Compatibility.INTENT_REPLY_NOTIF_ACTION)
|
||||
|| intent.getAction().equals(Compatibility.INTENT_MARK_AS_READ_ACTION)) {
|
||||
String remoteSipAddr =
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.linphone.settings;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
|
@ -223,8 +224,13 @@ public class CallSettingsFragment extends SettingsFragment {
|
|||
new SettingListenerBase() {
|
||||
@Override
|
||||
public void onClicked() {
|
||||
try {
|
||||
startActivity(
|
||||
new Intent("android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS"));
|
||||
new Intent(
|
||||
"android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS"));
|
||||
} catch (ActivityNotFoundException anfe) {
|
||||
Log.e("[Call Settings] Activity not found: ", anfe);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -189,6 +189,7 @@ public class LinphonePreferences {
|
|||
|
||||
// App settings
|
||||
public boolean isFirstLaunch() {
|
||||
if (getConfig() == null) return true;
|
||||
return getConfig().getBool("app", "first_launch", true);
|
||||
}
|
||||
|
||||
|
@ -599,12 +600,14 @@ public class LinphonePreferences {
|
|||
|
||||
public String getStunServer() {
|
||||
NatPolicy nat = getOrCreateNatPolicy();
|
||||
if (nat == null) return null;
|
||||
return nat.getStunServer();
|
||||
}
|
||||
|
||||
public void setStunServer(String stun) {
|
||||
if (getLc() == null) return;
|
||||
NatPolicy nat = getOrCreateNatPolicy();
|
||||
if (nat == null) return;
|
||||
nat.setStunServer(stun);
|
||||
|
||||
getLc().setNatPolicy(nat);
|
||||
|
@ -612,12 +615,14 @@ public class LinphonePreferences {
|
|||
|
||||
public boolean isIceEnabled() {
|
||||
NatPolicy nat = getOrCreateNatPolicy();
|
||||
if (nat == null) return false;
|
||||
return nat.iceEnabled();
|
||||
}
|
||||
|
||||
public void setIceEnabled(boolean enabled) {
|
||||
if (getLc() == null) return;
|
||||
NatPolicy nat = getOrCreateNatPolicy();
|
||||
if (nat == null) return;
|
||||
nat.enableIce(enabled);
|
||||
if (enabled) nat.enableStun(true);
|
||||
getLc().setNatPolicy(nat);
|
||||
|
@ -625,24 +630,28 @@ public class LinphonePreferences {
|
|||
|
||||
public boolean isTurnEnabled() {
|
||||
NatPolicy nat = getOrCreateNatPolicy();
|
||||
if (nat == null) return false;
|
||||
return nat.turnEnabled();
|
||||
}
|
||||
|
||||
public void setTurnEnabled(boolean enabled) {
|
||||
if (getLc() == null) return;
|
||||
NatPolicy nat = getOrCreateNatPolicy();
|
||||
if (nat == null) return;
|
||||
nat.enableTurn(enabled);
|
||||
getLc().setNatPolicy(nat);
|
||||
}
|
||||
|
||||
public String getTurnUsername() {
|
||||
NatPolicy nat = getOrCreateNatPolicy();
|
||||
if (nat == null) return null;
|
||||
return nat.getStunServerUsername();
|
||||
}
|
||||
|
||||
public void setTurnUsername(String username) {
|
||||
if (getLc() == null) return;
|
||||
NatPolicy nat = getOrCreateNatPolicy();
|
||||
if (nat == null) return;
|
||||
AuthInfo authInfo = getLc().findAuthInfo(null, nat.getStunServerUsername(), null);
|
||||
|
||||
if (authInfo != null) {
|
||||
|
@ -663,6 +672,7 @@ public class LinphonePreferences {
|
|||
public void setTurnPassword(String password) {
|
||||
if (getLc() == null) return;
|
||||
NatPolicy nat = getOrCreateNatPolicy();
|
||||
if (nat == null) return;
|
||||
AuthInfo authInfo = getLc().findAuthInfo(null, nat.getStunServerUsername(), null);
|
||||
|
||||
if (authInfo != null) {
|
||||
|
|
Loading…
Reference in a new issue