Exemplo n.º 1
0
  public static void create(
      Application app, String accountName, String developerSecret, Config config) {
    synchronized (Tapstream.class) {
      if (instance == null) {
        // Using reflection, try to instantiate the ActivityCallbacks class.  ActivityCallbacks
        // is derived from a class only available in api 14, so we expect this to fail for any
        // android version prior to 4.  For older android versions, a dummy implementation is used.
        ActivityEventSource aes;
        try {
          Class<?> cls = Class.forName("com.tapstream.sdk.api14.ActivityCallbacks");
          Constructor<?> constructor = cls.getConstructor(Application.class);
          aes = (ActivityEventSource) constructor.newInstance(app);
        } catch (Exception e) {
          aes = new ActivityEventSource();
        }

        instance =
            new Tapstream(
                new DelegateImpl(),
                new PlatformImpl(app),
                new CoreListenerImpl(),
                aes,
                new AdvertisingIdFetcher(app),
                accountName,
                developerSecret,
                config);
      } else {
        Logging.log(
            Logging.WARN,
            "Tapstream Warning: Tapstream already instantiated, it cannot be re-created.");
      }
    }
  }
Exemplo n.º 2
0
 public String getDeviceId() {
   try {
     TelephonyManager manager =
         (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
     return manager.getDeviceId();
   } catch (SecurityException e) {
     Logging.log(
         Logging.ERROR,
         "Tapstream Error: Failed to get device id - you need to add the READ_PHONE_STATE permission to your manifest.");
     return null;
   }
 }
Exemplo n.º 3
0
 public String getWifiMac() {
   try {
     WifiManager manager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
     WifiInfo info = manager.getConnectionInfo();
     return info.getMacAddress();
   } catch (SecurityException e) {
     Logging.log(
         Logging.ERROR,
         "Tapstream Error: Failed to get wifi mac address - you need to add the ACCESS_WIFI_STATE permission to your manifest.");
     return null;
   }
 }
Exemplo n.º 4
0
  /**
   * @param destinations peers we target, comma- or space-separated. Since 0.9.9, each dest may be
   *     appended with :port
   * @throws IllegalArgumentException if the I2PTunnel does not contain valid config to contact the
   *     router
   */
  public I2PTunnelClient(
      int localPort,
      String destinations,
      Logging l,
      boolean ownDest,
      EventDispatcher notifyThis,
      I2PTunnel tunnel,
      String pkf)
      throws IllegalArgumentException {
    super(
        localPort,
        ownDest,
        l,
        notifyThis,
        "Standard client on " + tunnel.listenHost + ':' + localPort,
        tunnel,
        pkf);

    _addrs = new ArrayList(1);
    if (waitEventValue("openBaseClientResult").equals("error")) {
      notifyEvent("openClientResult", "error");
      return;
    }

    dests = new ArrayList(1);
    buildAddresses(destinations);

    if (_addrs.isEmpty()) {
      l.log("No valid target destinations found");
      notifyEvent("openClientResult", "error");
      // Nothing is listening for the above event, so it's useless
      // Maybe figure out where to put a waitEventValue("openClientResult") ??
      // In the meantime, let's do this the easy way

      // Don't close() here, because it does a removeSession() and then
      // TunnelController can't acquire() it to release() it.
      // close(true);
      // Unfortunately, super() built the whole tunnel before we get here.
      throw new IllegalArgumentException("No valid target destinations found");
      // return;
    }

    setName(getLocalPort() + " -> " + destinations);

    startRunning();

    notifyEvent("openClientResult", "ok");
  }
 /**
  * Outputs a logging message to the log file.
  *
  * @param message the message to write to the log file.
  */
 public void out(String message) {
   if (log) Logging.log(message);
 }
Exemplo n.º 6
0
 /**
  * Method to end game
  *
  * @param message what to show player(s) at end of the game (for example "draw", "black wins"
  *     etc.)
  */
 public void endGame(String massage) {
   Logging.log(massage);
   JOptionPane.showMessageDialog(null, massage);
 }