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

Commit 9b83ba54 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add ADAS GNSS bypass functionality" into sc-dev am: 9490b84d am: c99a2717

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14681780

Change-Id: Id50d38c824049d905474f216721171532d180c71
parents a6446bc6 c99a2717
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1706,6 +1706,10 @@
         config_enableFusedLocationOverlay is false. -->
    <string name="config_fusedLocationProviderPackageName" translatable="false">com.android.location.fused</string>

    <!-- Default value for the ADAS GNSS Location Enabled setting if this setting has never been
         set before. -->
    <bool name="config_defaultAdasGnssLocationEnabled" translatable="false">false</bool>

    <string-array name="config_locationExtraPackageNames" translatable="false"></string-array>

    <!-- The package name of the default network recommendation app.
+1 −0
Original line number Diff line number Diff line
@@ -1919,6 +1919,7 @@
  <java-symbol type="bool" name="config_tintNotificationActionButtons" />
  <java-symbol type="bool" name="config_dozeAfterScreenOffByDefault" />
  <java-symbol type="bool" name="config_enableActivityRecognitionHardwareOverlay" />
  <java-symbol type="bool" name="config_defaultAdasGnssLocationEnabled" />
  <java-symbol type="bool" name="config_enableFusedLocationOverlay" />
  <java-symbol type="bool" name="config_enableGeocoderOverlay" />
  <java-symbol type="bool" name="config_enableGeofenceOverlay" />
+3 −0
Original line number Diff line number Diff line
@@ -122,6 +122,9 @@ interface ILocationManager
    boolean isLocationEnabledForUser(int userId);
    void setLocationEnabledForUser(boolean enabled, int userId);

    boolean isAdasGnssLocationEnabledForUser(int userId);
    void setAdasGnssLocationEnabledForUser(boolean enabled, int userId);

    void addTestProvider(String name, in ProviderProperties properties,
        in List<String> locationTags, String packageName, @nullable String attributionTag);
    void removeTestProvider(String provider, String packageName, @nullable String attributionTag);
+58 −2
Original line number Diff line number Diff line
@@ -34,12 +34,15 @@ import java.util.Objects;
public final class LastLocationRequest implements Parcelable {

    private final boolean mHiddenFromAppOps;
    private final boolean mAdasGnssBypass;
    private final boolean mLocationSettingsIgnored;

    private LastLocationRequest(
            boolean hiddenFromAppOps,
            boolean adasGnssBypass,
            boolean locationSettingsIgnored) {
        mHiddenFromAppOps = hiddenFromAppOps;
        mAdasGnssBypass = adasGnssBypass;
        mLocationSettingsIgnored = locationSettingsIgnored;
    }

@@ -55,6 +58,21 @@ public final class LastLocationRequest implements Parcelable {
        return mHiddenFromAppOps;
    }

    /**
     * Returns true if this request may access GNSS even if location settings would normally deny
     * this, in order to enable automotive safety features. This field is only respected on
     * automotive devices, and only if the client is recognized as a legitimate ADAS (Advanced
     * Driving Assistance Systems) application.
     *
     * @return true if all limiting factors will be ignored to satisfy GNSS request
     * @hide
     */
    // TODO: make this system api
    public boolean isAdasGnssBypass() {
        return mAdasGnssBypass;
    }


    /**
     * Returns true if location settings, throttling, background location limits, and any other
     * possible limiting factors will be ignored in order to satisfy this last location request.
@@ -65,12 +83,22 @@ public final class LastLocationRequest implements Parcelable {
        return mLocationSettingsIgnored;
    }

    /**
     * Returns true if any bypass flag is set on this request. For internal use only.
     *
     * @hide
     */
    public boolean isBypass() {
        return mAdasGnssBypass || mLocationSettingsIgnored;
    }

    public static final @NonNull Parcelable.Creator<LastLocationRequest> CREATOR =
            new Parcelable.Creator<LastLocationRequest>() {
                @Override
                public LastLocationRequest createFromParcel(Parcel in) {
                    return new LastLocationRequest(
                            /* hiddenFromAppOps= */ in.readBoolean(),
                            /* adasGnssBypass= */ in.readBoolean(),
                            /* locationSettingsIgnored= */ in.readBoolean());
                }
                @Override
@@ -86,6 +114,7 @@ public final class LastLocationRequest implements Parcelable {
    @Override
    public void writeToParcel(@NonNull Parcel parcel, int flags) {
        parcel.writeBoolean(mHiddenFromAppOps);
        parcel.writeBoolean(mAdasGnssBypass);
        parcel.writeBoolean(mLocationSettingsIgnored);
    }

@@ -99,12 +128,13 @@ public final class LastLocationRequest implements Parcelable {
        }
        LastLocationRequest that = (LastLocationRequest) o;
        return mHiddenFromAppOps == that.mHiddenFromAppOps
                && mAdasGnssBypass == that.mAdasGnssBypass
                && mLocationSettingsIgnored == that.mLocationSettingsIgnored;
    }

    @Override
    public int hashCode() {
        return Objects.hash(mHiddenFromAppOps, mLocationSettingsIgnored);
        return Objects.hash(mHiddenFromAppOps, mAdasGnssBypass, mLocationSettingsIgnored);
    }

    @NonNull
@@ -115,8 +145,11 @@ public final class LastLocationRequest implements Parcelable {
        if (mHiddenFromAppOps) {
            s.append("hiddenFromAppOps, ");
        }
        if (mAdasGnssBypass) {
            s.append("adasGnssBypass, ");
        }
        if (mLocationSettingsIgnored) {
            s.append("locationSettingsIgnored, ");
            s.append("settingsBypass, ");
        }
        if (s.length() > "LastLocationRequest[".length()) {
            s.setLength(s.length() - 2);
@@ -131,6 +164,7 @@ public final class LastLocationRequest implements Parcelable {
    public static final class Builder {

        private boolean mHiddenFromAppOps;
        private boolean mAdasGnssBypass;
        private boolean mLocationSettingsIgnored;

        /**
@@ -138,6 +172,7 @@ public final class LastLocationRequest implements Parcelable {
         */
        public Builder() {
            mHiddenFromAppOps = false;
            mAdasGnssBypass = false;
            mLocationSettingsIgnored = false;
        }

@@ -146,6 +181,7 @@ public final class LastLocationRequest implements Parcelable {
         */
        public Builder(@NonNull LastLocationRequest lastLocationRequest) {
            mHiddenFromAppOps = lastLocationRequest.mHiddenFromAppOps;
            mAdasGnssBypass = lastLocationRequest.mAdasGnssBypass;
            mLocationSettingsIgnored = lastLocationRequest.mLocationSettingsIgnored;
        }

@@ -163,6 +199,25 @@ public final class LastLocationRequest implements Parcelable {
            return this;
        }

        /**
         * If set to true, indicates that the client is an ADAS (Advanced Driving Assistance
         * Systems) client, which requires access to GNSS even if location settings would normally
         * deny this, in order to enable auto safety features. This field is only respected on
         * automotive devices, and only if the client is recognized as a legitimate ADAS
         * application. Defaults to false.
         *
         * <p>Permissions enforcement occurs when resulting location request is actually used, not
         * when this method is invoked.
         *
         * @hide
         */
        // TODO: make this system api
        @RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS)
        public @NonNull LastLocationRequest.Builder setAdasGnssBypass(boolean adasGnssBypass) {
            mAdasGnssBypass = adasGnssBypass;
            return this;
        }

        /**
         * If set to true, indicates that location settings, throttling, background location limits,
         * and any other possible limiting factors should be ignored in order to satisfy this
@@ -186,6 +241,7 @@ public final class LastLocationRequest implements Parcelable {
        public @NonNull LastLocationRequest build() {
            return new LastLocationRequest(
                    mHiddenFromAppOps,
                    mAdasGnssBypass,
                    mLocationSettingsIgnored);
        }
    }
+63 −0
Original line number Diff line number Diff line
@@ -314,6 +314,33 @@ public class LocationManager {
     */
    public static final String EXTRA_LOCATION_ENABLED = "android.location.extra.LOCATION_ENABLED";

    /**
     * Broadcast intent action when the ADAS (Advanced Driving Assistance Systems) GNSS location
     * enabled state changes. Includes a boolean intent extra, {@link #EXTRA_ADAS_GNSS_ENABLED},
     * with the enabled state of ADAS GNSS location. This broadcast only has meaning on automotive
     * devices.
     *
     * @see #EXTRA_ADAS_GNSS_ENABLED
     * @see #isAdasGnssLocationEnabled()
     *
     * @hide
     */
    // TODO: @SystemApi
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_ADAS_GNSS_ENABLED_CHANGED =
            "android.location.action.ADAS_GNSS_ENABLED_CHANGED";

    /**
     * Intent extra included with {@link #ACTION_ADAS_GNSS_ENABLED_CHANGED} broadcasts, containing
     * the boolean enabled state of ADAS GNSS location.
     *
     * @see #ACTION_ADAS_GNSS_ENABLED_CHANGED
     *
     * @hide
     */
    // TODO: @SystemApi
    public static final String EXTRA_ADAS_GNSS_ENABLED = "android.location.extra.ADAS_GNSS_ENABLED";

    /**
     * Broadcast intent action indicating that a high power location requests
     * has either started or stopped being active.  The current state of
@@ -620,6 +647,42 @@ public class LocationManager {
        }
    }

    /**
     * Returns the current enabled/disabled state of ADAS (Advanced Driving Assistance Systems)
     * GNSS location access for the given user. This controls safety critical automotive access to
     * GNSS location. This only has meaning on automotive devices.
     *
     * @return true if ADAS location is enabled and false if ADAS location is disabled.
     *
     * @hide
     */
    //TODO: @SystemApi
    public boolean isAdasGnssLocationEnabled() {
        try {
            return mService.isAdasGnssLocationEnabledForUser(mContext.getUser().getIdentifier());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Enables or disables ADAS (Advanced Driving Assistance Systems) GNSS location access for the
     * given user. This only has meaning on automotive devices.
     *
     * @param enabled true to enable ADAS location and false to disable ADAS location.
     *
     * @hide
     */
    // TODO: @SystemApi
    @RequiresPermission(WRITE_SECURE_SETTINGS)
    public void setAdasGnssLocationEnabled(boolean enabled) {
        try {
            mService.setAdasGnssLocationEnabledForUser(enabled, mContext.getUser().getIdentifier());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Returns the current enabled/disabled status of the given provider. To listen for changes, see
     * {@link #PROVIDERS_CHANGED_ACTION}.
Loading