Home | History | Annotate | Download | only in sdklib
      1 /*
      2  * Copyright (C) 2007 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.sdklib;
     18 
     19 import java.io.File;
     20 
     21 /**
     22  * Constant definition class.<br>
     23  * <br>
     24  * Most constants have a prefix defining the content.
     25  * <ul>
     26  * <li><code>OS_</code> OS path constant. These paths are different depending on the platform.</li>
     27  * <li><code>FN_</code> File name constant.</li>
     28  * <li><code>FD_</code> Folder name constant.</li>
     29  * </ul>
     30  *
     31  */
     32 public final class SdkConstants {
     33     public final static int PLATFORM_UNKNOWN = 0;
     34     public final static int PLATFORM_LINUX = 1;
     35     public final static int PLATFORM_WINDOWS = 2;
     36     public final static int PLATFORM_DARWIN = 3;
     37 
     38     /**
     39      * Returns current platform, one of {@link #PLATFORM_WINDOWS}, {@link #PLATFORM_DARWIN},
     40      * {@link #PLATFORM_LINUX} or {@link #PLATFORM_UNKNOWN}.
     41      */
     42     public final static int CURRENT_PLATFORM = currentPlatform();
     43 
     44     /**
     45      * Charset for the ini file handled by the SDK.
     46      */
     47     public final static String INI_CHARSET = "UTF-8";
     48 
     49     /** An SDK Project's AndroidManifest.xml file */
     50     public static final String FN_ANDROID_MANIFEST_XML= "AndroidManifest.xml";
     51     /** An SDK Project's build.xml file */
     52     public final static String FN_BUILD_XML = "build.xml";
     53 
     54     /** Name of the framework library, i.e. "android.jar" */
     55     public static final String FN_FRAMEWORK_LIBRARY = "android.jar";
     56     /** Name of the layout attributes, i.e. "attrs.xml" */
     57     public static final String FN_ATTRS_XML = "attrs.xml";
     58     /** Name of the layout attributes, i.e. "attrs_manifest.xml" */
     59     public static final String FN_ATTRS_MANIFEST_XML = "attrs_manifest.xml";
     60     /** framework aidl import file */
     61     public static final String FN_FRAMEWORK_AIDL = "framework.aidl";
     62     /** layoutlib.jar file */
     63     public static final String FN_LAYOUTLIB_JAR = "layoutlib.jar";
     64     /** widget list file */
     65     public static final String FN_WIDGETS = "widgets.txt";
     66     /** Intent activity actions list file */
     67     public static final String FN_INTENT_ACTIONS_ACTIVITY = "activity_actions.txt";
     68     /** Intent broadcast actions list file */
     69     public static final String FN_INTENT_ACTIONS_BROADCAST = "broadcast_actions.txt";
     70     /** Intent service actions list file */
     71     public static final String FN_INTENT_ACTIONS_SERVICE = "service_actions.txt";
     72     /** Intent category list file */
     73     public static final String FN_INTENT_CATEGORIES = "categories.txt";
     74 
     75     /** platform build property file */
     76     public final static String FN_BUILD_PROP = "build.prop";
     77     /** plugin properties file */
     78     public final static String FN_PLUGIN_PROP = "plugin.prop";
     79     /** add-on manifest file */
     80     public final static String FN_MANIFEST_INI = "manifest.ini";
     81     /** add-on layout device XML file. */
     82     public final static String FN_DEVICES_XML = "devices.xml";
     83     /** hardware properties definition file */
     84     public final static String FN_HARDWARE_INI = "hardware-properties.ini";
     85 
     86     /** project property file */
     87     public final static String FN_DEFAULT_PROPERTIES = "default.properties";
     88 
     89     /** Skin layout file */
     90     public final static String FN_SKIN_LAYOUT = "layout";//$NON-NLS-1$
     91 
     92     /** dex.jar file */
     93     public static final String FN_DX_JAR = "dx.jar"; //$NON-NLS-1$
     94 
     95     /** dx executable (with extension for the current OS)  */
     96     public final static String FN_DX = (CURRENT_PLATFORM == PLATFORM_WINDOWS) ?
     97             "dx.bat" : "dx"; //$NON-NLS-1$ //$NON-NLS-2$
     98 
     99     /** aapt executable (with extension for the current OS)  */
    100     public final static String FN_AAPT = (CURRENT_PLATFORM == PLATFORM_WINDOWS) ?
    101             "aapt.exe" : "aapt"; //$NON-NLS-1$ //$NON-NLS-2$
    102 
    103     /** aidl executable (with extension for the current OS)  */
    104     public final static String FN_AIDL = (CURRENT_PLATFORM == PLATFORM_WINDOWS) ?
    105             "aidl.exe" : "aidl"; //$NON-NLS-1$ //$NON-NLS-2$
    106 
    107     /** adb executable (with extension for the current OS)  */
    108     public final static String FN_ADB = (CURRENT_PLATFORM == PLATFORM_WINDOWS) ?
    109             "adb.exe" : "adb"; //$NON-NLS-1$ //$NON-NLS-2$
    110 
    111     /** emulator executable (with extension for the current OS) */
    112     public final static String FN_EMULATOR = (CURRENT_PLATFORM == PLATFORM_WINDOWS) ?
    113             "emulator.exe" : "emulator"; //$NON-NLS-1$ //$NON-NLS-2$
    114 
    115     /** zipalign executable (with extension for the current OS)  */
    116     public final static String FN_ZIPALIGN = (CURRENT_PLATFORM == PLATFORM_WINDOWS) ?
    117             "zipalign.exe" : "zipalign"; //$NON-NLS-1$ //$NON-NLS-2$
    118 
    119     /** properties file for SDK Updater packages */
    120     public final static String FN_SOURCE_PROP = "source.properties"; //$NON-NLS-1$
    121     /** properties file for content hash of installed packages */
    122     public final static String FN_CONTENT_HASH_PROP = "content_hash.properties"; //$NON-NLS-1$
    123     /** properties file for the SDK */
    124     public final static String FN_SDK_PROP = "sdk.properties"; //$NON-NLS-1$
    125 
    126     /* Folder Names for Android Projects . */
    127 
    128     /** Resources folder name, i.e. "res". */
    129     public final static String FD_RESOURCES = "res"; //$NON-NLS-1$
    130     /** Assets folder name, i.e. "assets" */
    131     public final static String FD_ASSETS = "assets"; //$NON-NLS-1$
    132     /** Default source folder name, i.e. "src" */
    133     public final static String FD_SOURCES = "src"; //$NON-NLS-1$
    134     /** Default generated source folder name, i.e. "gen" */
    135     public final static String FD_GEN_SOURCES = "gen"; //$NON-NLS-1$
    136     /** Default native library folder name inside the project, i.e. "libs"
    137      * While the folder inside the .apk is "lib", we call that one libs because
    138      * that's what we use in ant for both .jar and .so and we need to make the 2 development ways
    139      * compatible. */
    140     public final static String FD_NATIVE_LIBS = "libs"; //$NON-NLS-1$
    141     /** Native lib folder inside the APK: "lib" */
    142     public final static String FD_APK_NATIVE_LIBS = "lib"; //$NON-NLS-1$
    143     /** Default output folder name, i.e. "bin" */
    144     public final static String FD_OUTPUT = "bin"; //$NON-NLS-1$
    145     /** Default anim resource folder name, i.e. "anim" */
    146     public final static String FD_ANIM = "anim"; //$NON-NLS-1$
    147     /** Default color resource folder name, i.e. "color" */
    148     public final static String FD_COLOR = "color"; //$NON-NLS-1$
    149     /** Default drawable resource folder name, i.e. "drawable" */
    150     public final static String FD_DRAWABLE = "drawable"; //$NON-NLS-1$
    151     /** Default layout resource folder name, i.e. "layout" */
    152     public final static String FD_LAYOUT = "layout"; //$NON-NLS-1$
    153     /** Default menu resource folder name, i.e. "menu" */
    154     public final static String FD_MENU = "menu"; //$NON-NLS-1$
    155     /** Default values resource folder name, i.e. "values" */
    156     public final static String FD_VALUES = "values"; //$NON-NLS-1$
    157     /** Default xml resource folder name, i.e. "xml" */
    158     public final static String FD_XML = "xml"; //$NON-NLS-1$
    159     /** Default raw resource folder name, i.e. "raw" */
    160     public final static String FD_RAW = "raw"; //$NON-NLS-1$
    161 
    162     /* Folder Names for the Android SDK */
    163 
    164     /** Name of the SDK platforms folder. */
    165     public final static String FD_PLATFORMS = "platforms";
    166     /** Name of the SDK addons folder. */
    167     public final static String FD_ADDONS = "add-ons";
    168     /** Name of the SDK tools folder. */
    169     public final static String FD_TOOLS = "tools";
    170     /** Name of the SDK tools/lib folder. */
    171     public final static String FD_LIB = "lib";
    172     /** Name of the SDK docs folder. */
    173     public final static String FD_DOCS = "docs";
    174     /** Name of the doc folder containing API reference doc (javadoc) */
    175     public static final String FD_DOCS_REFERENCE = "reference";
    176     /** Name of the SDK images folder. */
    177     public final static String FD_IMAGES = "images";
    178     /** Name of the SDK skins folder. */
    179     public final static String FD_SKINS = "skins";
    180     /** Name of the SDK samples folder. */
    181     public final static String FD_SAMPLES = "samples";
    182     /** Name of the SDK templates folder, i.e. "templates" */
    183     public final static String FD_TEMPLATES = "templates";
    184     /** Name of the SDK Ant folder, i.e. "ant" */
    185     public final static String FD_ANT = "ant";
    186     /** Name of the SDK data folder, i.e. "data" */
    187     public final static String FD_DATA = "data";
    188     /** Name of the SDK resources folder, i.e. "res" */
    189     public final static String FD_RES = "res";
    190     /** Name of the SDK font folder, i.e. "fonts" */
    191     public final static String FD_FONTS = "fonts";
    192     /** Name of the android sources directory */
    193     public static final String FD_ANDROID_SOURCES = "sources";
    194     /** Name of the addon libs folder. */
    195     public final static String FD_ADDON_LIBS = "libs";
    196 
    197     /** Namespace for the resource XML, i.e. "http://schemas.android.com/apk/res/android" */
    198     public final static String NS_RESOURCES = "http://schemas.android.com/apk/res/android";
    199 
    200     /** The name of the uses-library that provides "android.test.runner" */
    201     public final static String ANDROID_TEST_RUNNER_LIB = "android.test.runner";
    202 
    203     /* Folder path relative to the SDK root */
    204     /** Path of the documentation directory relative to the sdk folder.
    205      *  This is an OS path, ending with a separator. */
    206     public final static String OS_SDK_DOCS_FOLDER = FD_DOCS + File.separator;
    207 
    208     /** Path of the tools directory relative to the sdk folder, or to a platform folder.
    209      *  This is an OS path, ending with a separator. */
    210     public final static String OS_SDK_TOOLS_FOLDER = FD_TOOLS + File.separator;
    211 
    212     /** Path of the lib directory relative to the sdk folder, or to a platform folder.
    213      *  This is an OS path, ending with a separator. */
    214     public final static String OS_SDK_TOOLS_LIB_FOLDER =
    215             OS_SDK_TOOLS_FOLDER + FD_LIB + File.separator;
    216 
    217     /* Folder paths relative to a platform or add-on folder */
    218 
    219     /** Path of the images directory relative to a platform or addon folder.
    220      *  This is an OS path, ending with a separator. */
    221     public final static String OS_IMAGES_FOLDER = FD_IMAGES + File.separator;
    222 
    223     /** Path of the skin directory relative to a platform or addon folder.
    224      *  This is an OS path, ending with a separator. */
    225     public final static String OS_SKINS_FOLDER = FD_SKINS + File.separator;
    226 
    227     /* Folder paths relative to a Platform folder */
    228 
    229     /** Path of the data directory relative to a platform folder.
    230      *  This is an OS path, ending with a separator. */
    231     public final static String OS_PLATFORM_DATA_FOLDER = FD_DATA + File.separator;
    232 
    233     /** Path of the samples directory relative to a platform folder.
    234      *  This is an OS path, ending with a separator. */
    235     public final static String OS_PLATFORM_SAMPLES_FOLDER = FD_SAMPLES + File.separator;
    236 
    237     /** Path of the resources directory relative to a platform folder.
    238      *  This is an OS path, ending with a separator. */
    239     public final static String OS_PLATFORM_RESOURCES_FOLDER =
    240             OS_PLATFORM_DATA_FOLDER + FD_RES + File.separator;
    241 
    242     /** Path of the fonts directory relative to a platform folder.
    243      *  This is an OS path, ending with a separator. */
    244     public final static String OS_PLATFORM_FONTS_FOLDER =
    245             OS_PLATFORM_DATA_FOLDER + FD_FONTS + File.separator;
    246 
    247     /** Path of the android source directory relative to a platform folder.
    248      *  This is an OS path, ending with a separator. */
    249     public final static String OS_PLATFORM_SOURCES_FOLDER = FD_ANDROID_SOURCES + File.separator;
    250 
    251     /** Path of the android templates directory relative to a platform folder.
    252      *  This is an OS path, ending with a separator. */
    253     public final static String OS_PLATFORM_TEMPLATES_FOLDER = FD_TEMPLATES + File.separator;
    254 
    255     /** Path of the Ant build rules directory relative to a platform folder.
    256      *  This is an OS path, ending with a separator. */
    257     public final static String OS_PLATFORM_ANT_FOLDER = FD_ANT + File.separator;
    258 
    259     /** Path of the attrs.xml file relative to a platform folder. */
    260     public final static String OS_PLATFORM_ATTRS_XML =
    261             OS_PLATFORM_RESOURCES_FOLDER + FD_VALUES + File.separator + FN_ATTRS_XML;
    262 
    263     /** Path of the attrs_manifest.xml file relative to a platform folder. */
    264     public final static String OS_PLATFORM_ATTRS_MANIFEST_XML =
    265             OS_PLATFORM_RESOURCES_FOLDER + FD_VALUES + File.separator + FN_ATTRS_MANIFEST_XML;
    266 
    267     /** Path of the layoutlib.jar file relative to a platform folder. */
    268     public final static String OS_PLATFORM_LAYOUTLIB_JAR =
    269             OS_PLATFORM_DATA_FOLDER + FN_LAYOUTLIB_JAR;
    270 
    271     /* Folder paths relative to a addon folder */
    272 
    273     /** Path of the images directory relative to a folder folder.
    274      *  This is an OS path, ending with a separator. */
    275     public final static String OS_ADDON_LIBS_FOLDER = FD_ADDON_LIBS + File.separator;
    276 
    277     /** Skin default **/
    278     public final static String SKIN_DEFAULT = "default";
    279 
    280     /** SDK property: support for library */
    281     public final static String PROP_SDK_SUPPORT_LIBRARY = "sdk.build.support.library"; //$NON-NLS-1$
    282     /** SDK property: ant build revision */
    283     public final static String PROP_SDK_ANT_BUILD_REVISION = "sdk.ant.build.revision"; //$NON-NLS-1$
    284     /** SDK property: ant templates revision */
    285     public final static String PROP_SDK_ANT_TEMPLATES_REVISION = "sdk.ant.templates.revision"; //$NON-NLS-1$
    286 
    287 
    288     /** Returns the appropriate name for the 'android' command, which is 'android.bat' for
    289      * Windows and 'android' for all other platforms. */
    290     public static String androidCmdName() {
    291         String os = System.getProperty("os.name");
    292         String cmd = "android";
    293         if (os.startsWith("Windows")) {
    294             cmd += ".bat";
    295         }
    296         return cmd;
    297     }
    298 
    299     /** Returns the appropriate name for the 'mksdcard' command, which is 'mksdcard.exe' for
    300      * Windows and 'mkdsdcard' for all other platforms. */
    301     public static String mkSdCardCmdName() {
    302         String os = System.getProperty("os.name");
    303         String cmd = "mksdcard";
    304         if (os.startsWith("Windows")) {
    305             cmd += ".exe";
    306         }
    307         return cmd;
    308     }
    309 
    310     /**
    311      * Returns current platform
    312      *
    313      * @return one of {@link #PLATFORM_WINDOWS}, {@link #PLATFORM_DARWIN},
    314      * {@link #PLATFORM_LINUX} or {@link #PLATFORM_UNKNOWN}.
    315      */
    316     public static int currentPlatform() {
    317         String os = System.getProperty("os.name");          //$NON-NLS-1$
    318         if (os.startsWith("Mac OS")) {                      //$NON-NLS-1$
    319             return PLATFORM_DARWIN;
    320         } else if (os.startsWith("Windows")) {              //$NON-NLS-1$
    321             return PLATFORM_WINDOWS;
    322         } else if (os.startsWith("Linux")) {                //$NON-NLS-1$
    323             return PLATFORM_LINUX;
    324         }
    325 
    326         return PLATFORM_UNKNOWN;
    327     }
    328 }
    329