Environment add device brand and model info
This commit is contained in:
		@@ -18,6 +18,7 @@ package pub.doric.engine;
 | 
				
			|||||||
import android.content.Context;
 | 
					import android.content.Context;
 | 
				
			||||||
import android.content.pm.PackageInfo;
 | 
					import android.content.pm.PackageInfo;
 | 
				
			||||||
import android.content.pm.PackageManager;
 | 
					import android.content.pm.PackageManager;
 | 
				
			||||||
 | 
					import android.os.Build;
 | 
				
			||||||
import android.os.Handler;
 | 
					import android.os.Handler;
 | 
				
			||||||
import android.os.HandlerThread;
 | 
					import android.os.HandlerThread;
 | 
				
			||||||
import android.os.Looper;
 | 
					import android.os.Looper;
 | 
				
			||||||
@@ -106,7 +107,8 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time
 | 
				
			|||||||
                .put("appVersion", appVersion)
 | 
					                .put("appVersion", appVersion)
 | 
				
			||||||
                .put("screenWidth", DoricUtils.px2dp(DoricUtils.getScreenWidth()))
 | 
					                .put("screenWidth", DoricUtils.px2dp(DoricUtils.getScreenWidth()))
 | 
				
			||||||
                .put("screenHeight", DoricUtils.px2dp(DoricUtils.getScreenHeight()))
 | 
					                .put("screenHeight", DoricUtils.px2dp(DoricUtils.getScreenHeight()))
 | 
				
			||||||
                .put("statusBarHeight", DoricUtils.px2dp(DoricUtils.getStatusBarHeight(Doric.application())));
 | 
					                .put("deviceBrand", Build.BRAND)
 | 
				
			||||||
 | 
					                .put("deviceModel", Build.MODEL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Map<String, Object> extend = mDoricRegistry.getEnvironmentVariables();
 | 
					        Map<String, Object> extend = mDoricRegistry.getEnvironmentVariables();
 | 
				
			||||||
        for (String key : extend.keySet()) {
 | 
					        for (String key : extend.keySet()) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,6 +25,7 @@
 | 
				
			|||||||
#import "DoricConstant.h"
 | 
					#import "DoricConstant.h"
 | 
				
			||||||
#import "DoricUtil.h"
 | 
					#import "DoricUtil.h"
 | 
				
			||||||
#import "DoricBridgeExtension.h"
 | 
					#import "DoricBridgeExtension.h"
 | 
				
			||||||
 | 
					#import <sys/utsname.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@interface DoricJSEngine ()
 | 
					@interface DoricJSEngine ()
 | 
				
			||||||
@property(nonatomic, strong) NSMutableDictionary *timers;
 | 
					@property(nonatomic, strong) NSMutableDictionary *timers;
 | 
				
			||||||
@@ -39,6 +40,12 @@ - (instancetype)init {
 | 
				
			|||||||
        _jsQueue = dispatch_queue_create("doric.jsengine", DISPATCH_QUEUE_SERIAL);
 | 
					        _jsQueue = dispatch_queue_create("doric.jsengine", DISPATCH_QUEUE_SERIAL);
 | 
				
			||||||
        _bridgeExtension = [[DoricBridgeExtension alloc] init];
 | 
					        _bridgeExtension = [[DoricBridgeExtension alloc] init];
 | 
				
			||||||
        NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
 | 
					        NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
 | 
				
			||||||
 | 
					        struct utsname systemInfo;
 | 
				
			||||||
 | 
					        uname(&systemInfo);
 | 
				
			||||||
 | 
					        NSString *platform = [NSString stringWithCString:systemInfo.machine encoding:NSASCIIStringEncoding];
 | 
				
			||||||
 | 
					        if (TARGET_OS_SIMULATOR == 1) {
 | 
				
			||||||
 | 
					            platform = [NSProcessInfo new].environment[@"SIMULATOR_MODEL_IDENTIFIER"];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        _innerEnvironmentDictionary = @{
 | 
					        _innerEnvironmentDictionary = @{
 | 
				
			||||||
                @"platform": @"iOS",
 | 
					                @"platform": @"iOS",
 | 
				
			||||||
                @"platformVersion": [[UIDevice currentDevice] systemVersion],
 | 
					                @"platformVersion": [[UIDevice currentDevice] systemVersion],
 | 
				
			||||||
@@ -47,6 +54,8 @@ - (instancetype)init {
 | 
				
			|||||||
                @"screenWidth": @([[UIScreen mainScreen] bounds].size.width),
 | 
					                @"screenWidth": @([[UIScreen mainScreen] bounds].size.width),
 | 
				
			||||||
                @"screenHeight": @([[UIScreen mainScreen] bounds].size.height),
 | 
					                @"screenHeight": @([[UIScreen mainScreen] bounds].size.height),
 | 
				
			||||||
                @"statusBarHeight": @([[UIApplication sharedApplication] statusBarFrame].size.height),
 | 
					                @"statusBarHeight": @([[UIApplication sharedApplication] statusBarFrame].size.height),
 | 
				
			||||||
 | 
					                @"deviceBrand": @"Apple",
 | 
				
			||||||
 | 
					                @"deviceModel": platform,
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
        dispatch_async(_jsQueue, ^() {
 | 
					        dispatch_async(_jsQueue, ^() {
 | 
				
			||||||
            self.timers = [[NSMutableDictionary alloc] init];
 | 
					            self.timers = [[NSMutableDictionary alloc] init];
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								doric-js/index.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								doric-js/index.d.ts
									
									
									
									
										vendored
									
									
								
							@@ -51,6 +51,8 @@ declare module 'doric/lib/src/runtime/global' {
 | 
				
			|||||||
                    screenWidth: number;
 | 
					                    screenWidth: number;
 | 
				
			||||||
                    screenHeight: number;
 | 
					                    screenHeight: number;
 | 
				
			||||||
                    statusBarHeight: number;
 | 
					                    statusBarHeight: number;
 | 
				
			||||||
 | 
					                    deviceBrand: string;
 | 
				
			||||||
 | 
					                    deviceModel: string;
 | 
				
			||||||
                    [index: string]: number | string | boolean | object | undefined;
 | 
					                    [index: string]: number | string | boolean | object | undefined;
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
            function Entry(constructor: {
 | 
					            function Entry(constructor: {
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								doric-js/lib/src/runtime/global.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								doric-js/lib/src/runtime/global.d.ts
									
									
									
									
										vendored
									
									
								
							@@ -37,6 +37,8 @@ declare global {
 | 
				
			|||||||
        screenWidth: number;
 | 
					        screenWidth: number;
 | 
				
			||||||
        screenHeight: number;
 | 
					        screenHeight: number;
 | 
				
			||||||
        statusBarHeight: number;
 | 
					        statusBarHeight: number;
 | 
				
			||||||
 | 
					        deviceBrand: string;
 | 
				
			||||||
 | 
					        deviceModel: string;
 | 
				
			||||||
        [index: string]: number | string | boolean | object | undefined;
 | 
					        [index: string]: number | string | boolean | object | undefined;
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    function Entry(constructor: {
 | 
					    function Entry(constructor: {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -62,6 +62,15 @@ declare global {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        statusBarHeight: number,
 | 
					        statusBarHeight: number,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /**
 | 
				
			||||||
 | 
					         * ex:Apple or Google 
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
 | 
					        deviceBrand: string,
 | 
				
			||||||
 | 
					        /**
 | 
				
			||||||
 | 
					         * ex: iPhone12,5 or pixel 3
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
 | 
					        deviceModel: string,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [index: string]: number | string | boolean | object | undefined
 | 
					        [index: string]: number | string | boolean | object | undefined
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    function Entry(constructor: { new(...args: any[]): {} }): any
 | 
					    function Entry(constructor: { new(...args: any[]): {} }): any
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user