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

Commit 1b864293 authored by Ludovic Barman's avatar Ludovic Barman Committed by Android (Google) Code Review
Browse files

Merge changes from topic "population-density-provider" into main

* changes:
  Coarse locations based on population density.
  Add PopulationDensityProvider
parents cbc24b90 7749835f
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -2174,6 +2174,16 @@
        <item>com.android.location.fused</item>
    </string-array>

    <!-- Package name providing population density location support. -->
    <string name="config_populationDensityProviderPackageName" translatable="false">com.android.location.populationdensity</string>

    <!-- Whether to enable population density provider overlay, which allows the population density provider to
         be replaced by an app at run-time. When disabled, only the
         config_populationDensityProviderPackageName package will be searched for a population density
         provider, otherwise any system package is eligible. Anyone who wants to disable the overlay
         mechanism can set it to false. -->
    <bool name="config_enablePopulationDensityProviderOverlay" translatable="false">true</bool>

   <!-- Package name of the extension software fallback. -->
    <string name="config_extensionFallbackPackageName" translatable="false"></string>

+2 −0
Original line number Diff line number Diff line
@@ -2012,6 +2012,8 @@
  <java-symbol type="array" name="config_locationProviderPackageNames" />
  <java-symbol type="array" name="config_locationDriverAssistancePackageNames" />
  <java-symbol type="array" name="config_locationExtraPackageNames" />
  <java-symbol type="string" name="config_populationDensityProviderPackageName" />
  <java-symbol type="bool" name="config_enablePopulationDensityProviderOverlay" />
  <java-symbol type="array" name="config_testLocationProviders" />
  <java-symbol type="array" name="config_defaultNotificationVibePattern" />
  <java-symbol type="array" name="config_defaultNotificationVibeWaveform" />
+8 −0
Original line number Diff line number Diff line
@@ -642,6 +642,14 @@ package android.location.provider {
    method public void onFlushComplete();
  }

  @FlaggedApi("android.location.flags.population_density_provider") public abstract class PopulationDensityProviderBase {
    ctor public PopulationDensityProviderBase(@NonNull android.content.Context, @NonNull String);
    method @Nullable public final android.os.IBinder getBinder();
    method public abstract void onGetCoarsenedS2Cell(double, double, @NonNull android.os.OutcomeReceiver<long[],java.lang.Throwable>);
    method public abstract void onGetDefaultCoarseningLevel(@NonNull android.os.OutcomeReceiver<java.lang.Integer,java.lang.Throwable>);
    field public static final String ACTION_POPULATION_DENSITY_PROVIDER = "com.android.location.service.PopulationDensityProvider";
  }

  public final class ProviderRequest implements android.os.Parcelable {
    method public int describeContents();
    method @IntRange(from=0) public long getIntervalMillis();
+45 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.location.provider;

import android.os.Bundle;

import android.location.Location;
import android.location.provider.IS2CellIdsCallback;
import android.location.provider.IS2LevelCallback;

/**
 * Binder interface for services that implement a population density provider. Do not implement this
 * directly, extend {@link PopulationDensityProviderBase} instead.
 * @hide
 */
oneway interface IPopulationDensityProvider {
    /**
     * Gets the default S2 level to be used to coarsen any location, in case a more precise answer
     * from the method below can't be obtained.
     */
    void getDefaultCoarseningLevel(in IS2LevelCallback callback);

    /**
     * Returns a list of IDs of the S2 cells to be used to coarsen a location. The answer should
     * contain at least one S2 cell, which should contain the requested location. Its level
     * represents the population density. Optionally, additional nearby cells can be also returned,
     * to assist in coarsening nearby locations.
     */
    void getCoarsenedS2Cell(double latitudeDegrees, double longitudeDegrees, in IS2CellIdsCallback
        callback);
}
+36 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.location.provider;

import android.location.Location;

/**
 * Binder interface for S2 cell IDs callbacks.
 * @hide
 */
oneway interface IS2CellIdsCallback {

    /**
     * Called with the resulting list of S2 cell IDs. The first cell is expected to contain
     * the requested latitude/longitude. Its level represent the population density. Optionally,
     * the list can also contain additional nearby cells.
     */
    void onResult(in long[] s2CellIds);

    /** Called if any error occurs while processing the query. */
    void onError();
}
Loading