appcenter icon indicating copy to clipboard operation
appcenter copied to clipboard

Rotation not handled by app pages

Open eswick opened this issue 9 years ago • 1 comments

eswick avatar Feb 01 '17 15:02 eswick

Tried to use the code from OS Experience to implement a fix for this. However it doesn't do anything on my 5S :/

SpringBoard.h

@protocol BSXPCCoding
@end

@interface BSMachPortRight : NSObject <BSXPCCoding, NSSecureCoding>
@end

@interface BSMachPortSendRight : BSMachPortRight <NSCopying>

- (unsigned int)sendRight;

@end

@interface SBApplication : NSObject

- (FBScene*)mainScene;
- (NSString*)bundleIdentifier;
- (BOOL)isRunning;
- (NSString*)displayName;
- (BOOL)hasHiddenTag;
- (BOOL)isActivating;
@property(retain, nonatomic) BSMachPortSendRight *xpcEventPort;
- (void)rotateToInterfaceOrientation:(int)orientation;//New

@end

Tweak.xm add #import <GraphicsServices/GraphicsServices.h>

%hook SBApplication

%new
- (void)rotateToInterfaceOrientation:(int)orientation{

	struct GSOrientationEvent {
		GSEventRecord record;
		GSDeviceOrientationInfo orientationInfo;
	} event;

	bzero(&event, sizeof(event));

	event.record.type = kGSEventDeviceOrientationChanged;
	event.record.flags = (GSEventFlags)0;
	event.record.infoSize = 4;
	event.orientationInfo.orientation = orientation;

	GSSendEvent((GSEventRecord*)&event, (mach_port_t)[[self xpcEventPort] sendRight]);
}

%new
- (void)appcenter_startBackgroundingWithCompletion:(void (^)(BOOL))completion {
  if (![self isRunning]) {
    [[%c(FBSSystemService) sharedService] openApplication:[self bundleIdentifier] options:@{ FBSOpenApplicationOptionKeyActivateSuspended : @true } withResult:^{
      [self appcenter_setBackgrounded:false withCompletion:completion];
    }];
  } else {
    [self appcenter_setBackgrounded:false withCompletion:completion];
  }
  UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
  [self rotateToInterfaceOrientation:orientation];
}

Not working but also not crashing. Presumably the GraphicsServices framework has changed. I have no clue about that so if you have any knowledge on this left from OSE maybe you can pick it up from here. 😄

EDIT: Here's a link to OSE code, rotation function is in line 739: https://github.com/eswick/osexperience/blob/master/Hooks.xm

conath avatar Feb 05 '17 13:02 conath