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

Commit afba8161 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Add new background location APIs.

Work on issue #109754053: Implement tri-state location in platform

- New background location permission
- New (temporary?) API level for compatibility with old apps

None of this is exposed yet as a public API, that will be
done in the future.

Bug: 109754053
Test: atest FrameworksServicesTests:AppOpsServiceTest
Test: atest CtsPermissionTestCases:AppOpsTest
Change-Id: I986dc871b9e8ed3bf592d2546eadaefb4fefe099
parent 22fbbd1f
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import static android.os.Build.VERSION_CODES.O;
import static android.os.Trace.TRACE_TAG_PACKAGE_MANAGER;
import static android.view.WindowManager.LayoutParams.ROTATION_ANIMATION_UNSPECIFIED;

import android.Manifest;
import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
@@ -303,7 +304,13 @@ public class PackageParser {
                    android.os.Build.VERSION_CODES.JELLY_BEAN),
            new PackageParser.SplitPermissionInfo(android.Manifest.permission.WRITE_CONTACTS,
                    new String[] { android.Manifest.permission.WRITE_CALL_LOG },
                    android.os.Build.VERSION_CODES.JELLY_BEAN)
                    android.os.Build.VERSION_CODES.JELLY_BEAN),
            new PackageParser.SplitPermissionInfo(Manifest.permission.ACCESS_FINE_LOCATION,
                    new String[] { android.Manifest.permission.ACCESS_BACKGROUND_LOCATION },
                    android.os.Build.VERSION_CODES.P0),
            new PackageParser.SplitPermissionInfo(Manifest.permission.ACCESS_COARSE_LOCATION,
                    new String[] { android.Manifest.permission.ACCESS_BACKGROUND_LOCATION },
                    android.os.Build.VERSION_CODES.P0),
    };

    /**
+6 −0
Original line number Diff line number Diff line
@@ -923,6 +923,12 @@ public class Build {
         * engaged. It's now time to see if you can dance.</em>
         */
        public static final int Q = CUR_DEVELOPMENT;

        /**
         * Stub for a potential new API level after P.
         * @hide
         */
        public static final int P0 = Q;
    }

    /** The type of build, like "user" or "eng". */
+13 −0
Original line number Diff line number Diff line
@@ -843,6 +843,19 @@
        android:description="@string/permdesc_accessCoarseLocation"
        android:protectionLevel="dangerous|instant" />

    <!-- Allows an app to access location in the background.  If you
         are requesting this, you should also request {@link #ACCESS_FINE_LOCATION}.
         Requesting this by itself is not sufficient to give you
         location access.
         <p>Protection level: dangerous
         @hide
    -->
    <permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"
        android:permissionGroup="android.permission-group.LOCATION"
        android:label="@string/permlab_accessBackgroundLocation"
        android:description="@string/permdesc_accessBackgroundLocation"
        android:protectionLevel="dangerous|instant" />

    <!-- ====================================================================== -->
    <!-- Permissions for accessing the call log                                 -->
    <!-- ====================================================================== -->
+8 −4
Original line number Diff line number Diff line
@@ -1082,10 +1082,9 @@
        with the operation of the GPS or other location sources.</string>

    <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
    <string name="permlab_accessFineLocation">access precise location (GPS and
      network-based)</string>
    <string name="permlab_accessFineLocation">access precise only in the foreground</string>
    <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
    <string name="permdesc_accessFineLocation">This app can get your location based on GPS or network location sources such as cell towers and Wi-Fi networks. These location services must be turned on and available on your phone for the app to be able to use them. This may increase battery consumption.</string>
    <string name="permdesc_accessFineLocation">This app can get your exact location only when it is in the foreground. These location services must be turned on and available on your phone for the app to be able to use them. This may increase battery consumption.</string>

    <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
    <string name="permlab_accessCoarseLocation">access approximate location
@@ -1097,6 +1096,11 @@
    <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
    <string name="permdesc_accessCoarseLocation" product="default">This app can get your location based on network sources such as cell towers and Wi-Fi networks. These location services must be turned on and available on your phone for the app to be able to use them.</string>

    <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
    <string name="permlab_accessBackgroundLocation">access precise location in the background</string>
    <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
    <string name="permdesc_accessBackgroundLocation">This app can get your exact location any time it is in the background. These location services must be turned on and available on your phone for the app to be able to use them. This may increase battery consumption.</string>

    <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
    <string name="permlab_modifyAudioSettings">change your audio settings</string>
    <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->