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

Commit 8d53811e authored by Evan Severson's avatar Evan Severson
Browse files

Don't show sensor use dialog for system uid

If the system uid is being noted for mic or camera op, it will have to
be explicitely accounted for to show the user any sort of UI to unmute
the mic or camera.

Test: Add some logcat statements to verify the correct code paths are
          being hit when placing and answering phone calls.
Bug: 195122900
Change-Id: I3d1995291eadfef6946d1eafe6a35c277bae21d1
parent e8394e91
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.hardware.SensorPrivacyManager;
import android.os.Binder;
import android.os.Bundle;
import android.os.Handler;
@@ -986,6 +987,7 @@ public class InCallController extends CallsManagerListenerBase implements

    private final Context mContext;
    private final AppOpsManager mAppOpsManager;
    private final SensorPrivacyManager mSensorPrivacyManager;
    private final TelecomSystem.SyncRoot mLock;
    private final CallsManager mCallsManager;
    private final SystemStateHelper mSystemStateHelper;
@@ -1042,6 +1044,7 @@ public class InCallController extends CallsManagerListenerBase implements
            CarModeTracker carModeTracker, ClockProxy clockProxy) {
        mContext = context;
        mAppOpsManager = context.getSystemService(AppOpsManager.class);
        mSensorPrivacyManager = context.getSystemService(SensorPrivacyManager.class);
        mLock = lock;
        mCallsManager = callsManager;
        mSystemStateHelper = systemStateHelper;
@@ -1397,6 +1400,7 @@ public class InCallController extends CallsManagerListenerBase implements
            if (shouldStart) {
                mAppOpsManager.startOp(AppOpsManager.OP_PHONE_CALL_CAMERA, myUid(),
                        mContext.getOpPackageName(), false, null, null);
                mSensorPrivacyManager.showSensorUseDialog(SensorPrivacyManager.Sensors.CAMERA);
            }
        } else {
            boolean hadCall = !mCallsUsingCamera.isEmpty();
@@ -2274,6 +2278,7 @@ public class InCallController extends CallsManagerListenerBase implements
            if (mIsCallUsingMicrophone) {
                mAppOpsManager.startOp(AppOpsManager.OP_PHONE_CALL_MICROPHONE, myUid(),
                        mContext.getOpPackageName(), false, null, null);
                mSensorPrivacyManager.showSensorUseDialog(SensorPrivacyManager.Sensors.MICROPHONE);
            } else {
                mAppOpsManager.finishOp(AppOpsManager.OP_PHONE_CALL_MICROPHONE, myUid(),
                        mContext.getOpPackageName(), null);
+6 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.hardware.SensorPrivacyManager;
import android.location.Country;
import android.location.CountryDetector;
import android.media.AudioManager;
@@ -221,6 +222,8 @@ public class ComponentContextFixture implements TestFixture<Context> {
                    return mVibratorManager;
                case Context.PERMISSION_CHECKER_SERVICE:
                    return mPermissionCheckerManager;
                case Context.SENSOR_PRIVACY_SERVICE:
                    return mSensorPrivacyManager;
                default:
                    return null;
            }
@@ -248,6 +251,8 @@ public class ComponentContextFixture implements TestFixture<Context> {
                return Context.VIBRATOR_MANAGER_SERVICE;
            } else if (svcClass == PermissionCheckerManager.class) {
                return Context.PERMISSION_CHECKER_SERVICE;
            } else if (svcClass == SensorPrivacyManager.class) {
                return Context.SENSOR_PRIVACY_SERVICE;
            }
            throw new UnsupportedOperationException();
        }
@@ -527,6 +532,7 @@ public class ComponentContextFixture implements TestFixture<Context> {
    private final PermissionCheckerManager mPermissionCheckerManager =
            mock(PermissionCheckerManager.class);
    private final PermissionInfo mPermissionInfo = mock(PermissionInfo.class);
    private final SensorPrivacyManager mSensorPrivacyManager = mock(SensorPrivacyManager.class);

    private TelecomManager mTelecomManager = mock(TelecomManager.class);