sdklib

16:52:17.582 INFO  jd.cli.Main - Decompiling sdklib.jar
package com.android.sdklib;

import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
import java.util.Properties;
import java.util.regex.Pattern;

public final class AndroidVersion
  implements Comparable<AndroidVersion>
{
  private final int mApiLevel;
  private final String mCodename;
  
  public static final class AndroidVersionException
    extends Exception
  {
    private static final long serialVersionUID = 1L;
    
    AndroidVersionException(String message, Throwable cause)
    {
      super(cause);
    }
  }
  
  public AndroidVersion(int apiLevel, @Nullable String codename)
  {
    mApiLevel = apiLevel;
    mCodename = sanitizeCodename(codename);
  }
  
  public AndroidVersion(@Nullable Properties properties, int defaultApiLevel, @Nullable String defaultCodeName)
  {
    if (properties == null)
    {
      mApiLevel = defaultApiLevel;
      mCodename = sanitizeCodename(defaultCodeName);
    }
    else
    {
      mApiLevel = Integer.parseInt(properties.getProperty("AndroidVersion.ApiLevel", Integer.toString(defaultApiLevel)));
      
      mCodename = sanitizeCodename(properties.getProperty("AndroidVersion.CodeName", defaultCodeName));
    }
  }
  
  public AndroidVersion(@NonNull Properties properties)
    throws AndroidVersion.AndroidVersionException
  {
    Exception error = null;
    
    String apiLevel = properties.getProperty("AndroidVersion.ApiLevel", null);
    if (apiLevel != null) {
      try
      {
        mApiLevel = Integer.parseInt(apiLevel);
        mCodename = sanitizeCodename(properties.getProperty("AndroidVersion.CodeName", null));
        
        return;
      }
      catch (NumberFormatException e)
      {
        error = e;
      }
    }
    throw new AndroidVersionException("AndroidVersion.ApiLevel not found!", error);
  }
  
  public AndroidVersion(@NonNull String apiOrCodename)
    throws AndroidVersion.AndroidVersionException
  {
    int apiLevel = 0;
    String codename = null;
    try
    {
      apiLevel = Integer.parseInt(apiOrCodename);
    }
    catch (NumberFormatException ignore)
    {
      if ((!"REL".equals(apiOrCodename)) && 
        (Pattern.matches("[A-Z_]+", apiOrCodename))) {
        codename = apiOrCodename;
      }
    }
    mApiLevel = apiLevel;
    mCodename = sanitizeCodename(codename);
    if ((mApiLevel <= 0) && (codename == null)) {
      throw new AndroidVersionException("Invalid android API or codename " + apiOrCodename, null);
    }
  }
  
  public void saveProperties(@NonNull Properties props)
  {
    props.setProperty("AndroidVersion.ApiLevel", Integer.toString(mApiLevel));
    if (mCodename != null) {
      props.setProperty("AndroidVersion.CodeName", mCodename);
    }
  }
  
  public int getApiLevel()
  {
    return mApiLevel;
  }
  
  @Nullable
  public String getCodename()
  {
    return mCodename;
  }
  
  @NonNull
  public String getApiString()
  {
    if (mCodename != null) {
      return mCodename;
    }
    return Integer.toString(mApiLevel);
  }
  
  public boolean isPreview()
  {
    return mCodename != null;
  }
  
  public boolean canRun(@NonNull AndroidVersion appVersion)
  {
    if (mCodename != null) {
      return mCodename.equals(mCodename);
    }
    return mApiLevel >= mApiLevel;
  }
  
  public boolean equals(int apiLevel)
  {
    return (mCodename == null) && (apiLevel == mApiLevel);
  }
  
  public boolean equals(Object obj)
  {
    if ((obj instanceof AndroidVersion))
    {
      AndroidVersion version = (AndroidVersion)obj;
      if (mCodename == null) {
        return (mCodename == null) && (mApiLevel == mApiLevel);
      }
      return (mCodename.equals(mCodename)) && (mApiLevel == mApiLevel);
    }
    if ((obj instanceof String))
    {
      if (mCodename != null) {
        return mCodename.equals(obj);
      }
      try
      {
        int value = Integer.parseInt((String)obj);
        return value == mApiLevel;
      }
      catch (NumberFormatException e) {}
    }
    return false;
  }
  
  public int hashCode()
  {
    if (mCodename != null) {
      return mCodename.hashCode();
    }
    return mApiLevel;
  }
  
  public String toString()
  {
    String s = String.format("API %1$d", new Object[] { Integer.valueOf(mApiLevel) });
    if (isPreview()) {
      s = s + String.format(", %1$s preview", new Object[] { mCodename });
    }
    return s;
  }
  
  public int compareTo(AndroidVersion o)
  {
    return compareTo(mApiLevel, mCodename);
  }
  
  public int compareTo(int apiLevel, @Nullable String codename)
  {
    if (mCodename == null)
    {
      if (codename == null) {
        return mApiLevel - apiLevel;
      }
      if (mApiLevel == apiLevel) {
        return -1;
      }
      return mApiLevel - apiLevel;
    }
    if (mApiLevel == apiLevel)
    {
      if (codename == null) {
        return 1;
      }
      return mCodename.compareTo(codename);
    }
    return mApiLevel - apiLevel;
  }
  
  public boolean isGreaterOrEqualThan(int api)
  {
    return compareTo(api, null) >= 0;
  }
  
  @Nullable
  private String sanitizeCodename(@Nullable String codename)
  {
    if (codename != null)
    {
      codename = codename.trim();
      if ((codename.length() == 0) || ("REL".equals(codename))) {
        codename = null;
      }
    }
    return codename;
  }
}

/* Location:
 * Qualified Name:     com.android.sdklib.AndroidVersion
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.sdklib;

import com.android.annotations.NonNull;
import com.android.annotations.Nullable;

public abstract class AndroidTargetHash
{
  private static final String PLATFORM_HASH_PREFIX = "android-";
  public static final String ADD_ON_FORMAT = "%s:%s:%s";
  static final String PLATFORM_HASH = "android-%s";
  
  @NonNull
  public static String getPlatformHashString(@NonNull AndroidVersion version)
  {
    return String.format("android-%s", new Object[] { version.getApiString() });
  }
  
  @Nullable
  public static AndroidVersion getPlatformVersion(@NonNull String hashString)
  {
    if (hashString.startsWith("android-"))
    {
      String suffix = hashString.substring("android-".length());
      if (!suffix.isEmpty())
      {
        if (Character.isDigit(suffix.charAt(0)))
        {
          int api = Integer.parseInt(suffix);
          return new AndroidVersion(api, null);
        }
        return new AndroidVersion(1, suffix);
      }
    }
    return null;
  }
  
  public static String getAddonHashString(@NonNull String addonVendor, @NonNull String addonName, @NonNull AndroidVersion version)
  {
    return String.format("%s:%s:%s", new Object[] { addonVendor, addonName, version.getApiString() });
  }
  
  public static String getTargetHashString(@NonNull IAndroidTarget target)
  {
    if (target.isPlatform()) {
      return getPlatformHashString(target.getVersion());
    }
    return getAddonHashString(target.getVendor(), target.getName(), target.getVersion());
  }
  
  public static boolean isPlatform(@NonNull String hashString)
  {
    return hashString.startsWith("android-");
  }
}

/* Location:
 * Qualified Name:     com.android.sdklib.AndroidTargetHash
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.sdklib;

import com.android.annotations.NonNull;
import com.android.sdklib.repository.FullRevision;

public enum BuildToolInfo$PathId
{
  AAPT("1.0.0"),  AIDL("1.0.0"),  DX("1.0.0"),  DX_JAR("1.0.0"),  LLVM_RS_CC("1.0.0"),  ANDROID_RS("1.0.0"),  ANDROID_RS_CLANG("1.0.0"),  BCC_COMPAT("18.1.0"),  LD_ARM("18.1.0"),  LD_X86("18.1.0"),  LD_MIPS("18.1.0");
  
  private final FullRevision mMinRevision;
  
  private BuildToolInfo$PathId(@NonNull String minRevision)
  {
    mMinRevision = FullRevision.parseRevision(minRevision);
  }
  
  boolean isPresentIn(@NonNull FullRevision fullRevision)
  {
    return fullRevision.compareTo(mMinRevision) >= 0;
  }
}

/* Location:
 * Qualified Name:     com.android.sdklib.BuildToolInfo.PathId
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.sdklib;

import com.android.annotations.NonNull;
import com.android.sdklib.repository.descriptors.IdDisplay;
import java.io.File;

public abstract interface ISystemImage
  extends Comparable<ISystemImage>
{
  @NonNull
  public abstract File getLocation();
  
  @NonNull
  public abstract LocationType getLocationType();
  
  @NonNull
  public abstract IdDisplay getTag();
  
  @NonNull
  public abstract String getAbiType();
  
  @NonNull
  public abstract File[] getSkins();
  
  public static enum LocationType
  {
    IN_PLATFORM_LEGACY,  IN_PLATFORM_SUBFOLDER,  IN_SYSTEM_IMAGE;
    
    private LocationType() {}
  }
}

/* Location:
 * Qualified Name:     com.android.sdklib.ISystemImage
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.sdklib;

public abstract interface IAndroidTarget$IOptionalLibrary
{
  public abstract String getName();
  
  public abstract String getJarName();
  
  public abstract String getJarPath();
  
  public abstract String getDescription();
}

/* Location:
 * Qualified Name:     com.android.sdklib.IAndroidTarget.IOptionalLibrary
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.sdklib;

import com.android.SdkConstants;
import com.android.annotations.NonNull;
import com.android.sdklib.io.FileOp;
import com.android.sdklib.repository.descriptors.IdDisplay;
import java.io.File;
import java.util.Locale;

public class SystemImage
  implements ISystemImage
{
  public static final String ANDROID_PREFIX = "android-";
  public static final IdDisplay DEFAULT_TAG = new IdDisplay("default", "Default");
  private final ISystemImage.LocationType mLocationtype;
  private final IdDisplay mTag;
  private final String mAbiType;
  private final File mLocation;
  private final File[] mSkins;
  
  public SystemImage(@NonNull File location, @NonNull ISystemImage.LocationType locationType, @NonNull IdDisplay tag, @NonNull String abiType, @NonNull File[] skins)
  {
    mLocation = location;
    mLocationtype = locationType;
    mTag = tag;
    mAbiType = abiType;
    mSkins = skins;
  }
  
  public SystemImage(@NonNull SdkManager sdkManager, @NonNull IAndroidTarget target, @NonNull ISystemImage.LocationType locationType, @NonNull IdDisplay tag, @NonNull String abiType, @NonNull File[] skins)
  {
    mLocationtype = locationType;
    mTag = tag;
    mAbiType = abiType;
    mSkins = skins;
    
    File location = null;
    switch (locationType)
    {
    case IN_PLATFORM_LEGACY: 
      location = new File(target.getLocation(), SdkConstants.OS_IMAGES_FOLDER);
      break;
    case IN_PLATFORM_SUBFOLDER: 
      location = FileOp.append(target.getLocation(), new String[] { SdkConstants.OS_IMAGES_FOLDER, abiType });
      break;
    case IN_SYSTEM_IMAGE: 
      if (!target.isPlatform()) {
        throw new IllegalArgumentException("Add-ons do not support the system-image location type");
      }
      location = getCanonicalFolder(sdkManager.getLocation(), target.getVersion(), tag.getId(), abiType);
      
      break;
    default: 
      if (!$assertionsDisabled) {
        throw new AssertionError("SystemImage used with an incorrect locationType");
      }
      break;
    }
    mLocation = location;
  }
  
  @NonNull
  public static File getCanonicalFolder(String sdkOsPath, AndroidVersion platformVersion, String tagId, String abiType)
  {
    File root = FileOp.append(sdkOsPath, new String[] { "system-images", "android-" + platformVersion.getApiString() });
    if (tagId != null) {
      root = FileOp.append(root, new String[] { tagId });
    }
    if (abiType == null) {
      return root;
    }
    return FileOp.append(root, new String[] { abiType });
  }
  
  @NonNull
  public File getLocation()
  {
    return mLocation;
  }
  
  @NonNull
  public ISystemImage.LocationType getLocationType()
  {
    return mLocationtype;
  }
  
  @NonNull
  public IdDisplay getTag()
  {
    return mTag;
  }
  
  @NonNull
  public String getAbiType()
  {
    return mAbiType;
  }
  
  public File[] getSkins()
  {
    return mSkins;
  }
  
  public int compareTo(ISystemImage other)
  {
    int t = getTag().compareTo(other.getTag());
    if (t != 0) {
      return t;
    }
    return getAbiType().compareToIgnoreCase(other.getAbiType());
  }
  
  @NonNull
  public String toString()
  {
    return String.format("SystemImage tag=%s, ABI=%s, location %s='%s'", new Object[] { mTag.getId(), mAbiType, mLocationtype.toString().replace('_', ' ').toLowerCase(Locale.US), mLocation });
  }
}

/* Location:
 * Qualified Name:     com.android.sdklib.SystemImage
 * Java Class Version: 6 (50.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: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.sdklib;

import com.android.annotations.NonNull;

public class SdkManager$LayoutlibVersion
  implements Comparable<LayoutlibVersion>
{
  private final int mApi;
  private final int mRevision;
  public static final int NOT_SPECIFIED = 0;
  
  public SdkManager$LayoutlibVersion(int api, int revision)
  {
    mApi = api;
    mRevision = revision;
  }
  
  public int getApi()
  {
    return mApi;
  }
  
  public int getRevision()
  {
    return mRevision;
  }
  
  public int compareTo(@NonNull LayoutlibVersion rhs)
  {
    boolean useRev = (mRevision > 0) && (mRevision > 0);
    int lhsValue = (mApi << 16) + (useRev ? mRevision : 0);
    int rhsValue = (mApi << 16) + (useRev ? mRevision : 0);
    return lhsValue - rhsValue;
  }
}

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

import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
import com.android.sdklib.repository.descriptors.IdDisplay;
import java.io.File;
import java.util.List;
import java.util.Map;

public abstract interface IAndroidTarget
  extends Comparable<IAndroidTarget>
{
  public static final int ANDROID_JAR = 1;
  public static final int ANDROID_AIDL = 2;
  public static final int SAMPLES = 4;
  public static final int SKINS = 5;
  public static final int TEMPLATES = 6;
  public static final int DATA = 7;
  public static final int ATTRIBUTES = 8;
  public static final int MANIFEST_ATTRIBUTES = 9;
  public static final int LAYOUT_LIB = 10;
  public static final int RESOURCES = 11;
  public static final int FONTS = 12;
  public static final int WIDGETS = 13;
  public static final int ACTIONS_ACTIVITY = 14;
  public static final int ACTIONS_BROADCAST = 15;
  public static final int ACTIONS_SERVICE = 16;
  public static final int CATEGORIES = 17;
  public static final int SOURCES = 18;
  public static final int DOCS = 19;
  public static final int ANT = 24;
  public static final int UI_AUTOMATOR_JAR = 27;
  public static final int NO_USB_ID = 0;
  
  public abstract String getLocation();
  
  public abstract String getVendor();
  
  public abstract String getName();
  
  public abstract String getFullName();
  
  public abstract String getClasspathName();
  
  public abstract String getShortClasspathName();
  
  public abstract String getDescription();
  
  public abstract AndroidVersion getVersion();
  
  public abstract String getVersionName();
  
  public abstract int getRevision();
  
  public abstract boolean isPlatform();
  
  public abstract IAndroidTarget getParent();
  
  public abstract String getPath(int paramInt);
  
  public abstract File getFile(int paramInt);
  
  public abstract BuildToolInfo getBuildToolInfo();
  
  @NonNull
  public abstract List<String> getBootClasspath();
  
  public abstract boolean hasRenderingLibrary();
  
  @NonNull
  public abstract File[] getSkins();
  
  @Nullable
  public abstract File getDefaultSkin();
  
  public abstract IOptionalLibrary[] getOptionalLibraries();
  
  public abstract String[] getPlatformLibraries();
  
  public abstract String getProperty(String paramString);
  
  public abstract Integer getProperty(String paramString, Integer paramInteger);
  
  public abstract Boolean getProperty(String paramString, Boolean paramBoolean);
  
  public abstract Map<String, String> getProperties();
  
  public abstract int getUsbVendorId();
  
  public abstract ISystemImage[] getSystemImages();
  
  @Nullable
  public abstract ISystemImage getSystemImage(@NonNull IdDisplay paramIdDisplay, @NonNull String paramString);
  
  public abstract boolean canRunOn(IAndroidTarget paramIAndroidTarget);
  
  public abstract String hashString();
  
  public static abstract interface IOptionalLibrary
  {
    public abstract String getName();
    
    public abstract String getJarName();
    
    public abstract String getJarPath();
    
    public abstract String getDescription();
  }
}

/* Location:
 * Qualified Name:     com.android.sdklib.IAndroidTarget
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.sdklib;

import com.android.SdkConstants;
import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
import com.android.sdklib.repository.FullRevision;
import com.android.utils.ILogger;
import com.google.common.collect.Maps;
import java.io.File;
import java.util.Map;
import java.util.Map.Entry;

public class BuildToolInfo
{
  private final FullRevision mRevision;
  private final File mPath;
  
  public static enum PathId
  {
    AAPT("1.0.0"),  AIDL("1.0.0"),  DX("1.0.0"),  DX_JAR("1.0.0"),  LLVM_RS_CC("1.0.0"),  ANDROID_RS("1.0.0"),  ANDROID_RS_CLANG("1.0.0"),  BCC_COMPAT("18.1.0"),  LD_ARM("18.1.0"),  LD_X86("18.1.0"),  LD_MIPS("18.1.0");
    
    private final FullRevision mMinRevision;
    
    private PathId(@NonNull String minRevision)
    {
      mMinRevision = FullRevision.parseRevision(minRevision);
    }
    
    boolean isPresentIn(@NonNull FullRevision fullRevision)
    {
      return fullRevision.compareTo(mMinRevision) >= 0;
    }
  }
  
  private final Map<PathId, String> mPaths = Maps.newEnumMap(PathId.class);
  
  public BuildToolInfo(@NonNull FullRevision revision, @NonNull File path)
  {
    mRevision = revision;
    mPath = path;
    
    add(PathId.AAPT, SdkConstants.FN_AAPT);
    add(PathId.AIDL, SdkConstants.FN_AIDL);
    add(PathId.DX, SdkConstants.FN_DX);
    add(PathId.DX_JAR, "lib" + File.separator + "dx.jar");
    add(PathId.LLVM_RS_CC, SdkConstants.FN_RENDERSCRIPT);
    add(PathId.ANDROID_RS, SdkConstants.OS_FRAMEWORK_RS);
    add(PathId.ANDROID_RS_CLANG, SdkConstants.OS_FRAMEWORK_RS_CLANG);
    add(PathId.BCC_COMPAT, SdkConstants.FN_BCC_COMPAT);
    add(PathId.LD_ARM, SdkConstants.FN_LD_ARM);
    add(PathId.LD_X86, SdkConstants.FN_LD_X86);
    add(PathId.LD_MIPS, SdkConstants.FN_LD_MIPS);
  }
  
  public BuildToolInfo(FullRevision revision, @NonNull File mainPath, @NonNull File aapt, @NonNull File aidl, @NonNull File dx, @NonNull File dxJar, @NonNull File llmvRsCc, @NonNull File androidRs, @NonNull File androidRsClang, @Nullable File bccCompat, @Nullable File ldArm, @Nullable File ldX86, @Nullable File ldMips)
  {
    mRevision = revision;
    mPath = mainPath;
    add(PathId.AAPT, aapt);
    add(PathId.AIDL, aidl);
    add(PathId.DX, dx);
    add(PathId.DX_JAR, dxJar);
    add(PathId.LLVM_RS_CC, llmvRsCc);
    add(PathId.ANDROID_RS, androidRs);
    add(PathId.ANDROID_RS_CLANG, androidRsClang);
    if (bccCompat != null) {
      add(PathId.BCC_COMPAT, bccCompat);
    } else if (PathId.BCC_COMPAT.isPresentIn(revision)) {
      throw new IllegalArgumentException("BCC_COMPAT required in " + revision.toString());
    }
    if (ldArm != null) {
      add(PathId.LD_ARM, ldArm);
    } else if (PathId.LD_ARM.isPresentIn(revision)) {
      throw new IllegalArgumentException("LD_ARM required in " + revision.toString());
    }
    if (ldX86 != null) {
      add(PathId.LD_X86, ldX86);
    } else if (PathId.LD_X86.isPresentIn(revision)) {
      throw new IllegalArgumentException("LD_X86 required in " + revision.toString());
    }
    if (ldMips != null) {
      add(PathId.LD_MIPS, ldMips);
    } else if (PathId.LD_MIPS.isPresentIn(revision)) {
      throw new IllegalArgumentException("LD_MIPS required in " + revision.toString());
    }
  }
  
  private void add(PathId id, String leaf)
  {
    add(id, new File(mPath, leaf));
  }
  
  private void add(PathId id, File path)
  {
    String str = path.getAbsolutePath();
    if ((path.isDirectory()) && (str.charAt(str.length() - 1) != File.separatorChar)) {
      str = str + File.separatorChar;
    }
    mPaths.put(id, str);
  }
  
  @NonNull
  public FullRevision getRevision()
  {
    return mRevision;
  }
  
  @NonNull
  public File getLocation()
  {
    return mPath;
  }
  
  public String getPath(PathId pathId)
  {
    assert (pathId.isPresentIn(mRevision));
    
    return (String)mPaths.get(pathId);
  }
  
  public boolean isValid(@Nullable ILogger log)
  {
    for (Map.Entry<PathId, String> entry : mPaths.entrySet())
    {
      File f = new File((String)entry.getValue());
      if ((!f.exists()) && (((PathId)entry.getKey()).isPresentIn(mRevision)))
      {
        if (log != null) {
          log.warning("Build-tool %1$s is missing %2$s at %3$s", new Object[] { mRevision.toString(), entry.getKey(), f.getAbsolutePath() });
        }
        return false;
      }
    }
    return true;
  }
  
  public String toString()
  {
    StringBuilder builder = new StringBuilder();
    builder.append("<BuildToolInfo rev=").append(mRevision);
    builder.append(", mPath=").append(mPath);
    builder.append(", mPaths=").append(getPathString());
    builder.append(">");
    return builder.toString();
  }
  
  private String getPathString()
  {
    StringBuilder sb = new StringBuilder("{");
    for (Map.Entry<PathId, String> entry : mPaths.entrySet()) {
      if (((PathId)entry.getKey()).isPresentIn(mRevision))
      {
        if (sb.length() > 1) {
          sb.append(", ");
        }
        sb.append(entry.getKey()).append('=').append((String)entry.getValue());
      }
    }
    sb.append('}');
    
    return sb.toString();
  }
}

/* Location:
 * Qualified Name:     com.android.sdklib.BuildToolInfo
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.sdklib;

public final class AndroidVersion$AndroidVersionException
  extends Exception
{
  private static final long serialVersionUID = 1L;
  
  AndroidVersion$AndroidVersionException(String message, Throwable cause)
  {
    super(message, cause);
  }
}

/* Location:
 * Qualified Name:     com.android.sdklib.AndroidVersion.AndroidVersionException
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.sdklib;

import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
import com.android.prefs.AndroidLocation;
import com.android.prefs.AndroidLocation.AndroidLocationException;
import com.android.sdklib.internal.androidTarget.PlatformTarget;
import com.android.sdklib.repository.FullRevision;
import com.android.sdklib.repository.descriptors.IPkgDesc;
import com.android.sdklib.repository.descriptors.PkgType;
import com.android.sdklib.repository.local.LocalExtraPkgInfo;
import com.android.sdklib.repository.local.LocalPkgInfo;
import com.android.sdklib.repository.local.LocalSdk;
import com.android.utils.ILogger;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;

public class SdkManager
{
  private static final boolean DEBUG = System.getenv("SDKMAN_DEBUG") != null;
  private static final String ADB_INI_FILE = "adb_usb.ini";
  private static final String ADB_INI_HEADER = "# ANDROID 3RD PARTY USB VENDOR ID LIST -- DO NOT EDIT.\n# USE 'android update adb' TO GENERATE.\n# 1 USB VENDOR ID PER LINE.\n";
  private final LocalSdk mLocalSdk;
  
  protected SdkManager(@NonNull String osSdkPath)
  {
    mLocalSdk = new LocalSdk(new File(osSdkPath));
  }
  
  @Nullable
  public static SdkManager createManager(@NonNull String osSdkPath, @NonNull ILogger log)
  {
    try
    {
      SdkManager manager = new SdkManager(osSdkPath);
      manager.reloadSdk(log);
      
      return manager;
    }
    catch (Throwable throwable)
    {
      log.error(throwable, "Error parsing the sdk.", new Object[0]);
    }
    return null;
  }
  
  @NonNull
  public LocalSdk getLocalSdk()
  {
    return mLocalSdk;
  }
  
  public void reloadSdk(@NonNull ILogger log)
  {
    mLocalSdk.clearLocalPkg(PkgType.PKG_ALL);
  }
  
  public boolean hasChanged()
  {
    return hasChanged(null);
  }
  
  public boolean hasChanged(@Nullable ILogger log)
  {
    return mLocalSdk.hasChanged(EnumSet.of(PkgType.PKG_PLATFORMS, PkgType.PKG_ADDONS, PkgType.PKG_BUILD_TOOLS));
  }
  
  @NonNull
  public String getLocation()
  {
    File f = mLocalSdk.getLocation();
    
    assert (f != null);
    return f.getPath();
  }
  
  @NonNull
  public IAndroidTarget[] getTargets()
  {
    return mLocalSdk.getTargets();
  }
  
  @Deprecated
  @NonNull
  public Set<FullRevision> getBuildTools()
  {
    LocalPkgInfo[] pkgs = mLocalSdk.getPkgsInfos(PkgType.PKG_BUILD_TOOLS);
    TreeSet<FullRevision> bt = new TreeSet();
    for (LocalPkgInfo pkg : pkgs)
    {
      IPkgDesc d = pkg.getDesc();
      if (d.hasFullRevision()) {
        bt.add(d.getFullRevision());
      }
    }
    return Collections.unmodifiableSet(bt);
  }
  
  @Nullable
  public BuildToolInfo getLatestBuildTool()
  {
    return mLocalSdk.getLatestBuildTool();
  }
  
  @Nullable
  public BuildToolInfo getBuildTool(@Nullable FullRevision revision)
  {
    return mLocalSdk.getBuildTool(revision);
  }
  
  @Nullable
  public IAndroidTarget getTargetFromHashString(@Nullable String hash)
  {
    return mLocalSdk.getTargetFromHashString(hash);
  }
  
  public void updateAdb()
    throws AndroidLocation.AndroidLocationException, IOException
  {
    FileWriter writer = null;
    try
    {
      File adbIni = new File(AndroidLocation.getFolder(), "adb_usb.ini");
      writer = new FileWriter(adbIni);
      
      HashSet<Integer> set = new HashSet();
      IAndroidTarget[] targets = getTargets();
      for (IAndroidTarget target : targets) {
        if (target.getUsbVendorId() != 0) {
          set.add(Integer.valueOf(target.getUsbVendorId()));
        }
      }
      writer.write("# ANDROID 3RD PARTY USB VENDOR ID LIST -- DO NOT EDIT.\n# USE 'android update adb' TO GENERATE.\n# 1 USB VENDOR ID PER LINE.\n");
      for (Integer i : set) {
        writer.write(String.format("0x%04x\n", new Object[] { i }));
      }
    }
    finally
    {
      if (writer != null) {
        writer.close();
      }
    }
  }
  
  @Deprecated
  @Nullable
  public LayoutlibVersion getMaxLayoutlibVersion()
  {
    LayoutlibVersion maxVersion = null;
    for (IAndroidTarget target : getTargets()) {
      if ((target instanceof PlatformTarget))
      {
        LayoutlibVersion lv = ((PlatformTarget)target).getLayoutlibVersion();
        if ((lv != null) && (
          (maxVersion == null) || (lv.compareTo(maxVersion) > 0))) {
          maxVersion = lv;
        }
      }
    }
    return maxVersion;
  }
  
  @NonNull
  public Map<File, String> getExtraSamples()
  {
    LocalPkgInfo[] pkgsInfos = mLocalSdk.getPkgsInfos(PkgType.PKG_EXTRAS);
    Map<File, String> samples = new HashMap();
    for (LocalPkgInfo info : pkgsInfos)
    {
      assert ((info instanceof LocalExtraPkgInfo));
      
      File root = info.getLocalDir();
      File path = new File(root, "samples");
      if (path.isDirectory())
      {
        samples.put(path, info.getListDescription());
      }
      else
      {
        path = new File(root, "sample");
        if ((path.isDirectory()) && (new File(path, "AndroidManifest.xml").isFile())) {
          samples.put(path, info.getListDescription());
        }
      }
    }
    return samples;
  }
  
  @Deprecated
  @NonNull
  public Map<String, Integer> getExtrasVersions()
  {
    LocalPkgInfo[] pkgsInfos = mLocalSdk.getPkgsInfos(PkgType.PKG_EXTRAS);
    Map<String, Integer> extraVersions = new TreeMap();
    for (LocalPkgInfo info : pkgsInfos)
    {
      assert ((info instanceof LocalExtraPkgInfo));
      if ((info instanceof LocalExtraPkgInfo))
      {
        LocalExtraPkgInfo ei = (LocalExtraPkgInfo)info;
        IPkgDesc d = ei.getDesc();
        String vendor = d.getVendorId();
        String path = d.getPath();
        int majorRev = d.getFullRevision().getMajor();
        
        extraVersions.put(vendor + '/' + path, Integer.valueOf(majorRev));
      }
    }
    return extraVersions;
  }
  
  @Nullable
  public String getPlatformToolsVersion()
  {
    LocalPkgInfo info = mLocalSdk.getPkgInfo(PkgType.PKG_PLATFORM_TOOLS);
    IPkgDesc d = info == null ? null : info.getDesc();
    if ((d != null) && (d.hasFullRevision())) {
      return d.getFullRevision().toShortString();
    }
    return null;
  }
  
  public static class LayoutlibVersion
    implements Comparable<LayoutlibVersion>
  {
    private final int mApi;
    private final int mRevision;
    public static final int NOT_SPECIFIED = 0;
    
    public LayoutlibVersion(int api, int revision)
    {
      mApi = api;
      mRevision = revision;
    }
    
    public int getApi()
    {
      return mApi;
    }
    
    public int getRevision()
    {
      return mRevision;
    }
    
    public int compareTo(@NonNull LayoutlibVersion rhs)
    {
      boolean useRev = (mRevision > 0) && (mRevision > 0);
      int lhsValue = (mApi << 16) + (useRev ? mRevision : 0);
      int rhsValue = (mApi << 16) + (useRev ? mRevision : 0);
      return lhsValue - rhsValue;
    }
  }
}

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

public enum ISystemImage$LocationType
{
  IN_PLATFORM_LEGACY,  IN_PLATFORM_SUBFOLDER,  IN_SYSTEM_IMAGE;
  
  private ISystemImage$LocationType() {}
}

/* Location:
 * Qualified Name:     com.android.sdklib.ISystemImage.LocationType
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.sdklib.devices;

import com.android.resources.Density;
import com.android.resources.ScreenRatio;
import com.android.resources.ScreenSize;
import com.android.resources.TouchScreen;

public class Screen
{
  private ScreenSize mScreenSize;
  private double mDiagonalLength;
  private Density mPixelDensity;
  private ScreenRatio mScreenRatio;
  private int mXDimension;
  private int mYDimension;
  private double mXdpi;
  private double mYdpi;
  private Multitouch mMultitouch;
  private TouchScreen mMechanism;
  private ScreenType mScreenType;
  
  public ScreenSize getSize()
  {
    return mScreenSize;
  }
  
  public void setSize(ScreenSize s)
  {
    mScreenSize = s;
  }
  
  public double getDiagonalLength()
  {
    return mDiagonalLength;
  }
  
  public void setDiagonalLength(double diagonalLength)
  {
    mDiagonalLength = diagonalLength;
  }
  
  public Density getPixelDensity()
  {
    return mPixelDensity;
  }
  
  public void setPixelDensity(Density pDensity)
  {
    mPixelDensity = pDensity;
  }
  
  public ScreenRatio getRatio()
  {
    return mScreenRatio;
  }
  
  public void setRatio(ScreenRatio ratio)
  {
    mScreenRatio = ratio;
  }
  
  public int getXDimension()
  {
    return mXDimension;
  }
  
  public void setXDimension(int xDimension)
  {
    mXDimension = xDimension;
  }
  
  public int getYDimension()
  {
    return mYDimension;
  }
  
  public void setYDimension(int yDimension)
  {
    mYDimension = yDimension;
  }
  
  public double getXdpi()
  {
    return mXdpi;
  }
  
  public void setXdpi(double xdpi)
  {
    mXdpi = xdpi;
  }
  
  public double getYdpi()
  {
    return mYdpi;
  }
  
  public void setYdpi(double ydpi)
  {
    mYdpi = ydpi;
  }
  
  public Multitouch getMultitouch()
  {
    return mMultitouch;
  }
  
  public void setMultitouch(Multitouch m)
  {
    mMultitouch = m;
  }
  
  public TouchScreen getMechanism()
  {
    return mMechanism;
  }
  
  public void setMechanism(TouchScreen mechanism)
  {
    mMechanism = mechanism;
  }
  
  public ScreenType getScreenType()
  {
    return mScreenType;
  }
  
  public void setScreenType(ScreenType screenType)
  {
    mScreenType = screenType;
  }
  
  public Screen deepCopy()
  {
    Screen s = new Screen();
    mScreenSize = mScreenSize;
    mDiagonalLength = mDiagonalLength;
    mPixelDensity = mPixelDensity;
    mScreenRatio = mScreenRatio;
    mXDimension = mXDimension;
    mYDimension = mYDimension;
    mXdpi = mXdpi;
    mYdpi = mYdpi;
    mMultitouch = mMultitouch;
    mMechanism = mMechanism;
    mScreenType = mScreenType;
    return s;
  }
  
  public boolean equals(Object o)
  {
    if (o == this) {
      return true;
    }
    if (!(o instanceof Screen)) {
      return false;
    }
    Screen s = (Screen)o;
    return (mScreenSize == mScreenSize) && (mDiagonalLength == mDiagonalLength) && (mPixelDensity == mPixelDensity) && (mScreenRatio == mScreenRatio) && (mXDimension == mXDimension) && (mYDimension == mYDimension) && (mXdpi == mXdpi) && (mYdpi == mYdpi) && (mMultitouch == mMultitouch) && (mMechanism == mMechanism) && (mScreenType == mScreenType);
  }
  
  public int hashCode()
  {
    int hash = 17;
    hash = 31 * hash + mScreenSize.ordinal();
    long f = Double.doubleToLongBits(mDiagonalLength);
    hash = 31 * hash + (int)(f ^ f >>> 32);
    hash = 31 * hash + mPixelDensity.ordinal();
    hash = 31 * hash + mScreenRatio.ordinal();
    hash = 31 * hash + mXDimension;
    hash = 31 * hash + mYDimension;
    f = Double.doubleToLongBits(mXdpi);
    hash = 31 * hash + (int)(f ^ f >>> 32);
    f = Double.doubleToLongBits(mYdpi);
    hash = 31 * hash + (int)(f ^ f >>> 32);
    hash = 31 * hash + mMultitouch.ordinal();
    hash = 31 * hash + mMechanism.ordinal();
    hash = 31 * hash + mScreenType.ordinal();
    return hash;
  }
  
  public String toString()
  {
    StringBuilder sb = new StringBuilder();
    sb.append("Screen [mScreenSize=");
    sb.append(mScreenSize);
    sb.append(", mDiagonalLength=");
    sb.append(mDiagonalLength);
    sb.append(", mPixelDensity=");
    sb.append(mPixelDensity);
    sb.append(", mScreenRatio=");
    sb.append(mScreenRatio);
    sb.append(", mXDimension=");
    sb.append(mXDimension);
    sb.append(", mYDimension=");
    sb.append(mYDimension);
    sb.append(", mXdpi=");
    sb.append(mXdpi);
    sb.append(", mYdpi=");
    sb.append(mYdpi);
    sb.append(", mMultitouch=");
    sb.append(mMultitouch);
    sb.append(", mMechanism=");
    sb.append(mMechanism);
    sb.append(", mScreenType=");
    sb.append(mScreenType);
    sb.append("]");
    return sb.toString();
  }
}

/* Location:
 * Qualified Name:     com.android.sdklib.devices.Screen
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.sdklib.devices;

import com.android.annotations.NonNull;
import com.android.annotations.Nullable;

public enum BluetoothProfile
{
  A2DP("A2DP"),  ATT("ATT"),  AVRCP("AVRCP"),  AVDTP("AVDTP"),  BIP("BIP"),  BPP("BPP"),  CIP("CIP"),  CTP("CTP"),  DIP("DIP"),  DUN("DUN"),  FAX("FAX"),  FTP("FTP"),  GAVDP("GAVDP"),  GAP("GAP"),  GATT("GATT"),  GOEP("GOEP"),  HCRP("HCRP"),  HDP("HDP"),  HFP("HFP"),  HID("HID"),  HSP("HSP"),  ICP("ICP"),  LAP("LAP"),  MAP("MAP"),  OPP("OPP"),  PAN("PAN"),  PBA("PBA"),  PBAP("PBAP"),  SPP("SPP"),  SDAP("SDAP"),  SAP("SAP"),  SIM("SIM"),  rSAP("rSAP"),  SYNCH("SYNCH"),  VDP("VDP"),  WAPB("WAPB");
  
  @NonNull
  private final String mValue;
  
  private BluetoothProfile(@NonNull String value)
  {
    mValue = value;
  }
  
  @Nullable
  public static BluetoothProfile getEnum(@NonNull String value)
  {
    for (BluetoothProfile bp : ) {
      if (mValue.equals(value)) {
        return bp;
      }
    }
    return null;
  }
  
  public String toString()
  {
    return mValue;
  }
}

/* Location:
 * Qualified Name:     com.android.sdklib.devices.BluetoothProfile
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.sdklib.devices;

import com.android.annotations.NonNull;
import com.android.annotations.Nullable;

public enum PowerType
{
  PLUGGEDIN("plugged-in"),  BATTERY("battery");
  
  @NonNull
  private final String mValue;
  
  private PowerType(@NonNull String value)
  {
    mValue = value;
  }
  
  @Nullable
  public static PowerType getEnum(@NonNull String value)
  {
    for (PowerType c : ) {
      if (mValue.equals(value)) {
        return c;
      }
    }
    return null;
  }
  
  public String toString()
  {
    return mValue;
  }
}

/* Location:
 * Qualified Name:     com.android.sdklib.devices.PowerType
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.sdklib.devices;

import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

public class Device$Builder
{
  private String mName;
  private String mId;
  private String mManufacturer;
  private final List<Software> mSoftware = new ArrayList();
  private final List<State> mState = new ArrayList();
  private Meta mMeta;
  private State mDefaultState;
  private String mTagId;
  private final Map<String, String> mBootProps = new TreeMap();
  
  public Device$Builder() {}
  
  public Device$Builder(Device d)
  {
    mTagId = null;
    mName = d.getDisplayName();
    mId = d.getId();
    mManufacturer = d.getManufacturer();
    for (Software s : d.getAllSoftware()) {
      mSoftware.add(s.deepCopy());
    }
    for (State s : d.getAllStates()) {
      mState.add(s.deepCopy());
    }
    mSoftware.addAll(d.getAllSoftware());
    mState.addAll(d.getAllStates());
    mMeta = d.getMeta();
    mDefaultState = d.getDefaultState();
  }
  
  public void setName(@NonNull String name)
  {
    mName = name;
  }
  
  public void setId(@NonNull String id)
  {
    mId = id;
  }
  
  public void setTagId(@Nullable String tagId)
  {
    mTagId = tagId;
  }
  
  public void addBootProp(@NonNull String propName, @NonNull String propValue)
  {
    mBootProps.put(propName, propValue);
  }
  
  public void setManufacturer(@NonNull String manufacturer)
  {
    mManufacturer = manufacturer;
  }
  
  public void addSoftware(@NonNull Software sw)
  {
    mSoftware.add(sw);
  }
  
  public void addAllSoftware(@NonNull Collection<? extends Software> sw)
  {
    mSoftware.addAll(sw);
  }
  
  public void addState(State state)
  {
    mState.add(state);
  }
  
  public void addAllState(@NonNull Collection<? extends State> states)
  {
    mState.addAll(states);
  }
  
  public boolean removeState(@NonNull String stateName)
  {
    for (int i = 0; i < mState.size(); i++) {
      if ((stateName != null) && (stateName.equals(((State)mState.get(i)).getName())))
      {
        mState.remove(i);
        return true;
      }
    }
    return false;
  }
  
  public void setMeta(@NonNull Meta meta)
  {
    mMeta = meta;
  }
  
  public Device build()
  {
    if (mName == null) {
      throw generateBuildException("Device missing name");
    }
    if (mManufacturer == null) {
      throw generateBuildException("Device missing manufacturer");
    }
    if (mSoftware.size() <= 0) {
      throw generateBuildException("Device software not configured");
    }
    if (mState.size() <= 0) {
      throw generateBuildException("Device states not configured");
    }
    if (mId == null) {
      mId = mName;
    }
    if (mMeta == null) {
      mMeta = new Meta();
    }
    for (State s : mState) {
      if (s.isDefaultState())
      {
        mDefaultState = s;
        break;
      }
    }
    if (mDefaultState == null) {
      throw generateBuildExc
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

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-2017. Infinite Loop Ltd