Skip to content

Commit

Permalink
G.IsIPad bool from objc (keybase#22652)
Browse files Browse the repository at this point in the history
* g.IsIPad from objc

* android
  • Loading branch information
mlsteele authored Feb 21, 2020
1 parent e8cc720 commit b44f6e3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
9 changes: 7 additions & 2 deletions go/bind/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func ExtensionIsInited() bool {
}

func ExtensionInit(homeDir string, mobileSharedHome string, logFile string, runModeStr string,
accessGroupOverride bool, pusher PushNotifier, mobileOsVersion string) (err error) {
accessGroupOverride bool, pusher PushNotifier, mobileOsVersion string, isIPad bool) (err error) {
extensionInitMu.Lock()
defer extensionInitMu.Unlock()
defer func() { err = flattenError(err) }()
Expand Down Expand Up @@ -154,8 +154,13 @@ func ExtensionInit(homeDir string, mobileSharedHome string, logFile string, runM
kbCtx.Init()
kbCtx.SetProofServices(externals.NewProofServices(kbCtx))

fmt.Printf("Go: Mobile OS version is: %q\n", mobileOsVersion)
var suffix string
if isIPad {
suffix = " (iPad)"
}
fmt.Printf("Go: Mobile OS version is: %q%v\n", mobileOsVersion, suffix)
kbCtx.MobileOsVersion = mobileOsVersion
kbCtx.IsIPad = isIPad

// 10k uid -> FullName cache entries allowed
kbCtx.SetUIDMapper(uidmap.NewUIDMap(10000))
Expand Down
13 changes: 9 additions & 4 deletions go/bind/keybase.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ func setInited() {
// InitOnce runs the Keybase services (only runs one time)
func InitOnce(homeDir, mobileSharedHome, logFile, runModeStr string,
accessGroupOverride bool, dnsNSFetcher ExternalDNSNSFetcher, nvh NativeVideoHelper,
mobileOsVersion string) {
mobileOsVersion string, isIPad bool) {
startOnce.Do(func() {
if err := Init(homeDir, mobileSharedHome, logFile, runModeStr, accessGroupOverride, dnsNSFetcher, nvh, mobileOsVersion); err != nil {
if err := Init(homeDir, mobileSharedHome, logFile, runModeStr, accessGroupOverride, dnsNSFetcher, nvh, mobileOsVersion, isIPad); err != nil {
kbCtx.Log.Errorf("Init error: %s", err)
}
})
Expand All @@ -132,7 +132,7 @@ func InitOnce(homeDir, mobileSharedHome, logFile, runModeStr string,
// Init runs the Keybase services
func Init(homeDir, mobileSharedHome, logFile, runModeStr string,
accessGroupOverride bool, externalDNSNSFetcher ExternalDNSNSFetcher, nvh NativeVideoHelper,
mobileOsVersion string) (err error) {
mobileOsVersion string, isIPad bool) (err error) {
defer func() {
err = flattenError(err)
if err == nil {
Expand Down Expand Up @@ -173,8 +173,13 @@ func Init(homeDir, mobileSharedHome, logFile, runModeStr string,
kbCtx.Init()
kbCtx.SetProofServices(externals.NewProofServices(kbCtx))

fmt.Printf("Go: Mobile OS version is: %q\n", mobileOsVersion)
var suffix string
if isIPad {
suffix = " (iPad)"
}
fmt.Printf("Go: Mobile OS version is: %q%v\n", mobileOsVersion, suffix)
kbCtx.MobileOsVersion = mobileOsVersion
kbCtx.IsIPad = isIPad

// 10k uid -> FullName cache entries allowed
kbCtx.SetUIDMapper(uidmap.NewUIDMap(10000))
Expand Down
1 change: 1 addition & 0 deletions go/libkb/globals.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ type GlobalContext struct {
// OS Version passed from mobile native code. iOS and Android only.
// See go/bind/keybase.go
MobileOsVersion string
IsIPad bool

SyncedContactList SyncedContactListProvider

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ public static void setupKBRuntime(Context context, boolean shouldCreateDummyFile
createDummyFile(context);
}
String mobileOsVersion = Integer.toString(android.os.Build.VERSION.SDK_INT);
boolean isIPad = false;
initOnce(context.getFilesDir().getPath(), "", context.getFileStreamPath("service.log").getAbsolutePath(), "prod", false,
new DNSNSFetcher(), new VideoHelper(), mobileOsVersion);
new DNSNSFetcher(), new VideoHelper(), mobileOsVersion, isIPad);

}

Expand Down
3 changes: 2 additions & 1 deletion shared/ios/Keybase/Engine.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ - (void)onRNReload {

- (void)setupKeybaseWithSettings:(NSDictionary *)settings error:(NSError **)error {
NSString* systemVer = [[UIDevice currentDevice] systemVersion];
KeybaseInit(settings[@"homedir"], settings[@"sharedHome"], settings[@"logFile"], settings[@"runmode"], settings[@"SecurityAccessGroupOverride"], NULL, NULL, systemVer, error);
BOOL isIPad = [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad;
KeybaseInit(settings[@"homedir"], settings[@"sharedHome"], settings[@"logFile"], settings[@"runmode"], settings[@"SecurityAccessGroupOverride"], NULL, NULL, systemVer, isIPad, error);
}

- (void)setupQueues {
Expand Down

0 comments on commit b44f6e3

Please sign in to comment.