com.crashlytics.tools.android_2.1.0

 writeSignatureFile(SignatureOutputStream paramSignatureOutputStream)
    throws IOException, GeneralSecurityException
  {
    Manifest localManifest = new Manifest();
    Attributes localAttributes = localManifest.getMainAttributes();
    localAttributes.putValue("Signature-Version", "1.0");
    localAttributes.putValue("Created-By", "1.0 (Android)");
    
    BASE64Encoder localBASE64Encoder = new BASE64Encoder();
    MessageDigest localMessageDigest = MessageDigest.getInstance("SHA1");
    PrintStream localPrintStream = new PrintStream(new DigestOutputStream(new ByteArrayOutputStream(), localMessageDigest), true, "UTF-8");
    
    mManifest.write(localPrintStream);
    localPrintStream.flush();
    localAttributes.putValue("SHA1-Digest-Manifest", localBASE64Encoder.encode(localMessageDigest.digest()));
    
    Map localMap = mManifest.getEntries();
    for (Map.Entry localEntry1 : localMap.entrySet())
    {
      localPrintStream.print("Name: " + (String)localEntry1.getKey() + "\r\n");
      for (Object localObject = ((Attributes)localEntry1.getValue()).entrySet().iterator(); ((Iterator)localObject).hasNext();)
      {
        Map.Entry localEntry2 = (Map.Entry)((Iterator)localObject).next();
        localPrintStream.print(localEntry2.getKey() + ": " + localEntry2.getValue() + "\r\n");
      }
      localPrintStream.print("\r\n");
      localPrintStream.flush();
      
      localObject = new Attributes();
      ((Attributes)localObject).putValue("SHA1-Digest", localBASE64Encoder.encode(localMessageDigest.digest()));
      localManifest.getEntries().put(localEntry1.getKey(), localObject);
    }
    localManifest.write(paramSignatureOutputStream);
    if (paramSignatureOutputStream.size() % 1024 == 0)
    {
      paramSignatureOutputStream.write(13);
      paramSignatureOutputStream.write(10);
    }
  }
  
  private void writeSignatureBlock(Signature paramSignature, X509Certificate paramX509Certificate, PrivateKey paramPrivateKey)
    throws IOException, GeneralSecurityException
  {
    SignerInfo localSignerInfo = new SignerInfo(new X500Name(paramX509Certificate.getIssuerX500Principal().getName()), paramX509Certificate.getSerialNumber(), AlgorithmId.get("SHA1"), AlgorithmId.get(paramPrivateKey.getAlgorithm()), paramSignature.sign());
    
    PKCS7 localPKCS7 = new PKCS7(new AlgorithmId[] { AlgorithmId.get("SHA1") }, new ContentInfo(ContentInfo.DATA_OID, null), new X509Certificate[] { paramX509Certificate }, new SignerInfo[] { localSignerInfo });
    
    localPKCS7.encodeSignedData(mOutputJar);
  }
}

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

public enum ProjectCreator$OutputLevel
{
  SILENT,  NORMAL,  VERBOSE;
  
  private ProjectCreator$OutputLevel() {}
}

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

class ProjectCreator$ProjectCreateException
  extends Exception
{
  private static final long serialVersionUID = 1L;
  
  ProjectCreator$ProjectCreateException(String paramString)
  {
    super(paramString);
  }
  
  ProjectCreator$ProjectCreateException(Throwable paramThrowable, String paramString, Object... paramVarArgs)
  {
    super(paramString != null ? String.format(paramString, paramVarArgs) : paramString, paramThrowable);
  }
  
  ProjectCreator$ProjectCreateException(String paramString, Object... paramVarArgs)
  {
    super(String.format(paramString, paramVarArgs));
  }
}

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

import com.android.io.FileWrapper;
import com.android.io.FolderWrapper;
import com.android.sdklib.AndroidVersion;
import com.android.sdklib.IAndroidTarget;
import com.android.sdklib.ISdkLog;
import com.android.sdklib.SdkConstants;
import com.android.sdklib.SdkManager;
import com.android.sdklib.xml.AndroidManifest;
import com.android.sdklib.xml.AndroidXPathFactory;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;

public class ProjectCreator
{
  private static final int MIN_BUILD_VERSION_TAG = 1;
  private static final String PH_JAVA_FOLDER = "PACKAGE_PATH";
  private static final String PH_PACKAGE = "PACKAGE";
  @Deprecated
  private static final String PH_ACTIVITY_NAME = "ACTIVITY_NAME";
  private static final String PH_ACTIVITY_ENTRY_NAME = "ACTIVITY_ENTRY_NAME";
  private static final String PH_ACTIVITY_CLASS_NAME = "ACTIVITY_CLASS_NAME";
  private static final String PH_ACTIVITY_FQ_NAME = "ACTIVITY_FQ_NAME";
  private static final String PH_ACTIVITY_TESTED_CLASS_NAME = "ACTIVITY_TESTED_CLASS_NAME";
  private static final String PH_PROJECT_NAME = "PROJECT_NAME";
  private static final String PH_ICON = "ICON";
  private static final String PH_VERSION_TAG = "VERSION_TAG";
  private static final String XPATH_PROJECT_NAME = "/project/@name";
  public static final Pattern RE_PROJECT_NAME = Pattern.compile("[a-zA-Z0-9_]+");
  public static final String CHARS_PROJECT_NAME = "a-z A-Z 0-9 _";
  public static final Pattern RE_PACKAGE_NAME = Pattern.compile("[a-zA-Z_][a-zA-Z0-9_]*(?:\\.[a-zA-Z_][a-zA-Z0-9_]*)+");
  public static final String CHARS_PACKAGE_NAME = "a-z A-Z 0-9 _";
  public static final Pattern RE_ACTIVITY_NAME = Pattern.compile("[a-zA-Z_][a-zA-Z0-9_]*");
  public static final String CHARS_ACTIVITY_NAME = "a-z A-Z 0-9 _";
  private final OutputLevel mLevel;
  private final ISdkLog mLog;
  private final String mSdkFolder;
  private final SdkManager mSdkManager;
  
  public static enum OutputLevel
  {
    SILENT,  NORMAL,  VERBOSE;
    
    private OutputLevel() {}
  }
  
  private static class ProjectCreateException
    extends Exception
  {
    private static final long serialVersionUID = 1L;
    
    ProjectCreateException(String paramString)
    {
      super();
    }
    
    ProjectCreateException(Throwable paramThrowable, String paramString, Object... paramVarArgs)
    {
      super(paramThrowable);
    }
    
    ProjectCreateException(String paramString, Object... paramVarArgs)
    {
      super();
    }
  }
  
  public ProjectCreator(SdkManager paramSdkManager, String paramString, OutputLevel paramOutputLevel, ISdkLog paramISdkLog)
  {
    mSdkManager = paramSdkManager;
    mSdkFolder = paramString;
    mLevel = paramOutputLevel;
    mLog = paramISdkLog;
  }
  
  public void createProject(String paramString1, String paramString2, String paramString3, String paramString4, IAndroidTarget paramIAndroidTarget, boolean paramBoolean, String paramString5)
  {
    File localFile = checkNewProjectLocation(paramString1);
    if (localFile == null) {
      return;
    }
    try
    {
      int i = paramString5 != null ? 1 : 0;
      
      ProjectPropertiesWorkingCopy localProjectPropertiesWorkingCopy1 = ProjectProperties.create(paramString1, ProjectProperties.PropertyType.LOCAL);
      
      localProjectPropertiesWorkingCopy1.setProperty("sdk.dir", mSdkFolder);
      localProjectPropertiesWorkingCopy1.save();
      
      ProjectPropertiesWorkingCopy localProjectPropertiesWorkingCopy2 = ProjectProperties.create(paramString1, ProjectProperties.PropertyType.PROJECT);
      
      localProjectPropertiesWorkingCopy2.setProperty("target", paramIAndroidTarget.hashString());
      if (paramBoolean) {
        localProjectPropertiesWorkingCopy2.setProperty("android.library", "true");
      }
      localProjectPropertiesWorkingCopy2.save();
      
      ProjectPropertiesWorkingCopy localProjectPropertiesWorkingCopy3 = ProjectProperties.create(paramString1, ProjectProperties.PropertyType.ANT);
      if (i != 0) {
        localProjectPropertiesWorkingCopy3.setProperty("tested.project.dir", paramString5);
      }
      localProjectPropertiesWorkingCopy3.save();
      
      HashMap localHashMap = new HashMap();
      
      String str1 = stripString(paramString3.replace(".", File.separator), File.separatorChar);
      
      localHashMap.put("PACKAGE_PATH", str1);
      localHashMap.put("PACKAGE", paramString3);
      localHashMap.put("VERSION_TAG", Integer.toString(1));
      
      String str2 = null;String str3 = null;String str4 = null;
      String str5 = paramString4;
      String str6 = null;
      if (paramString4 != null)
      {
        if (i != 0)
        {
          paramString4 = paramString4 + "Test";
          
          int j = str5.lastIndexOf('.');
          if (j != -1) {
            str6 = str5.substring(j + 1);
          } else {
            str6 = str5;
          }
        }
        str2 = AndroidManifest.combinePackageAndClassName(paramString3, paramString4);
        
        str3 = stripString(str2.replace(".", File.separator), File.separatorChar);
        
        str3 = str3.substring(0, str3.lastIndexOf(File.separatorChar));
        
        str4 = str2.substring(str2.lastIndexOf('.') + 1);
      }
      if (paramIAndroidTarget.getVersion().getApiLevel() < 4)
      {
        if (str5 != null) {
          localHashMap.put("ACTIVITY_NAME", str5);
        }
      }
      else if (paramString4 != null)
      {
        localHashMap.put("ACTIVITY_ENTRY_NAME", paramString4);
        localHashMap.put("ACTIVITY_CLASS_NAME", str4);
        localHashMap.put("ACTIVITY_FQ_NAME", str2);
        if (str6 != null) {
          localHashMap.put("ACTIVITY_TESTED_CLASS_NAME", str6);
        }
      }
      if (paramString2 != null)
      {
        localHashMap.put("PROJECT_NAME", paramString2);
      }
      else if (str4 != null)
      {
        localHashMap.put("PROJECT_NAME", str4);
      }
      else
      {
        paramString2 = localFile.getName();
        localHashMap.put("PROJECT_NAME", paramString2);
      }
      Object localObject3;
      if (str4 != null)
      {
        localObject1 = "src" + File.separator + str3;
        
        localObject2 = createDirs(localFile, (String)localObject1);
        
        localObject3 = i != 0 ? "java_tests_file.template" : "java_file.template";
        
        String str7 = str4 + ".java";
        
        installTargetTemplate((String)localObject3, new File((File)localObject2, str7), localHashMap, paramIAndroidTarget);
      }
      else
      {
        createDirs(localFile, "src");
      }
      Object localObject1 = createDirs(localFile, "res");
      createDirs(localFile, "bin");
      createDirs(localFile, "libs");
      if (i == 0)
      {
        localObject2 = createDirs((File)localObject1, "values");
        installTargetTemplate("strings.template", new File((File)localObject2, "strings.xml"), localHashMap, paramIAndroidTarget);
        
        localObject3 = createDirs((File)localObject1, "layout");
        installTargetTemplate("layout.template", new File((File)localObject3, "main.xml"), localHashMap, paramIAndroidTarget);
        if (installIcons((File)localObject1, paramIAndroidTarget)) {
          localHashMap.put("ICON", "android:icon=\"@drawable/ic_launcher\"");
        } else {
          localHashMap.put("ICON", "");
        }
      }
      Object localObject2 = "AndroidManifest.template";
      if (i != 0) {
        localObject2 = "AndroidManifest.tests.template";
      }
      installTargetTemplate((String)localObject2, new File(localFile, "AndroidManifest.xml"), localHashMap, paramIAndroidTarget);
      
      installTemplate("build.template", new File(localFile, "build.xml"), localHashMap);
      
      installTemplate("proguard-project.txt", new File(localFile, "proguard-project.txt"), null);
    }
    catch (Exception localException)
    {
      mLog.error(localException, null, new Object[0]);
    }
  }
  
  private File checkNewProjectLocation(String paramString)
  {
    File localFile = new File(paramString);
    Object localObject2;
    if (!localFile.exists())
    {
      boolean bool = false;
      localObject2 = null;
      try
      {
        bool = localFile.mkdirs();
      }
      catch (Exception localException1)
      {
        localObject2 = localException1;
      }
      if (bool)
      {
        println("Created project directory: %1$s", new Object[] { localFile });
      }
      else
      {
        mLog.error((Throwable)localObject2, "Could not create directory: %1$s", new Object[] { localFile });
        return null;
      }
    }
    else
    {
      Object localObject1 = null;
      localObject2 = null;
      try
      {
        String[] arrayOfString = localFile.list();
        if (arrayOfString == null) {
          localObject2 = "Project folder '%1$s' is not a directory.";
        } else if (arrayOfString.length != 0) {
          localObject2 = "Project folder '%1$s' is not empty. Please consider using '%2$s update' instead.";
        }
      }
      catch (Exception localException2)
      {
        localObject1 = localException2;
      }
      if ((localObject1 != null) || (localObject2 != null)) {
        mLog.error((Throwable)localObject1, (String)localObject2, new Object[] { localFile, SdkConstants.androidCmdName() });
      }
    }
    return localFile;
  }
  
  public boolean updateProject(String paramString1, IAndroidTarget paramIAndroidTarget, String paramString2, String paramString3)
  {
    FileWrapper localFileWrapper = checkProjectFolder(paramString1, "AndroidManifest.xml");
    if (localFileWrapper == null) {
      return false;
    }
    FolderWrapper localFolderWrapper = (FolderWrapper)localFileWrapper.getParentFolder();
    
    int i = 0;
    
    IAndroidTarget localIAndroidTarget = null;
    int j = 0;
    ProjectProperties localProjectProperties = ProjectProperties.load(localFolderWrapper, ProjectProperties.PropertyType.PROJECT);
    if (localProjectProperties == null)
    {
      localProjectProperties = ProjectProperties.load(localFolderWrapper, ProjectProperties.PropertyType.LEGACY_DEFAULT);
      j = 1;
    }
    if (localProjectProperties != null)
    {
      String str1 = localProjectProperties.getProperty("target");
      localIAndroidTarget = mSdkManager.getTargetFromHashString(str1);
      
      i = localProjectProperties.getProperty("proguard.config") != null ? 1 : 0;
    }
    if ((localIAndroidTarget == null) && (paramIAndroidTarget == null))
    {
      mLog.error(null, "The project either has no target set or the target is invalid.\nPlease provide a --target to the '%1$s update' command.", new Object[] { SdkConstants.androidCmdName() });
      
      return false;
    }
    int k = 0;
    
    ProjectPropertiesWorkingCopy localProjectPropertiesWorkingCopy = null;
    if ((paramIAndroidTarget != null) || (j != 0))
    {
      if (localProjectProperties == null) {
        localProjectPropertiesWorkingCopy = ProjectProperties.create(localFolderWrapper, ProjectProperties.PropertyType.PROJECT);
      } else {
        localProjectPropertiesWorkingCopy = localProjectProperties.makeWorkingCopy(ProjectProperties.PropertyType.PROJECT);
      }
      if (paramIAndroidTarget != null) {
        localProjectPropertiesWorkingCopy.setProperty("target", paramIAndroidTarget.hashString());
      }
      k = 1;
    }
    Object localObject2;
    if (paramString3 != null)
    {
      if (localProjectPropertiesWorkingCopy == null)
      {
        assert (localProjectProperties != null);
        localProjectPropertiesWorkingCopy = localProjectProperties.makeWorkingCopy();
      }
      File localFile1 = new File(paramString3);
      String str2;
      if (!localFile1.isAbsolute())
      {
        localFile1 = new File(localFolderWrapper, paramString3);
        try
        {
          str2 = localFile1.getCanonicalPath();
        }
        catch (IOException localIOException1)
        {
          mLog.error(localIOException1, "Unable to resolve path to library project: %1$s", new Object[] { paramString3 });
          return false;
        }
      }
      else
      {
        str2 = localFile1.getAbsolutePath();
      }
      println("Resolved location of library project to: %1$s", new Object[] { str2 });
      if (checkProjectFolder(str2, "AndroidManifest.xml") == null)
      {
        mLog.error(null, "No Android Manifest at: %1$s", new Object[] { str2 });
        return false;
      }
      int n = 1;
      for (;;)
      {
        localObject2 = "android.library.reference." + Integer.toString(n);
        assert (localProjectProperties != null);
        if (localProjectProperties == null) {
          break;
        }
        String str3 = localProjectProperties.getProperty((String)localObject2);
        if (str3 == null) {
          break;
        }
        n++;
      }
      localObject2 = "android.library.reference." + Integer.toString(n);
      localProjectPropertiesWorkingCopy.setProperty((String)localObject2, paramString3);
      k = 1;
    }
    if (k != 0)
    {
      try
      {
        assert (localProjectPropertiesWorkingCopy != null);
        localProjectPropertiesWorkingCopy.save();
        if (j != 0) {
          println("Updated and renamed %1$s to %2$s", new Object[] { ProjectProperties.PropertyType.LEGACY_DEFAULT.getFilename(), ProjectProperties.PropertyType.PROJECT.getFilename() });
        } else {
          println("Updated %1$s", new Object[] { ProjectProperties.PropertyType.PROJECT.getFilename() });
        }
      }
      catch (Exception localException1)
      {
        mLog.error(localException1, "Failed to write %1$s file in '%2$s'", new Object[] { ProjectProperties.PropertyType.PROJECT.getFilename(), paramString1 });
        
        return false;
      }
      if (j != 0) {
        ProjectProperties.delete(localFolderWrapper, ProjectProperties.PropertyType.LEGACY_DEFAULT);
      }
    }
    localProjectProperties = ProjectProperties.load(localFolderWrapper, ProjectProperties.PropertyType.LOCAL);
    if (localProjectProperties == null) {
      localProjectPropertiesWorkingCopy = ProjectProperties.create(localFolderWrapper, ProjectProperties.PropertyType.LOCAL);
    } else {
      localProjectPropertiesWorkingCopy = localProjectProperties.makeWorkingCopy();
    }
    localProjectPropertiesWorkingCopy.setProperty("sdk.dir", mSdkFolder);
    try
    {
      localProjectPropertiesWorkingCopy.save();
      println("Updated %1$s", new Object[] { ProjectProperties.PropertyType.LOCAL.getFilename() });
    }
    catch (Exception localException2)
    {
      mLog.error(localException2, "Failed to write %1$s file in '%2$s'", new Object[] { ProjectProperties.PropertyType.LOCAL.getFilename(), paramString1 });
      
      return false;
    }
    localProjectProperties = ProjectProperties.load(localFolderWrapper, ProjectProperties.PropertyType.ANT);
    if (localProjectProperties == null)
    {
      localProjectProperties = ProjectProperties.load(localFolderWrapper, ProjectProperties.PropertyType.LEGACY_BUILD);
      if (localProjectProperties != null) {
        try
        {
          localProjectPropertiesWorkingCopy = localProjectProperties.makeWorkingCopy(ProjectProperties.PropertyType.ANT);
          localProjectPropertiesWorkingCopy.save();
          
          ProjectProperties.delete(localFolderWrapper, ProjectProperties.PropertyType.LEGACY_BUILD);
          
          println("Renamed %1$s to %2$s", new Object[] { ProjectProperties.PropertyType.LEGACY_BUILD.getFilename(), ProjectProperties.PropertyType.ANT.getFilename() });
        }
        catch (Exception localException3)
        {
          mLog.error(localException3, "Failed to write %1$s file in '%2$s'", new Object[] { ProjectProperties.PropertyType.ANT.getFilename(), paramString1 });
          
          return false;
        }
      }
    }
    File localFile2 = new File(localFolderWrapper, "build.xml");
    int m = (paramString2 != null) || (!localFile2.exists()) ? 1 : 0;
    Object localObject1;
    if (m == 0) {
      if (checkFileContainsRegexp(localFile2, "version-tag:\\s*custom") != null)
      {
        println("%1$s: Found version-tag: custom. File will not be updated.", new Object[] { "build.xml" });
      }
      else
      {
        localObject1 = checkFileContainsRegexp(localFile2, "version-tag:\\s*(\\d+)");
        if (localObject1 == null)
        {
          println("----------\n%1$s: Failed to find version-tag string. File must be updated.\nIn order to not erase potential customizations, the file will not be automatically regenerated.\nIf no changes have been made to the file, delete it manually and run the command again.\nIf you have made customizations to the build process, the file must be manually updated.\nIt is recommended to:\n\t* Copy current file to a safe location.\n\t* Delete original file.\n\t* Run command again to generate a new file.\n\t* Port customizations to the new file, by looking at the new rules file\n\t  located at <SDK>/tools/ant/build.xml\n\t* Update file to contain\n\t      version-tag: custom\n\t  to prevent file from being rewritten automatically by the SDK tools.\n----------\n", new Object[] { "build.xml" });
        }
        else
        {
          localObject2 = ((Matcher)localObject1).group(1);
          if (localObject2 != null)
          {
            int i1 = Integer.parseInt((String)localObject2);
            if (i1 < 1)
            {
              println("%1$s: Found version-tag: %2$d. Expected version-tag: %3$d: file must be updated.", new Object[] { "build.xml", Integer.valueOf(i1), Integer.valueOf(1) });
              
              m = 1;
            }
          }
        }
      }
    }
    if (m != 0)
    {
      localObject1 = new HashMap();
      
      ((HashMap)localObject1).put("VERSION_TAG", Integer.toString(1));
      if (paramString2 == null)
      {
        if (localFile2.exists()) {
          try
          {
            localObject2 = XPathFactory.newInstance();
            XPath localXPath = ((XPathFactory)localObject2).newXPath();
            
            paramString2 = localXPath.evaluate("/project/@name", new InputSource(new FileInputStream(localFile2)));
          }
          catch (XPathExpressionException localXPathExpressionException)
          {
            mLog.error(localXPathExpressionException, "Unable to find existing project name from %1$s", new Object[] { "build.xml" });
          }
          catch (FileNotFoundException localFileNotFoundException) {}
        }
        if (paramString2 == null)
        {
          extractPackageFromManifest(localFileWrapper, (Map)localObject1);
          Object localObject3;
          if (((HashMap)localObject1).containsKey("ACTIVITY_ENTRY_NAME"))
          {
            localObject3 = (String)((HashMap)localObject1).get("ACTIVITY_ENTRY_NAME");
            
            int i2 = ((String)localObject3).lastIndexOf('.');
            if (i2 != -1) {
              localObject3 = ((String)localObject3).substring(i2 + 1);
            }
            paramString2 = (String)localObject3;
            
            println("No project name specified, using Activity name '%1$s'.\nIf you wish to change it, edit the first line of %2$s.", new Object[] { localObject3, "build.xml" });
          }
          else
          {
            localObject3 = localFolderWrapper;
            try
            {
              localObject3 = ((File)localObject3).getCanonicalFile();
            }
            catch (IOException localIOException2) {}
            paramString2 = ((File)localObject3).getName();
            
            println("No project name specified, using project folder name '%1$s'.\nIf you wish to change it, edit the first line of %2$s.", new Object[] { paramString2, "build.xml" });
          }
        }
      }
      ((HashMap)localObject1).put("PROJECT_NAME", paramString2);
      if (mLevel == OutputLevel.VERBOSE) {
        println("Regenerating %1$s with project name %2$s", new Object[] { "build.xml", ((HashMap)localObject1).get("PROJECT_NAME") });
      }
      try
      {
        installTemplate("build.template", localFile2, (Map)localObject1);
      }
      catch (ProjectCreateException localProjectCreateException2)
      {
        mLog.error(localProjectCreateException2, null, new Object[0]);
        return false;
      }
    }
    if (i == 0) {
      try
      {
        installTemplate("proguard-project.txt", new File(localFolderWrapper, "proguard-project.txt"), null);
      }
      catch (ProjectCreateException localProjectCreateException1)
      {
        mLog.error(localProjectCreateException1, null, new Object[0]);
        return false;
      }
    }
    return true;
  }
  
  public void updateTestProject(String paramString1, String paramString2, SdkManager paramSdkManager)
  {
    if (checkProjectFolder(paramString1, "AndroidManifest.xml") == null) {
      return;
    }
    File localFile1 = new File(paramString2);
    String str1;
    if (!localFile1.isAbsolute())
    {
      localFile1 = new File(paramString1, paramString2);
      try
      {
        str1 = localFile1.getCanonicalPath();
      }
      catch (IOException localIOException)
      {
        mLog.error(localIOException, "Unable to resolve path to main project: %1$s", new Object[] { paramString2 });
        return;
      }
    }
    else
    {
      str1 = localFile1.getAbsolutePath();
    }
    println("Resolved location of main project to: %1$s", new Object[] { str1 });
    if (checkProjectFolder(str1, "AndroidManifest.xml") == null)
    {
      mLog.error(null, "No Android Manifest at: %1$s", new Object[] { str1 });
      return;
    }
    ProjectProperties localProjectProperties = ProjectProperties.load(str1, ProjectProperties.PropertyType.PROJECT);
    if (localProjectProperties == null)
    {
      localProjectProperties = ProjectProperties.load(str1, ProjectProperties.PropertyType.LEGACY_DEFAULT);
      if (localProjectProperties == null)
      {
        mLog.error(null, "No %1$s at: %2$s", new Object[] { ProjectProperties.PropertyType.PROJECT.getFilename(), str1 });
        
        return;
      }
    }
    String str2 = localProjectProperties.getProperty("target");
    if (str2 == null)
    {
      mLog.error(null, "%1$s in the main project has no target property.", new Object[] { ProjectProperties.PropertyType.PROJECT.getFilename() });
      
      return;
    }
    IAndroidTarget localIAndroidTarget = paramSdkManager.getTargetFromHashString(str2);
    if (localIAndroidTarget == null)
    {
      mLog.error(null, "Main project target %1$s is not a valid target.", new Object[] { str2 });
      return;
    }
    String str3 = null;
    XPathFactory localXPathFactory = XPathFactory.newInstance();
    XPath localXPath = localXPathFactory.newXPath();
    
    File localFile2 = new File(paramString1, "build.xml");
    if (!localFile2.isFile())
    {
      localObject = new File(str1, "build.xml");
      if (((File)localObject).isFile()) {
        try
        {
          String str4 = localXPath.evaluate("/project/@name", new InputSource(new FileInputStream((File)localObject)));
          
          str3 = str4 + "Test";
        }
        catch (XPathExpressionException localXPathExpressionException)
        {
          mLog.warning("Failed to parse %1$s.\nFile may not be valid. Consider running 'android update project' on the main project.", new Object[] { ((File)localObject).getPath() });
        }
        catch (FileNotFoundException localFileNotFoundException) {}
      }
    }
    if (!updateProject(paramString1, localIAndroidTarget, str3, null)) {
      return;
    }
    Object localObject = ProjectProperties.load(paramString1, ProjectProperties.PropertyType.ANT);
    ProjectPropertiesWorkingCopy localProjectPropertiesWorkingCopy;
    if (localObject == null) {
      localProjectPropertiesWorkingCopy = ProjectProperties.create(paramString1, ProjectProperties.PropertyType.ANT);
    } else {
      localProjectPropertiesWorkingCopy = ((ProjectProperties)localObject).makeWorkingCopy();
    }
    localProjectPropertiesWorkingCopy.setProperty("tested.project.dir", paramString2);
    try
    {
      localProjectPropertiesWorkingCopy.save();
      println("Updated %1$s", new Object[] { ProjectProperties.PropertyType.ANT.getFilename() });
    }
    catch (Exception localException)
    {
      mLog.error(localException, "Failed to write %1$s file in '%2$s'", new Object[] { ProjectProperties.PropertyType.ANT.getFilename(), paramString1 });
      
      return;
    }
  }
  
  private FileWrapper checkProjectFolder(String paramString1, String paramString2)
  {
    FolderWrapper localFolderWrapper = new FolderWrapper(paramString1);
    if (!localFolderWrapper.isDirectory())
    {
      mLog.error(null, "Project folder '%1$s' is not a valid directory.", new Object[] { localFolderWrapper });
      
      return null;
    }
    FileWrapper localFileWrapper = new FileWrapper(localFolderWrapper, paramString2);
    if (!localFileWrapper.isFile())
    {
      mLog.error(null, "%1$s is not a valid project (%2$s not found).", new Object[] { paramString1, paramString2 });
      
      return null;
    }
    return localFileWrapper;
  }
  
  private Matcher checkFileContainsRegexp(File paramFile, String paramString)
  {
    Pattern localPattern = Pattern.compile(paramString);
    try
    {
      BufferedReader localBufferedReader = new BufferedReader(new FileReader(paramFile));
      String str;
      while ((str = localBufferedReader.readLine()) != null)
      {
        Matcher localMatcher = localPattern.matcher(str);
        if (localMatcher.find()) {
          return localMatcher;
        }
      }
      localBufferedReader.close();
    }
    catch (Exception localException) {}
    return null;
  }
  
  private boolean extractPackageFromManifest(File paramFile, Map<String, String> paramMap)
  {
    try
    {
      XPath localXPath = AndroidXPathFactory.newXPath();
      
      localObject = new InputSource(new FileReader(paramFile));
      String str1 = localXPath.evaluate("/manifest/@package", (InputSource)localObject);
      
      localObject = new InputSource(new FileReader(paramFile));
      
      String str2 = String.format("/manifest/application/activity[intent-filter/action/@%1$s:name='android.intent.action.MAIN' and intent-filter/category/@%1$s:name='android.intent.category.LAUNCHER']/@%1$s:name", new Object[] { "android" });
      
      NodeList localNodeList = (NodeList)localXPath.evaluate(str2, (InputSource)localObject, XPathConstants.NODESET);
      if ((str1 == null) || (str1.length() == 0))
      {
        mLog.error(null, "Missing <manifest package=\"...\"> in '%1$s'", new Object[] { paramFile.getName() });
        
        return false;
      }
      String str3 = "";
      if (localNodeList.getLength() > 0) {
        str3 = localNodeList.item(0).getNodeValue();
      }
      if ((mLevel == OutputLevel.VERBOSE) && (localNodeList.getLength() > 1))
      {
        println("WARNING: There is more than one activity defined in '%1$s'.\nOnly the first one will be used. If this is not appropriate, you need\nto specify one of these values manually instead:", new Object[] { paramFile.getName() });
        for (int i = 0; i < localNodeList.getLength(); i++)
        {
          String str4 = localNodeList.item(i).getNodeValue();
          str4 = combinePackageActivityNames(str1, str4);
          println("- %1$s", new Object[] { str4 });
        }
      }
      if (str3.length() == 0) {
        mLog.warning("Missing <activity %1$s:name=\"...\"> in '%2$s'.\nNo activity will be generated.", new Object[] { "android", paramFile.getName() });
      } else {
        paramMap.put("ACTIVITY_ENTRY_NAME", str3);
      }
      paramMap.put("PACKAGE", str1);
      return true;
    }
    catch (IOException localIOException)
    {
      mLog.error(localIOException, "Failed to read %1$s", new Object[] { paramFile.getName() });
    }
    catch (XPathExpressionException localXPathExpressionException)
    {
      Object localObject = localXPathExpressionException.getCause();
      mLog.error(localObject == null ? localXPathExpressionException : (Throwable)localObject, "Failed to parse %1$s", new Object[] { paramFile.getName() });
    }
    return false;
  }
  
  private String combinePackageActivityNames(String paramString1, String paramString2)
  {
    int i = paramString2.indexOf('.');
    if (i == 0) {
      return paramString1 + paramString2;
    }
    if (i > 0) {
      return paramString2;
    }
    return paramString1 + "." + paramString2;
  }
  
  private void installTargetTemplate(String paramString, File paramFile, Map<String, String> paramMap, IAndroidTarget paramIAndroidTarget)
    throws ProjectCreator.ProjectCreateException
  {
    String str1 = paramIAndroidTarget.getPath(6);
    String str2 = str1 + File.separator + paramString;
    
    installFullPathTemplate(str2, paramFile, paramMap);
  }
  
  private void installTemplate(String paramString, File paramFile, Map<String, String> paramMap)
    throws ProjectCreator.ProjectCreateException
  {
    String str1 = mSdkFolder + File.separator + SdkConstants.OS_SDK_TOOLS_LIB_FOLDER;
    String str2 = str1 + File.separator + paramString;
    
    installFullPathTemplate(str2, paramFile, paramMap);
  }
  
  private void installFullPathTemplate(String paramString, File paramFile, Map<String, String> paramMap)
    throws ProjectCreator.ProjectCreateException
  {
    boolean bool = paramFile.exists();
    try
    {
      BufferedWriter localBufferedWriter = new BufferedWriter(new FileWriter(paramFile));
      BufferedReader localBufferedReader = new BufferedReader(new FileReader(paramString));
      String str;
      while ((str = localBufferedReader.readLine()) != null)
      {
        if (paramMap != null) {
          for (Map.Entry localEntry : paramMap.entrySet()) {
            str = str.replace((CharSequence)localEntry.getKey(), (CharSequence)localEntry.getValue());
          }
        }
        localBufferedWriter.write(str);
        localBufferedWriter.newLine();
      }
      localBufferedWriter.close();
      localBufferedReader.close();
    }
    catch (Exception localException)
    {
      throw new ProjectCreateException(localException, "Could not access %1$s: %2$s", new Object[] { paramFile, localException.getMessage() });
    }
    println("%1$s file %2$s", new Object[] { bool ? "Updated" : "Added", paramFile });
  }
  
  private boolean installIcons(File paramFile, IAndroidTarget paramIAndroidTarget)
    throws ProjectCreator.ProjectCreateException
  {
    String str = paramIAndroidTarget.getPath(6);
    
    boolean bool = false;
    
    bool |= installIcon(str, "ic_launcher_xhdpi.png", paramFile, "drawable-xhdpi");
    
    bool |= installIcon(str, "ic_launcher_hdpi.png", paramFile, "drawable-hdpi");
    
    bool |= installIcon(str, "ic_launcher_mdpi.png", paramFile, "drawable-mdpi");
    
    bool |= installIcon(str, "ic_launcher_ldpi.png", paramFile, "drawable-ldpi");
    
    return bool;
  }
  
  private boolean installIcon(String paramString1, String paramString2, File paramFile, String paramString3)
    throws ProjectCreator.ProjectCreateException
  {
    File localFile1 = new File(paramString1, paramString2);
    if (localFile1.exists())
    {
      File localFile2 = createDirs(paramFile, paramString3);
      installBinaryFile(localFile1, new File(localFile2, "ic_launcher.png"));
      return true;
    }
    return false;
  }
  
  private void installBinaryFile(File paramFile1, File paramFile2)
    throws ProjectCreator.ProjectCreateException
  {
    byte[] arrayOfByte = new byte['?'];
    
    FileInputStream localFileInputStream = null;
    FileOutputStream localFileOutputStream = null;
    try
    {
      localFileInputStream = new FileInputStream(paramFile1);
      localFileOutputStream = new FileOutputStream(paramFile2);
      int i;
      while ((i = localFileInputStream.read(arrayOfByte)) != -1) {
        localFileOutputStream.write(arrayOfByte, 0, i);
      }
      return;
    }
    catch (FileNotFoundException localFileNotFoundException) {}catch (IOException localIOException5)
    {
      throw new ProjectCreateException(localIOException5, "Failed to read binary file: %1$s", new Object[] { paramFile1.getAbsolutePath() });
    }
    finally
    {
      if (localFileInputStream != null) {
        try
        {
          localFileInputStream.close();
        }
        catch (IOException localIOException6) {}
      }
      if (localFileOutputStream != null) {
        try
        {
          localFileOutputStream.close();
        }
        catch (IOException localIOException7) {}
      }
    }
  }
  
  private void println(String paramString, Object... paramVarArgs)
  {
    if (mLevel != OutputLevel.SILENT)
    {
      if (!paramString.endsWith("\n")) {
        paramString = paramString + "\n";
      }
      mLog.printf(paramString, paramVarArgs);
    }
  }
  
  private File createDirs(File paramFile, String paramString)
    throws ProjectCreator.ProjectCreateException
  {
    File localFile = new File(paramFile, paramString);
    int i = 1;
    if (!localFile.exists())
    {
      if (!localFile.mkdirs()) {
        throw new ProjectCreateException("Could not create directory: %1$s", new Object[] { localFile });
      }
      i = 0;
    }
    if (localFile.isDirectory())
    {
      if (!localFile.canWrite()) {
        throw new ProjectCreateException("Path is not writable: %1$s", new Object[] { localFile });
      }
    }
    else {
      throw new ProjectCreateException("Path is not a directory: %1$s", new Object[] { localFile });
    }
    if (i == 0) {
      try
      {
        println("Created directory %1$s", new Object[] { localFile.getCanonicalPath() });
      }
      catch (IOException localIOException)
      {
        throw new ProjectCreateException("Could not determine canonical path of created directory", new Object[] { localIOException });
      }
    }
    return localFile;
  }
  
  private static String stripString(String paramString, char paramChar)
  {
    int i = paramString.length();
    int j = 0;int k = i - 1;
    while ((j < i) && (paramString.charAt(j) == paramChar)) {
      j++;
    }
    while ((k >= 0) && (paramString.charAt(k) == paramChar)) {
      k--;
    }
    k++;
    if ((j >= i) || (k < 0)) {
      return "";
    }
    return paramString.substring(j, k);
  }
}

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

import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;

public enum ProjectProperties$PropertyType
{
  ANT("ant.properties", "# This file is used to override default values used by the Ant build system.\n#\n# This file must be checked into Version Control Systems, as it is\n# integral to the build system of your project.\n\n# This file is only used by the Ant script.\n\n# You can use this to override default values such as\n#  'source.dir' for the location of your java source folder and\n#  'out.dir' for the location of your output folder.\n\n# You can also use it define how the release builds are signed by declaring\n# the following properties:\n#  'key.store' for the location of your keystore and\n#  'key.alias' for the name of the key to use.\n# The password will be asked during the build when you use the 'release' target.\
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