<commit_before>'use strict';

var adb = require('adbkit');
var chalk = require('chalk');
var events = require('events');

function DeviceModel(fb) {
  var deviceIds = [];
  var deviceDisplayTypes = {};

  var adbClient = adb.createClient();
  adbClient.trackDevices(function(err, tracker) {
    if (err) {
      this.log('DeviceModel: Could not set up adbkit', err);
      process.exit();
    }

    tracker.on('add', function(device) {
      this.log('DeviceModel: Device %s was plugged in', device.id);
      this.addDevice(device);
    }.bind(this));
    tracker.on('remove', function(device) {
      this.log('DeviceModel: Device %s was unplugged', device.id);
      this.removeDevice(device);
    }.bind(this));
    tracker.on('change', function(device) {
      this.log('DeviceModel: Device %s changed', device.id);
      if (device.type === 'device') {
        this.addDevice(device);
      } else if (device.type === 'offline') {
        this.removeDevice(device);
      }
    }.bind(this));
  }.bind(this));

  fb.child('device-display-types').on('value', function(snapshot) {
    var value = snapshot.val();
    deviceDisplayTypes = value;
  });

  this.addDevice = function(device) {
    if (deviceIds.indexOf(device.id) !== -1) {
      return;
    }

    deviceIds.push(device.id);
    this.emit('DeviceAdded', device.id);
    console.log('addDevice: ', deviceIds);
  };

  this.removeDevice = function(device) {
    var index = deviceIds.indexOf(device.id);
    if (index >= 0) {
      deviceIds.splice(index, 1);
    }
  };

  this.getAdbClient = function() {
    return adbClient;
  };

  this.getDeviceIds = function() {
    return deviceIds;
  };

  this.getDeviceDisplayType = function(deviceId) {
    if (deviceDisplayTypes[deviceId]) {
      return deviceDisplayTypes[deviceId];<commit_msg>Speculative fix for display types<commit_after>'use strict';

var adb = require('adbkit');
var chalk = require('chalk');
var events = require('events');

function DeviceModel(fb) {
  var deviceIds = [];
  var deviceDisplayTypes = {};

  var adbClient = adb.createClient();
  adbClient.trackDevices(function(err, tracker) {
    if (err) {
      this.log('DeviceModel: Could not set up adbkit', err);
      process.exit();
    }

    tracker.on('add', function(device) {
      this.log('DeviceModel: Device %s was plugged in', device.id);
      this.addDevice(device);
    }.bind(this));
    tracker.on('remove', function(device) {
      this.log('DeviceModel: Device %s was unplugged', device.id);
      this.removeDevice(device);
    }.bind(this));
    tracker.on('change', function(device) {
      this.log('DeviceModel: Device %s changed', device.id);
      if (device.type === 'device') {
        this.addDevice(device);
      } else if (device.type === 'offline') {
        this.removeDevice(device);
      }
    }.bind(this));
  }.bind(this));

  fb.child('device-display-types').on('value', function(snapshot) {
    var value = snapshot.val();
    if (!value) {
      value = {};
    }
    deviceDisplayTypes = value;
  });

  this.addDevice = function(device) {
    if (deviceIds.indexOf(device.id) !== -1) {
      return;
    }

    deviceIds.push(device.id);
    this.emit('DeviceAdded', device.id);
    console.log('addDevice: ', deviceIds);
  };

  this.removeDevice = function(device) {
    var index = deviceIds.indexOf(device.id);
    if (index >= 0) {
      deviceIds.splice(index, 1);
    }
  };

  this.getAdbClient = function() {
    return adbClient;
  };

  this.getDeviceIds = function() {
    return deviceIds;
  };

  this.getDeviceDisplayType = function(deviceId) {
    if (deviceDisplayTypes[deviceId]) {
      return deviceDisplayTypes[deviceId];
{'fraction_non_alphanumeric': 0.16268332428028245, 'fraction_numerical': 0.0016295491580662683, 'mean_word_length': 3.204337899543379, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3712567', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1171, 'n_words': 232}