<commit_before>require 'hive/diagnostic'
module Hive
	class Diagnostic
		class Android
			class Wifi < Diagnostic
				attr_accessor :status, :wifi, :message

        def diagnose
          self.fail( :message => 'WIFI on wrong network', {} )
          self.pass( :message => 'WIFI is fine' )
        end
        
        def repair(result)
          result.passed!
        end

				def wifi_status
				end

				def diagnose
				  
				  wifi_status = self.device.wifi
					
					result
					
					if wifi_status['blah']
					  result = self.fail( :message => 'Wifi not connected' )
				  elsif wifi_status['ap'] == config['ap']
				    result = self.fail( :message => 'Wrong access point' )
				  end
				  
				  result = self.pass(:message => 'Wifi ok') if !result
				  result
			end
		end
	end
end
<commit_msg>Added repair - to toggle ON wifi<commit_after>require 'hive/diagnostic'
module Hive
	class Diagnostic
		class Android
			class Wifi < Diagnostic

			def device
				@device = DeviceAPI::Android::ADB
			end

			def wifi
				wifi_details = self.device.wifi(@serial)
				return {:status => wifi_details[:status].scan(/^[^\/]*/)[0], :access_point => wifi_details[:access_point]}
			end

			def diagnose
				wifi_status = wifi
				if wifi_status[:status].capitalize == config[:status] 
					result = self.fail('Wifi Disconnected', "wifi")
				else 
					result = self.pass("Wifi connected to '#{wifi_status[:access_point]}'", "wifi")
				end
				result
			end

			def repair(result)
				Hive.logger.info("Trying to repair wifi")
				options = {:serial => @serial, :apk => '/opt/resources/wifi-toggle.apk'}#'/Users/khana46/opt/device_api-android/wifi-toggle.apk'}
				self.device.install_apk(options)
				self.device.am(@serial, "-n com.wifi.togglewifi/.MainActivity -e wifi true")
				sleep 5 
				self.device.uninstall_apk(:serial => @serial, :package_name => 'com.wifi.togglewifi')
				diagnose
			end
	
			end
		end
	end
end
{'fraction_non_alphanumeric': 0.12248062015503876, 'fraction_numerical': 0.0020671834625322996, 'mean_word_length': 2.645951035781544, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1062739', 'n_tokens_mistral': 800, 'n_tokens_neox': 614, 'n_words': 152}