boolean onlySingleExpansionFileFound() {
    for (OBBData.XAPKFile xf : OBBData.xAPKS) {
      String fileName = Helpers.getExpansionAPKFileName(this, xf.mIsMain, xf.mFileVersion);
      GameActivity.Log.debug("Checking for file : " + fileName);
      String fileForNewFile = Helpers.generateSaveFileName(this, fileName);
      String fileForDevFile = Helpers.generateSaveFileNameDevelopment(this, fileName);

      if (Helpers.doesFileExist(this, fileName, xf.mFileSize, false)
          && Helpers.doesFileExistDev(this, fileName, xf.mFileSize, false)) return false;
    }

    return true;
  }
  /**
   * Go through each of the APK Expansion files defined in the structure above and determine if the
   * files are present and match the required size. Free applications should definitely consider
   * doing this, as this allows the application to be launched for the first time without having a
   * network connection present. Paid applications that use LVL should probably do at least one LVL
   * check that requires the network to be present, so this is not as necessary.
   *
   * @return true if they are present.
   */
  boolean expansionFilesDelivered() {

    for (OBBData.XAPKFile xf : OBBData.xAPKS) {
      String fileName = Helpers.getExpansionAPKFileName(this, xf.mIsMain, xf.mFileVersion);
      GameActivity.Log.debug("Checking for file : " + fileName);
      String fileForNewFile = Helpers.generateSaveFileName(this, fileName);
      String fileForDevFile = Helpers.generateSaveFileNameDevelopment(this, fileName);
      GameActivity.Log.debug(
          "which is really being resolved to : " + fileForNewFile + "\n Or : " + fileForDevFile);
      if (!Helpers.doesFileExist(this, fileName, xf.mFileSize, false)
          && !Helpers.doesFileExistDev(this, fileName, xf.mFileSize, false)) return false;
    }
    return true;
  }
Пример #3
0
 public static boolean expansionExists(boolean main) {
   String fileName = null;
   int version = 0;
   for (XAPKFile xf : xAPKS) {
     if (xf.mIsMain) {
       fileName =
           Helpers.getExpansionAPKFileName(
               NativeUtility.getMainActivity(), xf.mIsMain, xf.mFileVersion);
       if (!Helpers.doesFileExist(
           NativeUtility.getMainActivity(), fileName, xf.mFileSize, false)) {
         fileName = "NOTDOWNLOADED";
       } else {
         version = xf.mFileVersion;
       }
     }
   }
   return fileName != null && version != 0 && !fileName.equals(new String("NOTDOWNLAODED"));
 }
Пример #4
0
  /**
   * Allow to know if the expansion files was downloaded Always return true in debug mode It's the
   * caller responsibility to setup the download UI if it returns false
   *
   * @return true if the expansion was delivered, false if it's starting to download
   */
  public static boolean checkExpansionFiles() {
    boolean isDebuggable =
        (0
            != (NativeUtility.getMainActivity().getApplicationInfo().flags
                & ApplicationInfo.FLAG_DEBUGGABLE));
    if (isDebuggable) {
      // return true;
    }
    if (xAPKS == null) {
      return true;
    }
    for (XAPKFile xf : xAPKS) {
      String fileName =
          Helpers.getExpansionAPKFileName(
              NativeUtility.getMainActivity(), xf.mIsMain, xf.mFileVersion);
      if (!Helpers.doesFileExist(NativeUtility.getMainActivity(), fileName, xf.mFileSize, false)) {
        // Build an Intent to start this activity from the Notification
        Intent notifierIntent =
            new Intent(NativeUtility.getMainActivity(), NativeUtility.getMainActivity().getClass());
        notifierIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);

        PendingIntent pendingIntent =
            PendingIntent.getActivity(
                NativeUtility.getMainActivity(),
                0,
                notifierIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);

        // Start the download service (if required)
        int startResult = -1;
        try {
          startResult =
              DownloaderClientMarshaller.startDownloadServiceIfRequired(
                  NativeUtility.getMainActivity(), pendingIntent, ExpansionSupport.class);
        } catch (NameNotFoundException e) {
          e.printStackTrace();
        }
        // If download has started, initialize this activity to show download progress
        if (startResult != DownloaderClientMarshaller.NO_DOWNLOAD_REQUIRED) {
          // The caller will setup the download UI
          Log.i(TAG, "creating stub for download ...");
          NativeUtility.getMainActivity()
              .runOnUiThread(
                  new Runnable() {
                    public void
                        run() { // For some reasons, that needs to be runned on UI Thread because it
                      // requires a Looper ....
                      try {
                        mDownloaderClientStub =
                            DownloaderClientMarshaller.CreateStub(
                                ExpansionSupport.getInstance(), ExpansionSupport.class);
                        if (NativeUtility.getMainActivity().isActive()) {
                          mDownloaderClientStub.connect(NativeUtility.getMainActivity());
                        }
                      } catch (Exception e) {
                        e.printStackTrace();
                      }
                    }
                  });
          Log.i(TAG, "Stub created! Returning false");

          return false;
        }
      }
    }
    Log.i(TAG, "Expansion file exists");
    return true;
  }