Provide last known cell id for emergency call am: 8330df01a7
Original change: https://android-review.googlesource.com/c/platform/packages/services/Telecomm/+/1869707
Change-Id: Iea82cbf715f351d58762c4c82d8fe16da32fd467
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 45e3151..0776e9d 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -56,6 +56,7 @@
<uses-permission android:name="android.permission.READ_BLOCKED_NUMBERS"/>
<uses-permission android:name="android.permission.WRITE_BLOCKED_NUMBERS"/>
<uses-permission android:name="android.permission.SUBSTITUTE_NOTIFICATION_APP_NAME"/>
+ <uses-permission android:name="com.android.phone.permission.ACCESS_LAST_KNOWN_CELL_ID"/>
<permission android:name="android.permission.BROADCAST_CALLLOG_INFO"
android:label="Broadcast the call type/duration information"
diff --git a/src/com/android/server/telecom/ConnectionServiceWrapper.java b/src/com/android/server/telecom/ConnectionServiceWrapper.java
index da2669c..4018d54 100755
--- a/src/com/android/server/telecom/ConnectionServiceWrapper.java
+++ b/src/com/android/server/telecom/ConnectionServiceWrapper.java
@@ -45,6 +45,8 @@
import android.telecom.StatusHints;
import android.telecom.TelecomManager;
import android.telecom.VideoProfile;
+import android.telephony.CellIdentity;
+import android.telephony.TelephonyManager;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telecom.IConnectionService;
@@ -1236,6 +1238,24 @@
}
}
+ private CellIdentity getLastKnownCellIdentity() {
+ TelephonyManager telephonyManager = mContext.getSystemService(TelephonyManager.class);
+ if (telephonyManager != null) {
+ CellIdentity lastKnownCellIdentity = telephonyManager.getLastKnownCellIdentity();
+ try {
+ mAppOpsManager.noteOp(AppOpsManager.OP_FINE_LOCATION,
+ mContext.getPackageManager().getPackageUid(
+ getComponentName().getPackageName(), 0),
+ getComponentName().getPackageName());
+ } catch (PackageManager.NameNotFoundException nameNotFoundException) {
+ Log.e(this, nameNotFoundException, "could not find the package -- %s",
+ getComponentName().getPackageName());
+ }
+ return lastKnownCellIdentity;
+ }
+ return null;
+ }
+
/**
* Creates a conference for a new outgoing call or attach to an existing incoming call.
*/
@@ -1355,6 +1375,11 @@
Log.piiHandle(call.getHandle()) + " via:" +
getComponentName().getPackageName());
+ if (call.isEmergencyCall()) {
+ extras.putParcelable(Connection.EXTRA_LAST_KNOWN_CELL_IDENTITY,
+ getLastKnownCellIdentity());
+ }
+
ConnectionRequest connectionRequest = new ConnectionRequest.Builder()
.setAccountHandle(call.getTargetPhoneAccount())
.setAddress(call.getHandle())