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

Commit c9fd7aa9 authored by Rocky Fang's avatar Rocky Fang
Browse files

Add debug log to show why sensor event connection is not created

Bug: 362600798
Test: Presubmit
Flag: EXEMPT bugfix
Change-Id: Ib596938785f7e08a1f946f6d13445aa03a6a6550
parent 493e36c9
Loading
Loading
Loading
Loading
+18 −3
Original line number Diff line number Diff line
@@ -1583,6 +1583,10 @@ sp<ISensorEventConnection> SensorService::createSensorEventConnection(const Stri
    // Only 4 modes supported for a SensorEventConnection ... NORMAL, DATA_INJECTION,
    // REPLAY_DATA_INJECTION and HAL_BYPASS_REPLAY_DATA_INJECTION
    if (requestedMode != NORMAL && !isInjectionMode(requestedMode)) {
      ALOGE(
          "Failed to create sensor event connection: invalid request mode. "
          "requestMode: %d",
          requestedMode);
      return nullptr;
    }
    resetTargetSdkVersionCache(opPackageName);
@@ -1591,8 +1595,19 @@ sp<ISensorEventConnection> SensorService::createSensorEventConnection(const Stri
    // To create a client in DATA_INJECTION mode to inject data, SensorService should already be
    // operating in DI mode.
    if (requestedMode == DATA_INJECTION) {
        if (mCurrentOperatingMode != DATA_INJECTION) return nullptr;
        if (!isAllowListedPackage(packageName)) return nullptr;
      if (mCurrentOperatingMode != DATA_INJECTION) {
        ALOGE(
            "Failed to create sensor event connection: sensor service not in "
            "DI mode when creating a client in DATA_INJECTION mode");
        return nullptr;
      }
      if (!isAllowListedPackage(packageName)) {
        ALOGE(
            "Failed to create sensor event connection: package %s not in "
            "allowed list for DATA_INJECTION mode",
            packageName.c_str());
        return nullptr;
      }
    }

    uid_t uid = IPCThreadState::self()->getCallingUid();