Bug 1550291 - Ensure we save CRASHED status to be able to restore previous tabs; r=AndreiLazar

Default app behavior for when a crash occurs involves starting an Activity that
lets users submit a crash report and maybe provide additional info.
In the event of a crash we want to restore for the user all previous tabs, this
Activity being the component that saves the CRASHED status that will trigger
the restore process.

On Android Q, when a crash notification is posted but ignored by the user, upon
starting the app would not know it crashed and it would not try restoring tabs.
Executing the "save CRASHED status" logic whenever a crash occurs, irrespective
of if we'll show the Activity or just post a notification ensures users will
always have their previous tabs restored.

Differential Revision: https://phabricator.services.mozilla.com/D34826

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Petru Lingurar 2019-06-13 13:26:57 +00:00
Родитель 590b4eb288
Коммит efebb8836e
2 изменённых файлов: 13 добавлений и 8 удалений

Просмотреть файл

@ -8,10 +8,15 @@ import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.provider.Settings;
import android.util.Log;
import org.mozilla.gecko.notifications.NotificationHelper;
import java.io.File;
import java.io.IOException;
public class CrashHandlerService extends Service {
private static final String LOGTAG = "CrashHandlerService";
private static final String ACTION_STOP = "action_stop";
// Build.VERSION_CODES.Q placeholder. While Android Q is in Beta it shares API 28 with Android P.
private static final int ANDROID_Q = 29;
@ -21,6 +26,14 @@ public class CrashHandlerService extends Service {
if (ACTION_STOP.equals(intent.getAction())) {
dismissNotification();
} else {
// Notify GeckoApp that we've crashed, so it can react appropriately during the next start.
try {
File crashFlag = new File(GeckoProfileDirectories.getMozillaDirectory(this), "CRASHED");
crashFlag.createNewFile();
} catch (GeckoProfileDirectories.NoMozillaDirectoryException | IOException e) {
Log.e(LOGTAG, "Cannot set crash flag: ", e);
}
intent.setClass(this, CrashReporterActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

Просмотреть файл

@ -204,14 +204,6 @@ public class CrashReporterActivity extends AppCompatActivity
Log.e(LOGTAG, "Cannot send the crash ping: ", e);
}
// Notify GeckoApp that we've crashed, so it can react appropriately during the next start.
try {
File crashFlag = new File(GeckoProfileDirectories.getMozillaDirectory(this), "CRASHED");
crashFlag.createNewFile();
} catch (GeckoProfileDirectories.NoMozillaDirectoryException | IOException e) {
Log.e(LOGTAG, "Cannot set crash flag: ", e);
}
final CheckBox allowContactCheckBox = (CheckBox) findViewById(R.id.allow_contact);
final CheckBox includeUrlCheckBox = (CheckBox) findViewById(R.id.include_url);
final CheckBox sendReportCheckBox = (CheckBox) findViewById(R.id.send_report);