You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3079316 on 2016/08/05 by Ben.Marsh
Better PCH selection in ShaderFormatOpenGL and MetalShaderFormat - make sure Core is the first included header.
Change 3080579 on 2016/08/08 by Ben.Marsh
Slate: Move DEBUG_TAB_MANAGEMENT into SDockingTabStack.h to remove circular include dependency with DockingPrivate.h.
Change 3080587 on 2016/08/08 by Ben.Marsh
StandaloneRenderer: Move platform includes into a separate header so we can make individual headers self-contained, without having a circular dependency on StandaloneRendererPrivate.h.
Change 3080789 on 2016/08/08 by Ben.Marsh
Move BuildGraph tasks for chunking, posting builds, labeling builds, and merging manifests into the MCP project. While we do provide public interfaces for this functionality, we don't currently expect anyone outside Epic to be using them.
Change 3080815 on 2016/08/08 by Ben.Marsh
BuildGraph: Add a -GenerateDocs option, which writes out an HTML file constructed from C# XML documentation containing all the task information.
Change 3081374 on 2016/08/08 by Ben.Marsh
UBT: Invalidate the makefile if any UHT headers are deleted. Should fix issue where files are moved from one module to another, and the original module no longer contains any generated headers. Its include path needs to be removed from the compile environment.
Change 3083152 on 2016/08/09 by Ben.Marsh
PR #2667: Add Intel C++ Compiler support to Windows build (Contributed by JeffRous)
Change 3084039 on 2016/08/10 by Ben.Marsh
BuildGraph: Add additional markup for parameter attributes. Also improve some documation.
Change 3084240 on 2016/08/10 by Ben.Marsh
Plugins: Allow plugins in the project folder to replace plugins in the engine folder with the same name. Prohibit multiple plugins with the same name at other times.
Change 3084337 on 2016/08/10 by Ben.Marsh
UBT: Specify the -precompile option when generating project files for a target, so we include all valid modules for intellisense.
Change 3085594 on 2016/08/11 by Ben.Marsh
Change modules which reference a public header for their PCH to use a private PCH instead, even if it just includes the public header for now.
Change 3085999 on 2016/08/11 by Ben.Marsh
Add some missing #pragma once directives.
Change 3086146 on 2016/08/11 by Ben.Marsh
Core: Move prototype and linkage specifier for ConsoleCommandLibrary_* functions into header matching cpp file.
Change 3086172 on 2016/08/11 by Ben.Marsh
Fixup some C-style header guards to use #pragma once instead.
Change 3087289 on 2016/08/12 by Ben.Marsh
Split out UPackage and UMetaData into their own headers (they're already implemented in separate CPP files)
Change 3087310 on 2016/08/12 by Ben.Marsh
Move method stubs for FNullSlateSoundDevice into a CPP file, since they're exported from the SlateCore module.
Change 3087341 on 2016/08/12 by Ben.Marsh
UdpMessaging: Move PCH before #if PLATFORM_DESKTOP; it will only be defined if the definition is included.
Change 3087457 on 2016/08/12 by Ben.Marsh
Core: Reorganize the FTransform and FMatrix headers: Transform.h now includes TransformNonVectorized.h or TransformVectorized.h as appropriate, and UnrealMatrix.h is now Matrix.inl (and included from Matrix.h).
Change 3088407 on 2016/08/13 by Ben.Marsh
Replace use of Windows SIZE_T define with the regular C++ size_t.
Change 3088416 on 2016/08/13 by Ben.Marsh
Include a header from all .generated.cpp files (GeneratedCppIncludes.h) which includes all the basic types required to compile them, rather than assuming that the module PCH will include everything.
Also include the real declarations of noexport classes in Object.h (now renamed to NoExportTypes.h for clarity) when the CPP macro is defined, so the .generated.deps.h file will automatically have the correct definitions for them at compile time rather than relying on them being in the private PCH.
Finally, rename UObject.h to Object.h for consistency with the naming convention for all other UObject classes. UObject.h still exists for now, but outputs a deprecated message if included.
Change 3088544 on 2016/08/14 by Ben.Marsh
Core: Move the definition of the TEXT() macro into Platform.h, to avoid having to include OS headers to get it.
Change 3088552 on 2016/08/14 by Ben.Marsh
Fix compile errors for some modules that don't already include CoreUObject.h.
Change 3088925 on 2016/08/15 by Ben.Marsh
Remove circular include dependencies from VulkanRHI.
Change 3088926 on 2016/08/15 by Ben.Marsh
Remove duplicate definition for WITH_FIXED_AREA_ENTERING_COST from EngineDefines.h - always uses the definition from DetourNavMeshQuery.h instead.
Change 3088930 on 2016/08/15 by Ben.Marsh
Remove circular include dependency from PhysX.
Change 3088935 on 2016/08/15 by Ben.Marsh
OnlineSubsystemUtils: Move CPP files out of public header directory.
Change 3088965 on 2016/08/15 by Ben.Marsh
Add private PCH to Landscape, MoviePlayer, TaskGraph, XAudio2 and RealtimeProfiler modules.
Change 3088966 on 2016/08/15 by Ben.Marsh
Engine: Move CPP files out of public header directories.
Change 3089520 on 2016/08/15 by Ben.Marsh
BuildGraph: Change documentation command to output markdown.
Change 3090299 on 2016/08/16 by Ben.Marsh
D3D12RHI: Move around some implementations to fix circular header dependencies which are masked by delayed template instantiation.
Change 3090303 on 2016/08/16 by Ben.Marsh
Engine: Add a template specialization for TPointerIsConvertibleFromTo<AActor, const volatile UObject> to fix dependency on complete AActor definition for static assert in TWeakPointer<AActor>, which only appears if including Level.h without Actor.h. Delayed template instantiation usually masks this issue.
Change 3091861 on 2016/08/17 by Ben.Marsh
Remove circular header dependencies, and fix ambiguous include paths in OSVR.
Change 3092068 on 2016/08/17 by Ben.Marsh
Moving VulkanDynamicRHI into its own header.
Change 3093133 on 2016/08/18 by Ben.Marsh
EC: Include additional context lines for Clang errors.
Change 3093147 on 2016/08/18 by Ben.Marsh
UBT: Add an error message when attempting to do a single-file compile with the wrong target selected.
Change 3093228 on 2016/08/18 by Ben.Marsh
Remove redundant setting for remote server name from XML config, and set it to a valid machine in the engine config.
[CL 3093264 by Ben Marsh in Main branch]
397 lines
12 KiB
C++
397 lines
12 KiB
C++
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved
|
|
|
|
#include "IOSTargetPlatformPrivatePCH.h"
|
|
|
|
#include <CoreFoundation/CoreFoundation.h>
|
|
|
|
struct AMDeviceNotificationCallbackInformation
|
|
{
|
|
void *deviceHandle;
|
|
uint32_t msgType;
|
|
};
|
|
|
|
struct AFCCommConnection
|
|
{
|
|
};
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
int AMDeviceConnect (void *device);
|
|
int AMDeviceValidatePairing (void *device);
|
|
int AMDeviceStartSession (void *device);
|
|
int AMDeviceStopSession (void *device);
|
|
int AMDeviceDisconnect (void *device);
|
|
int AMDeviceNotificationSubscribe(void*, int, int, int, void**);
|
|
int AMDeviceStartService(void*, CFStringRef, void**, int);
|
|
CFStringRef AMDeviceCopyValue(void*, int unknown, CFStringRef cfstring);
|
|
int AMDeviceSecureUpgradeApplication(void*, void*, CFURLRef, void*, void*, void*);
|
|
|
|
uint32 AFCConnectionOpen(void*, uint32, void**);
|
|
uint32 AFCConnectionClose(void*);
|
|
uint32 AFCDirectoryCreate(void*, const char*);
|
|
uint32 AFCFileRefOpen(void*, const char*, uint64, uint64*);
|
|
uint32 AFCFileRefClose(void*, uint64);
|
|
uint32 AFCFileRefWrite(void*, uint64, void*, uint32);
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
class AFC
|
|
{
|
|
public:
|
|
static int StartService(void* DeviceHandle, void** OutHandle)
|
|
{
|
|
int Result = AMDeviceStartService(DeviceHandle, CFSTR("com.apple.afc"), OutHandle, 0);
|
|
return Result;
|
|
}
|
|
|
|
static int ConnectionOpen(void* ServiceHandle, AFCCommConnection** OutConn)
|
|
{
|
|
void* Conn = NULL;
|
|
int result = AFCConnectionOpen(ServiceHandle, 0, &Conn);
|
|
*OutConn = (AFCCommConnection*)Conn;
|
|
return result;
|
|
}
|
|
|
|
static int ConnectionClose(AFCCommConnection* Connection)
|
|
{
|
|
return AFCConnectionClose(Connection);
|
|
}
|
|
|
|
static uint32 DirectoryCreate(AFCCommConnection* Connection, FString Dir)
|
|
{
|
|
const char* IPAPath = TCHAR_TO_UTF8(*Dir);
|
|
uint Result = AFCDirectoryCreate(Connection, IPAPath);
|
|
return Result;
|
|
}
|
|
|
|
static uint32 FileRefOpen(AFCCommConnection* Connection, FString Path, int mode, uint64* OutHandle)
|
|
{
|
|
const char* IPAPath = TCHAR_TO_UTF8(*Path);
|
|
uint Result = AFCFileRefOpen(Connection, IPAPath, mode, OutHandle);
|
|
return Result;
|
|
}
|
|
|
|
static uint32 FileRefClose(AFCCommConnection* Connection, uint64 Handle)
|
|
{
|
|
return AFCFileRefClose(Connection, Handle);
|
|
}
|
|
|
|
static uint32 FileRefWrite(AFCCommConnection* Connection, uint64 Handle, void* Data, uint32 Length)
|
|
{
|
|
return AFCFileRefWrite(Connection, Handle, Data, Length);
|
|
}
|
|
};
|
|
|
|
class InstallProxy
|
|
{
|
|
public:
|
|
static int StartService(void* DeviceHandle, void** OutHandle)
|
|
{
|
|
int Result = AMDeviceStartService(DeviceHandle, CFSTR("com.apple.mobile.installation_proxy"), OutHandle, 0);
|
|
return Result;
|
|
}
|
|
|
|
static int SecureUpgradeApplication(void* ServiceConnection, void* DeviceHandle, CFURLRef UrlPath, void* Options, void* InstallCallback, void* UserData)
|
|
{
|
|
return AMDeviceSecureUpgradeApplication(ServiceConnection, DeviceHandle, UrlPath, Options, InstallCallback, UserData);
|
|
}
|
|
};
|
|
|
|
class IOSDevice
|
|
{
|
|
public:
|
|
IOSDevice(void* device)
|
|
: DeviceHandle(device)
|
|
, AFCHandle(NULL)
|
|
, InstallHandle(NULL)
|
|
{
|
|
}
|
|
|
|
bool Connect()
|
|
{
|
|
bool Result = false;
|
|
int AppLogLevel = 7;
|
|
CFPreferencesSetAppValue(CFSTR("LogLevel"), CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &AppLogLevel), CFSTR("com.apple.MobileDevice"));
|
|
|
|
// connect to the device
|
|
int32 rc = AMDeviceConnect(DeviceHandle);
|
|
if (!rc)
|
|
{
|
|
// validate the pairing
|
|
rc = AMDeviceValidatePairing(DeviceHandle);
|
|
if (!rc)
|
|
{
|
|
// start a session
|
|
rc = AMDeviceStartSession(DeviceHandle);
|
|
Result = !rc;
|
|
}
|
|
else
|
|
{
|
|
UE_LOG(LogTemp, Display, TEXT("Couldn't validate pairing to device"));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
UE_LOG(LogTemp, Display, TEXT("Couldn't connect to device"));
|
|
}
|
|
return Result;
|
|
}
|
|
|
|
bool Disconnect()
|
|
{
|
|
bool Result = false;
|
|
// close the session
|
|
int32 rc = AMDeviceStopSession(DeviceHandle);
|
|
if (!rc)
|
|
{
|
|
// disconnect from the device
|
|
rc = AMDeviceDisconnect(DeviceHandle);
|
|
Result = !rc;
|
|
}
|
|
else
|
|
{
|
|
UE_LOG(LogTemp, Display, TEXT("Couldn't stop session"));
|
|
}
|
|
return Result;
|
|
}
|
|
|
|
bool CopyFileToPublicStaging(const FString& SourceFile)
|
|
{
|
|
FString IpaFilename = FPaths::GetCleanFilename(SourceFile);
|
|
return CopyFileToDevice(SourceFile, FString(TEXT("/PublicStaging/")) + IpaFilename, 1024*1024);
|
|
}
|
|
|
|
bool TryUpgrade(const FString& IPAPath)
|
|
{
|
|
// reconnect to the device and start the Installation service
|
|
Connect();
|
|
InstallProxy::StartService(DeviceHandle, &InstallHandle);
|
|
|
|
CFURLRef UrlPath = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, FPlatformString::TCHARToCFString(*IPAPath), kCFURLWindowsPathStyle, 0);
|
|
int Result = InstallProxy::SecureUpgradeApplication(0, DeviceHandle, UrlPath, 0, 0, 0);
|
|
return Result == 0;
|
|
}
|
|
|
|
void* Handle() const
|
|
{
|
|
return DeviceHandle;
|
|
}
|
|
|
|
bool CreateDirectory(FString Dir)
|
|
{
|
|
return !(AFC::DirectoryCreate(AFCConnection, Dir) != 0);
|
|
}
|
|
|
|
private:
|
|
|
|
bool CopyFileToDevice(const FString& IPAPath, FString PathOnDevice, int PacketSize)
|
|
{
|
|
bool Result = false;
|
|
// reconnect to the device and start the AFC service
|
|
Connect();
|
|
if (!AFC::StartService(DeviceHandle, &AFCHandle))
|
|
{
|
|
if (!AFC::ConnectionOpen(AFCHandle, &AFCConnection))
|
|
{
|
|
|
|
// ensure the directory on the phone exists
|
|
FString DirectoryOnDevice = FPaths::GetPath(PathOnDevice);
|
|
CreateDirectory(DirectoryOnDevice + TEXT("/"));
|
|
|
|
// transfer the file
|
|
IPlatformFile& PlatformFile = IPlatformFile::GetPlatformPhysical();
|
|
IFileHandle* SourceFile = PlatformFile.OpenRead(*IPAPath);
|
|
if (SourceFile != NULL)
|
|
{
|
|
uint64 DestinationHandle = 0;
|
|
if (AFC::FileRefOpen(AFCConnection, PathOnDevice, 3, &DestinationHandle) == 0)
|
|
{
|
|
int TotalBytes = 0;
|
|
int PacketCount = SourceFile->Size() / PacketSize;
|
|
uint8* buffer = new uint8[PacketSize];
|
|
for (int Index = 0; Index < PacketCount; ++Index)
|
|
{
|
|
if (SourceFile->Read(buffer, PacketSize))
|
|
{
|
|
TotalBytes += PacketSize;
|
|
AFC::FileRefWrite(AFCConnection, DestinationHandle, buffer, PacketSize);
|
|
}
|
|
}
|
|
|
|
if (SourceFile->Read(buffer, SourceFile->Size() - TotalBytes))
|
|
{
|
|
AFC::FileRefWrite(AFCConnection, DestinationHandle, buffer, SourceFile->Size() - TotalBytes);
|
|
}
|
|
|
|
// flush the destination and close
|
|
AFC::FileRefClose(AFCConnection, DestinationHandle);
|
|
|
|
Result = true;
|
|
}
|
|
delete SourceFile;
|
|
}
|
|
|
|
// stop the AFC service and disconnect from the device
|
|
AFC::ConnectionClose(AFCConnection);
|
|
AFCConnection = NULL;
|
|
Disconnect();
|
|
}
|
|
}
|
|
return Result;
|
|
}
|
|
|
|
void* DeviceHandle;
|
|
void* AFCHandle;
|
|
AFCCommConnection* AFCConnection;
|
|
void* InstallHandle;
|
|
};
|
|
|
|
|
|
/* FIOSDeviceHelper structors
|
|
*****************************************************************************/
|
|
|
|
static TMap<IOSDevice*, FIOSLaunchDaemonPong> ConnectedDevices;
|
|
|
|
void FIOSDeviceHelper::Initialize(bool bIsTVOS)
|
|
{
|
|
static bool bIsInitialized = false;
|
|
|
|
if (!bIsInitialized)
|
|
{
|
|
void *subscribe;
|
|
int32 rc = AMDeviceNotificationSubscribe((void*)FIOSDeviceHelper::DeviceCallback, 0, 0, 0, &subscribe);
|
|
if (rc < 0)
|
|
{
|
|
//@todo right out to the log that we can't subscribe
|
|
}
|
|
bIsInitialized = true;
|
|
}
|
|
}
|
|
|
|
void FIOSDeviceHelper::DeviceCallback(void* CallbackInfo)
|
|
{
|
|
struct AMDeviceNotificationCallbackInformation* cbi = (AMDeviceNotificationCallbackInformation*)CallbackInfo;
|
|
|
|
void* deviceHandle = cbi->deviceHandle;
|
|
|
|
switch(cbi->msgType)
|
|
{
|
|
case 1:
|
|
FIOSDeviceHelper::DoDeviceConnect(deviceHandle);
|
|
break;
|
|
|
|
case 2:
|
|
FIOSDeviceHelper::DoDeviceDisconnect(deviceHandle);
|
|
break;
|
|
|
|
case 3:
|
|
break;
|
|
}
|
|
}
|
|
|
|
void FIOSDeviceHelper::DoDeviceConnect(void* deviceHandle)
|
|
{
|
|
// connect to the device
|
|
IOSDevice* Device = new IOSDevice(deviceHandle);
|
|
bool Connected = Device->Connect();
|
|
if (Connected)
|
|
{
|
|
// get the needed data
|
|
CFStringRef deviceName = AMDeviceCopyValue(deviceHandle, 0, CFSTR("DeviceName"));
|
|
CFStringRef deviceId = AMDeviceCopyValue(deviceHandle, 0, CFSTR("UniqueDeviceID"));
|
|
CFStringRef productType = AMDeviceCopyValue(deviceHandle, 0, CFSTR("ProductType"));
|
|
|
|
// fire the event
|
|
TCHAR idBuffer[128];
|
|
TCHAR nameBuffer[256];
|
|
TCHAR productBuffer[128];
|
|
FPlatformString::CFStringToTCHAR(deviceId, idBuffer);
|
|
FPlatformString::CFStringToTCHAR(deviceName, nameBuffer);
|
|
FPlatformString::CFStringToTCHAR(productType, productBuffer);
|
|
FIOSLaunchDaemonPong Event;
|
|
Event.DeviceID = FString::Printf(TEXT("%s@%s"), (FString(productBuffer).Contains("AppleTV") ? TEXT("TVOS") : TEXT("IOS")), idBuffer);
|
|
Event.DeviceName = FString::Printf(TEXT("%s"), nameBuffer);
|
|
Event.bCanReboot = false;
|
|
Event.bCanPowerOn = false;
|
|
Event.bCanPowerOff = false;
|
|
Event.DeviceType = FString::Printf(TEXT("%s"), productBuffer);
|
|
FIOSDeviceHelper::OnDeviceConnected().Broadcast(Event);
|
|
|
|
// add to the device list
|
|
ConnectedDevices.Add(Device, Event);
|
|
|
|
// disconnect the device for now
|
|
Device->Disconnect();
|
|
}
|
|
else
|
|
{
|
|
UE_LOG(LogTemp, Display, TEXT("Couldn't connect to device"));
|
|
}
|
|
}
|
|
|
|
void FIOSDeviceHelper::DoDeviceDisconnect(void* deviceHandle)
|
|
{
|
|
IOSDevice* device = NULL;
|
|
for (auto DeviceIterator = ConnectedDevices.CreateIterator(); DeviceIterator; ++DeviceIterator)
|
|
{
|
|
if (DeviceIterator.Key()->Handle() == deviceHandle)
|
|
{
|
|
device = DeviceIterator.Key();
|
|
break;
|
|
}
|
|
}
|
|
if (device != NULL)
|
|
{
|
|
// extract the device id from the connected list¯
|
|
FIOSLaunchDaemonPong Event = ConnectedDevices.FindAndRemoveChecked(device);
|
|
|
|
// fire the event
|
|
FIOSDeviceHelper::OnDeviceDisconnected().Broadcast(Event);
|
|
|
|
// delete the device
|
|
delete device;
|
|
}
|
|
}
|
|
|
|
bool FIOSDeviceHelper::InstallIPAOnDevice(const FTargetDeviceId& DeviceId, const FString& IPAPath)
|
|
{
|
|
// check for valid path
|
|
if (IPAPath.Len() == 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// check for valid device
|
|
IOSDevice* device = NULL;
|
|
FIOSLaunchDaemonPong DeviceMessage;
|
|
for (auto DeviceIterator = ConnectedDevices.CreateIterator(); DeviceIterator; ++DeviceIterator)
|
|
{
|
|
DeviceMessage = DeviceIterator.Value();
|
|
if (DeviceMessage.DeviceID == DeviceId.ToString())
|
|
{
|
|
device = DeviceIterator.Key();
|
|
break;
|
|
}
|
|
}
|
|
if (device == NULL)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// we have the device and a IPA path
|
|
// copy to the stage
|
|
if (device->CopyFileToPublicStaging(IPAPath))
|
|
{
|
|
// install on the device
|
|
return device->TryUpgrade(IPAPath);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void FIOSDeviceHelper::EnableDeviceCheck(bool OnOff)
|
|
{
|
|
|
|
} |