Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph-hart committed Nov 21, 2022
2 parents b361ccf + 8154a0b commit e90e794
Show file tree
Hide file tree
Showing 153 changed files with 10,426 additions and 11,740 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/ci_mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI Build
on:
workflow_dispatch:
push:
branches:
- develop
jobs:
ci_macos:
runs-on: [self-hosted, macos]
steps:
- name: Cleanup working directory
run: rm -rf "${{github.workspace}}"
- name: Checkout HISE repository
uses: actions/checkout@v1
with:
ref: 'develop'
- name: Build & Run CI script
working-directory: ${{ github.workspace }}/tools/auto_build/
run: sh ./build_ci.sh
ci_windows:
runs-on: [self-hosted, windows]
steps:
- name: Cleanup working directory
working-directory: ${{ github.workspace }}
run: del *.* /Q /S
shell: cmd
- name: Checkout HISE repository
uses: actions/checkout@v1
with:
ref: 'develop'
- name: Build HISE CI, run unit tests & export demo project
working-directory: ${{ github.workspace }}/tools/auto_build/
run: build_ci.bat
shell: cmd
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,7 @@ hi_snex/xml/
\#*\#
.\#*
*~
tools/faust/include
tools/faust/share
tools/faust/lib
tools/faust/bin
25 changes: 25 additions & 0 deletions JUCE/modules/juce_core/native/juce_android_SystemStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@ namespace AndroidStatsHelpers
javaString (name).get())));
}

static String getAndroidID()
{
auto* env = getEnv();

if (auto settings = (jclass) env->FindClass ("android/provider/Settings$Secure"))
{
if (auto fId = env->GetStaticFieldID (settings, "ANDROID_ID", "Ljava/lang/String;"))
{
auto androidID = (jstring) env->GetStaticObjectField (settings, fId);
return juceString (LocalRef<jstring> (androidID));
}
}

return "";
}

static String getLocaleValue (bool isRegion)
{
auto* env = getEnv();
Expand Down Expand Up @@ -170,6 +186,15 @@ String SystemStats::getUserLanguage() { return AndroidStatsHelpers::getLocale
String SystemStats::getUserRegion() { return AndroidStatsHelpers::getLocaleValue (true); }
String SystemStats::getDisplayLanguage() { return getUserLanguage() + "-" + getUserRegion(); }

String SystemStats::getUniqueDeviceID()
{
auto id = String ((uint64_t) AndroidStatsHelpers::getAndroidID().hashCode64());

// Please tell someone at JUCE if this occurs
jassert (id.isNotEmpty());
return id;
}

//==============================================================================
void CPUInformation::initialise() noexcept
{
Expand Down
58 changes: 58 additions & 0 deletions JUCE/modules/juce_core/native/juce_linux_SystemStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,64 @@ void CPUInformation::initialise() noexcept
#endif
}

String SystemStats::getUniqueDeviceID()
{
static const auto deviceId = []()
{
const auto call = [] (auto command) -> String
{
ChildProcess proc;

if (proc.start (command, ChildProcess::wantStdOut))
return proc.readAllProcessOutput();

return {};
};

auto data = call ("cat /sys/class/dmi/id/board_serial");

// 'board_serial' is enough on its own, fallback to bios stuff if we can't find it.
if (data.isEmpty())
{
data = call ("cat /sys/class/dmi/id/bios_date")
+ call ("cat /sys/class/dmi/id/bios_release")
+ call ("cat /sys/class/dmi/id/bios_vendor")
+ call ("cat /sys/class/dmi/id/bios_version");
}

auto cpuData = call ("lscpu");

if (cpuData.isNotEmpty())
{
auto getCpuInfo = [&cpuData] (auto key) -> String
{
auto index = cpuData.indexOf (key);

if (index >= 0)
{
auto start = cpuData.indexOf (index, ":");
auto end = cpuData.indexOf (start, "\n");

return cpuData.substring (start + 1, end).trim();
}

return {};
};

data += getCpuInfo ("CPU family:");
data += getCpuInfo ("Model:");
data += getCpuInfo ("Model name:");
data += getCpuInfo ("Vendor ID:");
}

return String ((uint64_t) data.hashCode64());
}();

// Please tell someone at JUCE if this occurs
jassert (deviceId.isNotEmpty());
return deviceId;
}

//==============================================================================
uint32 juce_millisecondsSinceStartup() noexcept
{
Expand Down
30 changes: 30 additions & 0 deletions JUCE/modules/juce_core/native/juce_mac_SystemStats.mm
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,34 @@ uint32 millisecondsSinceStartup() const noexcept
return (int) NSPageSize();
}

String SystemStats::getUniqueDeviceID()
{
static const auto deviceId = []
{
ChildProcess proc;

if (proc.start ("ioreg -rd1 -c IOPlatformExpertDevice", ChildProcess::wantStdOut))
{
constexpr const char key[] = "\"IOPlatformUUID\"";
constexpr const auto keyLen = (int) sizeof (key);

auto output = proc.readAllProcessOutput();
auto index = output.indexOf (key);

if (index >= 0)
{
auto start = output.indexOf (index + keyLen, "\"");
auto end = output.indexOf (start + 1, "\"");
return output.substring (start + 1, end).replace("-", "");
}
}

return String();
}();

// Please tell someone at JUCE if this occurs
jassert (deviceId.isNotEmpty());
return deviceId;
}

} // namespace juce
29 changes: 29 additions & 0 deletions JUCE/modules/juce_core/native/juce_win32_SystemStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,4 +587,33 @@ String SystemStats::getDisplayLanguage()
return languagesBuffer.data();
}

String SystemStats::getUniqueDeviceID()
{
#define PROVIDER(string) (DWORD) (string[0] << 24 | string[1] << 16 | string[2] << 8 | string[3])

auto bufLen = GetSystemFirmwareTable (PROVIDER ("RSMB"), PROVIDER ("RSDT"), nullptr, 0);

if (bufLen > 0)
{
HeapBlock<uint8_t> buffer { bufLen };
GetSystemFirmwareTable (PROVIDER ("RSMB"), PROVIDER ("RSDT"), (void*) buffer.getData(), bufLen);

return [&]
{
uint64_t hash = 0;
const auto start = buffer.getData();
const auto end = start + jmin (1024, (int) bufLen);

for (auto dataPtr = start; dataPtr != end; ++dataPtr)
hash = hash * (uint64_t) 101 + *dataPtr;

return String (hash);
}();
}

// Please tell someone at JUCE if this occurs
jassertfalse;
return {};
}

} // namespace juce
21 changes: 21 additions & 0 deletions JUCE/modules/juce_core/system/juce_SystemStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,25 @@ bool SystemStats::isRunningInAppExtensionSandbox() noexcept
#endif
}

#if JUCE_UNIT_TESTS

class UniqueHardwareIDTest : public UnitTest
{
public:
//==============================================================================
UniqueHardwareIDTest() : UnitTest ("UniqueHardwareID", UnitTestCategories::analytics) {}

void runTest() override
{
beginTest ("getUniqueDeviceID returns usable data.");
{
expect (SystemStats::getUniqueDeviceID().isNotEmpty());
}
}
};

static UniqueHardwareIDTest uniqueHardwareIDTest;

#endif

} // namespace juce
8 changes: 8 additions & 0 deletions JUCE/modules/juce_core/system/juce_SystemStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ class JUCE_API SystemStats final
*/
static StringArray getDeviceIdentifiers();

/** This method returns a machine unique ID unaffected by storage or peripheral
changes.
This ID will be invalidated by changes to the motherboard and CPU on non-mobile
platforms, or resetting an Android device.
*/
static String getUniqueDeviceID();

//==============================================================================
// CPU and memory information..

Expand Down
10 changes: 10 additions & 0 deletions JUCE/modules/juce_product_unlocking/juce_product_unlocking.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@
#include <juce_gui_extra/juce_gui_extra.h>
#endif

/** Config: JUCE_USE_BETTER_MACHINE_IDS
If enabled, this will use a more robust function to get the system ID to prevent
OS updates from changing the ID. By default it is deactivated for backwards compatibility,
but you can enable it if you want to use the new ID.
*/
#ifndef JUCE_USE_BETTER_MACHINE_IDS
#define JUCE_USE_BETTER_MACHINE_IDS 0
#endif

#if JUCE_IN_APP_PURCHASES
#include "in_app_purchases/juce_InAppPurchases.h"
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,16 +314,15 @@ void OnlineUnlockStatus::MachineIDUtilities::addMACAddressesToList (StringArray&
ids.add (getEncodedIDString (address.toString()));
}

#ifndef JUCE_CREATE_DUMMY_MACHINE_IDS
#define JUCE_CREATE_DUMMY_MACHINE_IDS 0
#endif
String OnlineUnlockStatus::MachineIDUtilities::getUniqueMachineID()
{
return getEncodedIDString (SystemStats::getUniqueDeviceID());
}

StringArray OnlineUnlockStatus::MachineIDUtilities::getLocalMachineIDs()
{
#if JUCE_CREATE_DUMMY_MACHINE_IDS
StringArray sa;
sa.add("DUMMYID1234");
return sa;
#if JUCE_USE_BETTER_MACHINE_IDS
return { getUniqueMachineID() };
#else
auto identifiers = SystemStats::getDeviceIdentifiers();

Expand All @@ -343,6 +342,27 @@ void OnlineUnlockStatus::userCancelled()
{
}

bool OnlineUnlockStatus::unlockWithTime(Time safeTimeObject)
{
Time times[2] = { getExpiryTime(), safeTimeObject };

if (times[0] == Time(0))
return isUnlocked();

var actualResult(0), dummyResult(1.0);

var v(!(times[0] < times[1]));
actualResult.swapWith(v);
v = var(times[0] == times[1]);
dummyResult.swapWith(v);
jassert(!dummyResult);

if ((!dummyResult) && actualResult)
status.setProperty(unlockedProp, actualResult, nullptr);

return var(actualResult);
}

void OnlineUnlockStatus::setUserEmail (const String& usernameOrEmail)
{
status.setProperty (userNameProp, usernameOrEmail, nullptr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,20 @@ class JUCE_API OnlineUnlockStatus
*/
inline Time getExpiryTime() const { return Time (static_cast<int64> (status[expiryTimeProp])); }

/** Attempts to unlock a license with an expiration date using a Time object that is verified in some way.
The function returns true if the expiration date is later than the supplied time object.
This modifies the value returned by isUnlocked() so if you don't want to distinguish between those scenarios,
you can use this to unlock the license if it's not expired (by default isUnlocked() will return false if the
license key file contains a expiration date).
Note: If you pass in Time::getCurrentTime() here, the user can just change the system clock to bypass
the activation check so make sure you are using a more reliable way to get the time.
If the license key doesn't contain an expiration data, this function will do nothing and just return the
current unlocked state.
*/
bool unlockWithTime(Time verifiedTimeObject);

/** Optionally allows the app to provide the user's email address if
it is known.
You don't need to call this, but if you do it may save the user
Expand Down Expand Up @@ -242,6 +256,7 @@ class JUCE_API OnlineUnlockStatus
/** Utility function that you may want to use in your machine-ID generation code.
This adds some ID strings to the given array which represent each MAC address of the machine.
*/
[[deprecated ("MAC addresses are no longer reliable methods of ID generation. You should use getUniqueMachineID() instead, You can still get a list of this device's MAC addresses with MACAddress::findAllAddresses().")]]
static void addMACAddressesToList (StringArray& result);

/** This method calculates some machine IDs based on things like network
Expand All @@ -260,6 +275,12 @@ class JUCE_API OnlineUnlockStatus
since the product was first registered.
*/
static StringArray getLocalMachineIDs();

/** Returns an encoded unique machine ID.
@see SystemStats::getUniqueDeviceID
*/
static String getUniqueMachineID();
};

private:
Expand Down
Loading

0 comments on commit e90e794

Please sign in to comment.