Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ed337299 authored by Danny Baumann's avatar Danny Baumann Committed by Gerrit Code Review
Browse files

Don't crash if print spooler doesn't have location permission.

Change-Id: Iae85bbf7ba6a8fe84bea4defee39b969b436206b
parent 52197050
Loading
Loading
Loading
Loading
+15 −11
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.app.LoaderManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Loader;
import android.content.pm.PackageManager;
import android.content.pm.ServiceInfo;
import android.location.Criteria;
import android.location.Location;
@@ -251,6 +252,8 @@ public final class FusedPrintersProvider extends Loader<List<PrinterInfo>>
            Log.i(LOG_TAG, "onStartLoading() " + FusedPrintersProvider.this.hashCode());
        }

        if (getContext().checkSelfPermission(android.Manifest.permission.ACCESS_FINE_LOCATION)
                == PackageManager.PERMISSION_GRANTED) {
            mLocationManager.requestLocationUpdates(LocationRequest.create()
                    .setQuality(LocationRequest.POWER_LOW).setInterval(LOCATION_UPDATE_MS), this,
                    Looper.getMainLooper());
@@ -264,6 +267,7 @@ public final class FusedPrintersProvider extends Loader<List<PrinterInfo>>
            Criteria oneTimeCriteria = new Criteria();
            oneTimeCriteria.setAccuracy(Criteria.ACCURACY_FINE);
            mLocationManager.requestSingleUpdate(oneTimeCriteria, this, Looper.getMainLooper());
        }

        // The contract is that if we already have a valid,
        // result the we have to deliver it immediately.