1*bf47c682SAndroid Build Coastguard Worker/* 2*bf47c682SAndroid Build Coastguard Worker * Copyright (C) 2016 The Android Open Source Project 3*bf47c682SAndroid Build Coastguard Worker * 4*bf47c682SAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*bf47c682SAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*bf47c682SAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*bf47c682SAndroid Build Coastguard Worker * 8*bf47c682SAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*bf47c682SAndroid Build Coastguard Worker * 10*bf47c682SAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*bf47c682SAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*bf47c682SAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*bf47c682SAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*bf47c682SAndroid Build Coastguard Worker * limitations under the License. 15*bf47c682SAndroid Build Coastguard Worker */ 16*bf47c682SAndroid Build Coastguard Worker 17*bf47c682SAndroid Build Coastguard Worker#import "WALTAppDelegate.h" 18*bf47c682SAndroid Build Coastguard Worker 19*bf47c682SAndroid Build Coastguard Worker#include <sys/utsname.h> 20*bf47c682SAndroid Build Coastguard Worker 21*bf47c682SAndroid Build Coastguard Worker#import "UIAlertView+Extensions.h" 22*bf47c682SAndroid Build Coastguard Worker#import "WALTClient.h" 23*bf47c682SAndroid Build Coastguard Worker#import "WALTLogger.h" 24*bf47c682SAndroid Build Coastguard Worker 25*bf47c682SAndroid Build Coastguard Worker@interface WALTAppDelegate () 26*bf47c682SAndroid Build Coastguard Worker@property (readwrite, nonatomic) WALTClient *client; 27*bf47c682SAndroid Build Coastguard Worker@end 28*bf47c682SAndroid Build Coastguard Worker 29*bf47c682SAndroid Build Coastguard Worker@implementation WALTAppDelegate 30*bf47c682SAndroid Build Coastguard Worker- (BOOL)application:(UIApplication *)application 31*bf47c682SAndroid Build Coastguard Worker willFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 32*bf47c682SAndroid Build Coastguard Worker struct utsname systemInfo; 33*bf47c682SAndroid Build Coastguard Worker if (uname(&systemInfo) != 0) { 34*bf47c682SAndroid Build Coastguard Worker UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"System Error" 35*bf47c682SAndroid Build Coastguard Worker message:@"Cannot identify system." 36*bf47c682SAndroid Build Coastguard Worker delegate:nil 37*bf47c682SAndroid Build Coastguard Worker cancelButtonTitle:@"Dismiss" 38*bf47c682SAndroid Build Coastguard Worker otherButtonTitles:nil]; 39*bf47c682SAndroid Build Coastguard Worker [alert show]; 40*bf47c682SAndroid Build Coastguard Worker } else { 41*bf47c682SAndroid Build Coastguard Worker [[WALTLogger sessionLogger] appendFormat:@"DEVICE\t%s\t%s\t%s\t%s\t%s\n", 42*bf47c682SAndroid Build Coastguard Worker systemInfo.machine, 43*bf47c682SAndroid Build Coastguard Worker systemInfo.sysname, 44*bf47c682SAndroid Build Coastguard Worker systemInfo.release, 45*bf47c682SAndroid Build Coastguard Worker systemInfo.nodename, 46*bf47c682SAndroid Build Coastguard Worker systemInfo.version]; 47*bf47c682SAndroid Build Coastguard Worker } 48*bf47c682SAndroid Build Coastguard Worker 49*bf47c682SAndroid Build Coastguard Worker NSError *error = nil; 50*bf47c682SAndroid Build Coastguard Worker self.client = [[WALTClient alloc] initWithError:&error]; 51*bf47c682SAndroid Build Coastguard Worker if (!self.client) { 52*bf47c682SAndroid Build Coastguard Worker UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"WALT Connection Error" error:error]; 53*bf47c682SAndroid Build Coastguard Worker [alert show]; 54*bf47c682SAndroid Build Coastguard Worker } 55*bf47c682SAndroid Build Coastguard Worker 56*bf47c682SAndroid Build Coastguard Worker return YES; 57*bf47c682SAndroid Build Coastguard Worker} 58*bf47c682SAndroid Build Coastguard Worker@end 59