Skip to content

Commit

Permalink
Merge branch 'master' into emargolis/feature/doc-update-android-build…
Browse files Browse the repository at this point in the history
…ing-md
  • Loading branch information
andy31415 authored May 10, 2023
2 parents fa63838 + 447b9ec commit d1c7118
Show file tree
Hide file tree
Showing 33 changed files with 20,533 additions and 19,597 deletions.
8 changes: 6 additions & 2 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -677,10 +677,14 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
if (enable_tizen_builds) {
group("check:tizen") {
testonly = true
deps = [ "${chip_root}/src/test_driver/tizen/integration-tests:check" ]
deps = [ "${chip_root}/src/test_driver/tizen:check(${chip_root}/build/toolchain/tizen:tizen_arm)" ]
}

extra_check_deps += [ ":check:tizen" ]
# Include Tizen check target only if BLE is not enabled, since
# currently, QEMU-based Tizen does not support Bluetooth.
if (!chip_config_network_layer_ble) {
extra_check_deps += [ ":check:tizen" ]
}
}

if (enable_mw320_shell_build) {
Expand Down
2 changes: 2 additions & 0 deletions examples/android/CHIPTool/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
xmlns:tools="http://schemas.android.com/tools"
package="com.google.chip.chiptool">

<uses-sdk android:minSdkVersion="28" />

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import chip.platform.PreferencesKeyValueStoreManager
import com.google.chip.chiptool.attestation.ExampleAttestationTrustStoreDelegate
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException
import kotlin.coroutines.suspendCoroutine
import kotlinx.coroutines.suspendCancellableCoroutine

/** Lazily instantiates [ChipDeviceController] and holds a reference to it. */
object ChipClient {
Expand Down Expand Up @@ -75,7 +75,7 @@ object ChipClient {
// once we are done with the returned device pointer. Memory leak was introduced since the refactor
// that introduced it was very large in order to fix a use after free, which was considered to be
// worse than the memory leak that was introduced.
return suspendCoroutine { continuation ->
return suspendCancellableCoroutine { continuation ->
getDeviceController(context).getConnectedDevicePointer(
nodeId,
object : GetConnectedDeviceCallback {
Expand Down
6 changes: 3 additions & 3 deletions examples/chip-tool/commands/common/CHIPCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ CHIP_ERROR CHIPCommand::MaybeSetUpStack()
ReturnLogErrorOnFailure(chip::DeviceLayer::Internal::BLEMgrImpl().ConfigureBle(mBleAdapterId.ValueOr(0), true));
#endif

ReturnLogErrorOnFailure(mDefaultStorage.Init());
ReturnLogErrorOnFailure(mDefaultStorage.Init(nullptr, GetStorageDirectory().ValueOr(nullptr)));
ReturnLogErrorOnFailure(mOperationalKeystore.Init(&mDefaultStorage));
ReturnLogErrorOnFailure(mOpCertStore.Init(&mDefaultStorage));

Expand Down Expand Up @@ -326,7 +326,7 @@ CHIP_ERROR CHIPCommand::GetIdentityNodeId(std::string identity, chip::NodeId * n
return CHIP_NO_ERROR;
}

ReturnLogErrorOnFailure(mCommissionerStorage.Init(identity.c_str()));
ReturnLogErrorOnFailure(mCommissionerStorage.Init(identity.c_str(), GetStorageDirectory().ValueOr(nullptr)));

*nodeId = mCommissionerStorage.GetLocalNodeId();

Expand Down Expand Up @@ -419,7 +419,7 @@ CHIP_ERROR CHIPCommand::InitializeCommissioner(CommissionerIdentity & identity,
// TODO - OpCreds should only be generated for pairing command
// store the credentials in persistent storage, and
// generate when not available in the storage.
ReturnLogErrorOnFailure(mCommissionerStorage.Init(identity.mName.c_str()));
ReturnLogErrorOnFailure(mCommissionerStorage.Init(identity.mName.c_str(), GetStorageDirectory().ValueOr(nullptr)));
if (mUseMaxSizedCerts.HasValue())
{
auto option = CredentialIssuerCommands::CredentialIssuerOptions::kMaximizeCertificateSizes;
Expand Down
2 changes: 2 additions & 0 deletions examples/chip-tool/commands/common/CHIPCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ class CHIPCommand : public Command
AddArgument("trace_decode", 0, 1, &mTraceDecode);
#endif // CHIP_CONFIG_TRANSPORT_TRACE_ENABLED
AddArgument("ble-adapter", 0, UINT16_MAX, &mBleAdapterId);
AddArgument("storage-directory", &mStorageDirectory,
"Directory to place chip-tool's storage files in. Defaults to $TMPDIR, with fallback to /tmp");
}

/////////// Command Interface /////////
Expand Down
11 changes: 9 additions & 2 deletions examples/chip-tool/commands/common/Command.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,19 @@ class Command

bool IsInteractive() { return mIsInteractive; }

CHIP_ERROR RunAsInteractive()
CHIP_ERROR RunAsInteractive(const chip::Optional<char *> & interactiveStorageDirectory)
{
mIsInteractive = true;
mStorageDirectory = interactiveStorageDirectory;
mIsInteractive = true;
return Run();
}

const chip::Optional<char *> & GetStorageDirectory() const { return mStorageDirectory; }

protected:
// mStorageDirectory lives here so we can just set it in RunAsInteractive.
chip::Optional<char *> mStorageDirectory;

private:
bool InitArgument(size_t argIndex, char * argValue);
size_t AddArgument(const char * name, int64_t min, uint64_t max, void * out, ArgumentType type, const char * desc,
Expand Down
27 changes: 23 additions & 4 deletions examples/chip-tool/commands/common/Commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ int Commands::Run(int argc, char ** argv)
return (err == CHIP_NO_ERROR) ? EXIT_SUCCESS : EXIT_FAILURE;
}

int Commands::RunInteractive(const char * command)
int Commands::RunInteractive(const char * command, const chip::Optional<char *> & storageDirectory)
{
std::vector<std::string> arguments;
VerifyOrReturnValue(DecodeArgumentsFromInteractiveMode(command, arguments), EXIT_FAILURE);
Expand All @@ -174,7 +174,7 @@ int Commands::RunInteractive(const char * command)
}

ChipLogProgress(chipTool, "Command: %s", commandStr.c_str());
auto err = RunCommand(argc, argv, true);
auto err = RunCommand(argc, argv, true, storageDirectory);

// Do not delete arg[0]
for (auto i = 1; i < argc; i++)
Expand All @@ -185,7 +185,8 @@ int Commands::RunInteractive(const char * command)
return (err == CHIP_NO_ERROR) ? EXIT_SUCCESS : EXIT_FAILURE;
}

CHIP_ERROR Commands::RunCommand(int argc, char ** argv, bool interactive)
CHIP_ERROR Commands::RunCommand(int argc, char ** argv, bool interactive,
const chip::Optional<char *> & interactiveStorageDirectory)
{
Command * command = nullptr;

Expand Down Expand Up @@ -271,7 +272,25 @@ CHIP_ERROR Commands::RunCommand(int argc, char ** argv, bool interactive)
return CHIP_ERROR_INVALID_ARGUMENT;
}

return interactive ? command->RunAsInteractive() : command->Run();
if (interactive)
{
return command->RunAsInteractive(interactiveStorageDirectory);
}

// Now that the command is initialized, get our storage from it as needed
// and set up our loging level.
#ifdef CONFIG_USE_LOCAL_STORAGE
CHIP_ERROR err = mStorage.Init(nullptr, command->GetStorageDirectory().ValueOr(nullptr));
if (err != CHIP_NO_ERROR)
{
ChipLogError(Controller, "Init Storage failure: %s", chip::ErrorStr(err));
return err;
}

chip::Logging::SetLogFilter(mStorage.GetLoggingLevel());
#endif // CONFIG_USE_LOCAL_STORAGE

return command->Run();
}

Commands::ClusterMap::iterator Commands::GetCluster(std::string clusterName)
Expand Down
5 changes: 3 additions & 2 deletions examples/chip-tool/commands/common/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ class Commands

void Register(const char * clusterName, commands_list commandsList, const char * helpText = nullptr);
int Run(int argc, char ** argv);
int RunInteractive(const char * command);
int RunInteractive(const char * command, const chip::Optional<char *> & storageDirectory = chip::NullOptional);

private:
using ClusterMap = std::map<std::string, std::pair<CommandsVector, const char *>>;

CHIP_ERROR RunCommand(int argc, char ** argv, bool interactive = false);
CHIP_ERROR RunCommand(int argc, char ** argv, bool interactive = false,
const chip::Optional<char *> & interactiveStorageDirectory = chip::NullOptional);

ClusterMap::iterator GetCluster(std::string clusterName);
Command * GetCommand(CommandsVector & commands, std::string commandName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ bool InteractiveCommand::ParseCommand(char * command, int * status)

ClearLine();

*status = mHandler->RunInteractive(command);
*status = mHandler->RunInteractive(command, GetStorageDirectory());

return true;
}
Expand Down
Loading

0 comments on commit d1c7118

Please sign in to comment.