Skip to content

Commit

Permalink
fix: prominent google play errors. (#842)
Browse files Browse the repository at this point in the history
  • Loading branch information
aanorbel authored Nov 25, 2024
1 parent e560c90 commit bc10ca1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import org.openobservatory.ooniprobe.common.OONIDescriptor
import org.openobservatory.ooniprobe.common.OONITests
import org.openobservatory.ooniprobe.common.PreferenceManager
import org.openobservatory.ooniprobe.common.ResubmitTask
import org.openobservatory.ooniprobe.common.ThirdPartyServices
import org.openobservatory.ooniprobe.databinding.ActivityResultDetailBinding
import org.openobservatory.ooniprobe.domain.GetResults
import org.openobservatory.ooniprobe.domain.GetTestSuite
Expand Down Expand Up @@ -85,7 +86,14 @@ class ResultDetailActivity : AbstractActivity(), View.OnClickListener, OnConfirm

else -> {
result = iResult
result.getTestSuite(this@ResultDetailActivity).get()?.themeLight?.let { setTheme(it) }
val optionalSuite = result.getTestSuite(this@ResultDetailActivity)
if (optionalSuite.isPresent){
try {
setTheme(optionalSuite.get().themeLight)
} catch (e: Exception) {
ThirdPartyServices.logException(e)
}
}
binding = ActivityResultDetailBinding.inflate(layoutInflater)
setContentView(binding.root)
setSupportActionBar(binding.toolbar)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,14 @@ public int onStartCommand(Intent intent, int flags, int startId) {
.setProgress(100, 0, false)
.build();

task = (TestAsyncTask) new TestAsyncTask(app, testSuites, store_db, unattended).execute();
//This intent is used to manage the stop test button in the notification
Intent broadcastIntent = new Intent();
broadcastIntent.setAction(RunTestService.ACTION_INTERRUPT);
PendingIntent pIntent = pendingIntentGetBroadcast(this, 1, broadcastIntent);
builder.addAction(0, getApplicationContext().getString(R.string.Notification_StopTest), pIntent);
startForeground(NOTIFICATION_ID, builder.build());

task = (TestAsyncTask) new TestAsyncTask(app, testSuites, store_db, unattended).execute();
/*
START_NOT_STICKY says that, after returning from onStartCreated(),
if the process is killed with no remaining start commands to deliver,
Expand Down Expand Up @@ -202,7 +203,12 @@ public void stopTest() {
public synchronized void interrupt() {
task.interrupt();
if (task.isInterrupted()) {
ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE);
try {
ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE);
stopSelf();
} catch (Exception e) {
ThirdPartyServices.logException(e);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class ProgressFragment : Fragment() {
}

private fun updateUI(service: RunTestService?) {
if ((requireActivity().application as Application).isTestRunning) {
if (isAdded && (requireActivity().application as Application).isTestRunning) {
val progressLevel = testProgressRepository.progress.value
when {
progressLevel != null -> {
Expand Down

0 comments on commit bc10ca1

Please sign in to comment.