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

Commit 3f4886b5 authored by Chris Manton's avatar Chris Manton Committed by Gerrit Code Review
Browse files

Merge "headless: Add check to see if android is running"

parents 22b2f51e f6ba9971
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ cc_binary {
        "main.cc",
        "messenger.cc",
        "pairing/pairing.cc",
        "util.cc",
        "discovery/discovery.cc",
        "dumpsys/dumpsys.cc",
        "scan/scan.cc",
+6 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@
#include "test/headless/read/read.h"
#include "test/headless/scan/scan.h"
#include "test/headless/sdp/sdp.h"
#include "test/headless/util.h"

using namespace bluetooth::test::headless;

@@ -123,6 +124,11 @@ class Main : public HeadlessTest<int> {
    }

    start_trick_the_android_logging_subsystem();
    if (is_android_running()) {
      LOG_CONSOLE("Android must be shutdown for binary to run");
      LOG_CONSOLE("     /system/bin/stop");
      return -1;
    }
    LOG_CONSOLE("bt_headless version:\'%s\'", build_id().c_str());
    int rc = HeadlessTest<int>::Run();
    stop_trick_the_android_logging_subsystem();
+34 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 The Android Open Source Project
 *
 * 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.
 */

#include <string>

#include "osi/include/properties.h"

namespace {
constexpr char kZygoteService[] = "init.svc.zygote";
constexpr char kZygoteServiceRunning[] = "running";

}  // namespace

bool is_android_running() {
  char value[PROPERTY_VALUE_MAX];
  osi_property_get(kZygoteService, value, kZygoteServiceRunning);
  if (!strncmp(kZygoteServiceRunning, value, PROPERTY_VALUE_MAX)) {
    return true;
  }
  return false;
}
+17 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 The Android Open Source Project
 *
 * 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.
 */

bool is_android_running();