• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     /** Skin layout file */
87     public final static String FN_SKIN_LAYOUT = "layout";//$NON-NLS-1$
88 
89     /** dex.jar file */
90     public static final String FN_DX_JAR = "dx.jar"; //$NON-NLS-1$
91 
92     /** dx executable (with extension for the current OS)  */
93     public final static String FN_DX = (CURRENT_PLATFORM == PLATFORM_WINDOWS) ?
94             "dx.bat" : "dx"; //$NON-NLS-1$ //$NON-NLS-2$
95 
96     /** aapt executable (with extension for the current OS)  */
97     public final static String FN_AAPT = (CURRENT_PLATFORM == PLATFORM_WINDOWS) ?
98             "aapt.exe" : "aapt"; //$NON-NLS-1$ //$NON-NLS-2$
99 
100     /** aidl executable (with extension for the current OS)  */
101     public final static String FN_AIDL = (CURRENT_PLATFORM == PLATFORM_WINDOWS) ?
102             "aidl.exe" : "aidl"; //$NON-NLS-1$ //$NON-NLS-2$
103 
104     /** adb executable (with extension for the current OS)  */
105     public final static String FN_ADB = (CURRENT_PLATFORM == PLATFORM_WINDOWS) ?
106             "adb.exe" : "adb"; //$NON-NLS-1$ //$NON-NLS-2$
107 
108     /** emulator executable (with extension for the current OS) */
109     public final static String FN_EMULATOR = (CURRENT_PLATFORM == PLATFORM_WINDOWS) ?
110             "emulator.exe" : "emulator"; //$NON-NLS-1$ //$NON-NLS-2$
111 
112     /** zipalign executable (with extension for the current OS)  */
113     public final static String FN_ZIPALIGN = (CURRENT_PLATFORM == PLATFORM_WINDOWS) ?
114             "zipalign.exe" : "zipalign"; //$NON-NLS-1$ //$NON-NLS-2$
115 
116     /* Folder Names for Android Projects . */
117 
118     /** Resources folder name, i.e. "res". */
119     public final static String FD_RESOURCES = "res"; //$NON-NLS-1$
120     /** Assets folder name, i.e. "assets" */
121     public final static String FD_ASSETS = "assets"; //$NON-NLS-1$
122     /** Default source folder name, i.e. "src" */
123     public final static String FD_SOURCES = "src"; //$NON-NLS-1$
124     /** Default generated source folder name, i.e. "gen" */
125     public final static String FD_GEN_SOURCES = "gen"; //$NON-NLS-1$
126     /** Default native library folder name inside the project, i.e. "libs"
127      * While the folder inside the .apk is "lib", we call that one libs because
128      * that's what we use in ant for both .jar and .so and we need to make the 2 development ways
129      * compatible. */
130     public final static String FD_NATIVE_LIBS = "libs"; //$NON-NLS-1$
131     /** Native lib folder inside the APK: "lib" */
132     public final static String FD_APK_NATIVE_LIBS = "lib"; //$NON-NLS-1$
133     /** Default output folder name, i.e. "bin" */
134     public final static String FD_OUTPUT = "bin"; //$NON-NLS-1$
135     /** Default anim resource folder name, i.e. "anim" */
136     public final static String FD_ANIM = "anim"; //$NON-NLS-1$
137     /** Default color resource folder name, i.e. "color" */
138     public final static String FD_COLOR = "color"; //$NON-NLS-1$
139     /** Default drawable resource folder name, i.e. "drawable" */
140     public final static String FD_DRAWABLE = "drawable"; //$NON-NLS-1$
141     /** Default layout resource folder name, i.e. "layout" */
142     public final static String FD_LAYOUT = "layout"; //$NON-NLS-1$
143     /** Default menu resource folder name, i.e. "menu" */
144     public final static String FD_MENU = "menu"; //$NON-NLS-1$
145     /** Default values resource folder name, i.e. "values" */
146     public final static String FD_VALUES = "values"; //$NON-NLS-1$
147     /** Default xml resource folder name, i.e. "xml" */
148     public final static String FD_XML = "xml"; //$NON-NLS-1$
149     /** Default raw resource folder name, i.e. "raw" */
150     public final static String FD_RAW = "raw"; //$NON-NLS-1$
151 
152     /* Folder Names for the Android SDK */
153 
154     /** Name of the SDK platforms folder. */
155     public final static String FD_PLATFORMS = "platforms";
156     /** Name of the SDK addons folder. */
157     public final static String FD_ADDONS = "add-ons";
158     /** Name of the SDK tools folder. */
159     public final static String FD_TOOLS = "tools";
160     /** Name of the SDK tools/lib folder. */
161     public final static String FD_LIB = "lib";
162     /** Name of the SDK docs folder. */
163     public final static String FD_DOCS = "docs";
164     /** Name of the doc folder containing API reference doc (javadoc) */
165     public static final String FD_DOCS_REFERENCE = "reference";
166     /** Name of the SDK images folder. */
167     public final static String FD_IMAGES = "images";
168     /** Name of the SDK skins folder. */
169     public final static String FD_SKINS = "skins";
170     /** Name of the SDK samples folder. */
171     public final static String FD_SAMPLES = "samples";
172     /** Name of the SDK templates folder, i.e. "templates" */
173     public final static String FD_TEMPLATES = "templates";
174     /** Name of the SDK data folder, i.e. "data" */
175     public final static String FD_DATA = "data";
176     /** Name of the SDK resources folder, i.e. "res" */
177     public final static String FD_RES = "res";
178     /** Name of the SDK font folder, i.e. "fonts" */
179     public final static String FD_FONTS = "fonts";
180     /** Name of the android sources directory */
181     public static final String FD_ANDROID_SOURCES = "sources";
182     /** Name of the addon libs folder. */
183     public final static String FD_ADDON_LIBS = "libs";
184 
185     /** Namespace for the resource XML, i.e. "http://schemas.android.com/apk/res/android" */
186     public final static String NS_RESOURCES = "http://schemas.android.com/apk/res/android";
187 
188     /** The name of the uses-library that provides "android.test.runner" */
189     public final static String ANDROID_TEST_RUNNER_LIB = "android.test.runner";
190 
191     /* Folder path relative to the SDK root */
192     /** Path of the documentation directory relative to the sdk folder.
193      *  This is an OS path, ending with a separator. */
194     public final static String OS_SDK_DOCS_FOLDER = FD_DOCS + File.separator;
195 
196     /** Path of the tools directory relative to the sdk folder, or to a platform folder.
197      *  This is an OS path, ending with a separator. */
198     public final static String OS_SDK_TOOLS_FOLDER = FD_TOOLS + File.separator;
199 
200     /** Path of the lib directory relative to the sdk folder, or to a platform folder.
201      *  This is an OS path, ending with a separator. */
202     public final static String OS_SDK_TOOLS_LIB_FOLDER =
203             OS_SDK_TOOLS_FOLDER + FD_LIB + File.separator;
204 
205     /* Folder paths relative to a platform or add-on folder */
206 
207     /** Path of the images directory relative to a platform or addon folder.
208      *  This is an OS path, ending with a separator. */
209     public final static String OS_IMAGES_FOLDER = FD_IMAGES + File.separator;
210 
211     /** Path of the skin directory relative to a platform or addon folder.
212      *  This is an OS path, ending with a separator. */
213     public final static String OS_SKINS_FOLDER = FD_SKINS + File.separator;
214 
215     /* Folder paths relative to a Platform folder */
216 
217     /** Path of the data directory relative to a platform folder.
218      *  This is an OS path, ending with a separator. */
219     public final static String OS_PLATFORM_DATA_FOLDER = FD_DATA + File.separator;
220 
221     /** Path of the samples directory relative to a platform folder.
222      *  This is an OS path, ending with a separator. */
223     public final static String OS_PLATFORM_SAMPLES_FOLDER = FD_SAMPLES + File.separator;
224 
225     /** Path of the resources directory relative to a platform folder.
226      *  This is an OS path, ending with a separator. */
227     public final static String OS_PLATFORM_RESOURCES_FOLDER =
228             OS_PLATFORM_DATA_FOLDER + FD_RES + File.separator;
229 
230     /** Path of the fonts directory relative to a platform folder.
231      *  This is an OS path, ending with a separator. */
232     public final static String OS_PLATFORM_FONTS_FOLDER =
233             OS_PLATFORM_DATA_FOLDER + FD_FONTS + File.separator;
234 
235     /** Path of the android source directory relative to a platform folder.
236      *  This is an OS path, ending with a separator. */
237     public final static String OS_PLATFORM_SOURCES_FOLDER = FD_ANDROID_SOURCES + File.separator;
238 
239     /** Path of the android templates directory relative to a platform folder.
240      *  This is an OS path, ending with a separator. */
241     public final static String OS_PLATFORM_TEMPLATES_FOLDER = FD_TEMPLATES + File.separator;
242 
243     /** Path of the attrs.xml file relative to a platform folder. */
244     public final static String OS_PLATFORM_ATTRS_XML =
245             OS_PLATFORM_RESOURCES_FOLDER + FD_VALUES + File.separator + FN_ATTRS_XML;
246 
247     /** Path of the attrs_manifest.xml file relative to a platform folder. */
248     public final static String OS_PLATFORM_ATTRS_MANIFEST_XML =
249             OS_PLATFORM_RESOURCES_FOLDER + FD_VALUES + File.separator + FN_ATTRS_MANIFEST_XML;
250 
251     /** Path of the layoutlib.jar file relative to a platform folder. */
252     public final static String OS_PLATFORM_LAYOUTLIB_JAR =
253             OS_PLATFORM_DATA_FOLDER + FN_LAYOUTLIB_JAR;
254 
255     /* Folder paths relative to a addon folder */
256 
257     /** Path of the images directory relative to a folder folder.
258      *  This is an OS path, ending with a separator. */
259     public final static String OS_ADDON_LIBS_FOLDER = FD_ADDON_LIBS + File.separator;
260 
261 
262     /** Skin default **/
263     public final static String SKIN_DEFAULT = "default";
264 
265     /** Returns the appropriate name for the 'android' command, which is 'android.bat' for
266      * Windows and 'android' for all other platforms. */
androidCmdName()267     public static String androidCmdName() {
268         String os = System.getProperty("os.name");
269         String cmd = "android";
270         if (os.startsWith("Windows")) {
271             cmd += ".bat";
272         }
273         return cmd;
274     }
275 
276     /** Returns the appropriate name for the 'mksdcard' command, which is 'mksdcard.exe' for
277      * Windows and 'mkdsdcard' for all other platforms. */
mkSdCardCmdName()278     public static String mkSdCardCmdName() {
279         String os = System.getProperty("os.name");
280         String cmd = "mksdcard";
281         if (os.startsWith("Windows")) {
282             cmd += ".exe";
283         }
284         return cmd;
285     }
286 
287     /**
288      * Returns current platform
289      *
290      * @return one of {@link #PLATFORM_WINDOWS}, {@link #PLATFORM_DARWIN},
291      * {@link #PLATFORM_LINUX} or {@link #PLATFORM_UNKNOWN}.
292      */
currentPlatform()293     public static int currentPlatform() {
294         String os = System.getProperty("os.name");          //$NON-NLS-1$
295         if (os.startsWith("Mac OS")) {                      //$NON-NLS-1$
296             return PLATFORM_DARWIN;
297         } else if (os.startsWith("Windows")) {              //$NON-NLS-1$
298             return PLATFORM_WINDOWS;
299         } else if (os.startsWith("Linux")) {                //$NON-NLS-1$
300             return PLATFORM_LINUX;
301         }
302 
303         return PLATFORM_UNKNOWN;
304     }
305 }
306