Loading flags/telecom_call_flags.aconfig +7 −0 Original line number Diff line number Diff line package: "com.android.server.telecom.flags" container: "system" flag { name: "prevent_redundant_location_permission_grant_and_revoke" namespace: "telecom" description: "avoid redundant action of grant and revoke location permission for multiple emergency calls" bug: "345386002" } flag { name: "transactional_cs_verifier" namespace: "telecom" Loading src/com/android/server/telecom/EmergencyCallHelper.java +9 −2 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.telecom.Log; import android.telecom.PhoneAccountHandle; import com.android.internal.annotations.VisibleForTesting; import com.android.server.telecom.flags.FeatureFlags; /** * Helps with emergency calls by: Loading Loading @@ -51,19 +52,25 @@ public class EmergencyCallHelper { private long mLastEmergencyCallTimestampMillis; private long mLastOutgoingEmergencyCallTimestampMillis; private final FeatureFlags mFeatureFlags; @VisibleForTesting public EmergencyCallHelper( Context context, DefaultDialerCache defaultDialerCache, Timeouts.Adapter timeoutsAdapter) { Timeouts.Adapter timeoutsAdapter, FeatureFlags featureFlags) { mContext = context; mDefaultDialerCache = defaultDialerCache; mTimeoutsAdapter = timeoutsAdapter; mFeatureFlags = featureFlags; } @VisibleForTesting public void maybeGrantTemporaryLocationPermission(Call call, UserHandle userHandle) { if (shouldGrantTemporaryLocationPermission(call)) { if (shouldGrantTemporaryLocationPermission(call) && ( !mFeatureFlags.preventRedundantLocationPermissionGrantAndRevoke() || !wasGrantedTemporaryLocationPermission())) { grantLocationPermission(userHandle); } if (call != null && call.isEmergencyCall()) { Loading src/com/android/server/telecom/InCallController.java +11 −3 Original line number Diff line number Diff line Loading @@ -1263,6 +1263,8 @@ public class InCallController extends CallsManagerListenerBase implements private ArraySet<String> mAllCarrierPrivilegedApps = new ArraySet<>(); private ArraySet<String> mActiveCarrierPrivilegedApps = new ArraySet<>(); private java.lang.Runnable mCallRemovedRunnable; public InCallController(Context context, TelecomSystem.SyncRoot lock, CallsManager callsManager, SystemStateHelper systemStateHelper, DefaultDialerCache defaultDialerCache, Timeouts.Adapter timeoutsAdapter, EmergencyCallHelper emergencyCallHelper, Loading Loading @@ -1476,7 +1478,11 @@ public class InCallController extends CallsManagerListenerBase implements /** Let's add a 2 second delay before we send unbind to the services to hopefully * give them enough time to process all the pending messages. */ mHandler.postDelayed(new Runnable("ICC.oCR", mLock) { if (mCallRemovedRunnable != null && mFeatureFlags.preventRedundantLocationPermissionGrantAndRevoke()) { mHandler.removeCallbacks(mCallRemovedRunnable); } mCallRemovedRunnable = new Runnable("ICC.oCR", mLock) { @Override public void loggedRun() { // Check again to make sure there are no active calls for the associated user. Loading @@ -1490,7 +1496,9 @@ public class InCallController extends CallsManagerListenerBase implements mEmergencyCallHelper.maybeRevokeTemporaryLocationPermission(); } } }.prepare(), mTimeoutsAdapter.getCallRemoveUnbindInCallServicesDelay( }.prepare(); mHandler.postDelayed(mCallRemovedRunnable, mTimeoutsAdapter.getCallRemoveUnbindInCallServicesDelay( mContext.getContentResolver())); } call.removeListener(mCallListener); Loading src/com/android/server/telecom/TelecomSystem.java +1 −1 Original line number Diff line number Diff line Loading @@ -288,7 +288,7 @@ public class TelecomSystem { mContactsAsyncHelper, mLock); EmergencyCallHelper emergencyCallHelper = new EmergencyCallHelper(mContext, defaultDialerCache, timeoutsAdapter); defaultDialerCache, timeoutsAdapter, mFeatureFlags); InCallControllerFactory inCallControllerFactory = new InCallControllerFactory() { @Override Loading tests/src/com/android/server/telecom/tests/EmergencyCallHelperTest.java +56 −1 Original line number Diff line number Diff line Loading @@ -75,7 +75,7 @@ public class EmergencyCallHelperTest extends TelecomTestCase { mContext = mComponentContextFixture.getTestDouble().getApplicationContext(); when(mContext.getPackageManager()).thenReturn(mPackageManager); mEmergencyCallHelper = new EmergencyCallHelper(mContext, mDefaultDialerCache, mTimeoutsAdapter); mTimeoutsAdapter, mFeatureFlags); when(mDefaultDialerCache.getSystemDialerApplication()).thenReturn(SYSTEM_DIALER_PACKAGE); //start with no perms Loading Loading @@ -183,6 +183,61 @@ public class EmergencyCallHelperTest extends TelecomTestCase { verifyRevokeNotInvokedFor(ACCESS_FINE_LOCATION); } @SmallTest @Test public void testPermGrantAndRevokeForEmergencyCall() { when(mFeatureFlags.preventRedundantLocationPermissionGrantAndRevoke()).thenReturn(true); mEmergencyCallHelper.maybeGrantTemporaryLocationPermission(mCall, mUserHandle); mEmergencyCallHelper.maybeRevokeTemporaryLocationPermission(); //permissions should be granted then revoked verifyGrantInvokedFor(ACCESS_BACKGROUND_LOCATION); verifyGrantInvokedFor(ACCESS_FINE_LOCATION); verifyRevokeInvokedFor(ACCESS_BACKGROUND_LOCATION); verifyRevokeInvokedFor(ACCESS_FINE_LOCATION); } @SmallTest @Test public void testPermGrantAndRevokeForMultiEmergencyCall() { when(mFeatureFlags.preventRedundantLocationPermissionGrantAndRevoke()).thenReturn(true); //first call is emergency call mEmergencyCallHelper.maybeGrantTemporaryLocationPermission(mCall, mUserHandle); //second call is emergency call mEmergencyCallHelper.maybeGrantTemporaryLocationPermission(mCall, mUserHandle); mEmergencyCallHelper.maybeRevokeTemporaryLocationPermission(); //permissions should be granted then revoked verifyGrantInvokedFor(ACCESS_BACKGROUND_LOCATION); verifyGrantInvokedFor(ACCESS_FINE_LOCATION); verifyRevokeInvokedFor(ACCESS_BACKGROUND_LOCATION); verifyRevokeInvokedFor(ACCESS_FINE_LOCATION); } @SmallTest @Test public void testPermGrantAndRevokeForEmergencyCallAndNormalCall() { when(mFeatureFlags.preventRedundantLocationPermissionGrantAndRevoke()).thenReturn(true); //first call is emergency call mEmergencyCallHelper.maybeGrantTemporaryLocationPermission(mCall, mUserHandle); //second call is normal call when(mCall.isEmergencyCall()).thenReturn(false); mEmergencyCallHelper.maybeGrantTemporaryLocationPermission(mCall, mUserHandle); mEmergencyCallHelper.maybeRevokeTemporaryLocationPermission(); //permissions should be granted then revoked verifyGrantInvokedFor(ACCESS_BACKGROUND_LOCATION); verifyGrantInvokedFor(ACCESS_FINE_LOCATION); verifyRevokeInvokedFor(ACCESS_BACKGROUND_LOCATION); verifyRevokeInvokedFor(ACCESS_FINE_LOCATION); } @SmallTest @Test public void testNoPermGrantForNonEmergencyCall() { Loading Loading
flags/telecom_call_flags.aconfig +7 −0 Original line number Diff line number Diff line package: "com.android.server.telecom.flags" container: "system" flag { name: "prevent_redundant_location_permission_grant_and_revoke" namespace: "telecom" description: "avoid redundant action of grant and revoke location permission for multiple emergency calls" bug: "345386002" } flag { name: "transactional_cs_verifier" namespace: "telecom" Loading
src/com/android/server/telecom/EmergencyCallHelper.java +9 −2 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.telecom.Log; import android.telecom.PhoneAccountHandle; import com.android.internal.annotations.VisibleForTesting; import com.android.server.telecom.flags.FeatureFlags; /** * Helps with emergency calls by: Loading Loading @@ -51,19 +52,25 @@ public class EmergencyCallHelper { private long mLastEmergencyCallTimestampMillis; private long mLastOutgoingEmergencyCallTimestampMillis; private final FeatureFlags mFeatureFlags; @VisibleForTesting public EmergencyCallHelper( Context context, DefaultDialerCache defaultDialerCache, Timeouts.Adapter timeoutsAdapter) { Timeouts.Adapter timeoutsAdapter, FeatureFlags featureFlags) { mContext = context; mDefaultDialerCache = defaultDialerCache; mTimeoutsAdapter = timeoutsAdapter; mFeatureFlags = featureFlags; } @VisibleForTesting public void maybeGrantTemporaryLocationPermission(Call call, UserHandle userHandle) { if (shouldGrantTemporaryLocationPermission(call)) { if (shouldGrantTemporaryLocationPermission(call) && ( !mFeatureFlags.preventRedundantLocationPermissionGrantAndRevoke() || !wasGrantedTemporaryLocationPermission())) { grantLocationPermission(userHandle); } if (call != null && call.isEmergencyCall()) { Loading
src/com/android/server/telecom/InCallController.java +11 −3 Original line number Diff line number Diff line Loading @@ -1263,6 +1263,8 @@ public class InCallController extends CallsManagerListenerBase implements private ArraySet<String> mAllCarrierPrivilegedApps = new ArraySet<>(); private ArraySet<String> mActiveCarrierPrivilegedApps = new ArraySet<>(); private java.lang.Runnable mCallRemovedRunnable; public InCallController(Context context, TelecomSystem.SyncRoot lock, CallsManager callsManager, SystemStateHelper systemStateHelper, DefaultDialerCache defaultDialerCache, Timeouts.Adapter timeoutsAdapter, EmergencyCallHelper emergencyCallHelper, Loading Loading @@ -1476,7 +1478,11 @@ public class InCallController extends CallsManagerListenerBase implements /** Let's add a 2 second delay before we send unbind to the services to hopefully * give them enough time to process all the pending messages. */ mHandler.postDelayed(new Runnable("ICC.oCR", mLock) { if (mCallRemovedRunnable != null && mFeatureFlags.preventRedundantLocationPermissionGrantAndRevoke()) { mHandler.removeCallbacks(mCallRemovedRunnable); } mCallRemovedRunnable = new Runnable("ICC.oCR", mLock) { @Override public void loggedRun() { // Check again to make sure there are no active calls for the associated user. Loading @@ -1490,7 +1496,9 @@ public class InCallController extends CallsManagerListenerBase implements mEmergencyCallHelper.maybeRevokeTemporaryLocationPermission(); } } }.prepare(), mTimeoutsAdapter.getCallRemoveUnbindInCallServicesDelay( }.prepare(); mHandler.postDelayed(mCallRemovedRunnable, mTimeoutsAdapter.getCallRemoveUnbindInCallServicesDelay( mContext.getContentResolver())); } call.removeListener(mCallListener); Loading
src/com/android/server/telecom/TelecomSystem.java +1 −1 Original line number Diff line number Diff line Loading @@ -288,7 +288,7 @@ public class TelecomSystem { mContactsAsyncHelper, mLock); EmergencyCallHelper emergencyCallHelper = new EmergencyCallHelper(mContext, defaultDialerCache, timeoutsAdapter); defaultDialerCache, timeoutsAdapter, mFeatureFlags); InCallControllerFactory inCallControllerFactory = new InCallControllerFactory() { @Override Loading
tests/src/com/android/server/telecom/tests/EmergencyCallHelperTest.java +56 −1 Original line number Diff line number Diff line Loading @@ -75,7 +75,7 @@ public class EmergencyCallHelperTest extends TelecomTestCase { mContext = mComponentContextFixture.getTestDouble().getApplicationContext(); when(mContext.getPackageManager()).thenReturn(mPackageManager); mEmergencyCallHelper = new EmergencyCallHelper(mContext, mDefaultDialerCache, mTimeoutsAdapter); mTimeoutsAdapter, mFeatureFlags); when(mDefaultDialerCache.getSystemDialerApplication()).thenReturn(SYSTEM_DIALER_PACKAGE); //start with no perms Loading Loading @@ -183,6 +183,61 @@ public class EmergencyCallHelperTest extends TelecomTestCase { verifyRevokeNotInvokedFor(ACCESS_FINE_LOCATION); } @SmallTest @Test public void testPermGrantAndRevokeForEmergencyCall() { when(mFeatureFlags.preventRedundantLocationPermissionGrantAndRevoke()).thenReturn(true); mEmergencyCallHelper.maybeGrantTemporaryLocationPermission(mCall, mUserHandle); mEmergencyCallHelper.maybeRevokeTemporaryLocationPermission(); //permissions should be granted then revoked verifyGrantInvokedFor(ACCESS_BACKGROUND_LOCATION); verifyGrantInvokedFor(ACCESS_FINE_LOCATION); verifyRevokeInvokedFor(ACCESS_BACKGROUND_LOCATION); verifyRevokeInvokedFor(ACCESS_FINE_LOCATION); } @SmallTest @Test public void testPermGrantAndRevokeForMultiEmergencyCall() { when(mFeatureFlags.preventRedundantLocationPermissionGrantAndRevoke()).thenReturn(true); //first call is emergency call mEmergencyCallHelper.maybeGrantTemporaryLocationPermission(mCall, mUserHandle); //second call is emergency call mEmergencyCallHelper.maybeGrantTemporaryLocationPermission(mCall, mUserHandle); mEmergencyCallHelper.maybeRevokeTemporaryLocationPermission(); //permissions should be granted then revoked verifyGrantInvokedFor(ACCESS_BACKGROUND_LOCATION); verifyGrantInvokedFor(ACCESS_FINE_LOCATION); verifyRevokeInvokedFor(ACCESS_BACKGROUND_LOCATION); verifyRevokeInvokedFor(ACCESS_FINE_LOCATION); } @SmallTest @Test public void testPermGrantAndRevokeForEmergencyCallAndNormalCall() { when(mFeatureFlags.preventRedundantLocationPermissionGrantAndRevoke()).thenReturn(true); //first call is emergency call mEmergencyCallHelper.maybeGrantTemporaryLocationPermission(mCall, mUserHandle); //second call is normal call when(mCall.isEmergencyCall()).thenReturn(false); mEmergencyCallHelper.maybeGrantTemporaryLocationPermission(mCall, mUserHandle); mEmergencyCallHelper.maybeRevokeTemporaryLocationPermission(); //permissions should be granted then revoked verifyGrantInvokedFor(ACCESS_BACKGROUND_LOCATION); verifyGrantInvokedFor(ACCESS_FINE_LOCATION); verifyRevokeInvokedFor(ACCESS_BACKGROUND_LOCATION); verifyRevokeInvokedFor(ACCESS_FINE_LOCATION); } @SmallTest @Test public void testNoPermGrantForNonEmergencyCall() { Loading