• 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     /** Dex filename inside the APK. i.e. "classes.dex" */
52     public final static String FN_APK_CLASSES_DEX = "classes.dex"; //$NON-NLS-1$
53 
54     /** An SDK Project's build.xml file */
55     public final static String FN_BUILD_XML = "build.xml";
56 
57     /** Name of the framework library, i.e. "android.jar" */
58     public static final String FN_FRAMEWORK_LIBRARY = "android.jar";
59     /** Name of the layout attributes, i.e. "attrs.xml" */
60     public static final String FN_ATTRS_XML = "attrs.xml";
61     /** Name of the layout attributes, i.e. "attrs_manifest.xml" */
62     public static final String FN_ATTRS_MANIFEST_XML = "attrs_manifest.xml";
63     /** framework aidl import file */
64     public static final String FN_FRAMEWORK_AIDL = "framework.aidl";
65     /** layoutlib.jar file */
66     public static final String FN_LAYOUTLIB_JAR = "layoutlib.jar";
67     /** widget list file */
68     public static final String FN_WIDGETS = "widgets.txt";
69     /** Intent activity actions list file */
70     public static final String FN_INTENT_ACTIONS_ACTIVITY = "activity_actions.txt";
71     /** Intent broadcast actions list file */
72     public static final String FN_INTENT_ACTIONS_BROADCAST = "broadcast_actions.txt";
73     /** Intent service actions list file */
74     public static final String FN_INTENT_ACTIONS_SERVICE = "service_actions.txt";
75     /** Intent category list file */
76     public static final String FN_INTENT_CATEGORIES = "categories.txt";
77 
78     /** platform build property file */
79     public final static String FN_BUILD_PROP = "build.prop";
80     /** plugin properties file */
81     public final static String FN_PLUGIN_PROP = "plugin.prop";
82     /** add-on manifest file */
83     public final static String FN_MANIFEST_INI = "manifest.ini";
84     /** add-on layout device XML file. */
85     public final static String FN_DEVICES_XML = "devices.xml";
86     /** hardware properties definition file */
87     public final static String FN_HARDWARE_INI = "hardware-properties.ini";
88 
89     /** project default property file */
90     public final static String FN_DEFAULT_PROPERTIES = "default.properties";
91 
92     /** project export property file */
93     public final static String FN_EXPORT_PROPERTIES = "export.properties";
94 
95     /** project local property file */
96     public final static String FN_LOCAL_PROPERTIES = "local.properties";
97 
98     /** project build property file */
99     public final static String FN_BUILD_PROPERTIES = "build.properties";
100 
101     /** Skin layout file */
102     public final static String FN_SKIN_LAYOUT = "layout";//$NON-NLS-1$
103 
104     /** dex.jar file */
105     public static final String FN_DX_JAR = "dx.jar"; //$NON-NLS-1$
106 
107     /** dx executable (with extension for the current OS)  */
108     public final static String FN_DX = (CURRENT_PLATFORM == PLATFORM_WINDOWS) ?
109             "dx.bat" : "dx"; //$NON-NLS-1$ //$NON-NLS-2$
110 
111     /** aapt executable (with extension for the current OS)  */
112     public final static String FN_AAPT = (CURRENT_PLATFORM == PLATFORM_WINDOWS) ?
113             "aapt.exe" : "aapt"; //$NON-NLS-1$ //$NON-NLS-2$
114 
115     /** aidl executable (with extension for the current OS)  */
116     public final static String FN_AIDL = (CURRENT_PLATFORM == PLATFORM_WINDOWS) ?
117             "aidl.exe" : "aidl"; //$NON-NLS-1$ //$NON-NLS-2$
118 
119     /** adb executable (with extension for the current OS)  */
120     public final static String FN_ADB = (CURRENT_PLATFORM == PLATFORM_WINDOWS) ?
121             "adb.exe" : "adb"; //$NON-NLS-1$ //$NON-NLS-2$
122 
123     /** emulator executable (with extension for the current OS) */
124     public final static String FN_EMULATOR = (CURRENT_PLATFORM == PLATFORM_WINDOWS) ?
125             "emulator.exe" : "emulator"; //$NON-NLS-1$ //$NON-NLS-2$
126 
127     /** zipalign executable (with extension for the current OS)  */
128     public final static String FN_ZIPALIGN = (CURRENT_PLATFORM == PLATFORM_WINDOWS) ?
129             "zipalign.exe" : "zipalign"; //$NON-NLS-1$ //$NON-NLS-2$
130 
131     /** properties file for SDK Updater packages */
132     public final static String FN_SOURCE_PROP = "source.properties"; //$NON-NLS-1$
133     /** properties file for content hash of installed packages */
134     public final static String FN_CONTENT_HASH_PROP = "content_hash.properties"; //$NON-NLS-1$
135     /** properties file for the SDK */
136     public final static String FN_SDK_PROP = "sdk.properties"; //$NON-NLS-1$
137 
138     /**
139      * filename for gdbserver.
140      */
141     public final static String FN_GDBSERVER = "gdbserver";
142 
143     /* Folder Names for Android Projects . */
144 
145     /** Resources folder name, i.e. "res". */
146     public final static String FD_RESOURCES = "res"; //$NON-NLS-1$
147     /** Assets folder name, i.e. "assets" */
148     public final static String FD_ASSETS = "assets"; //$NON-NLS-1$
149     /** Default source folder name, i.e. "src" */
150     public final static String FD_SOURCES = "src"; //$NON-NLS-1$
151     /** Default generated source folder name, i.e. "gen" */
152     public final static String FD_GEN_SOURCES = "gen"; //$NON-NLS-1$
153     /** Default native library folder name inside the project, i.e. "libs"
154      * While the folder inside the .apk is "lib", we call that one libs because
155      * that's what we use in ant for both .jar and .so and we need to make the 2 development ways
156      * compatible. */
157     public final static String FD_NATIVE_LIBS = "libs"; //$NON-NLS-1$
158     /** Native lib folder inside the APK: "lib" */
159     public final static String FD_APK_NATIVE_LIBS = "lib"; //$NON-NLS-1$
160     /** Default output folder name, i.e. "bin" */
161     public final static String FD_OUTPUT = "bin"; //$NON-NLS-1$
162     /** Default anim resource folder name, i.e. "anim" */
163     public final static String FD_ANIM = "anim"; //$NON-NLS-1$
164     /** Default color resource folder name, i.e. "color" */
165     public final static String FD_COLOR = "color"; //$NON-NLS-1$
166     /** Default drawable resource folder name, i.e. "drawable" */
167     public final static String FD_DRAWABLE = "drawable"; //$NON-NLS-1$
168     /** Default layout resource folder name, i.e. "layout" */
169     public final static String FD_LAYOUT = "layout"; //$NON-NLS-1$
170     /** Default menu resource folder name, i.e. "menu" */
171     public final static String FD_MENU = "menu"; //$NON-NLS-1$
172     /** Default values resource folder name, i.e. "values" */
173     public final static String FD_VALUES = "values"; //$NON-NLS-1$
174     /** Default xml resource folder name, i.e. "xml" */
175     public final static String FD_XML = "xml"; //$NON-NLS-1$
176     /** Default raw resource folder name, i.e. "raw" */
177     public final static String FD_RAW = "raw"; //$NON-NLS-1$
178 
179     /* Folder Names for the Android SDK */
180 
181     /** Name of the SDK platforms folder. */
182     public final static String FD_PLATFORMS = "platforms";
183     /** Name of the SDK addons folder. */
184     public final static String FD_ADDONS = "add-ons";
185     /** Name of the SDK tools folder. */
186     public final static String FD_TOOLS = "tools";
187     /** Name of the SDK tools/lib folder. */
188     public final static String FD_LIB = "lib";
189     /** Name of the SDK docs folder. */
190     public final static String FD_DOCS = "docs";
191     /** Name of the doc folder containing API reference doc (javadoc) */
192     public static final String FD_DOCS_REFERENCE = "reference";
193     /** Name of the SDK images folder. */
194     public final static String FD_IMAGES = "images";
195     /** Name of the SDK skins folder. */
196     public final static String FD_SKINS = "skins";
197     /** Name of the SDK samples folder. */
198     public final static String FD_SAMPLES = "samples";
199     /** Name of the SDK templates folder, i.e. "templates" */
200     public final static String FD_TEMPLATES = "templates";
201     /** Name of the SDK Ant folder, i.e. "ant" */
202     public final static String FD_ANT = "ant";
203     /** Name of the SDK data folder, i.e. "data" */
204     public final static String FD_DATA = "data";
205     /** Name of the SDK resources folder, i.e. "res" */
206     public final static String FD_RES = "res";
207     /** Name of the SDK font folder, i.e. "fonts" */
208     public final static String FD_FONTS = "fonts";
209     /** Name of the android sources directory */
210     public static final String FD_ANDROID_SOURCES = "sources";
211     /** Name of the addon libs folder. */
212     public final static String FD_ADDON_LIBS = "libs";
213 
214     /** Namespace for the resource XML, i.e. "http://schemas.android.com/apk/res/android" */
215     public final static String NS_RESOURCES = "http://schemas.android.com/apk/res/android";
216 
217     /** The name of the uses-library that provides "android.test.runner" */
218     public final static String ANDROID_TEST_RUNNER_LIB = "android.test.runner";
219 
220     /* Folder path relative to the SDK root */
221     /** Path of the documentation directory relative to the sdk folder.
222      *  This is an OS path, ending with a separator. */
223     public final static String OS_SDK_DOCS_FOLDER = FD_DOCS + File.separator;
224 
225     /** Path of the tools directory relative to the sdk folder, or to a platform folder.
226      *  This is an OS path, ending with a separator. */
227     public final static String OS_SDK_TOOLS_FOLDER = FD_TOOLS + File.separator;
228 
229     /** Path of the lib directory relative to the sdk folder, or to a platform folder.
230      *  This is an OS path, ending with a separator. */
231     public final static String OS_SDK_TOOLS_LIB_FOLDER =
232             OS_SDK_TOOLS_FOLDER + FD_LIB + File.separator;
233 
234     /* Folder paths relative to a platform or add-on folder */
235 
236     /** Path of the images directory relative to a platform or addon folder.
237      *  This is an OS path, ending with a separator. */
238     public final static String OS_IMAGES_FOLDER = FD_IMAGES + File.separator;
239 
240     /** Path of the skin directory relative to a platform or addon folder.
241      *  This is an OS path, ending with a separator. */
242     public final static String OS_SKINS_FOLDER = FD_SKINS + File.separator;
243 
244     /* Folder paths relative to a Platform folder */
245 
246     /** Path of the data directory relative to a platform folder.
247      *  This is an OS path, ending with a separator. */
248     public final static String OS_PLATFORM_DATA_FOLDER = FD_DATA + File.separator;
249 
250     /** Path of the samples directory relative to a platform folder.
251      *  This is an OS path, ending with a separator. */
252     public final static String OS_PLATFORM_SAMPLES_FOLDER = FD_SAMPLES + File.separator;
253 
254     /** Path of the resources directory relative to a platform folder.
255      *  This is an OS path, ending with a separator. */
256     public final static String OS_PLATFORM_RESOURCES_FOLDER =
257             OS_PLATFORM_DATA_FOLDER + FD_RES + File.separator;
258 
259     /** Path of the fonts directory relative to a platform folder.
260      *  This is an OS path, ending with a separator. */
261     public final static String OS_PLATFORM_FONTS_FOLDER =
262             OS_PLATFORM_DATA_FOLDER + FD_FONTS + File.separator;
263 
264     /** Path of the android source directory relative to a platform folder.
265      *  This is an OS path, ending with a separator. */
266     public final static String OS_PLATFORM_SOURCES_FOLDER = FD_ANDROID_SOURCES + File.separator;
267 
268     /** Path of the android templates directory relative to a platform folder.
269      *  This is an OS path, ending with a separator. */
270     public final static String OS_PLATFORM_TEMPLATES_FOLDER = FD_TEMPLATES + File.separator;
271 
272     /** Path of the Ant build rules directory relative to a platform folder.
273      *  This is an OS path, ending with a separator. */
274     public final static String OS_PLATFORM_ANT_FOLDER = FD_ANT + File.separator;
275 
276     /** Path of the attrs.xml file relative to a platform folder. */
277     public final static String OS_PLATFORM_ATTRS_XML =
278             OS_PLATFORM_RESOURCES_FOLDER + FD_VALUES + File.separator + FN_ATTRS_XML;
279 
280     /** Path of the attrs_manifest.xml file relative to a platform folder. */
281     public final static String OS_PLATFORM_ATTRS_MANIFEST_XML =
282             OS_PLATFORM_RESOURCES_FOLDER + FD_VALUES + File.separator + FN_ATTRS_MANIFEST_XML;
283 
284     /** Path of the layoutlib.jar file relative to a platform folder. */
285     public final static String OS_PLATFORM_LAYOUTLIB_JAR =
286             OS_PLATFORM_DATA_FOLDER + FN_LAYOUTLIB_JAR;
287 
288     /* Folder paths relative to a addon folder */
289 
290     /** Path of the images directory relative to a folder folder.
291      *  This is an OS path, ending with a separator. */
292     public final static String OS_ADDON_LIBS_FOLDER = FD_ADDON_LIBS + File.separator;
293 
294     /** Skin default **/
295     public final static String SKIN_DEFAULT = "default";
296 
297     /** SDK property: support for library */
298     public final static String PROP_SDK_SUPPORT_LIBRARY = "sdk.build.support.library"; //$NON-NLS-1$
299     /** SDK property: ant build revision */
300     public final static String PROP_SDK_ANT_BUILD_REVISION = "sdk.ant.build.revision"; //$NON-NLS-1$
301     /** SDK property: ant templates revision */
302     public final static String PROP_SDK_ANT_TEMPLATES_REVISION = "sdk.ant.templates.revision"; //$NON-NLS-1$
303 
304 
305     /* Android Class Constants */
306     public final static String CLASS_ACTIVITY = "android.app.Activity"; //$NON-NLS-1$
307     public final static String CLASS_SERVICE = "android.app.Service"; //$NON-NLS-1$
308     public final static String CLASS_BROADCASTRECEIVER = "android.content.BroadcastReceiver"; //$NON-NLS-1$
309     public final static String CLASS_CONTENTPROVIDER = "android.content.ContentProvider"; //$NON-NLS-1$
310     public final static String CLASS_INSTRUMENTATION = "android.app.Instrumentation"; //$NON-NLS-1$
311     public final static String CLASS_INSTRUMENTATION_RUNNER =
312         "android.test.InstrumentationTestRunner"; //$NON-NLS-1$
313     public final static String CLASS_BUNDLE = "android.os.Bundle"; //$NON-NLS-1$
314     public final static String CLASS_R = "android.R"; //$NON-NLS-1$
315     public final static String CLASS_MANIFEST_PERMISSION = "android.Manifest$permission"; //$NON-NLS-1$
316     public final static String CLASS_INTENT = "android.content.Intent"; //$NON-NLS-1$
317     public final static String CLASS_CONTEXT = "android.content.Context"; //$NON-NLS-1$
318     public final static String CLASS_VIEW = "android.view.View"; //$NON-NLS-1$
319     public final static String CLASS_VIEWGROUP = "android.view.ViewGroup"; //$NON-NLS-1$
320     public final static String CLASS_NAME_LAYOUTPARAMS = "LayoutParams"; //$NON-NLS-1$
321     public final static String CLASS_VIEWGROUP_LAYOUTPARAMS =
322         CLASS_VIEWGROUP + "$" + CLASS_NAME_LAYOUTPARAMS; //$NON-NLS-1$
323     public final static String CLASS_NAME_FRAMELAYOUT = "FrameLayout"; //$NON-NLS-1$
324     public final static String CLASS_FRAMELAYOUT =
325         "android.widget." + CLASS_NAME_FRAMELAYOUT; //$NON-NLS-1$
326     public final static String CLASS_PREFERENCE = "android.preference.Preference"; //$NON-NLS-1$
327     public final static String CLASS_NAME_PREFERENCE_SCREEN = "PreferenceScreen"; //$NON-NLS-1$
328     public final static String CLASS_PREFERENCES =
329         "android.preference." + CLASS_NAME_PREFERENCE_SCREEN; //$NON-NLS-1$
330     public final static String CLASS_PREFERENCEGROUP = "android.preference.PreferenceGroup"; //$NON-NLS-1$
331     public final static String CLASS_PARCELABLE = "android.os.Parcelable"; //$NON-NLS-1$
332 
333 
334 
335     /** Returns the appropriate name for the 'android' command, which is 'android.bat' for
336      * Windows and 'android' for all other platforms. */
androidCmdName()337     public static String androidCmdName() {
338         String os = System.getProperty("os.name");
339         String cmd = "android";
340         if (os.startsWith("Windows")) {
341             cmd += ".bat";
342         }
343         return cmd;
344     }
345 
346     /** Returns the appropriate name for the 'mksdcard' command, which is 'mksdcard.exe' for
347      * Windows and 'mkdsdcard' for all other platforms. */
mkSdCardCmdName()348     public static String mkSdCardCmdName() {
349         String os = System.getProperty("os.name");
350         String cmd = "mksdcard";
351         if (os.startsWith("Windows")) {
352             cmd += ".exe";
353         }
354         return cmd;
355     }
356 
357     /**
358      * Returns current platform
359      *
360      * @return one of {@link #PLATFORM_WINDOWS}, {@link #PLATFORM_DARWIN},
361      * {@link #PLATFORM_LINUX} or {@link #PLATFORM_UNKNOWN}.
362      */
currentPlatform()363     public static int currentPlatform() {
364         String os = System.getProperty("os.name");          //$NON-NLS-1$
365         if (os.startsWith("Mac OS")) {                      //$NON-NLS-1$
366             return PLATFORM_DARWIN;
367         } else if (os.startsWith("Windows")) {              //$NON-NLS-1$
368             return PLATFORM_WINDOWS;
369         } else if (os.startsWith("Linux")) {                //$NON-NLS-1$
370             return PLATFORM_LINUX;
371         }
372 
373         return PLATFORM_UNKNOWN;
374     }
375 }
376