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

Commit dafe9975 authored by Soonil Nagarkar's avatar Soonil Nagarkar Committed by Automerger Merge Worker
Browse files

DO NOT MERGE Update NFW location access notification strings am: bfef65af am: 77a0961a

Change-Id: I6b9bf592bd1d8103bc11ba51e55fa7b601d90bbb
parents 2fe30a17 77a0961a
Loading
Loading
Loading
Loading
+13 −0
Original line number Original line Diff line number Diff line
@@ -3897,6 +3897,19 @@
         information. -->
         information. -->
    <string name="gpsVerifNo">No</string>
    <string name="gpsVerifNo">No</string>


    <!-- Notification title shown to user to inform them their device location was accessed by
         an external entity during an emergency (usually an emergency phone call).
         [CHAR LIMIT=40] -->
    <string name="gnss_nfw_notification_title">Emergency location accessed</string>
    <!-- Notification message shown to user to inform them their device location was accessed by
         something OEM related during an emergency (usually an emergency phone call).
         [CHAR LIMIT=NONE] -->
    <string name="gnss_nfw_notification_message_oem">Your device manufacturer accessed your location during a recent emergency session</string>
    <!-- Notification message shown to user to inform them their device location was accessed by
         something carrier related during an emergency (usually an emergency phone call).
         [CHAR LIMIT=NONE] -->
    <string name="gnss_nfw_notification_message_carrier">Your carrier accessed your location during a recent emergency session</string>

    <!-- Error message when the sync tried to delete too many things -->
    <!-- Error message when the sync tried to delete too many things -->
    <string name="sync_too_many_deletes">Delete limit exceeded</string>
    <string name="sync_too_many_deletes">Delete limit exceeded</string>
    <!-- Dialog message for when there are too many deletes that would take place and we want user confirmation -->
    <!-- Dialog message for when there are too many deletes that would take place and we want user confirmation -->
+3 −0
Original line number Original line Diff line number Diff line
@@ -740,6 +740,9 @@
  <java-symbol type="string" name="gpsNotifTitle" />
  <java-symbol type="string" name="gpsNotifTitle" />
  <java-symbol type="string" name="gpsVerifNo" />
  <java-symbol type="string" name="gpsVerifNo" />
  <java-symbol type="string" name="gpsVerifYes" />
  <java-symbol type="string" name="gpsVerifYes" />
  <java-symbol type="string" name="gnss_nfw_notification_title" />
  <java-symbol type="string" name="gnss_nfw_notification_message_carrier" />
  <java-symbol type="string" name="gnss_nfw_notification_message_oem" />
  <java-symbol type="string" name="gsm_alphabet_default_charset" />
  <java-symbol type="string" name="gsm_alphabet_default_charset" />
  <java-symbol type="string" name="httpError" />
  <java-symbol type="string" name="httpError" />
  <java-symbol type="string" name="httpErrorAuth" />
  <java-symbol type="string" name="httpErrorAuth" />
+4 −0
Original line number Original line Diff line number Diff line
@@ -256,6 +256,10 @@ message SystemMessage {
    // Package: android
    // Package: android
    NOTE_ADB_WIFI_ACTIVE = 62;
    NOTE_ADB_WIFI_ACTIVE = 62;


    // Notify user there was a non-framework gnss location access during an emergency
    // Package: android
    NOTE_GNSS_NFW_LOCATION_ACCESS = 63;

    // ADD_NEW_IDS_ABOVE_THIS_LINE
    // ADD_NEW_IDS_ABOVE_THIS_LINE
    // Legacy IDs with arbitrary values appear below
    // Legacy IDs with arbitrary values appear below
    // Legacy IDs existed as stable non-conflicting constants prior to the O release
    // Legacy IDs existed as stable non-conflicting constants prior to the O release
+46 −48
Original line number Original line Diff line number Diff line
@@ -21,13 +21,13 @@ import android.annotation.SuppressLint;
import android.app.AppOpsManager;
import android.app.AppOpsManager;
import android.app.Notification;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import android.hardware.gnss.visibility_control.V1_0.IGnssVisibilityControlCallback;
import android.location.LocationManager;
import android.location.LocationManager;
import android.os.Handler;
import android.os.Handler;
import android.os.Looper;
import android.os.Looper;
@@ -39,12 +39,14 @@ import android.util.Log;


import com.android.internal.R;
import com.android.internal.R;
import com.android.internal.location.GpsNetInitiatedHandler;
import com.android.internal.location.GpsNetInitiatedHandler;
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.util.FrameworkStatsLog;
import com.android.internal.util.FrameworkStatsLog;


import java.util.Arrays;
import java.util.Arrays;
import java.util.List;
import java.util.List;
import java.util.Map;
import java.util.Map;
import java.util.Objects;


/**
/**
 * Handles GNSS non-framework location access user visibility and control.
 * Handles GNSS non-framework location access user visibility and control.
@@ -283,21 +285,22 @@ class GnssVisibilityControl {


    // Represents NfwNotification structure in IGnssVisibilityControlCallback.hal
    // Represents NfwNotification structure in IGnssVisibilityControlCallback.hal
    private static class NfwNotification {
    private static class NfwNotification {
        // These must match with NfwResponseType enum in IGnssVisibilityControlCallback.hal.

        private static final byte NFW_RESPONSE_TYPE_REJECTED = 0;
        // These must match with NfwResponseType enum in IGnssVisibilityControlCallback.hal
        private static final byte NFW_RESPONSE_TYPE_ACCEPTED_NO_LOCATION_PROVIDED = 1;
        static final byte NFW_RESPONSE_TYPE_REJECTED = 0;
        private static final byte NFW_RESPONSE_TYPE_ACCEPTED_LOCATION_PROVIDED = 2;
        static final byte NFW_RESPONSE_TYPE_ACCEPTED_NO_LOCATION_PROVIDED = 1;

        static final byte NFW_RESPONSE_TYPE_ACCEPTED_LOCATION_PROVIDED = 2;
        private final String mProxyAppPackageName;

        private final byte mProtocolStack;
        final String mProxyAppPackageName;
        private final String mOtherProtocolStackName;
        final byte mProtocolStack;
        private final byte mRequestor;
        final String mOtherProtocolStackName;
        private final String mRequestorId;
        final byte mRequestor;
        private final byte mResponseType;
        final String mRequestorId;
        private final boolean mInEmergencyMode;
        final byte mResponseType;
        private final boolean mIsCachedLocation;
        final boolean mInEmergencyMode;

        final boolean mIsCachedLocation;
        private NfwNotification(String proxyAppPackageName, byte protocolStack,

        NfwNotification(String proxyAppPackageName, byte protocolStack,
                String otherProtocolStackName, byte requestor, String requestorId,
                String otherProtocolStackName, byte requestor, String requestorId,
                byte responseType, boolean inEmergencyMode, boolean isCachedLocation) {
                byte responseType, boolean inEmergencyMode, boolean isCachedLocation) {
            mProxyAppPackageName = proxyAppPackageName;
            mProxyAppPackageName = proxyAppPackageName;
@@ -610,43 +613,38 @@ class GnssVisibilityControl {
        logEvent(nfwNotification, isPermissionMismatched);
        logEvent(nfwNotification, isPermissionMismatched);


        if (nfwNotification.isLocationProvided()) {
        if (nfwNotification.isLocationProvided()) {
            postEmergencyLocationUserNotification(nfwNotification);
            displayNfwNotification(nfwNotification);
        }
        }
        }

    private void postEmergencyLocationUserNotification(NfwNotification nfwNotification) {
        // Emulate deprecated IGnssNi.hal user notification of emergency NI requests.
        NotificationManager notificationManager = (NotificationManager) mContext
                .getSystemService(Context.NOTIFICATION_SERVICE);
        if (notificationManager == null) {
            Log.w(TAG, "Could not notify user of emergency location request. Notification: "
                    + nfwNotification);
            return;
    }
    }


        notificationManager.notifyAsUser(/* tag= */ null, /* notificationId= */ 0,
    private void displayNfwNotification(NfwNotification nfwNotification) {
                createEmergencyLocationUserNotification(mContext), UserHandle.ALL);
        NotificationManager notificationManager = Objects.requireNonNull(
    }
                mContext.getSystemService(NotificationManager.class));


    private static Notification createEmergencyLocationUserNotification(Context context) {
        String title = mContext.getString(R.string.gnss_nfw_notification_title);
        // NOTE: Do not reuse the returned notification object as it will not reflect
        String message;
        //       changes to notification text when the system language is changed.
        if (nfwNotification.mRequestor == IGnssVisibilityControlCallback.NfwRequestor.CARRIER) {
        final String firstLineText = context.getString(R.string.gpsNotifTitle);
            message = mContext.getString(R.string.gnss_nfw_notification_message_carrier);
        final String secondLineText =  context.getString(R.string.global_action_emergency);
        } else {
        final String accessibilityServicesText = firstLineText + " (" + secondLineText + ")";
            message = mContext.getString(R.string.gnss_nfw_notification_message_oem);
        return new Notification.Builder(context, SystemNotificationChannels.NETWORK_ALERTS)
        }
                .setSmallIcon(com.android.internal.R.drawable.stat_sys_gps_on)

                .setWhen(0)
        Notification.Builder builder = new Notification.Builder(mContext,
                .setOngoing(false)
                SystemNotificationChannels.NETWORK_ALERTS)
                .setSmallIcon(R.drawable.stat_sys_gps_on)
                .setCategory(Notification.CATEGORY_SYSTEM)
                .setVisibility(Notification.VISIBILITY_SECRET)
                .setContentTitle(title)
                .setTicker(title)
                .setContentText(message)
                .setStyle(new Notification.BigTextStyle().bigText(message))
                .setAutoCancel(true)
                .setAutoCancel(true)
                .setColor(context.getColor(
                .setColor(mContext.getColor(R.color.system_notification_accent_color))
                        com.android.internal.R.color.system_notification_accent_color))
                .setWhen(System.currentTimeMillis())
                .setDefaults(0)
                .setShowWhen(true)
                .setTicker(accessibilityServicesText)
                .setDefaults(0);
                .setContentTitle(firstLineText)

                .setContentText(secondLineText)
        notificationManager.notify(SystemMessage.NOTE_GNSS_NFW_LOCATION_ACCESS, builder.build());
                .setContentIntent(PendingIntent.getBroadcast(context, 0, new Intent(), 0))
                .build();
    }
    }


    private void logEvent(NfwNotification notification, boolean isPermissionMismatched) {
    private void logEvent(NfwNotification notification, boolean isPermissionMismatched) {