Add a check on start of Activity to avoid crash

This commit is contained in:
Erwan Croze 2016-12-15 11:48:13 +01:00
parent 163ee62326
commit 29bbfcc1ba
8 changed files with 731 additions and 674 deletions

View file

@ -1,15 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.linphone"
android:installLocation="auto"
android:versionCode="3214"
android:versionName="3.2.1">
android:versionCode="3214" android:versionName="3.2.1" android:installLocation="auto">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="23"/>
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="23"/>
<!-- Permissions for Push Notification -->
<permission android:name="org.linphone.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <!-- Change package ! -->
<permission
android:name="org.linphone.permission.C2D_MESSAGE"
android:protectionLevel="signature"/> <!-- Change package ! -->
<uses-permission android:name="org.linphone.permission.C2D_MESSAGE"/> <!-- Change package ! -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
@ -19,12 +24,18 @@
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/>
<uses-permission android:name="android.permission.CALL_PHONE"/>
<!-- Needed to allow Linphone to install on tablets, since android.permission.CALL_PHONE implies android.hardware.telephony is required -->
<uses-feature android:name="android.hardware.telephony" android:required="false" />
<uses-feature
android:name="android.hardware.telephony"
android:required="false"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.CAMERA"/>
<!-- Needed to allow Linphone to install on tablets, since android.permission.CAMERA implies android.hardware.camera and android.hardware.camera.autofocus are required -->
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature
android:name="android.hardware.camera"
android:required="false"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<!-- Needed to store received images if the user wants to -->
@ -46,221 +57,251 @@
<!-- Needed for overlay widget -->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true"/>
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true"/>
<application android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:largeHeap="true" android:allowBackup="true">
<activity android:name="org.linphone.LinphoneLauncherActivity"
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:windowSoftInputMode="adjustPan|stateHidden"
android:largeHeap="true">
<activity
android:name=".LinphoneLauncherActivity"
android:exported="true"
android:theme="@style/NoTitle">
android:label="@string/app_name"
android:theme="@style/NoTitle"
android:windowSoftInputMode="adjustPan|stateHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.CALL"/>
<action android:name="android.intent.action.CALL_PRIVILEGED"/>
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="tel" />
<data android:scheme="sip" /> />
</intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="tel"/>
<data android:scheme="sip"/>
/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SENDTO"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="sip"/>
<data android:scheme="imto"/>
</intent-filter>
<intent-filter>
<data android:mimeType="@string/sync_mimetype"/> <!-- Change package in res/values/non_localizable_custom.xml ! -->
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name="org.linphone.LinphoneActivity"
android:theme="@style/NoTitle"
<activity
android:name=".LinphoneActivity"
android:launchMode="singleTask"
android:screenOrientation="behind"
android:launchMode="singleTask">
android:theme="@style/NoTitle">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>
<activity android:name=".CallIncomingActivity"
android:theme="@style/NoTitle"
<activity
android:name=".CallIncomingActivity"
android:launchMode="singleTop"
android:screenOrientation="behind">
android:screenOrientation="behind"
android:theme="@style/NoTitle">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>
<activity android:name=".CallOutgoingActivity"
android:theme="@style/NoTitle"
<activity
android:name=".CallOutgoingActivity"
android:launchMode="singleTop"
android:screenOrientation="behind">
android:screenOrientation="behind"
android:theme="@style/NoTitle">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>
<activity android:name=".CallActivity"
android:theme="@style/FullScreen"
android:launchMode="singleTop">
<activity
android:name=".CallActivity"
android:launchMode="singleTop"
android:theme="@style/FullScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
<!--<intent-filter>
<!--
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data android:mimeType="audio/*" />
<data android:mimeType="video/*" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>-->
</intent-filter>
-->
</activity>
<activity android:name=".assistant.AssistantActivity"
android:theme="@style/NoTitle"
android:screenOrientation="behind">
<activity
android:name=".assistant.AssistantActivity"
android:screenOrientation="behind"
android:theme="@style/NoTitle">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>
<activity android:name="org.linphone.purchase.InAppPurchaseActivity"
android:theme="@style/NoTitle"
android:screenOrientation="nosensor">
<activity
android:name=".purchase.InAppPurchaseActivity"
android:screenOrientation="nosensor"
android:theme="@style/NoTitle">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>
<activity android:name="org.linphone.assistant.RemoteProvisioningLoginActivity"
android:theme="@style/NoTitle"
android:screenOrientation="nosensor">
<activity
android:name=".assistant.RemoteProvisioningLoginActivity"
android:screenOrientation="nosensor"
android:theme="@style/NoTitle">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>
<activity android:name="org.linphone.assistant.RemoteProvisioningActivity"
android:theme="@style/NoTitle"
android:screenOrientation="nosensor">
<activity
android:name=".assistant.RemoteProvisioningActivity"
android:screenOrientation="nosensor"
android:theme="@style/NoTitle">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
<intent-filter>
<data android:scheme="linphone-config"/> <!-- Change if needed -->
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<service android:name="org.linphone.LinphoneService"
<service
android:name=".LinphoneService"
android:label="@string/service_name"
android:stopWithTask="false"/>
<service
android:name="org.linphone.sync.SyncService"
android:name=".sync.SyncService"
android:exported="true">
<intent-filter>
<action android:name="android.content.SyncAdapter"/>
</intent-filter>
<meta-data android:name="android.content.SyncAdapter" android:resource="@xml/syncadapter" />
<meta-data android:name="android.provider.CONTACTS_STRUCTURE" android:resource="@xml/contacts" />
</service>
<service
android:name="org.linphone.sync.AuthenticationService">
<meta-data
android:name="android.content.SyncAdapter"
android:resource="@xml/syncadapter"/>
<meta-data
android:name="android.provider.CONTACTS_STRUCTURE"
android:resource="@xml/contacts"/>
</service>
<service android:name=".sync.AuthenticationService">
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator"/>
</intent-filter>
<meta-data
android:name="android.accounts.AccountAuthenticator"
android:resource="@xml/authenticator"/>
</service>
<receiver android:name="org.linphone.NetworkManager">
<intent-filter><action android:name="android.net.conn.CONNECTIVITY_CHANGE"></action></intent-filter>
<receiver android:name=".NetworkManager">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
</intent-filter>
</receiver>
<receiver android:name="org.linphone.BluetoothManager" android:enabled="false">
<receiver
android:name=".BluetoothManager"
android:enabled="false">
</receiver>
<receiver android:name="org.linphone.BootReceiver">
<intent-filter><action android:name="android.intent.action.BOOT_COMPLETED"></action></intent-filter>
<intent-filter><action android:name="android.intent.action.ACTION_SHUTDOWN"></action></intent-filter>
<receiver android:name=".BootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.ACTION_SHUTDOWN"/>
</intent-filter>
</receiver>
<receiver android:name="org.linphone.PhoneStateChangedReceiver">
<intent-filter><action android:name="android.intent.action.PHONE_STATE" /></intent-filter>
<receiver android:name=".PhoneStateChangedReceiver">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE"/>
</intent-filter>
</receiver>
<!-- This one needs to be registered from application -->
<receiver android:name="KeepAliveReceiver"/>
<receiver android:name=".KeepAliveReceiver"/>
<!-- Needed for push notification -->
<receiver android:name="org.linphone.gcm.GCMReceiver" android:permission="com.google.android.c2dm.permission.SEND" >
<receiver
android:name=".gcm.GCMReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<category android:name="org.linphone"/> <!-- Change package ! -->
</intent-filter>
</receiver>
<service android:name="org.linphone.gcm.GCMService" />
<service android:name=".gcm.GCMService"/>
<activity android:name="org.linphone.tutorials.TutorialLauncherActivity"
<activity
android:name=".tutorials.TutorialLauncherActivity"
android:theme="@style/NoTitle">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>
<activity android:name="org.linphone.tutorials.TutorialBuddyStatusActivity"
<activity
android:name=".tutorials.TutorialBuddyStatusActivity"
android:theme="@style/NoTitle">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>
<activity android:name="org.linphone.tutorials.TutorialChatRoomActivity"
<activity
android:name=".tutorials.TutorialChatRoomActivity"
android:theme="@style/NoTitle">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>
<activity android:name="org.linphone.tutorials.TutorialHelloWorldActivity"
<activity
android:name=".tutorials.TutorialHelloWorldActivity"
android:theme="@style/NoTitle">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>
<activity android:name="org.linphone.tutorials.TutorialRegistrationActivity"
<activity
android:name=".tutorials.TutorialRegistrationActivity"
android:theme="@style/NoTitle">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>
<activity android:name="org.linphone.tutorials.TutorialCardDavSync"
<activity
android:name=".tutorials.TutorialCardDavSync"
android:theme="@style/NoTitle">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>
<activity android:name=".LinphoneGenericActivity">
</activity>
</application>
</manifest>

View file

@ -1,13 +1,14 @@
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 5ef1374..86e13be 100644
index fcc8434..0e80ea6 100755
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -52,7 +52,7 @@
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true"/>
- <application android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:largeHeap="true" android:allowBackup="true">
+ <application android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:largeHeap="true" android:allowBackup="true" android:debuggable="false">
<activity android:name="org.linphone.LinphoneLauncherActivity"
@@ -68,7 +68,8 @@
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
- android:largeHeap="true">
+ android:largeHeap="true"
+ android:debuggable="false">
<activity
android:name=".LinphoneLauncherActivity"
android:exported="true"

View file

@ -79,7 +79,7 @@ import android.widget.Toast;
/**
* @author Sylvain Berfini
*/
public class CallActivity extends Activity implements OnClickListener, SensorEventListener, ActivityCompat.OnRequestPermissionsResultCallback {
public class CallActivity extends LinphoneGenericActivity implements OnClickListener, SensorEventListener, ActivityCompat.OnRequestPermissionsResultCallback {
private final static int SECONDS_BEFORE_HIDING_CONTROLS = 4000;
private final static int SECONDS_BEFORE_DENYING_CALL_UPDATE = 30000;
private static final int PERMISSIONS_REQUEST_CAMERA = 202;

View file

@ -48,7 +48,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
public class CallIncomingActivity extends Activity implements LinphoneSliderTriggered {
public class CallIncomingActivity extends LinphoneGenericActivity implements LinphoneSliderTriggered {
private static CallIncomingActivity instance;
private TextView name, number;

View file

@ -46,7 +46,7 @@ import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
public class CallOutgoingActivity extends Activity implements OnClickListener{
public class CallOutgoingActivity extends LinphoneGenericActivity implements OnClickListener{
private static CallOutgoingActivity instance;
private TextView name, number;

View file

@ -99,7 +99,7 @@ import android.widget.Toast;
/**
* @author Sylvain Berfini
*/
public class LinphoneActivity extends Activity implements OnClickListener, ContactPicked, ActivityCompat.OnRequestPermissionsResultCallback {
public class LinphoneActivity extends LinphoneGenericActivity implements OnClickListener, ContactPicked, ActivityCompat.OnRequestPermissionsResultCallback {
public static final String PREF_FIRST_LAUNCH = "pref_first_launch";
private static final int SETTINGS_ACTIVITY = 123;
private static final int CALL_ACTIVITY = 19;
@ -157,12 +157,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
if (!LinphoneManager.isInstanciated()) {
finish();
startActivity(getIntent().setClass(this, LinphoneLauncherActivity.class));
return;
}
boolean useFirstLoginActivity = getResources().getBoolean(R.bool.display_account_assistant_at_first_start);
if (LinphonePreferences.instance().isProvisioningLoginViewEnabled()) {
Intent wizard = new Intent();

View file

@ -0,0 +1,21 @@
package org.linphone;
import android.app.Activity;
import android.os.Bundle;
public class LinphoneGenericActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/*After a crash, Android restart the last Activity so we need to check
* if all dependencies are load
*/
if (!LinphoneManager.isInstanciated()) {
finish();
startActivity(getIntent().setClass(this, LinphoneLauncherActivity.class));
return;
}
}
}