| 1 |
/* |
| 2 |
* Copyright (C) 2015 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.tools.fd.runtime; |
| 18 |
|
| 19 |
import com.android.annotations.NonNull; |
| 20 |
|
| 21 |
/** |
| 22 |
* Shared path-related logic between Android Studio and the Instant Run server. |
| 23 |
*/ |
| 24 |
public final class Paths { |
| 25 |
/** Name of the dex folder in the app's data directory */ |
| 26 |
public static final String DEX_DIRECTORY_NAME = "dex"; |
| 27 |
|
| 28 |
/** Temp directory on the device */ |
| 29 |
public static final String DEVICE_TEMP_DIR = "/data/local/tmp"; |
| 30 |
|
| 31 |
/** The name of the build timestamp file on the device in the data folder */ |
| 32 |
public static final String BUILD_ID_TXT = "build-id.txt"; |
| 33 |
|
| 34 |
/** Name of file to write resource data into, if not extracting resources */ |
| 35 |
public static final String RESOURCE_FILE_NAME = "resources.ap_"; |
| 36 |
|
| 37 |
/** Name for reload dex files */ |
| 38 |
public static final String RELOAD_DEX_FILE_NAME = "classes.dex.3"; |
| 39 |
|
| 40 |
/** Prefix for dex shard files */ |
| 41 |
public static final String DEX_SLICE_PREFIX = "slice-"; |
| 42 |
|
| 43 |
@NonNull |
| 44 |
public static String getMainApkDataDirectory(@NonNull String applicationId) { |
| 45 |
return "/data/data/" + applicationId; |
| 46 |
} |
| 47 |
|
| 48 |
@NonNull |
| 49 |
public static String getDataDirectory(@NonNull String applicationId) { |
| 50 |
return "/data/data/" + applicationId + "/files/instant-run"; |
| 51 |
} |
| 52 |
|
| 53 |
@NonNull |
| 54 |
public static String getDexFileDirectory(@NonNull String applicationId) { |
| 55 |
return getDataDirectory(applicationId) + "/" + DEX_DIRECTORY_NAME; |
| 56 |
} |
| 57 |
|
| 58 |
@NonNull |
| 59 |
public static String getInboxDirectory(@NonNull String applicationId) { |
| 60 |
return getDataDirectory(applicationId) + "/inbox"; |
| 61 |
} |
| 62 |
|
| 63 |
@NonNull |
| 64 |
public static String getDeviceIdFolder(@NonNull String pkg) { |
| 65 |
return DEVICE_TEMP_DIR + "/" + pkg + "-" + BUILD_ID_TXT; |
| 66 |
} |
| 67 |
|
| 68 |
} |