3636import androidx .annotation .NonNull ;
3737import androidx .annotation .Nullable ;
3838
39- import org .mozilla .gecko .util .ThreadUtils ;
40- import org .mozilla .geckoview .CrashReporter ;
41- import org .mozilla .geckoview .GeckoResult ;
4239import org .mozilla .geckoview .GeckoRuntime ;
4340import org .mozilla .geckoview .GeckoSession ;
4441import org .mozilla .geckoview .GeckoVRManager ;
6259import org .mozilla .vrbrowser .ui .widgets .TrayWidget ;
6360import org .mozilla .vrbrowser .ui .widgets .UISurfaceTextureRenderer ;
6461import org .mozilla .vrbrowser .ui .widgets .UIWidget ;
65- import org .mozilla .vrbrowser .ui .widgets .menus .VideoProjectionMenuWidget ;
6662import org .mozilla .vrbrowser .ui .widgets .Widget ;
6763import org .mozilla .vrbrowser .ui .widgets .WidgetManagerDelegate ;
6864import org .mozilla .vrbrowser .ui .widgets .WidgetPlacement ;
6965import org .mozilla .vrbrowser .ui .widgets .WindowWidget ;
7066import org .mozilla .vrbrowser .ui .widgets .Windows ;
7167import org .mozilla .vrbrowser .ui .widgets .dialogs .CrashDialogWidget ;
68+ import org .mozilla .vrbrowser .ui .widgets .dialogs .PromptDialogWidget ;
7269import org .mozilla .vrbrowser .ui .widgets .dialogs .WhatsNewWidget ;
73- import org .mozilla .vrbrowser .ui .widgets .prompts . ConfirmPromptWidget ;
70+ import org .mozilla .vrbrowser .ui .widgets .menus . VideoProjectionMenuWidget ;
7471import org .mozilla .vrbrowser .utils .BitmapCache ;
7572import org .mozilla .vrbrowser .utils .ConnectivityReceiver ;
7673import org .mozilla .vrbrowser .utils .ConnectivityReceiver .Delegate ;
7976import org .mozilla .vrbrowser .utils .ServoUtils ;
8077import org .mozilla .vrbrowser .utils .SystemUtils ;
8178
82- import java .io .BufferedReader ;
83- import java .io .File ;
84- import java .io .FileInputStream ;
85- import java .io .IOException ;
86- import java .io .InputStreamReader ;
87- import java .net .URISyntaxException ;
88- import java .nio .charset .StandardCharsets ;
8979import java .util .ArrayList ;
9080import java .util .Arrays ;
9181import java .util .HashMap ;
@@ -127,7 +117,6 @@ public void run() {
127117 static final int GestureSwipeRight = 1 ;
128118 static final int SwipeDelay = 1000 ; // milliseconds
129119 static final long RESET_CRASH_COUNT_DELAY = 5000 ;
130- static final String CRASH_STATS_URL = "https://crash-stats.mozilla.com/report/index/" ;
131120
132121 static final String LOGTAG = SystemUtils .createLogtag (VRBrowserActivity .class );
133122 HashMap <Integer , Widget > mWidgets ;
@@ -230,7 +219,7 @@ protected void onCreate(Bundle savedInstanceState) {
230219 // Create broadcast receiver for getting crash messages from crash process
231220 IntentFilter intentFilter = new IntentFilter ();
232221 intentFilter .addAction (CrashReporterService .CRASH_ACTION );
233- registerReceiver (mCrashReceiver , intentFilter , getString (R .string .app_permission_name ), null );
222+ registerReceiver (mCrashReceiver , intentFilter , BuildConfig . APPLICATION_ID + "." + getString (R .string .app_permission_name ), null );
234223
235224 mLastGesture = NoGesture ;
236225 super .onCreate (savedInstanceState );
@@ -594,27 +583,12 @@ private void checkForCrash() {
594583 }
595584 boolean isCrashReportingEnabled = SettingsStore .getInstance (this ).isCrashReportingEnabled ();
596585 if (isCrashReportingEnabled ) {
597- postCrashFiles (files );
586+ SystemUtils .postCrashFiles (this , files );
587+
598588 } else {
599589 if (mCrashDialog == null ) {
600- mCrashDialog = new CrashDialogWidget (this );
590+ mCrashDialog = new CrashDialogWidget (this , files );
601591 }
602- mCrashDialog .setCrashDialogDelegate (
603- new CrashDialogWidget .CrashDialogDelegate () {
604- @ Override
605- public void onSendData () {
606- postCrashFiles (files );
607- }
608-
609- @ Override
610- public void onDoNotSendData () {
611- for (String file : files ) {
612- Log .e (LOGTAG , "Deleting crashfile: " + file );
613- getBaseContext ().deleteFile (file );
614- }
615- }
616- }
617- );
618592 mCrashDialog .show (UIWidget .REQUEST_FOCUS );
619593 }
620594 }
@@ -629,65 +603,16 @@ private void handleContentCrashIntent(@NonNull final Intent intent) {
629603
630604 boolean isCrashReportingEnabled = SettingsStore .getInstance (this ).isCrashReportingEnabled ();
631605 if (isCrashReportingEnabled ) {
632- postCrashFiles (dumpFile , extraFile );
606+ SystemUtils .postCrashFiles (this , dumpFile , extraFile );
607+
633608 } else {
634609 if (mCrashDialog == null ) {
635- mCrashDialog = new CrashDialogWidget (this );
610+ mCrashDialog = new CrashDialogWidget (this , dumpFile , extraFile );
636611 }
637- mCrashDialog .setCrashDialogDelegate (() -> postCrashFiles (dumpFile , extraFile ));
638612 mCrashDialog .show (UIWidget .REQUEST_FOCUS );
639613 }
640614 }
641615
642- private void sendCrashFiles (@ NonNull final String aDumpFile , @ NonNull final String aExtraFile ) {
643- try {
644- GeckoResult <String > result = CrashReporter .sendCrashReport (VRBrowserActivity .this , new File (aDumpFile ), new File (aExtraFile ), getString (R .string .crash_app_name ));
645-
646- result .accept (crashID -> {
647- Log .e (LOGTAG , "Submitted crash report id: " + crashID );
648- Log .e (LOGTAG , "Report available at: " + CRASH_STATS_URL + crashID );
649- }, ex -> {
650- Log .e (LOGTAG , "Failed to submit crash report: " + (ex != null ? ex .getMessage () : "Exception is NULL" ));
651- });
652- } catch (IOException | URISyntaxException e ) {
653- Log .e (LOGTAG , "Failed to send crash report: " + e .toString ());
654- }
655- }
656-
657- private void postCrashFiles (@ NonNull final String aDumpFile , @ NonNull final String aExtraFile ) {
658- ThreadUtils .postToBackgroundThread (() -> {
659- sendCrashFiles (aDumpFile , aExtraFile );
660- });
661- }
662-
663- private void postCrashFiles (final ArrayList <String > aFiles ) {
664- ThreadUtils .postToBackgroundThread (() -> {
665- for (String file : aFiles ) {
666- try {
667- ArrayList <String > list = new ArrayList <>(2 );
668- try (FileInputStream in = getBaseContext ().openFileInput (file )) {
669- try (BufferedReader br = new BufferedReader (new InputStreamReader (in , StandardCharsets .UTF_8 ))) {
670- String line ;
671- while ((line = br .readLine ()) != null ) {
672- list .add (line );
673- }
674- }
675- } catch (IOException e ) {
676- e .printStackTrace ();
677- }
678- if (list .size () < 2 ) {
679- Log .e (LOGTAG , "Failed read crash dump file names from: " + file );
680- return ;
681- }
682- sendCrashFiles (list .get (0 ), list .get (1 ));
683- } finally {
684- Log .d (LOGTAG ,"Removing crash file: " + file );
685- getBaseContext ().deleteFile (file );
686- }
687- }
688- });
689- }
690-
691616 @ Override
692617 public void onTrimMemory (int level ) {
693618
@@ -1109,7 +1034,7 @@ private void haltActivity(final int aReason) {
11091034 mWindows .getFocusedWindow ().showAlert (
11101035 getString (R .string .not_entitled_title ),
11111036 getString (R .string .not_entitled_message , getString (R .string .app_name )),
1112- () -> VRBrowserActivity . this . finish ());
1037+ index -> finish ());
11131038 }
11141039 });
11151040 }
@@ -1135,18 +1060,10 @@ private void handlePoorPerformance() {
11351060 }
11361061 window .getSession ().loadHomePage ();
11371062 final String [] buttons = {getString (R .string .ok_button ), getString (R .string .performance_unblock_page )};
1138- window .showButtonPrompt (getString (R .string .performance_title ), getString (R .string .performance_message ), buttons , new ConfirmPromptWidget .ConfirmPromptDelegate () {
1139- @ Override
1140- public void confirm (int index ) {
1141- if (index == GeckoSession .PromptDelegate .ButtonPrompt .Type .NEGATIVE ) {
1142- mPoorPerformanceWhiteList .add (originalUri );
1143- window .getSession ().loadUri (originalUri );
1144- }
1145- }
1146-
1147- @ Override
1148- public void dismiss () {
1149-
1063+ window .showConfirmPrompt (getString (R .string .performance_title ), getString (R .string .performance_message ), buttons , index -> {
1064+ if (index == PromptDialogWidget .NEGATIVE ) {
1065+ mPoorPerformanceWhiteList .add (originalUri );
1066+ window .getSession ().loadUri (originalUri );
11501067 }
11511068 });
11521069 });
0 commit comments