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

Commit bd62aa81 authored by Martin Herndl's avatar Martin Herndl Committed by Danny Baumann
Browse files

Lookup: make people lookups work without location

In contrast to nearby lookups they do not need a location and don't
need to be limited because of this.

Change-Id: Ia8facc0a019717be55e7c3f76aece814391d8287
parent 5a46f31a
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -128,27 +128,27 @@ public class LookupProvider extends ContentProvider {
            String[] selectionArgs, String sortOrder) {
        if (DEBUG) Log.v(TAG, "query: " + uri);

        Location lastLocation = null;
        final int match = sURIMatcher.match(uri);

        switch (match) {
        case NEARBY:
        case PEOPLE:
            if (!PermissionsUtil.hasLocationPermissions(getContext())) {
                Log.v(TAG, "Location permission is missing, ignoring query.");
                return null;
            }

            if (!isLocationEnabled()) {
                Log.v(TAG, "Location settings is disabled, ignoring query.");
                return null;
            }

            final Location lastLocation = getLastLocation();
            lastLocation = getLastLocation();
            if (lastLocation == null) {
                Log.v(TAG, "No location available, ignoring query.");
                return null;
            }
            // fall through to the actual query

        case PEOPLE:
            final String filter = Uri.encode(uri.getLastPathSegment());
            String limit = uri.getQueryParameter(ContactsContract.LIMIT_PARAM_KEY);

@@ -162,13 +162,14 @@ public class LookupProvider extends ContentProvider {
                Log.e(TAG, "query: invalid limit parameter: '" + limit + "'");
            }

            final Location finalLastLocation = lastLocation;
            final int finalMaxResults = maxResults;

            return execute(new Callable<Cursor>() {
                @Override
                public Cursor call() {
                    return handleFilter(match, projection, filter,
                            finalMaxResults, lastLocation);
                            finalMaxResults, finalLastLocation);
                }
            }, "FilterThread");
        }