Remove GnssNi related code
Bug: 294306993
Test: on device
Change-Id: I5561796c73247a62385792e1976f66fba3bad381
diff --git a/core/java/com/android/internal/app/NetInitiatedActivity.java b/core/java/com/android/internal/app/NetInitiatedActivity.java
deleted file mode 100644
index f34aabb..0000000
--- a/core/java/com/android/internal/app/NetInitiatedActivity.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 2007 Google Inc.
- *
- * 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 com.android.internal.app;
-
-import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
-
-import android.app.AlertDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.location.LocationManagerInternal;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.util.Log;
-
-import com.android.internal.R;
-import com.android.internal.location.GpsNetInitiatedHandler;
-import com.android.server.LocalServices;
-
-/**
- * This activity is shown to the user for them to accept or deny network-initiated
- * requests. It uses the alert dialog style. It will be launched from a notification.
- */
-public class NetInitiatedActivity extends AlertActivity implements DialogInterface.OnClickListener {
-
- private static final String TAG = "NetInitiatedActivity";
-
- private static final boolean DEBUG = true;
-
- private static final int POSITIVE_BUTTON = AlertDialog.BUTTON_POSITIVE;
- private static final int NEGATIVE_BUTTON = AlertDialog.BUTTON_NEGATIVE;
-
- private static final int GPS_NO_RESPONSE_TIME_OUT = 1;
- // Received ID from intent, -1 when no notification is in progress
- private int notificationId = -1;
- private int timeout = -1;
- private int default_response = -1;
- private int default_response_timeout = 6;
-
- private final Handler mHandler = new Handler() {
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case GPS_NO_RESPONSE_TIME_OUT: {
- if (notificationId != -1) {
- sendUserResponse(default_response);
- }
- finish();
- }
- break;
- default:
- }
- }
- };
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
-
- // Set up the "dialog"
- final Intent intent = getIntent();
- final AlertController.AlertParams p = mAlertParams;
- Context context = getApplicationContext();
- p.mTitle = intent.getStringExtra(GpsNetInitiatedHandler.NI_INTENT_KEY_TITLE);
- p.mMessage = intent.getStringExtra(GpsNetInitiatedHandler.NI_INTENT_KEY_MESSAGE);
- p.mPositiveButtonText = String.format(context.getString(R.string.gpsVerifYes));
- p.mPositiveButtonListener = this;
- p.mNegativeButtonText = String.format(context.getString(R.string.gpsVerifNo));
- p.mNegativeButtonListener = this;
-
- notificationId = intent.getIntExtra(GpsNetInitiatedHandler.NI_INTENT_KEY_NOTIF_ID, -1);
- timeout = intent.getIntExtra(GpsNetInitiatedHandler.NI_INTENT_KEY_TIMEOUT, default_response_timeout);
- default_response = intent.getIntExtra(GpsNetInitiatedHandler.NI_INTENT_KEY_DEFAULT_RESPONSE, GpsNetInitiatedHandler.GPS_NI_RESPONSE_ACCEPT);
- if (DEBUG) Log.d(TAG, "onCreate() : notificationId: " + notificationId + " timeout: " + timeout + " default_response:" + default_response);
-
- mHandler.sendMessageDelayed(mHandler.obtainMessage(GPS_NO_RESPONSE_TIME_OUT), (timeout * 1000));
- setupAlert();
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- if (DEBUG) Log.d(TAG, "onResume");
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- if (DEBUG) Log.d(TAG, "onPause");
- }
-
- /**
- * {@inheritDoc}
- */
- public void onClick(DialogInterface dialog, int which) {
- if (which == POSITIVE_BUTTON) {
- sendUserResponse(GpsNetInitiatedHandler.GPS_NI_RESPONSE_ACCEPT);
- }
- if (which == NEGATIVE_BUTTON) {
- sendUserResponse(GpsNetInitiatedHandler.GPS_NI_RESPONSE_DENY);
- }
-
- // No matter what, finish the activity
- finish();
- notificationId = -1;
- }
-
- // Respond to NI Handler under GnssLocationProvider, 1 = accept, 2 = deny
- private void sendUserResponse(int response) {
- if (DEBUG) Log.d(TAG, "sendUserResponse, response: " + response);
- LocationManagerInternal lm = LocalServices.getService(LocationManagerInternal.class);
- lm.sendNiResponse(notificationId, response);
- }
-}
diff --git a/location/java/android/location/LocationManagerInternal.java b/location/java/android/location/LocationManagerInternal.java
index d59756d..a48cc19 100644
--- a/location/java/android/location/LocationManagerInternal.java
+++ b/location/java/android/location/LocationManagerInternal.java
@@ -87,12 +87,6 @@
public abstract boolean isProvider(@Nullable String provider, @NonNull CallerIdentity identity);
/**
- * Should only be used by GNSS code.
- */
- // TODO: there is no reason for this to exist as part of any API. move all the logic into gnss
- public abstract void sendNiResponse(int notifId, int userResponse);
-
- /**
* Returns the GNSS provided time.
*
* @return LocationTime object that includes the current time, according to the GNSS location
diff --git a/location/java/com/android/internal/location/GpsNetInitiatedHandler.java b/location/java/com/android/internal/location/GpsNetInitiatedHandler.java
index fba4249..ee2510f 100644
--- a/location/java/com/android/internal/location/GpsNetInitiatedHandler.java
+++ b/location/java/com/android/internal/location/GpsNetInitiatedHandler.java
@@ -18,28 +18,14 @@
import android.Manifest;
import android.annotation.RequiresPermission;
-import android.app.Notification;
-import android.app.NotificationManager;
-import android.compat.annotation.UnsupportedAppUsage;
-import android.content.BroadcastReceiver;
import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.location.INetInitiatedListener;
import android.location.LocationManager;
-import android.os.RemoteException;
import android.os.SystemClock;
-import android.os.UserHandle;
import android.telephony.TelephonyCallback;
import android.telephony.TelephonyManager;
import android.telephony.emergency.EmergencyNumber;
import android.util.Log;
-import com.android.internal.R;
-import com.android.internal.notification.SystemNotificationChannels;
-import com.android.internal.telephony.GsmAlphabet;
-
-import java.io.UnsupportedEncodingException;
import java.util.concurrent.TimeUnit;
/**
@@ -53,95 +39,20 @@
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
- // string constants for defining data fields in NI Intent
- public static final String NI_INTENT_KEY_NOTIF_ID = "notif_id";
- public static final String NI_INTENT_KEY_TITLE = "title";
- public static final String NI_INTENT_KEY_MESSAGE = "message";
- public static final String NI_INTENT_KEY_TIMEOUT = "timeout";
- public static final String NI_INTENT_KEY_DEFAULT_RESPONSE = "default_resp";
-
- // the extra command to send NI response to GnssLocationProvider
- public static final String NI_RESPONSE_EXTRA_CMD = "send_ni_response";
-
- // the extra command parameter names in the Bundle
- public static final String NI_EXTRA_CMD_NOTIF_ID = "notif_id";
- public static final String NI_EXTRA_CMD_RESPONSE = "response";
-
- // these need to match GpsNiType constants in gps_ni.h
- public static final int GPS_NI_TYPE_VOICE = 1;
- public static final int GPS_NI_TYPE_UMTS_SUPL = 2;
- public static final int GPS_NI_TYPE_UMTS_CTRL_PLANE = 3;
- public static final int GPS_NI_TYPE_EMERGENCY_SUPL = 4;
-
- // these need to match GpsUserResponseType constants in gps_ni.h
- public static final int GPS_NI_RESPONSE_ACCEPT = 1;
- public static final int GPS_NI_RESPONSE_DENY = 2;
- public static final int GPS_NI_RESPONSE_NORESP = 3;
- public static final int GPS_NI_RESPONSE_IGNORE = 4;
-
- // these need to match GpsNiNotifyFlags constants in gps_ni.h
- public static final int GPS_NI_NEED_NOTIFY = 0x0001;
- public static final int GPS_NI_NEED_VERIFY = 0x0002;
- public static final int GPS_NI_PRIVACY_OVERRIDE = 0x0004;
-
- // these need to match GpsNiEncodingType in gps_ni.h
- public static final int GPS_ENC_NONE = 0;
- public static final int GPS_ENC_SUPL_GSM_DEFAULT = 1;
- public static final int GPS_ENC_SUPL_UTF8 = 2;
- public static final int GPS_ENC_SUPL_UCS2 = 3;
- public static final int GPS_ENC_UNKNOWN = -1;
-
private final Context mContext;
private final TelephonyManager mTelephonyManager;
// parent gps location provider
private final LocationManager mLocationManager;
- // configuration of notificaiton behavior
- private boolean mPlaySounds = false;
- private boolean mPopupImmediately = true;
-
- // read the SUPL_ES form gps.conf
- private volatile boolean mIsSuplEsEnabled;
-
// Set to true if the phone is having emergency call.
private volatile boolean mIsInEmergencyCall;
- // If Location function is enabled.
- private volatile boolean mIsLocationEnabled = false;
-
- private final INetInitiatedListener mNetInitiatedListener;
-
- // Set to true if string from HAL is encoded as Hex, e.g., "3F0039"
- @UnsupportedAppUsage
- static private boolean mIsHexInput = true;
// End time of emergency call, and extension, if set
private volatile long mCallEndElapsedRealtimeMillis = 0;
private volatile long mEmergencyExtensionMillis = 0;
- public static class GpsNiNotification
- {
- @android.compat.annotation.UnsupportedAppUsage
- public GpsNiNotification() {
- }
- public int notificationId;
- public int niType;
- public boolean needNotify;
- public boolean needVerify;
- public boolean privacyOverride;
- public int timeout;
- public int defaultResponse;
- @UnsupportedAppUsage
- public String requestorId;
- @UnsupportedAppUsage
- public String text;
- @UnsupportedAppUsage
- public int requestorIdEncoding;
- @UnsupportedAppUsage
- public int textEncoding;
- }
-
/** Callbacks for Emergency call events. */
public interface EmergencyCallCallback {
/** Callback invoked when an emergency call starts */
@@ -182,72 +93,20 @@
// reference here.
private final EmergencyCallListener mEmergencyCallListener = new EmergencyCallListener();
- /**
- * The notification that is shown when a network-initiated notification
- * (and verification) event is received.
- * <p>
- * This is lazily created, so use {@link #setNINotification()}.
- */
- private Notification.Builder mNiNotificationBuilder;
-
private final EmergencyCallCallback mEmergencyCallCallback;
public GpsNetInitiatedHandler(Context context,
- INetInitiatedListener netInitiatedListener,
EmergencyCallCallback emergencyCallCallback,
boolean isSuplEsEnabled) {
mContext = context;
-
- if (netInitiatedListener == null) {
- throw new IllegalArgumentException("netInitiatedListener is null");
- } else {
- mNetInitiatedListener = netInitiatedListener;
- }
mEmergencyCallCallback = emergencyCallCallback;
- setSuplEsEnabled(isSuplEsEnabled);
mLocationManager = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
- updateLocationMode();
mTelephonyManager =
(TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
mTelephonyManager.registerTelephonyCallback(mContext.getMainExecutor(),
mEmergencyCallListener);
- BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
-
- @Override
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- if (action.equals(LocationManager.MODE_CHANGED_ACTION)) {
- updateLocationMode();
- if (DEBUG) Log.d(TAG, "location enabled :" + getLocationEnabled());
- }
- }
- };
- mContext.registerReceiver(broadcastReceiver,
- new IntentFilter(LocationManager.MODE_CHANGED_ACTION));
- }
-
- public void setSuplEsEnabled(boolean isEnabled) {
- mIsSuplEsEnabled = isEnabled;
- }
-
- public boolean getSuplEsEnabled() {
- return mIsSuplEsEnabled;
- }
-
- /**
- * Updates Location enabler based on location setting.
- */
- public void updateLocationMode() {
- mIsLocationEnabled = mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
- }
-
- /**
- * Checks if user agreed to use location.
- */
- public boolean getLocationEnabled() {
- return mIsLocationEnabled;
}
/**
@@ -289,346 +148,4 @@
public void setEmergencyExtensionSeconds(int emergencyExtensionSeconds) {
mEmergencyExtensionMillis = TimeUnit.SECONDS.toMillis(emergencyExtensionSeconds);
}
-
- // Handles NI events from HAL
- @UnsupportedAppUsage
- public void handleNiNotification(GpsNiNotification notif) {
- if (DEBUG) Log.d(TAG, "in handleNiNotification () :"
- + " notificationId: " + notif.notificationId
- + " requestorId: " + notif.requestorId
- + " text: " + notif.text
- + " mIsSuplEsEnabled" + getSuplEsEnabled()
- + " mIsLocationEnabled" + getLocationEnabled());
-
- if (getSuplEsEnabled()) {
- handleNiInEs(notif);
- } else {
- handleNi(notif);
- }
-
- //////////////////////////////////////////////////////////////////////////
- // A note about timeout
- // According to the protocol, in the need_notify and need_verify case,
- // a default response should be sent when time out.
- //
- // In some GPS hardware, the GPS driver (under HAL) can handle the timeout case
- // and this class GpsNetInitiatedHandler does not need to do anything.
- //
- // However, the UI should at least close the dialog when timeout. Further,
- // for more general handling, timeout response should be added to the Handler here.
- //
- }
-
- // handle NI form HAL when SUPL_ES is disabled.
- private void handleNi(GpsNiNotification notif) {
- if (DEBUG) Log.d(TAG, "in handleNi () :"
- + " needNotify: " + notif.needNotify
- + " needVerify: " + notif.needVerify
- + " privacyOverride: " + notif.privacyOverride
- + " mPopupImmediately: " + mPopupImmediately
- + " mInEmergency: " + getInEmergency());
-
- if (!getLocationEnabled() && !getInEmergency()) {
- // Location is currently disabled, ignore all NI requests.
- try {
- mNetInitiatedListener.sendNiResponse(notif.notificationId,
- GPS_NI_RESPONSE_IGNORE);
- } catch (RemoteException e) {
- Log.e(TAG, "RemoteException in sendNiResponse");
- }
- }
- if (notif.needNotify) {
- // If NI does not need verify or the dialog is not requested
- // to pop up immediately, the dialog box will not pop up.
- if (notif.needVerify && mPopupImmediately) {
- // Popup the dialog box now
- openNiDialog(notif);
- } else {
- // Show the notification
- setNiNotification(notif);
- }
- }
- // ACCEPT cases: 1. Notify, no verify; 2. no notify, no verify;
- // 3. privacy override.
- if (!notif.needVerify || notif.privacyOverride) {
- try {
- mNetInitiatedListener.sendNiResponse(notif.notificationId,
- GPS_NI_RESPONSE_ACCEPT);
- } catch (RemoteException e) {
- Log.e(TAG, "RemoteException in sendNiResponse");
- }
- }
- }
-
- // handle NI from HAL when the SUPL_ES is enabled
- private void handleNiInEs(GpsNiNotification notif) {
-
- if (DEBUG) Log.d(TAG, "in handleNiInEs () :"
- + " niType: " + notif.niType
- + " notificationId: " + notif.notificationId);
-
- // UE is in emergency mode when in emergency call mode or in emergency call back mode
- /*
- 1. When SUPL ES bit is off and UE is not in emergency mode:
- Call handleNi() to do legacy behaviour.
- 2. When SUPL ES bit is on and UE is in emergency mode:
- Call handleNi() to do acceptance behaviour.
- 3. When SUPL ES bit is off but UE is in emergency mode:
- Ignore the emergency SUPL INIT.
- 4. When SUPL ES bit is on but UE is not in emergency mode:
- Ignore the emergency SUPL INIT.
- */
- boolean isNiTypeES = (notif.niType == GPS_NI_TYPE_EMERGENCY_SUPL);
- if (isNiTypeES != getInEmergency()) {
- try {
- mNetInitiatedListener.sendNiResponse(notif.notificationId,
- GPS_NI_RESPONSE_IGNORE);
- } catch (RemoteException e) {
- Log.e(TAG, "RemoteException in sendNiResponse");
- }
- } else {
- handleNi(notif);
- }
- }
-
- /**
- * Posts a notification in the status bar using the contents in {@code notif} object.
- */
- private synchronized void setNiNotification(GpsNiNotification notif) {
- NotificationManager notificationManager = (NotificationManager) mContext
- .getSystemService(Context.NOTIFICATION_SERVICE);
- if (notificationManager == null) {
- return;
- }
-
- String title = getNotifTitle(notif, mContext);
- String message = getNotifMessage(notif, mContext);
-
- if (DEBUG) Log.d(TAG, "setNiNotification, notifyId: " + notif.notificationId +
- ", title: " + title +
- ", message: " + message);
-
- // Construct Notification
- if (mNiNotificationBuilder == null) {
- mNiNotificationBuilder = new Notification.Builder(mContext,
- SystemNotificationChannels.NETWORK_ALERTS)
- .setSmallIcon(com.android.internal.R.drawable.stat_sys_gps_on)
- .setWhen(0)
- .setOngoing(true)
- .setAutoCancel(true)
- .setColor(mContext.getColor(
- com.android.internal.R.color.system_notification_accent_color));
- }
-
- if (mPlaySounds) {
- mNiNotificationBuilder.setDefaults(Notification.DEFAULT_SOUND);
- } else {
- mNiNotificationBuilder.setDefaults(0);
- }
-
- mNiNotificationBuilder.setTicker(getNotifTicker(notif, mContext))
- .setContentTitle(title)
- .setContentText(message);
-
- notificationManager.notifyAsUser(null, notif.notificationId, mNiNotificationBuilder.build(),
- UserHandle.ALL);
- }
-
- // Opens the notification dialog and waits for user input
- private void openNiDialog(GpsNiNotification notif)
- {
- Intent intent = getDlgIntent(notif);
-
- if (DEBUG) Log.d(TAG, "openNiDialog, notifyId: " + notif.notificationId +
- ", requestorId: " + notif.requestorId +
- ", text: " + notif.text);
-
- mContext.startActivity(intent);
- }
-
- // Construct the intent for bringing up the dialog activity, which shows the
- // notification and takes user input
- private Intent getDlgIntent(GpsNiNotification notif)
- {
- Intent intent = new Intent();
- String title = getDialogTitle(notif, mContext);
- String message = getDialogMessage(notif, mContext);
-
- // directly bring up the NI activity
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
- intent.setClass(mContext, com.android.internal.app.NetInitiatedActivity.class);
-
- // put data in the intent
- intent.putExtra(NI_INTENT_KEY_NOTIF_ID, notif.notificationId);
- intent.putExtra(NI_INTENT_KEY_TITLE, title);
- intent.putExtra(NI_INTENT_KEY_MESSAGE, message);
- intent.putExtra(NI_INTENT_KEY_TIMEOUT, notif.timeout);
- intent.putExtra(NI_INTENT_KEY_DEFAULT_RESPONSE, notif.defaultResponse);
-
- if (DEBUG) Log.d(TAG, "generateIntent, title: " + title + ", message: " + message +
- ", timeout: " + notif.timeout);
-
- return intent;
- }
-
- // Converts a string (or Hex string) to a char array
- static byte[] stringToByteArray(String original, boolean isHex)
- {
- int length = isHex ? original.length() / 2 : original.length();
- byte[] output = new byte[length];
- int i;
-
- if (isHex)
- {
- for (i = 0; i < length; i++)
- {
- output[i] = (byte) Integer.parseInt(original.substring(i*2, i*2+2), 16);
- }
- }
- else {
- for (i = 0; i < length; i++)
- {
- output[i] = (byte) original.charAt(i);
- }
- }
-
- return output;
- }
-
- /**
- * Unpacks an byte array containing 7-bit packed characters into a String.
- *
- * @param input a 7-bit packed char array
- * @return the unpacked String
- */
- static String decodeGSMPackedString(byte[] input)
- {
- final char PADDING_CHAR = 0x00;
- int lengthBytes = input.length;
- int lengthSeptets = (lengthBytes * 8) / 7;
- String decoded;
-
- /* Special case where the last 7 bits in the last byte could hold a valid
- * 7-bit character or a padding character. Drop the last 7-bit character
- * if it is a padding character.
- */
- if (lengthBytes % 7 == 0) {
- if (lengthBytes > 0) {
- if ((input[lengthBytes - 1] >> 1) == PADDING_CHAR) {
- lengthSeptets = lengthSeptets - 1;
- }
- }
- }
-
- decoded = GsmAlphabet.gsm7BitPackedToString(input, 0, lengthSeptets);
-
- // Return "" if decoding of GSM packed string fails
- if (null == decoded) {
- Log.e(TAG, "Decoding of GSM packed string failed");
- decoded = "";
- }
-
- return decoded;
- }
-
- static String decodeUTF8String(byte[] input)
- {
- String decoded = "";
- try {
- decoded = new String(input, "UTF-8");
- }
- catch (UnsupportedEncodingException e)
- {
- throw new AssertionError();
- }
- return decoded;
- }
-
- static String decodeUCS2String(byte[] input)
- {
- String decoded = "";
- try {
- decoded = new String(input, "UTF-16");
- }
- catch (UnsupportedEncodingException e)
- {
- throw new AssertionError();
- }
- return decoded;
- }
-
- /** Decode NI string
- *
- * @param original The text string to be decoded
- * @param isHex Specifies whether the content of the string has been encoded as a Hex string. Encoding
- * a string as Hex can allow zeros inside the coded text.
- * @param coding Specifies the coding scheme of the string, such as GSM, UTF8, UCS2, etc. This coding scheme
- * needs to match those used passed to HAL from the native GPS driver. Decoding is done according
- * to the <code> coding </code>, after a Hex string is decoded. Generally, if the
- * notification strings don't need further decoding, <code> coding </code> encoding can be
- * set to -1, and <code> isHex </code> can be false.
- * @return the decoded string
- */
- @UnsupportedAppUsage
- static private String decodeString(String original, boolean isHex, int coding)
- {
- if (coding == GPS_ENC_NONE || coding == GPS_ENC_UNKNOWN) {
- return original;
- }
-
- byte[] input = stringToByteArray(original, isHex);
-
- switch (coding) {
- case GPS_ENC_SUPL_GSM_DEFAULT:
- return decodeGSMPackedString(input);
-
- case GPS_ENC_SUPL_UTF8:
- return decodeUTF8String(input);
-
- case GPS_ENC_SUPL_UCS2:
- return decodeUCS2String(input);
-
- default:
- Log.e(TAG, "Unknown encoding " + coding + " for NI text " + original);
- return original;
- }
- }
-
- // change this to configure notification display
- static private String getNotifTicker(GpsNiNotification notif, Context context)
- {
- String ticker = String.format(context.getString(R.string.gpsNotifTicker),
- decodeString(notif.requestorId, mIsHexInput, notif.requestorIdEncoding),
- decodeString(notif.text, mIsHexInput, notif.textEncoding));
- return ticker;
- }
-
- // change this to configure notification display
- static private String getNotifTitle(GpsNiNotification notif, Context context)
- {
- String title = String.format(context.getString(R.string.gpsNotifTitle));
- return title;
- }
-
- // change this to configure notification display
- static private String getNotifMessage(GpsNiNotification notif, Context context)
- {
- String message = String.format(context.getString(R.string.gpsNotifMessage),
- decodeString(notif.requestorId, mIsHexInput, notif.requestorIdEncoding),
- decodeString(notif.text, mIsHexInput, notif.textEncoding));
- return message;
- }
-
- // change this to configure dialog display (for verification)
- static public String getDialogTitle(GpsNiNotification notif, Context context)
- {
- return getNotifTitle(notif, context);
- }
-
- // change this to configure dialog display (for verification)
- static private String getDialogMessage(GpsNiNotification notif, Context context)
- {
- return getNotifMessage(notif, context);
- }
-
}
diff --git a/services/core/java/com/android/server/location/LocationManagerService.java b/services/core/java/com/android/server/location/LocationManagerService.java
index 595b2e4..74b7f08 100644
--- a/services/core/java/com/android/server/location/LocationManagerService.java
+++ b/services/core/java/com/android/server/location/LocationManagerService.java
@@ -1750,13 +1750,6 @@
}
@Override
- public void sendNiResponse(int notifId, int userResponse) {
- if (mGnssManagerService != null) {
- mGnssManagerService.sendNiResponse(notifId, userResponse);
- }
- }
-
- @Override
public @Nullable LocationTime getGnssTimeMillis() {
LocationProviderManager gpsManager = getLocationProviderManager(GPS_PROVIDER);
if (gpsManager == null) {
diff --git a/services/core/java/com/android/server/location/gnss/GnssLocationProvider.java b/services/core/java/com/android/server/location/gnss/GnssLocationProvider.java
index ed5c130..e97a12a 100644
--- a/services/core/java/com/android/server/location/gnss/GnssLocationProvider.java
+++ b/services/core/java/com/android/server/location/gnss/GnssLocationProvider.java
@@ -62,7 +62,6 @@
import android.database.ContentObserver;
import android.location.GnssCapabilities;
import android.location.GnssStatus;
-import android.location.INetInitiatedListener;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
@@ -109,7 +108,6 @@
import com.android.internal.annotations.GuardedBy;
import com.android.internal.app.IBatteryStats;
import com.android.internal.location.GpsNetInitiatedHandler;
-import com.android.internal.location.GpsNetInitiatedHandler.GpsNiNotification;
import com.android.internal.util.FrameworkStatsLog;
import com.android.internal.util.HexDump;
import com.android.server.FgThread;
@@ -396,7 +394,6 @@
mC2KServerPort = mGnssConfiguration.getC2KPort(TCP_MIN_PORT);
mNIHandler.setEmergencyExtensionSeconds(mGnssConfiguration.getEsExtensionSec());
mSuplEsEnabled = mGnssConfiguration.getSuplEs(0) == 1;
- mNIHandler.setSuplEsEnabled(mSuplEsEnabled);
if (mGnssVisibilityControl != null) {
mGnssVisibilityControl.onConfigurationUpdated(mGnssConfiguration);
}
@@ -465,7 +462,6 @@
}
};
mNIHandler = new GpsNetInitiatedHandler(context,
- mNetInitiatedListener,
emergencyCallCallback,
mSuplEsEnabled);
// Trigger PSDS data download when the network comes up after booting.
@@ -1435,96 +1431,6 @@
updateRequirements();
}
- //=============================================================
- // NI Client support
- //=============================================================
- private final INetInitiatedListener mNetInitiatedListener = new INetInitiatedListener.Stub() {
- // Sends a response for an NI request to HAL.
- @Override
- public boolean sendNiResponse(int notificationId, int userResponse) {
- // TODO Add Permission check
-
- if (DEBUG) {
- Log.d(TAG, "sendNiResponse, notifId: " + notificationId
- + ", response: " + userResponse);
- }
- mGnssNative.sendNiResponse(notificationId, userResponse);
-
- FrameworkStatsLog.write(FrameworkStatsLog.GNSS_NI_EVENT_REPORTED,
- FrameworkStatsLog.GNSS_NI_EVENT_REPORTED__EVENT_TYPE__NI_RESPONSE,
- notificationId,
- /* niType= */ 0,
- /* needNotify= */ false,
- /* needVerify= */ false,
- /* privacyOverride= */ false,
- /* timeout= */ 0,
- /* defaultResponse= */ 0,
- /* requestorId= */ null,
- /* text= */ null,
- /* requestorIdEncoding= */ 0,
- /* textEncoding= */ 0,
- mSuplEsEnabled,
- isGpsEnabled(),
- userResponse);
-
- return true;
- }
- };
-
- public INetInitiatedListener getNetInitiatedListener() {
- return mNetInitiatedListener;
- }
-
- /** Reports a NI notification. */
- private void reportNiNotification(int notificationId, int niType, int notifyFlags, int timeout,
- int defaultResponse, String requestorId, String text, int requestorIdEncoding,
- int textEncoding) {
- Log.i(TAG, "reportNiNotification: entered");
- Log.i(TAG, "notificationId: " + notificationId
- + ", niType: " + niType
- + ", notifyFlags: " + notifyFlags
- + ", timeout: " + timeout
- + ", defaultResponse: " + defaultResponse);
-
- Log.i(TAG, "requestorId: " + requestorId
- + ", text: " + text
- + ", requestorIdEncoding: " + requestorIdEncoding
- + ", textEncoding: " + textEncoding);
-
- GpsNiNotification notification = new GpsNiNotification();
-
- notification.notificationId = notificationId;
- notification.niType = niType;
- notification.needNotify = (notifyFlags & GpsNetInitiatedHandler.GPS_NI_NEED_NOTIFY) != 0;
- notification.needVerify = (notifyFlags & GpsNetInitiatedHandler.GPS_NI_NEED_VERIFY) != 0;
- notification.privacyOverride =
- (notifyFlags & GpsNetInitiatedHandler.GPS_NI_PRIVACY_OVERRIDE) != 0;
- notification.timeout = timeout;
- notification.defaultResponse = defaultResponse;
- notification.requestorId = requestorId;
- notification.text = text;
- notification.requestorIdEncoding = requestorIdEncoding;
- notification.textEncoding = textEncoding;
-
- mNIHandler.handleNiNotification(notification);
- FrameworkStatsLog.write(FrameworkStatsLog.GNSS_NI_EVENT_REPORTED,
- FrameworkStatsLog.GNSS_NI_EVENT_REPORTED__EVENT_TYPE__NI_REQUEST,
- notification.notificationId,
- notification.niType,
- notification.needNotify,
- notification.needVerify,
- notification.privacyOverride,
- notification.timeout,
- notification.defaultResponse,
- notification.requestorId,
- notification.text,
- notification.requestorIdEncoding,
- notification.textEncoding,
- mSuplEsEnabled,
- isGpsEnabled(),
- /* userResponse= */ 0);
- }
-
private void demandUtcTimeInjection() {
if (DEBUG) Log.d(TAG, "demandUtcTimeInjection");
postWithWakeLockHeld(mNetworkTimeHelper::demandUtcTimeInjection);
@@ -1829,14 +1735,6 @@
}
@Override
- public void onReportNiNotification(int notificationId, int niType, int notifyFlags,
- int timeout, int defaultResponse, String requestorId, String text,
- int requestorIdEncoding, int textEncoding) {
- reportNiNotification(notificationId, niType, notifyFlags, timeout,
- defaultResponse, requestorId, text, requestorIdEncoding, textEncoding);
- }
-
- @Override
public void onRequestSetID(@GnssNative.AGpsCallbacks.AgpsSetIdFlags int flags) {
TelephonyManager phone = (TelephonyManager)
mContext.getSystemService(Context.TELEPHONY_SERVICE);
diff --git a/services/core/java/com/android/server/location/gnss/GnssManagerService.java b/services/core/java/com/android/server/location/gnss/GnssManagerService.java
index c962bc4..133704d 100644
--- a/services/core/java/com/android/server/location/gnss/GnssManagerService.java
+++ b/services/core/java/com/android/server/location/gnss/GnssManagerService.java
@@ -38,7 +38,6 @@
import android.location.util.identity.CallerIdentity;
import android.os.BatteryStats;
import android.os.Binder;
-import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.util.IndentingPrintWriter;
@@ -275,17 +274,6 @@
}
/**
- * Send Ni Response, indicating a location request initiated by a network carrier.
- */
- public void sendNiResponse(int notifId, int userResponse) {
- try {
- mGnssLocationProvider.getNetInitiatedListener().sendNiResponse(notifId, userResponse);
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
- }
-
- /**
* Dump info for debugging.
*/
public void dump(FileDescriptor fd, IndentingPrintWriter ipw, String[] args) {
diff --git a/services/core/java/com/android/server/location/gnss/hal/GnssNative.java b/services/core/java/com/android/server/location/gnss/hal/GnssNative.java
index 7618419..bdd4885 100644
--- a/services/core/java/com/android/server/location/gnss/hal/GnssNative.java
+++ b/services/core/java/com/android/server/location/gnss/hal/GnssNative.java
@@ -284,9 +284,6 @@
/** Callbacks for notifications. */
public interface NotificationCallbacks {
- void onReportNiNotification(int notificationId, int niType, int notifyFlags,
- int timeout, int defaultResponse, String requestorId, String text,
- int requestorIdEncoding, int textEncoding);
void onReportNfwNotification(String proxyAppPackageName, byte protocolStack,
String otherProtocolStackName, byte requestor, String requestorId,
byte responseType, boolean inEmergencyMode, boolean isCachedLocation);
@@ -933,14 +930,6 @@
}
/**
- * Send a network initiated respnse.
- */
- public void sendNiResponse(int notificationId, int userResponse) {
- Preconditions.checkState(mRegistered);
- mGnssHal.sendNiResponse(notificationId, userResponse);
- }
-
- /**
* Request an eventual update of GNSS power statistics.
*/
public void requestPowerStats() {
@@ -1244,16 +1233,6 @@
}
@NativeEntryPoint
- void reportNiNotification(int notificationId, int niType, int notifyFlags,
- int timeout, int defaultResponse, String requestorId, String text,
- int requestorIdEncoding, int textEncoding) {
- Binder.withCleanCallingIdentity(
- () -> mNotificationCallbacks.onReportNiNotification(notificationId, niType,
- notifyFlags, timeout, defaultResponse, requestorId, text,
- requestorIdEncoding, textEncoding));
- }
-
- @NativeEntryPoint
void requestSetID(int flags) {
Binder.withCleanCallingIdentity(() -> mAGpsCallbacks.onRequestSetID(flags));
}
@@ -1488,10 +1467,6 @@
return native_is_gnss_visibility_control_supported();
}
- protected void sendNiResponse(int notificationId, int userResponse) {
- native_send_ni_response(notificationId, userResponse);
- }
-
protected void requestPowerStats() {
native_request_power_stats();
}
@@ -1648,8 +1623,6 @@
private static native boolean native_is_gnss_visibility_control_supported();
- private static native void native_send_ni_response(int notificationId, int userResponse);
-
// power stats APIs
private static native void native_request_power_stats();
diff --git a/services/core/jni/com_android_server_location_GnssLocationProvider.cpp b/services/core/jni/com_android_server_location_GnssLocationProvider.cpp
index e1de05c..11c40d7 100644
--- a/services/core/jni/com_android_server_location_GnssLocationProvider.cpp
+++ b/services/core/jni/com_android_server_location_GnssLocationProvider.cpp
@@ -69,7 +69,6 @@
static jclass class_gnssPowerStats;
-static jmethodID method_reportNiNotification;
static jmethodID method_reportGnssPowerStats;
static jmethodID method_reportNfwNotification;
static jmethodID method_isInEmergencySession;
@@ -92,8 +91,6 @@
using android::hardware::gnss::V1_0::GnssLocationFlags;
using android::hardware::gnss::V1_0::IGnssNavigationMessage;
using android::hardware::gnss::V1_0::IGnssNavigationMessageCallback;
-using android::hardware::gnss::V1_0::IGnssNi;
-using android::hardware::gnss::V1_0::IGnssNiCallback;
using android::hardware::gnss::V1_0::IGnssXtra;
using android::hardware::gnss::V1_0::IGnssXtraCallback;
using android::hardware::gnss::V2_0::ElapsedRealtimeFlags;
@@ -127,7 +124,6 @@
using GnssLocationAidl = android::hardware::gnss::GnssLocation;
using IGnssAntennaInfoAidl = android::hardware::gnss::IGnssAntennaInfo;
-sp<IGnssNi> gnssNiIface = nullptr;
sp<IGnssPowerIndication> gnssPowerIndicationIface = nullptr;
std::unique_ptr<android::gnss::GnssHal> gnssHal = nullptr;
@@ -195,42 +191,6 @@
return Status::ok();
}
-/*
- * GnssNiCallback implements callback methods required by the IGnssNi interface.
- */
-struct GnssNiCallback : public IGnssNiCallback {
- Return<void> niNotifyCb(const IGnssNiCallback::GnssNiNotification& notification)
- override;
-};
-
-Return<void> GnssNiCallback::niNotifyCb(
- const IGnssNiCallback::GnssNiNotification& notification) {
- JNIEnv* env = getJniEnv();
- jstring requestorId = env->NewStringUTF(notification.requestorId.c_str());
- jstring text = env->NewStringUTF(notification.notificationMessage.c_str());
-
- if (requestorId && text) {
- env->CallVoidMethod(mCallbacksObj, method_reportNiNotification,
- notification.notificationId, notification.niType,
- notification.notifyFlags, notification.timeoutSec,
- notification.defaultResponse, requestorId, text,
- notification.requestorIdEncoding,
- notification.notificationIdEncoding);
- } else {
- ALOGE("%s: OOM Error\n", __func__);
- }
-
- if (requestorId) {
- env->DeleteLocalRef(requestorId);
- }
-
- if (text) {
- env->DeleteLocalRef(text);
- }
- checkAndClearExceptionFromCallback(env, __FUNCTION__);
- return Void();
-}
-
/* Initializes the GNSS service handle. */
static void android_location_gnss_hal_GnssNative_set_gps_service_handle() {
gnssHal = std::make_unique<gnss::GnssHal>();
@@ -242,10 +202,6 @@
android_location_gnss_hal_GnssNative_set_gps_service_handle();
// Cache methodIDs and class IDs.
-
- method_reportNiNotification = env->GetMethodID(clazz, "reportNiNotification",
- "(IIIIILjava/lang/String;Ljava/lang/String;II)V");
-
method_reportNfwNotification = env->GetMethodID(clazz, "reportNfwNotification",
"(Ljava/lang/String;BLjava/lang/String;BLjava/lang/String;BZZ)V");
method_reportGnssPowerStats =
@@ -305,7 +261,6 @@
gnssAntennaInfoIface = gnssHal->getGnssAntennaInfoInterface();
gnssMeasurementCorrectionsIface = gnssHal->getMeasurementCorrectionsInterface();
gnssDebugIface = gnssHal->getGnssDebugInterface();
- gnssNiIface = gnssHal->getGnssNiInterface();
gnssConfigurationIface = gnssHal->getGnssConfigurationInterface();
gnssGeofencingIface = gnssHal->getGnssGeofenceInterface();
gnssBatchingIface = gnssHal->getGnssBatchingInterface();
@@ -376,15 +331,6 @@
ALOGI("Unable to initialize IGnssGeofencing interface.");
}
- // Set IGnssNi.hal callback.
- sp<IGnssNiCallback> gnssNiCbIface = new GnssNiCallback();
- if (gnssNiIface != nullptr) {
- auto status = gnssNiIface->setCallback(gnssNiCbIface);
- checkHidlReturn(status, "IGnssNi setCallback() failed.");
- } else {
- ALOGI("Unable to initialize IGnssNi interface.");
- }
-
// Set IAGnssRil callback.
if (agnssRilIface == nullptr ||
!agnssRilIface->setCallback(std::make_unique<gnss::AGnssRilCallback>())) {
@@ -592,18 +538,6 @@
}
}
-static void android_location_gnss_hal_GnssNative_send_ni_response(JNIEnv* /* env */, jclass,
- jint notifId, jint response) {
- if (gnssNiIface == nullptr) {
- ALOGE("%s: IGnssNi interface not available.", __func__);
- return;
- }
-
- auto result = gnssNiIface->respond(notifId,
- static_cast<IGnssNiCallback::GnssUserResponseType>(response));
- checkHidlReturn(result, "IGnssNi respond() failed.");
-}
-
static jstring android_location_gnss_hal_GnssNative_get_internal_state(JNIEnv* env, jclass) {
/*
* TODO: Create a jobject to represent GnssDebug.
@@ -987,8 +921,6 @@
reinterpret_cast<void*>(android_location_gnss_hal_GnssNative_set_agps_server)},
{"native_inject_ni_supl_message_data", "([BII)V",
reinterpret_cast<void*>(android_location_gnss_hal_GnssNative_inject_ni_supl_message_data)},
- {"native_send_ni_response", "(II)V",
- reinterpret_cast<void*>(android_location_gnss_hal_GnssNative_send_ni_response)},
{"native_get_internal_state", "()Ljava/lang/String;",
reinterpret_cast<void*>(android_location_gnss_hal_GnssNative_get_internal_state)},
{"native_is_gnss_visibility_control_supported", "()Z",
diff --git a/services/tests/mockingservicestests/src/com/android/server/location/gnss/hal/FakeGnssHal.java b/services/tests/mockingservicestests/src/com/android/server/location/gnss/hal/FakeGnssHal.java
index 2d962ac..1a8b12a 100644
--- a/services/tests/mockingservicestests/src/com/android/server/location/gnss/hal/FakeGnssHal.java
+++ b/services/tests/mockingservicestests/src/com/android/server/location/gnss/hal/FakeGnssHal.java
@@ -686,9 +686,6 @@
}
@Override
- protected void sendNiResponse(int notificationId, int userResponse) {}
-
- @Override
protected void requestPowerStats() {
Objects.requireNonNull(mGnssNative).reportGnssPowerStats(mState.mPowerStats);
}