Add remaining files
[juce-lv2.git] / juce / source / src / native / android / juce_android_SystemStats.cpp
blob07a2a6a94eea5a425cffd5269ba502bde5adc07e
1 /*
2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 // (This file gets included by juce_android_NativeCode.cpp, rather than being
27 // compiled on its own).
28 #if JUCE_INCLUDED_FILE
30 //==============================================================================
31 namespace AndroidStatsHelpers
33 String getSystemProperty (const String& name)
35 return juceString (LocalRef<jstring> ((jstring) getEnv()->CallStaticObjectMethod (android.systemClass,
36 android.getProperty,
37 javaString (name).get())));
41 //==============================================================================
42 SystemStats::OperatingSystemType SystemStats::getOperatingSystemType()
44 return Android;
47 String SystemStats::getOperatingSystemName()
49 return "Android " + AndroidStatsHelpers::getSystemProperty ("os.version");
52 bool SystemStats::isOperatingSystem64Bit()
54 #if JUCE_64BIT
55 return true;
56 #else
57 return false;
58 #endif
61 String SystemStats::getCpuVendor()
63 return AndroidStatsHelpers::getSystemProperty ("os.arch");
66 int SystemStats::getCpuSpeedInMegaherz()
68 return 0; // TODO
71 int SystemStats::getMemorySizeInMegabytes()
73 // xxx they forgot to implement sysinfo in the library, dammit! Should put this stuff back when they fix it.
74 /* struct sysinfo sysi;
76 if (sysinfo (&sysi) == 0)
77 return (sysi.totalram * sysi.mem_unit / (1024 * 1024));
79 DBG ("warning! memory size is unavailable due to an Android bug!");
80 return 0;
83 int SystemStats::getPageSize()
85 return sysconf (_SC_PAGESIZE);
88 //==============================================================================
89 String SystemStats::getLogonName()
91 const char* user = getenv ("USER");
93 if (user == 0)
95 struct passwd* const pw = getpwuid (getuid());
96 if (pw != 0)
97 user = pw->pw_name;
100 return CharPointer_UTF8 (user);
103 String SystemStats::getFullUserName()
105 return getLogonName();
108 String SystemStats::getComputerName()
110 char name [256] = { 0 };
111 if (gethostname (name, sizeof (name) - 1) == 0)
112 return name;
114 return String::empty;
117 //==============================================================================
118 SystemStats::CPUFlags::CPUFlags()
120 // TODO
121 hasMMX = false;
122 hasSSE = false;
123 hasSSE2 = false;
124 has3DNow = false;
126 numCpus = jmax (1, sysconf (_SC_NPROCESSORS_ONLN));
129 void PlatformUtilities::fpuReset() {}
131 //==============================================================================
132 uint32 juce_millisecondsSinceStartup() noexcept
134 timespec t;
135 clock_gettime (CLOCK_MONOTONIC, &t);
137 return t.tv_sec * 1000 + t.tv_nsec / 1000000;
140 int64 Time::getHighResolutionTicks() noexcept
142 timespec t;
143 clock_gettime (CLOCK_MONOTONIC, &t);
145 return (t.tv_sec * (int64) 1000000) + (t.tv_nsec / 1000);
148 int64 Time::getHighResolutionTicksPerSecond() noexcept
150 return 1000000; // (microseconds)
153 double Time::getMillisecondCounterHiRes() noexcept
155 return getHighResolutionTicks() * 0.001;
158 bool Time::setSystemTimeToThisTime() const
160 jassertfalse;
161 return false;
165 #endif