Skip to content

Commit

Permalink
Add functions to query the iPhone model name and iOS version
Browse files Browse the repository at this point in the history
Summary:
This returns the name of the current platform, for example `iPhone14,2`, and the version of the OS that's is running on the current platform, for example `17.6.1`.

This information will be used for the Hyperscape VRS files.

Reviewed By: janherling

Differential Revision: D65453491

fbshipit-source-id: 698d87fe5c9046a99e759a25a3562a3a0e235d15
  • Loading branch information
enpe authored and facebook-github-bot committed Nov 6, 2024
1 parent 49d3238 commit 00a05bc
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
objects = {

/* Begin PBXBuildFile section */
5042A4502CDAEFE10088D9DC /* System.h in Headers */ = {isa = PBXBuildFile; fileRef = 5042A44F2CDAEFE10088D9DC /* System.h */; };
5042A4512CDAEFE10088D9DC /* System.h in Headers */ = {isa = PBXBuildFile; fileRef = 5042A44F2CDAEFE10088D9DC /* System.h */; };
5042A4532CDAF02C0088D9DC /* System.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5042A4522CDAF02C0088D9DC /* System.mm */; };
5042A4542CDAF02C0088D9DC /* System.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5042A4522CDAF02C0088D9DC /* System.mm */; };
5DF0BD601D901DA400BE5D21 /* Utilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DD0BFC71BD1547700ABBC5B /* Utilities.h */; };
9309A54126B1D2CA00E3924A /* MessengerView.h in Headers */ = {isa = PBXBuildFile; fileRef = 9309A54026B1D2CA00E3924A /* MessengerView.h */; };
9309A54226B1D2CA00E3924A /* MessengerView.h in Headers */ = {isa = PBXBuildFile; fileRef = 9309A54026B1D2CA00E3924A /* MessengerView.h */; };
Expand All @@ -28,6 +32,8 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
5042A44F2CDAEFE10088D9DC /* System.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = System.h; path = /Users/nilsplath/fbsource/xplat/ocean/impl/ocean/platform/apple/ios/System.h; sourceTree = "<absolute>"; };
5042A4522CDAF02C0088D9DC /* System.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = System.mm; path = /Users/nilsplath/fbsource/xplat/ocean/impl/ocean/platform/apple/ios/System.mm; sourceTree = "<absolute>"; };
5DD0BFC71BD1547700ABBC5B /* Utilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Utilities.h; path = ../../../../../../../impl/ocean/platform/apple/ios/Utilities.h; sourceTree = "<group>"; };
5DF0BD661D901DA400BE5D21 /* libOceanPlatformAppleIOSD.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libOceanPlatformAppleIOSD.a; sourceTree = BUILT_PRODUCTS_DIR; };
9309A54026B1D2CA00E3924A /* MessengerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MessengerView.h; path = ../../../../../../../impl/ocean/platform/apple/ios/MessengerView.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -83,6 +89,7 @@
9309A54326B1D30800E3924A /* MessengerView.mm */,
93B184431FD2144F006F8B9B /* OpenGLFrameMediumViewController.mm */,
93C7C90D1FD2049600C8D59C /* OpenGLViewController.mm */,
5042A4522CDAF02C0088D9DC /* System.mm */,
93D233261F9566AA00F8BCAD /* Utilities.mm */,
);
name = "Source Files";
Expand All @@ -95,6 +102,7 @@
9309A54026B1D2CA00E3924A /* MessengerView.h */,
93B184461FD2145F006F8B9B /* OpenGLFrameMediumViewController.h */,
93C7C9081FD2045A00C8D59C /* OpenGLViewController.h */,
5042A44F2CDAEFE10088D9DC /* System.h */,
5DD0BFC71BD1547700ABBC5B /* Utilities.h */,
);
name = "Header Files";
Expand All @@ -112,6 +120,7 @@
5DF0BD601D901DA400BE5D21 /* Utilities.h in Headers */,
9309A54126B1D2CA00E3924A /* MessengerView.h in Headers */,
93B184471FD2145F006F8B9B /* OpenGLFrameMediumViewController.h in Headers */,
5042A4502CDAEFE10088D9DC /* System.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -124,6 +133,7 @@
C041EC9F1DABEF6E00BF5D76 /* Utilities.h in Headers */,
9309A54226B1D2CA00E3924A /* MessengerView.h in Headers */,
93B184481FD2145F006F8B9B /* OpenGLFrameMediumViewController.h in Headers */,
5042A4512CDAEFE10088D9DC /* System.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -229,6 +239,7 @@
buildActionMask = 2147483647;
files = (
9309A54426B1D30800E3924A /* MessengerView.mm in Sources */,
5042A4532CDAF02C0088D9DC /* System.mm in Sources */,
9360F7951FA15BC000BD37D1 /* Utilities.mm in Sources */,
93C7C9101FD2049600C8D59C /* OpenGLViewController.mm in Sources */,
93B184441FD2144F006F8B9B /* OpenGLFrameMediumViewController.mm in Sources */,
Expand All @@ -240,6 +251,7 @@
buildActionMask = 2147483647;
files = (
9309A54526B1D30800E3924A /* MessengerView.mm in Sources */,
5042A4542CDAF02C0088D9DC /* System.mm in Sources */,
9360F7961FA15BC000BD37D1 /* Utilities.mm in Sources */,
93C7C9111FD2049600C8D59C /* OpenGLViewController.mm in Sources */,
93B184451FD2144F006F8B9B /* OpenGLFrameMediumViewController.mm in Sources */,
Expand Down
56 changes: 56 additions & 0 deletions impl/ocean/platform/apple/ios/System.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#ifndef META_OCEAN_PLATFORM_APPLE_IOS_SYSTEM_H
#define META_OCEAN_PLATFORM_APPLE_IOS_SYSTEM_H

#include "ocean/platform/apple/ios/IOS.h"

namespace Ocean
{

namespace Platform
{

namespace Apple
{

namespace IOS
{

/**
* This class implements system functions on Apple iOS platforms.
* @ingroup platformappleios
*/
class System
{
public:

/**
* Returns the name of the current iPhone model.
* @param name The resulting name of the current device platform
* @return True, if succeeded
*/
static bool iphoneModelName(std::string& name);

/**
* Returns the version of iOS running on the current device.
* @param version The resulting version of the operating system
* @return True, if succeeded
*/
static bool iosVersion(std::string& version);
};

}

}

}

}

#endif // META_OCEAN_PLATFORM_APPLE_IOS_SYSTEM_H
53 changes: 53 additions & 0 deletions impl/ocean/platform/apple/ios/System.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#include "ocean/platform/apple/ios/System.h"

#include <UIKit/UIKit.h>

#import <sys/utsname.h>

namespace Ocean
{

namespace Platform
{

namespace Apple
{

namespace IOS
{

bool System::iphoneModelName(std::string& name)
{
struct utsname systemInfo;

if (uname(&systemInfo) == 0)
{
name = systemInfo.machine;
return true;
}

name.clear();

return false;
}

bool System::iosVersion(std::string& version)
{
version = [[[UIDevice currentDevice] systemVersion] UTF8String];
return true;
}

}

}

}

}

0 comments on commit 00a05bc

Please sign in to comment.