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

Commit 1fa23ed0 authored by Eugene Susla's avatar Eugene Susla
Browse files

[CDM] Bypass location setting when scanning for devices

Fixes: 140524365
Test: turn off location in settings and ensure devices still shown in UI
Change-Id: Ifea696c18977fc5e94d93ced4f5d8b916587d0ec
parent 0d2e2c2b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2175,6 +2175,7 @@ package android.content.pm {
  public class PermissionInfo extends android.content.pm.PackageItemInfo implements android.os.Parcelable {
    field public static final int FLAG_REMOVED = 2; // 0x2
    field public static final int PROTECTION_FLAG_APP_PREDICTOR = 2097152; // 0x200000
    field public static final int PROTECTION_FLAG_COMPANION = 8388608; // 0x800000
    field public static final int PROTECTION_FLAG_CONFIGURATOR = 524288; // 0x80000
    field public static final int PROTECTION_FLAG_DOCUMENTER = 262144; // 0x40000
    field public static final int PROTECTION_FLAG_INCIDENT_REPORT_APPROVER = 1048576; // 0x100000
+1 −0
Original line number Diff line number Diff line
@@ -809,6 +809,7 @@ package android.content.pm {
  public class PermissionInfo extends android.content.pm.PackageItemInfo implements android.os.Parcelable {
    field public static final int FLAG_REMOVED = 2; // 0x2
    field public static final int PROTECTION_FLAG_APP_PREDICTOR = 2097152; // 0x200000
    field public static final int PROTECTION_FLAG_COMPANION = 8388608; // 0x800000
    field public static final int PROTECTION_FLAG_CONFIGURATOR = 524288; // 0x80000
    field public static final int PROTECTION_FLAG_DOCUMENTER = 262144; // 0x40000
    field public static final int PROTECTION_FLAG_INCIDENT_REPORT_APPROVER = 1048576; // 0x100000
+12 −0
Original line number Diff line number Diff line
@@ -248,6 +248,17 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable {
    @TestApi
    public static final int PROTECTION_FLAG_TELEPHONY = 0x400000;

    /**
     * Additional flag for {@link #protectionLevel}, corresponding
     * to the <code>companion</code> value of
     * {@link android.R.attr#protectionLevel}.
     *
     * @hide
     */
    @SystemApi
    @TestApi
    public static final int PROTECTION_FLAG_COMPANION = 0x800000;

    /** @hide */
    @IntDef(flag = true, prefix = { "PROTECTION_FLAG_" }, value = {
            PROTECTION_FLAG_PRIVILEGED,
@@ -270,6 +281,7 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable {
            PROTECTION_FLAG_INCIDENT_REPORT_APPROVER,
            PROTECTION_FLAG_APP_PREDICTOR,
            PROTECTION_FLAG_TELEPHONY,
            PROTECTION_FLAG_COMPANION,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface ProtectionFlags {}
+43 −0
Original line number Diff line number Diff line
@@ -135,6 +135,13 @@ public class ArrayUtils {
        return (T[]) cache;
    }

    /**
     * Returns the same array or an empty one if it's null.
     */
    public static @NonNull <T> T[] emptyIfNull(@Nullable T[] items, Class<T> kind) {
        return items != null ? items : emptyArray(kind);
    }

    /**
     * Checks if given array is null or has zero elements.
     */
@@ -751,6 +758,42 @@ public class ArrayUtils {
        return result;
    }

    /**
     * Returns an array containing elements from the given one that match the given predicate.
     */
    public static @Nullable <T> T[] filter(@Nullable T[] items,
            @NonNull IntFunction<T[]> arrayConstructor,
            @NonNull java.util.function.Predicate<T> predicate) {
        if (isEmpty(items)) {
            return items;
        }

        int matchesCount = 0;
        int size = size(items);
        for (int i = 0; i < size; i++) {
            if (predicate.test(items[i])) {
                matchesCount++;
            }
        }
        if (matchesCount == 0) {
            return items;
        }
        if (matchesCount == items.length) {
            return items;
        }
        if (matchesCount == 0) {
            return null;
        }
        T[] result = arrayConstructor.apply(matchesCount);
        int outIdx = 0;
        for (int i = 0; i < size; i++) {
            if (predicate.test(items[i])) {
                result[outIdx++] = items[i];
            }
        }
        return result;
    }

    public static boolean startsWith(byte[] cur, byte[] val) {
        if (cur == null || val == null) return false;
        if (cur.length < val.length) return false;
+8 −0
Original line number Diff line number Diff line
@@ -1629,6 +1629,14 @@
    <permission android:name="android.permission.NETWORK_SETTINGS"
        android:protectionLevel="signature|telephony" />

    <!-- Allows holder to request bluetooth/wifi scan bypassing global "use location" setting and
         location permissions.
         <p>Not for use by third-party or privileged applications.
         @hide
    -->
    <permission android:name="android.permission.RADIO_SCAN_WITHOUT_LOCATION"
                android:protectionLevel="signature|companion" />

    <!-- Allows SetupWizard to call methods in Networking services
         <p>Not for use by any other third-party or privileged applications.
         @SystemApi
Loading