com.crashlytics.tools.android_2.1.0

Image = getPlatformSystemImages(paramString, paramFile, i, str2);
      
      Object localObject = new PlatformTarget(paramString, paramFile.getAbsolutePath(), i, str2, str3, j, localLayoutlibVersion, arrayOfISystemImage, localHashMap);
      
      String[] arrayOfString = parseSkinFolder(((PlatformTarget)localObject).getPath(5));
      ((PlatformTarget)localObject).setSkins(arrayOfString);
      
      return (PlatformTarget)localObject;
    }
    paramISdkLog.warning("Ignoring platform '%1$s': %2$s is missing.", new Object[] { paramFile.getName(), "build.prop" });
    
    return null;
  }
  
  private static ISystemImage[] getAddonSystemImages(File paramFile)
  {
    TreeSet localTreeSet = new TreeSet();
    
    paramFile = new File(paramFile, SdkConstants.OS_IMAGES_FOLDER);
    File[] arrayOfFile1 = paramFile.listFiles();
    int i = 0;
    if (arrayOfFile1 != null) {
      for (File localFile : arrayOfFile1) {
        if (localFile.isDirectory()) {
          localTreeSet.add(new SystemImage(localFile, ISystemImage.LocationType.IN_PLATFORM_SUBFOLDER, localFile.getName()));
        } else if ((i == 0) && (localFile.isFile()) && 
          (localFile.getName().endsWith(".img"))) {
          i = 1;
        }
      }
    }
    if ((localTreeSet.size() == 0) && (i != 0) && (paramFile.isDirectory())) {
      localTreeSet.add(new SystemImage(paramFile, ISystemImage.LocationType.IN_PLATFORM_LEGACY, "armeabi"));
    }
    return (ISystemImage[])localTreeSet.toArray(new ISystemImage[localTreeSet.size()]);
  }
  
  private static ISystemImage[] getPlatformSystemImages(String paramString1, File paramFile, int paramInt, String paramString2)
  {
    TreeSet localTreeSet = new TreeSet();
    HashSet localHashSet = new HashSet();
    
    AndroidVersion localAndroidVersion1 = new AndroidVersion(paramInt, paramString2);
    
    File[] arrayOfFile1 = new File(paramString1, "system-images").listFiles();
    Object localObject1;
    if (arrayOfFile1 != null) {
      for (localObject1 : arrayOfFile1)
      {
        File[] arrayOfFile3 = ((File)localObject1).listFiles();
        if (arrayOfFile3 != null) {
          for (File localFile2 : arrayOfFile3) {
            try
            {
              File localFile3 = new File(localFile2, "source.properties");
              Properties localProperties = new Properties();
              FileInputStream localFileInputStream = null;
              try
              {
                localFileInputStream = new FileInputStream(localFile3);
                localProperties.load(localFileInputStream);
              }
              finally
              {
                if (localFileInputStream != null) {
                  localFileInputStream.close();
                }
              }
              AndroidVersion localAndroidVersion2 = new AndroidVersion(localProperties);
              if (localAndroidVersion2.equals(localAndroidVersion1))
              {
                String str2 = localProperties.getProperty("SystemImage.Abi");
                if ((str2 != null) && (!localHashSet.contains(str2)))
                {
                  localTreeSet.add(new SystemImage(localFile2, ISystemImage.LocationType.IN_SYSTEM_IMAGE, str2));
                  
                  localHashSet.add(str2);
                }
              }
            }
            catch (Exception localException) {}
          }
        }
      }
    }
    paramFile = new File(paramFile, SdkConstants.OS_IMAGES_FOLDER);
    ??? = paramFile.listFiles();
    ??? = 1;
    ??? = 0;
    if (??? != null) {
      for (File localFile1 : ???) {
        if (localFile1.isDirectory())
        {
          ??? = 0;
          String str1 = localFile1.getName();
          if (!localHashSet.contains(str1))
          {
            localTreeSet.add(new SystemImage(localFile1, ISystemImage.LocationType.IN_PLATFORM_SUBFOLDER, str1));
            
            localHashSet.add(str1);
          }
        }
        else if ((??? == 0) && (localFile1.isFile()) && 
          (localFile1.getName().endsWith(".img")))
        {
          ??? = 1;
        }
      }
    }
    if ((??? != 0) && (??? != 0) && (paramFile.isDirectory()) && (!localHashSet.contains("armeabi"))) {
      localTreeSet.add(new SystemImage(paramFile, ISystemImage.LocationType.IN_PLATFORM_LEGACY, "armeabi"));
    }
    return (ISystemImage[])localTreeSet.toArray(new ISystemImage[localTreeSet.size()]);
  }
  
  private static void loadAddOns(String paramString, ArrayList<IAndroidTarget> paramArrayList, ISdkLog paramISdkLog)
  {
    File localFile1 = new File(paramString, "add-ons");
    if (localFile1.isDirectory())
    {
      File[] arrayOfFile1 = localFile1.listFiles();
      
      IAndroidTarget[] arrayOfIAndroidTarget = (IAndroidTarget[])paramArrayList.toArray(new IAndroidTarget[paramArrayList.size()]);
      for (File localFile2 : arrayOfFile1) {
        if (localFile2.isDirectory())
        {
          AddOnTarget localAddOnTarget = loadAddon(localFile2, arrayOfIAndroidTarget, paramISdkLog);
          if (localAddOnTarget != null) {
            paramArrayList.add(localAddOnTarget);
          }
        }
      }
      return;
    }
    if (!localFile1.exists())
    {
      if (!localFile1.mkdir()) {
        throw new RuntimeException(String.format("Failed to create %1$s.", new Object[] { localFile1.getAbsolutePath() }));
      }
    }
    else {
      throw new RuntimeException(String.format("%1$s is not a folder.", new Object[] { localFile1.getAbsolutePath() }));
    }
  }
  
  private static AddOnTarget loadAddon(File paramFile, IAndroidTarget[] paramArrayOfIAndroidTarget, ISdkLog paramISdkLog)
  {
    Pair localPair = parseAddonProperties(paramFile, paramArrayOfIAndroidTarget, paramISdkLog);
    
    Map localMap = (Map)localPair.getFirst();
    String str1 = (String)localPair.getSecond();
    if (str1 != null)
    {
      paramISdkLog.warning("Ignoring add-on '%1$s': %2$s", new Object[] { paramFile.getName(), str1 });
      return null;
    }
    try
    {
      assert (localMap != null);
      
      String str2 = (String)localMap.get("api");
      String str3 = (String)localMap.get("name");
      String str4 = (String)localMap.get("vendor");
      
      assert (str2 != null);
      assert (str3 != null);
      assert (str4 != null);
      
      PlatformTarget localPlatformTarget = null;
      for (str6 : paramArrayOfIAndroidTarget) {
        if ((str6.isPlatform()) && (str6.getVersion().equals(str2)))
        {
          localPlatformTarget = (PlatformTarget)str6;
          break;
        }
      }
      assert (localPlatformTarget != null);
      
      ??? = (String)localMap.get("description");
      
      ??? = 1;
      String str5 = (String)localMap.get("revision");
      if (str5 == null) {
        str5 = (String)localMap.get("version");
      }
      if (str5 != null) {
        ??? = Integer.parseInt(str5);
      }
      String str6 = (String)localMap.get("libraries");
      HashMap localHashMap = null;
      if (str6 != null)
      {
        str6 = str6.trim();
        if (str6.length() > 0)
        {
          localObject2 = str6.split(";");
          if (localObject2.length > 0)
          {
            localHashMap = new HashMap();
            for (localObject4 : localObject2)
            {
              localObject4 = ((String)localObject4).trim();
              
              localObject5 = (String)localMap.get(localObject4);
              if (localObject5 != null)
              {
                localObject6 = PATTERN_LIB_DATA.matcher((CharSequence)localObject5);
                if (((Matcher)localObject6).matches()) {
                  localHashMap.put(localObject4, new String[] { ((Matcher)localObject6).group(1), ((Matcher)localObject6).group(2) });
                } else {
                  paramISdkLog.warning("Ignoring library '%1$s', property value has wrong format\n\t%2$s", new Object[] { localObject4, localObject5 });
                }
              }
              else
              {
                paramISdkLog.warning("Ignoring library '%1$s', missing property value", new Object[] { localObject4, localObject5 });
              }
            }
          }
        }
      }
      Object localObject2 = getAddonSystemImages(paramFile);
      
      boolean bool = false;
      ??? = 0;
      
      File localFile = new File(paramFile, "data");
      if (localFile.isDirectory())
      {
        bool = new File(localFile, "layoutlib.jar").isFile();
        ??? = (new File(localFile, "res").isDirectory()) && (new File(localFile, "fonts").isDirectory()) ? 1 : 0;
      }
      Object localObject4 = new AddOnTarget(paramFile.getAbsolutePath(), str3, str4, ???, (String)???, (ISystemImage[])localObject2, localHashMap, bool, ???, localPlatformTarget);
      
      Object localObject5 = parseSkinFolder(((AddOnTarget)localObject4).getPath(5));
      
      Object localObject6 = (String)localMap.get("skin");
      if (localObject6 == null) {
        if (localObject5.length == 1) {
          localObject6 = localObject5[0];
        } else {
          localObject6 = localPlatformTarget.getDefaultSkin();
        }
      }
      int n = convertId((String)localMap.get("usb-vendor"));
      if (n != 0) {
        ((AddOnTarget)localObject4).setUsbVendorId(n);
      }
      ((AddOnTarget)localObject4).setSkins((String[])localObject5, (String)localObject6);
      
      return (AddOnTarget)localObject4;
    }
    catch (Exception localException)
    {
      paramISdkLog.warning("Ignoring add-on '%1$s': error %2$s.", new Object[] { paramFile.getName(), localException.toString() });
    }
    return null;
  }
  
  public static Pair<Map<String, String>, String> parseAddonProperties(File paramFile, IAndroidTarget[] paramArrayOfIAndroidTarget, ISdkLog paramISdkLog)
  {
    Map localMap = null;
    String str1 = null;
    
    FileWrapper localFileWrapper = new FileWrapper(paramFile, "manifest.ini");
    if (!localFileWrapper.isFile())
    {
      str1 = String.format("File not found: %1$s", new Object[] { "manifest.ini" });
    }
    else
    {
      localMap = ProjectProperties.parsePropertyFile(localFileWrapper, paramISdkLog);
      if (localMap == null)
      {
        str1 = String.format("Failed to parse properties from %1$s", new Object[] { "manifest.ini" });
      }
      else
      {
        String str2 = (String)localMap.get("name");
        if (str2 == null)
        {
          str1 = addonManifestWarning("name");
        }
        else
        {
          String str3 = (String)localMap.get("vendor");
          if (str3 == null)
          {
            str1 = addonManifestWarning("vendor");
          }
          else
          {
            String str4 = (String)localMap.get("api");
            PlatformTarget localPlatformTarget = null;
            if (str4 == null)
            {
              str1 = addonManifestWarning("api");
            }
            else
            {
              for (Object localObject2 : paramArrayOfIAndroidTarget) {
                if ((((IAndroidTarget)localObject2).isPlatform()) && (((IAndroidTarget)localObject2).getVersion().equals(str4)))
                {
                  localPlatformTarget = (PlatformTarget)localObject2;
                  break;
                }
              }
              if (localPlatformTarget == null)
              {
                str1 = String.format("Unable to find base platform with API level '%1$s'", new Object[] { str4 });
              }
              else
              {
                ??? = (String)localMap.get("revision");
                if (??? == null) {
                  ??? = (String)localMap.get("version");
                }
                if (??? != null) {
                  try
                  {
                    Integer.parseInt((String)???);
                  }
                  catch (NumberFormatException localNumberFormatException)
                  {
                    str1 = String.format("%1$s is not a valid number in %2$s.", new Object[] { "revision", "build.prop" });
                  }
                }
              }
            }
          }
        }
      }
    }
    return Pair.of(localMap, str1);
  }
  
  private static int convertId(String paramString)
  {
    if ((paramString != null) && (paramString.length() > 0) && 
      (PATTERN_USB_IDS.matcher(paramString).matches()))
    {
      String str = paramString.substring(2);
      try
      {
        return Integer.parseInt(str, 16);
      }
      catch (NumberFormatException localNumberFormatException) {}
    }
    return 0;
  }
  
  private static String addonManifestWarning(String paramString)
  {
    return String.format("'%1$s' is missing from %2$s.", new Object[] { paramString, "manifest.ini" });
  }
  
  private static boolean checkPlatformContent(File paramFile, ISdkLog paramISdkLog)
  {
    for (String str : sPlatformContentList)
    {
      File localFile = new File(paramFile, str);
      if (!localFile.exists())
      {
        paramISdkLog.warning("Ignoring platform '%1$s': %2$s is missing.", new Object[] { paramFile.getName(), str });
        
        return false;
      }
    }
    return true;
  }
  
  private static String[] parseSkinFolder(String paramString)
  {
    File localFile1 = new File(paramString);
    if (localFile1.isDirectory())
    {
      ArrayList localArrayList = new ArrayList();
      
      File[] arrayOfFile1 = localFile1.listFiles();
      for (File localFile2 : arrayOfFile1) {
        if (localFile2.isDirectory())
        {
          File localFile3 = new File(localFile2, "layout");
          if (localFile3.isFile()) {
            localArrayList.add(localFile2.getName());
          }
        }
      }
      return (String[])localArrayList.toArray(new String[localArrayList.size()]);
    }
    return new String[0];
  }
  
  private void initializeSamplePaths(ISdkLog paramISdkLog)
  {
    File localFile1 = new File(mOsSdkPath, "samples");
    if (localFile1.isDirectory())
    {
      File[] arrayOfFile1 = localFile1.listFiles();
      for (File localFile2 : arrayOfFile1) {
        if (localFile2.isDirectory())
        {
          AndroidVersion localAndroidVersion = getSamplesVersion(localFile2, paramISdkLog);
          if (localAndroidVersion != null) {
            for (IAndroidTarget localIAndroidTarget : mTargets) {
              if ((localIAndroidTarget.isPlatform()) && (localIAndroidTarget.getVersion().equals(localAndroidVersion)))
              {
                ((PlatformTarget)localIAndroidTarget).setSamplesPath(localFile2.getAbsolutePath());
                break;
              }
            }
          }
        }
      }
    }
  }
  
  private AndroidVersion getSamplesVersion(File paramFile, ISdkLog paramISdkLog)
  {
    File localFile = new File(paramFile, "source.properties");
    try
    {
      Properties localProperties = new Properties();
      FileInputStream localFileInputStream = null;
      try
      {
        localFileInputStream = new FileInputStream(localFile);
        localProperties.load(localFileInputStream);
      }
      finally
      {
        if (localFileInputStream != null) {
          localFileInputStream.close();
        }
      }
      return new AndroidVersion(localProperties);
    }
    catch (FileNotFoundException localFileNotFoundException)
    {
      paramISdkLog.warning("Ignoring sample '%1$s': does not contain %2$s.", new Object[] { paramFile.getName(), "source.properties" });
    }
    catch (IOException localIOException)
    {
      paramISdkLog.warning("Ignoring sample '%1$s': failed reading %2$s.", new Object[] { paramFile.getName(), "source.properties" });
    }
    catch (AndroidVersion.AndroidVersionException localAndroidVersionException)
    {
      paramISdkLog.warning("Ignoring sample '%1$s': no android version found in %2$s.", new Object[] { paramFile.getName(), "source.properties" });
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     com.android.sdklib.SdkManager
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.android.sdklib;

import java.io.PrintStream;

public class StdSdkLog
  implements ISdkLog
{
  public void error(Throwable paramThrowable, String paramString, Object... paramVarArgs)
  {
    if (paramString != null)
    {
      String str = String.format("Error: " + paramString, paramVarArgs);
      if ((SdkConstants.CURRENT_PLATFORM == 2) && (!str.endsWith("\r\n")) && (str.endsWith("\n"))) {
        str = str.substring(0, str.length() - 1);
      }
      System.err.print(str);
      if (!str.endsWith("\n")) {
        System.err.println();
      }
    }
    if (paramThrowable != null) {
      System.err.println(String.format("Error: %1$s%2$s", new Object[] { paramThrowable.getMessage() }));
    }
  }
  
  public void warning(String paramString, Object... paramVarArgs)
  {
    String str = String.format("Warning: " + paramString, paramVarArgs);
    if ((SdkConstants.CURRENT_PLATFORM == 2) && (!str.endsWith("\r\n")) && (str.endsWith("\n"))) {
      str = str.substring(0, str.length() - 1);
    }
    System.out.print(str);
    if (!str.endsWith("\n")) {
      System.out.println();
    }
  }
  
  public void printf(String paramString, Object... paramVarArgs)
  {
    String str = String.format(paramString, paramVarArgs);
    if ((SdkConstants.CURRENT_PLATFORM == 2) && (!str.endsWith("\r\n")) && (str.endsWith("\n"))) {
      str = str.substring(0, str.length() - 1);
    }
    System.out.print(str);
    if (!str.endsWith("\n")) {
      System.out.println();
    }
  }
}

/* Location:
 * Qualified Name:     com.android.sdklib.StdSdkLog
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.android.sdklib;

class SystemImage$1 {}

/* Location:
 * Qualified Name:     com.android.sdklib.SystemImage.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.android.sdklib;

import com.android.sdklib.io.FileOp;
import java.io.File;
import java.util.Locale;

public class SystemImage
  implements ISystemImage
{
  public static final String ANDROID_PREFIX = "android-";
  private final ISystemImage.LocationType mLocationtype;
  private final String mAbiType;
  private final File mLocation;
  
  public SystemImage(File paramFile, ISystemImage.LocationType paramLocationType, String paramString)
  {
    mLocation = paramFile;
    mLocationtype = paramLocationType;
    mAbiType = paramString;
  }
  
  public SystemImage(SdkManager paramSdkManager, IAndroidTarget paramIAndroidTarget, ISystemImage.LocationType paramLocationType, String paramString)
  {
    mLocationtype = paramLocationType;
    mAbiType = paramString;
    
    File localFile = null;
    switch (paramLocationType)
    {
    case IN_PLATFORM_LEGACY: 
      localFile = new File(paramIAndroidTarget.getLocation(), SdkConstants.OS_IMAGES_FOLDER);
      break;
    case IN_PLATFORM_SUBFOLDER: 
      localFile = FileOp.append(paramIAndroidTarget.getLocation(), new String[] { SdkConstants.OS_IMAGES_FOLDER, paramString });
      break;
    case IN_SYSTEM_IMAGE: 
      if (!paramIAndroidTarget.isPlatform()) {
        throw new IllegalArgumentException("Add-ons do not support the system-image location type");
      }
      localFile = getCanonicalFolder(paramSdkManager.getLocation(), paramIAndroidTarget.getVersion(), paramString);
      break;
    default: 
      if (!$assertionsDisabled) {
        throw new AssertionError("SystemImage used with an incorrect locationType");
      }
      break;
    }
    mLocation = localFile;
  }
  
  public static File getCanonicalFolder(String paramString1, AndroidVersion paramAndroidVersion, String paramString2)
  {
    File localFile = FileOp.append(paramString1, new String[] { "system-images", "android-" + paramAndroidVersion.getApiString() });
    if (paramString2 == null) {
      return localFile;
    }
    return FileOp.append(localFile, new String[] { paramString2 });
  }
  
  public File getLocation()
  {
    return mLocation;
  }
  
  public ISystemImage.LocationType getLocationType()
  {
    return mLocationtype;
  }
  
  public String getAbiType()
  {
    return mAbiType;
  }
  
  public int compareTo(ISystemImage paramISystemImage)
  {
    return getAbiType().compareToIgnoreCase(paramISystemImage.getAbiType());
  }
  
  public String toString()
  {
    return String.format("SystemImage ABI=%s, location %s='%s'", new Object[] { mAbiType, mLocationtype.toString().replace('_', ' ').toLowerCase(Locale.US), mLocation });
  }
}

/* Location:
 * Qualified Name:     com.android.sdklib.SystemImage
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.android.sdklib.build;

import com.android.sdklib.internal.build.DebugKeyProvider.IKeyGenOutput;
import java.io.PrintStream;

final class ApkBuilder$1
  implements DebugKeyProvider.IKeyGenOutput
{
  ApkBuilder$1(PrintStream paramPrintStream) {}
  
  public void out(String paramString)
  {
    val$verboseStream.println(paramString);
  }
  
  public void err(String paramString)
  {
    val$verboseStream.println(paramString);
  }
}

/* Location:
 * Qualified Name:     com.android.sdklib.build.ApkBuilder.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.android.sdklib.build;

import java.io.File;

public final class ApkBuilder$FileEntry
{
  public final File mFile;
  public final String mPath;
  
  ApkBuilder$FileEntry(File paramFile, String paramString)
  {
    mFile = paramFile;
    mPath = paramString;
  }
}

/* Location:
 * Qualified Name:     com.android.sdklib.build.ApkBuilder.FileEntry
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.android.sdklib.build;

import java.util.List;

public abstract interface ApkBuilder$JarStatus
{
  public abstract List<String> getNativeLibs();
  
  public abstract boolean hasNativeLibsConflicts();
}

/* Location:
 * Qualified Name:     com.android.sdklib.build.ApkBuilder.JarStatus
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.android.sdklib.build;

import java.util.List;

final class ApkBuilder$JarStatusImpl
  implements ApkBuilder.JarStatus
{
  public final List<String> mLibs;
  public final boolean mNativeLibsConflict;
  
  private ApkBuilder$JarStatusImpl(List<String> paramList, boolean paramBoolean)
  {
    mLibs = paramList;
    mNativeLibsConflict = paramBoolean;
  }
  
  public List<String> getNativeLibs()
  {
    return mLibs;
  }
  
  public boolean hasNativeLibsConflicts()
  {
    return mNativeLibsConflict;
  }
}

/* Location:
 * Qualified Name:     com.android.sdklib.build.ApkBuilder.JarStatusImpl
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.android.sdklib.build;

import com.android.sdklib.internal.build.SignedJarBuilder.IZipEntryFilter;
import com.android.sdklib.internal.build.SignedJarBuilder.IZipEntryFilter.ZipAbortException;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

final class ApkBuilder$JavaAndNativeResourceFilter
  implements SignedJarBuilder.IZipEntryFilter
{
  private final List<String> mNativeLibs = new ArrayList();
  private boolean mNativeLibsConflict = false;
  private File mInputFile;
  
  private ApkBuilder$JavaAndNativeResourceFilter(ApkBuilder paramApkBuilder) {}
  
  public boolean checkEntry(String paramString)
    throws SignedJarBuilder.IZipEntryFilter.ZipAbortException
  {
    String[] arrayOfString = paramString.split("/");
    if (arrayOfString.length == 0) {
      return false;
    }
    for (int i = 0; i < arrayOfString.length - 1; i++) {
      if (!ApkBuilder.checkFolderForPackaging(arrayOfString[i])) {
        return false;
      }
    }
    String str = arrayOfString[(arrayOfString.length - 1)];
    
    boolean bool = ApkBuilder.checkFileForPackaging(str);
    if (bool)
    {
      ApkBuilder.access$000(this$0, "=> %s", new Object[] { paramString });
      
      File localFile = ApkBuilder.access$100(this$0, paramString);
      if (localFile != null) {
        throw new DuplicateFileException(paramString, localFile, mInputFile);
      }
      ApkBuilder.access$200(this$0).put(paramString, mInputFile);
      if (paramString.endsWith(".so"))
      {
        mNativeLibs.add(paramString);
        if (paramString.startsWith("lib/")) {
          mNativeLibsConflict = true;
        }
      }
      else if (paramString.endsWith(".jnilib"))
      {
        mNativeLibs.add(paramString);
      }
    }
    return bool;
  }
  
  List<String> getNativeLibs()
  {
    return mNativeLibs;
  }
  
  boolean getNativeLibsConflict()
  {
    return mNativeLibsConflict;
  }
  
  void reset(File paramFile)
  {
    mInputFile = paramFile;
    mNativeLibs.clear();
    mNativeLibsConflict = false;
  }
}

/* Location:
 * Qualified Name:     com.android.sdklib.build.ApkBuilder.JavaAndNativeResourceFilter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.android.sdklib.build;

import com.android.sdklib.internal.build.SignedJarBuilder.IZipEntryFilter;
import com.android.sdklib.internal.build.SignedJarBuilder.IZipEntryFilter.ZipAbortException;
import java.io.File;
import java.util.HashMap;

final class ApkBuilder$NullZipFilter
  implements SignedJarBuilder.IZipEntryFilter
{
  private File mInputFile;
  
  private ApkBuilder$NullZipFilter(ApkBuilder paramApkBuilder) {}
  
  void reset(File paramFile)
  {
    mInputFile = paramFile;
  }
  
  public boolean checkEntry(String paramString)
    throws SignedJarBuilder.IZipEntryFilter.ZipAbortException
  {
    ApkBuilder.access$000(this$0, "=> %s", new Object[] { paramString });
    
    File localFile = ApkBuilder.access$100(this$0, paramString);
    if (localFile != null) {
      throw new DuplicateFileException(paramString, localFile, mInputFile);
    }
    ApkBuilder.access$200(this$0).put(paramString, mInputFile);
    
    return true;
  }
}

/* Location:
 * Qualified Name:     com.android.sdklib.build.ApkBuilder.NullZipFilter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.android.sdklib.build;

import java.security.PrivateKey;
import java.security.cert.X509Certificate;

public final class ApkBuilder$SigningInfo
{
  public final PrivateKey key;
  public final X509Certificate certificate;
  
  private ApkBuilder$SigningInfo(PrivateKey paramPrivateKey, X509Certificate paramX509Certificate)
  {
    if ((paramPrivateKey == null) || (paramX509Certificate == null)) {
      throw new IllegalArgumentException("key and certificate cannot be null");
    }
    key = paramPrivateKey;
    certificate = paramX509Certificate;
  }
}

/* Location:
 * Qualified Name:     com.android.sdklib.build.ApkBuilder.SigningInfo
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.android.sdklib.build;

import com.android.sdklib.internal.build.DebugKeyProvider;
import com.android.sdklib.internal.build.DebugKeyProvider.IKeyGenOutput;
import com.android.sdklib.internal.build.DebugKeyProvider.KeytoolException;
import com.android.sdklib.internal.build.SignedJarBuilder;
import com.android.sdklib.internal.build.SignedJarBuilder.IZipEntryFilter;
import com.android.sdklib.internal.build.SignedJarBuilder.IZipEntryFilter.ZipAbortException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public final class ApkBuilder
  implements IArchiveBuilder
{
  private static final Pattern PATTERN_NATIVELIB_EXT = Pattern.compile("^.+\\.so$", 2);
  private File mApkFile;
  private File mResFile;
  private File mDexFile;
  private PrintStream mVerboseStream;
  private SignedJarBuilder mBuilder;
  
  private final class NullZipFilter
    implements SignedJarBuilder.IZipEntryFilter
  {
    private File mInputFile;
    
    private NullZipFilter() {}
    
    void reset(File paramFile)
    {
      mInputFile = paramFile;
    }
    
    public boolean checkEntry(String paramString)
      throws SignedJarBuilder.IZipEntryFilter.ZipAbortException
    {
      ApkBuilder.this.verbosePrintln("=> %s", new Object[] { paramString });
      
      File localFile = ApkBuilder.this.checkFileForDuplicate(paramString);
      if (localFile != null) {
        throw new DuplicateFileException(paramString, localFile, mInputFile);
      }
      mAddedFiles.put(paramString, mInputFile);
      
      return true;
    }
  }
  
  private final class JavaAndNativeResourceFilter
    implements SignedJarBuilder.IZipEntryFilter
  {
    private final List<String> mNativeLibs = new ArrayList();
    private boolean mNativeLibsConflict = false;
    private File mInputFile;
    
    private JavaAndNativeResourceFilter() {}
    
    public boolean checkEntry(String paramString)
      throws SignedJarBuilder.IZipEntryFilter.ZipAbortException
    {
      String[] arrayOfString = paramString.split("/");
      if (arrayOfString.length == 0) {
        return false;
      }
      for (int i = 0; i < arrayOfString.length - 1; i++) {
        if (!ApkBuilder.checkFolderForPackaging(arrayOfString[i])) {
          return false;
        }
      }
      String str = arrayOfString[(arrayOfString.length - 1)];
      
      boolean bool = ApkBuilder.checkFileForPackaging(str);
      if (bool)
      {
        ApkBuilder.this.verbosePrintln("=> %s", new Object[] { paramString });
        
        File localFile = ApkBuilder.this.checkFileForDuplicate(paramString);
        if (localFile != null) {
          throw new DuplicateFileException(paramString, localFile, mInputFile);
        }
        mAddedFiles.put(paramString, mInputFile);
        if (paramString.endsWith(".so"))
        {
          mNativeLibs.add(paramString);
          if (paramString.startsWith("lib/")) {
            mNativeLibsConflict = true;
          }
        }
        else if (paramString.endsWith(".jnilib"))
        {
          mNativeLibs.add(paramString);
        }
      }
      return bool;
    }
    
    List<String> getNativeLibs()
    {
      return mNativeLibs;
    }
    
    boolean getNativeLibsConflict()
    {
      return mNativeLibsConflict;
    }
    
    void reset(File paramFile)
    {
      mInputFile = paramFile;
      mNativeLibs.clear();
      mNativeLibsConflict = false;
    }
  }
  
  private boolean mDebugMode = false;
  private boolean mIsSealed = false;
  private final NullZipFilter mNullFilter = new NullZipFilter(null);
  private final JavaAndNativeResourceFilter mFilter = new JavaAndNativeResourceFilter(null);
  private final HashMap<String, File> mAddedFiles = new HashMap();
  
  public static abstract interface JarStatus
  {
    public abstract List<String> getNativeLibs();
    
    public abstract boolean hasNativeLibsConflicts();
  }
  
  private static final class JarStatusImpl
    implements ApkBuilder.JarStatus
  {
    public final List<String> mLibs;
    public final boolean mNativeLibsConflict;
    
    private JarStatusImpl(List<String> paramList, boolean paramBoolean)
    {
      mLibs = paramList;
      mNativeLibsConflict = paramBoolean;
    }
    
    public List<String> getNativeLibs()
    {
      return mLibs;
    }
    
    public boolean hasNativeLibsConflicts()
    {
      return mNativeLibsConflict;
    }
  }
  
  public static final class SigningInfo
  {
    public final PrivateKey key;
    public final X509Certificate certificate;
    
    private SigningInfo(PrivateKey paramPrivateKey, X509Certificate paramX509Certificate)
    {
      if ((paramPrivateKey == null) || (paramX509Certificate == null)) {
        throw new IllegalArgumentException("key and certificate cannot be null");
      }
      key = paramPrivateKey;
      certificate = paramX509Certificate;
    }
  }
  
  public static SigningInfo getDebugKey(String paramString, PrintStream paramPrintStream)
    throws ApkCreationException
  {
    try
    {
      if (paramString != null)
      {
        File localFile = new File(paramString);
        try
        {
          checkInputFile(localFile);
        }
        catch (FileNotFoundException localFileNotFoundException) {}
        if (paramPrintStream != null) {
          paramPrintStream.println(String.format("Using keystore: %s", new Object[] { paramString }));
        }
        DebugKeyProvider.IKeyGenOutput local1 = null;
        if (paramPrintStream != null) {
          local1 = new DebugKeyProvider.IKeyGenOutput()
          {
            public void out(String paramAnonymousString)
            {
              val$verboseStream.println(paramAnonymousString);
            }
            
            public void err(String paramAnonymousString)
            {
              val$verboseStream.println(paramAnonymousString);
            }
          };
        }
        DebugKeyProvider localDebugKeyProvider = new DebugKeyProvider(paramString, null, local1);
        
        PrivateKey localPrivateKey = localDebugKeyProvider.getDebugKey();
        X509Certificate localX509Certificate = (X509Certificate)localDebugKeyProvider.getCertificate();
        if (localPrivateKey == null) {
          throw new ApkCreationException("Unable to get debug signature key", new Object[0]);
        }
        if ((localX509Certificate != null) && (localX509Certificate.getNotAfter().compareTo(new Date()) < 0)) {
          throw new ApkCreationException("Debug Certificate expired on " + DateFormat.getInstance().format(localX509Certificate.getNotAfter()), new Object[0]);
        }
        return new SigningInfo(localPrivateKey, localX509Certificate, null);
      }
      return null;
    }
    catch (DebugKeyProvider.KeytoolException localKeytoolException)
    {
      if (localKeytoolException.getJavaHome() == null) {
        throw new ApkCreationException(localKeytoolException.getMessage() + "\nJAVA_HOME seems undefined, setting it will help locating keytool automatically\n" + "You can also manually execute the following command\n:" + localKeytoolException.getCommandLine(), new Object[] { localKeytoolException });
      }
      throw new ApkCreationException(localKeytoolException.getMessage() + "\nJAVA_HOME is set to: " + localKeytoolException.getJavaHome() + "\nUpdate it if necessary, or manually execute the following command:\n" + localKeytoolException.getCommandLine(), new Object[] { localKeytoolException });
    }
    catch (ApkCreationException localApkCreationException)
    {
      throw localApkCreationException;
    }
    catch (Exception localException)
    {
      throw new ApkCreationException(localException);
    }
  }
  
  public ApkBuilder(String paramString1, String paramString2, String paramString3, String paramString4, PrintStream paramPrintStream)
    throws ApkCreationException
  {
    this(new File(paramString1), new File(paramString2), paramString3 != null ? new File(paramString3) : null, paramString4, paramPrintStream);
  }
  
  public ApkBuilder(String paramString1, String paramString2, String paramString3, PrivateKey paramPrivateKey, X509Certificate paramX509Certificate, PrintStream paramPrintStream)
    throws ApkCreationException
  {
    this(new File(paramString1), new File(paramString2), paramString3 != null ? new File(paramString3) : null, paramPrivateKey, paramX509Certificate, paramPrintStream);
  }
  
  public ApkBuilder(File paramFile1, File paramFile2, File paramFile3, String paramString, PrintStream paramPrintStream)
    throws ApkCreationException
  {
    SigningInfo localSigningInfo = getDebugKey(paramString, paramPrintStream);
    if (localSigningInfo != null) {
      init(paramFile1, paramFile2, paramFile3, key, certificate, paramPrintStream);
    } else {
      init(paramFile1, paramFile2, paramFile3, null, null, paramPrintStream);
    }
  }
  
  public ApkBuilder(File paramFile1, File paramFile2, File paramFile3, PrivateKey paramPrivateKey, X509Certificate paramX509Certificate, PrintStream paramPrintStream)
    throws ApkCreationException
  {
    init(paramFile1, paramFile2, paramFile3, paramPrivateKey, paramX509Certificate, paramPrintStream);
  }
  
  private void init(File paramFile1, File paramFile2, File paramFile3, PrivateKey paramPrivateKey, X509Certificate paramX509Certificate, PrintStream paramPrintStream)
    throws ApkCreationException
  {
    try
    {
      checkOutputFile(mApkFile = paramFile1);
      checkInputFile(mResFile = paramFile2);
      if (paramFile3 != null) {
        checkInputFile(mDexFile = paramFile3);
      } else {
        mDexFile = null;
      }
      mVerboseStream = paramPrintStream;
      
      mBuilder = new SignedJarBuilder(new FileOutputStream(mApkFile, false), paramPrivateKey, paramX509Certificate);
      
      verbosePrintln("Packaging %s", new Object[] { mApkFile.getName() });
      
      addZipFile(mResFile);
      if (mDexFile != null) {
        addFile(mDexFile, "classes.dex");
      }
    }
    catch (ApkCreationException localApkCreationException)
    {
      throw localApkCreationException;
    }
    catch (Exception localException)
    {
      throw new ApkCreationException(localException);
    }
  }
  
  public void setDebugMode(boolean paramBoolean)
  {
    mDebugMode = paramBoolean;
  }
  
  public void addFile(File paramFile, String paramString)
    throws ApkCreationException, SealedApkException, DuplicateFileException
  {
    if (mIsSealed) {
      throw new SealedApkException("APK is already sealed", new Object[0]);
    }
    try
    {
      doAddFile(paramFile, paramString);
    }
    catch (DuplicateFileException localDuplicateFileException)
    {
      throw localDuplicateFileException;
    }
    catch (Exception localException)
    {
      throw new ApkCreationException(localException, "Failed to add %s", new Object[] { paramFile });
    }
  }
  
  public void addZipFile(File paramFile)
    throws ApkCreationException, SealedApkException, DuplicateFileException
  {
    if (mIsSealed) {
      throw new SealedApkException("APK is already sealed", new Object[0]);
    }
    try
    {
      verbosePrintln("%s:", new Object[] { paramFile });
      
      mNullFilter.reset(paramFile);
      
      FileInputStream localFileInputStream = new FileInputStream(paramFile);
      mBuilder.writeZip(localFileInputStream, mNullFilter);
    }
    catch (DuplicateFileException localDuplicateFileException)
    {
      throw localDuplicateFileException;
    }
    catch (Exception localException)
    {
      throw new ApkCreationException(localException, "Failed to add %s", new Object[] { paramFile });
    }
  }
  
  public JarStatus addResourcesFromJar(File paramFile)
    throws ApkCreationException, SealedApkException, DuplicateFileException
  {
    if (mIsSealed) {
      throw new SealedApkException("APK is already sealed", new Object[0]);
    }
    try
    {
      verbosePrintln("%s:", new Object[] { paramFile });
      
      mFilter.reset(paramFile);
      
      FileInputStream localFileInputStream = new FileInputStream(paramFile);
      mBuilder.writeZip(localFileInputStream, mFilter);
      
      return new JarStatusImpl(mFilter.getNativeLibs(), mFilter.getNativeLibsConflict(), null);
    }
    catch (DuplicateFileException localDuplicateFileException)
    {
      throw localDuplicateFileException;
    }
    catch (Exception localException)
    {
      throw new ApkCreationException(localException, "Failed to add %s", new Object[] { paramFile });
    }
  }
  
  public void addSourceFolder(File paramFile)
    throws ApkCreationException, SealedApkException, DuplicateFileException
  {
    if (mIsSealed) {
      throw new SealedApkException("APK is already sealed", new Object[0]);
    }
    addSourceFolder(this, paramFile);
  }
  
  public static void addSourceFolder(IArchiveBuilder paramIArchiveBuilder, File paramFile)
    throws ApkCreationException, DuplicateFileException
  
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd