提交 64c72c59 编写于 作者: B Blankj

see 04/16 log

上级 e51b1e2f
......@@ -41,7 +41,7 @@
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.13.10-brightgreen.svg
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.13.11-brightgreen.svg
[auc]: https://github.com/Blankj/AndroidUtilCode
[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg
......
......@@ -41,7 +41,7 @@ If this project helps you a lot and you want to support the project's developmen
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.13.10-brightgreen.svg
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.13.11-brightgreen.svg
[auc]: https://github.com/Blankj/AndroidUtilCode
[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg
......
......@@ -60,7 +60,7 @@ dependencies {
// LeakCanary
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakcanary_version"
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakcanary_version"
// implementation 'com.blankj:utilcode:1.13.10'
// implementation 'com.blankj:utilcode:1.13.11'
}
......@@ -33,8 +33,8 @@ ext {
min_sdk_version = 14
target_sdk_version = 27
version_code = 1_013_010
version_name = '1.13.10'// E.g 1.9.72 => 1,009,072
version_code = 1_013_011
version_name = '1.13.11'// E.g 1.9.72 => 1,009,072
// App dependencies
support_version = '27.1.0'
......
package com.blankj.subutil.util;
import android.os.Build;
import android.os.Environment;
import android.support.annotation.RequiresApi;
/**
* <pre>
* author: Blankj
* blog : http://blankj.com
* time : 2018/04/15
* desc : 路径相关工具类
* </pre>
*/
public class PathUtils {
private PathUtils() {
throw new UnsupportedOperationException("u can't instantiate me...");
}
/**
* 获取 Android 系统根目录
* <pre>path: /system</pre>
*
* @return 系统根目录
*/
public static String getRootPath() {
return Environment.getRootDirectory().getAbsolutePath();
}
/**
* 获取 data 目录
* <pre>path: /data</pre>
*
* @return data 目录
*/
public static String getDataPath() {
return Environment.getDataDirectory().getAbsolutePath();
}
/**
* 获取缓存目录
* <pre>path: data/cache</pre>
*
* @return 缓存目录
*/
public static String getIntDownloadCachePath() {
return Environment.getDownloadCacheDirectory().getAbsolutePath();
}
/**
* 获取此应用的缓存目录
* <pre>path: /data/data/package/cache</pre>
*
* @return 此应用的缓存目录
*/
public static String getAppIntCachePath() {
return Utils.getApp().getCacheDir().getAbsolutePath();
}
/**
* 获取此应用的文件目录
* <pre>path: /data/data/package/files</pre>
*
* @return 此应用的文件目录
*/
public static String getAppIntFilesPath() {
return Utils.getApp().getFilesDir().getAbsolutePath();
}
/**
* 获取此应用的数据库文件目录
* <pre>path: /data/data/package/databases/name</pre>
*
* @param name 数据库文件名
* @return 数据库文件目录
*/
public static String getAppIntDbPath(String name) {
return Utils.getApp().getDatabasePath(name).getAbsolutePath();
}
/**
* 获取 Android 外置储存的根目录
* <pre>path: /storage/emulated/0</pre>
*
* @return 外置储存根目录
*/
public static String getExtStoragePath() {
return Environment.getExternalStorageDirectory().getAbsolutePath();
}
/**
* 获取闹钟铃声目录
* <pre>path: /storage/emulated/0/Alarms</pre>
*
* @return 闹钟铃声目录
*/
public static String getExtAlarmsPath() {
return Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_ALARMS)
.getAbsolutePath();
}
/**
* 获取相机拍摄的照片和视频的目录
* <pre>path: /storage/emulated/0/DCIM</pre>
*
* @return 照片和视频目录
*/
public static String getExtDcimPath() {
return Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM)
.getAbsolutePath();
}
/**
* 获取文档目录
* <pre>path: /storage/emulated/0/Documents</pre>
*
* @return 文档目录
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
public static String getExtDocumentsPath() {
return Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS)
.getAbsolutePath();
}
/**
* 获取下载目录
* <pre>path: /storage/emulated/0/Download</pre>
*
* @return 下载目录
*/
public static String getExtDownloadsPath() {
return Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
.getAbsolutePath();
}
/**
* 获取视频目录
* <pre>path: /storage/emulated/0/Movies</pre>
*
* @return 视频目录
*/
public static String getExtMoviesPath() {
return Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES)
.getAbsolutePath();
}
/**
* 获取音乐目录
* <pre>path: /storage/emulated/0/Music</pre>
*
* @return 音乐目录
*/
public static String getExtMusicPath() {
return Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC)
.getAbsolutePath();
}
/**
* 获取提示音目录
* <pre>path: /storage/emulated/0/Notifications</pre>
*
* @return 提示音目录
*/
public static String getExtNotificationsPath() {
return Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_NOTIFICATIONS)
.getAbsolutePath();
}
/**
* 获取图片目录
* <pre>path: /storage/emulated/0/Pictures</pre>
*
* @return 图片目录
*/
public static String getExtPicturesPath() {
return Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
.getAbsolutePath();
}
/**
* 获取 Podcasts 目录
* <pre>path: /storage/emulated/0/Podcasts</pre>
*
* @return Podcasts 目录
*/
public static String getExtPodcastsPath() {
return Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_PODCASTS)
.getAbsolutePath();
}
/**
* 获取铃声目录
* <pre>path: /storage/emulated/0/Ringtones</pre>
*
* @return 下载目录
*/
public static String getExtRingtonesPath() {
return Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_RINGTONES)
.getAbsolutePath();
}
/**
* 获取此应用在外置储存中的缓存目录
* <pre>path: /storage/emulated/0/Android/data/package/cache</pre>
*
* @return 此应用在外置储存中的缓存目录
*/
public static String getAppExtCachePath() {
return Utils.getApp().getExternalCacheDir().getAbsolutePath();
}
/**
* 获取此应用在外置储存中的文件目录
* <pre>path: /storage/emulated/0/Android/data/package/files</pre>
*
* @return 此应用在外置储存中的文件目录
*/
public static String getAppExtFilePath() {
return Utils.getApp().getExternalFilesDir(null).getAbsolutePath();
}
/**
* 获取此应用在外置储存中的闹钟铃声目录
* <pre>path: /storage/emulated/0/Android/data/package/files/Alarms</pre>
*
* @return 此应用在外置储存中的闹钟铃声目录
*/
public static String getAppExtAlarmsPath() {
return Utils.getApp().getExternalFilesDir(Environment.DIRECTORY_ALARMS)
.getAbsolutePath();
}
/**
* 获取此应用在外置储存中的相机目录
* <pre>path: /storage/emulated/0/Android/data/package/files/DCIM</pre>
*
* @return 此应用在外置储存中的相机目录
*/
public static String getAppExtDcimPath() {
return Utils.getApp().getExternalFilesDir(Environment.DIRECTORY_DCIM)
.getAbsolutePath();
}
/**
* 获取此应用在外置储存中的文档目录
* <pre>path: /storage/emulated/0/Android/data/package/files/Documents</pre>
*
* @return 此应用在外置储存中的文档目录
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
public static String getAppExtDocumentsPath() {
return Utils.getApp().getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS)
.getAbsolutePath();
}
/**
* 获取此应用在外置储存中的闹钟目录
* <pre>path: /storage/emulated/0/Android/data/package/files/Download</pre>
*
* @return 此应用在外置储存中的闹钟目录
*/
public static String getAppExtDownloadPath() {
return Utils.getApp().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS)
.getAbsolutePath();
}
/**
* 获取此应用在外置储存中的视频目录
* <pre>path: /storage/emulated/0/Android/data/package/files/Movies</pre>
*
* @return 此应用在外置储存中的视频目录
*/
public static String getAppExtMoviesPath() {
return Utils.getApp().getExternalFilesDir(Environment.DIRECTORY_MOVIES)
.getAbsolutePath();
}
/**
* 获取此应用在外置储存中的音乐目录
* <pre>path: /storage/emulated/0/Android/data/package/files/Music</pre>
*
* @return 此应用在外置储存中的音乐目录
*/
public static String getAppExtMusicPath() {
return Utils.getApp().getExternalFilesDir(Environment.DIRECTORY_MUSIC)
.getAbsolutePath();
}
/**
* 获取此应用在外置储存中的提示音目录
* <pre>path: /storage/emulated/0/Android/data/package/files/Notifications</pre>
*
* @return 此应用在外置储存中的提示音目录
*/
public static String getAppExtNotificationsPath() {
return Utils.getApp().getExternalFilesDir(Environment.DIRECTORY_NOTIFICATIONS)
.getAbsolutePath();
}
/**
* 获取此应用在外置储存中的图片目录
* <pre>path: /storage/emulated/0/Android/data/package/files/Pictures</pre>
*
* @return 此应用在外置储存中的图片目录
*/
public static String getAppExtPicturesPath() {
return Utils.getApp().getExternalFilesDir(Environment.DIRECTORY_PICTURES)
.getAbsolutePath();
}
/**
* 获取此应用在外置储存中的 Podcasts 目录
* <pre>path: /storage/emulated/0/Android/data/package/files/Podcasts</pre>
*
* @return 此应用在外置储存中的 Podcasts 目录
*/
public static String getAppExtPodcastsPath() {
return Utils.getApp().getExternalFilesDir(Environment.DIRECTORY_PODCASTS)
.getAbsolutePath();
}
/**
* 获取此应用在外置储存中的铃声目录
* <pre>path: /storage/emulated/0/Android/data/package/files/Ringtones</pre>
*
* @return 此应用在外置储存中的铃声目录
*/
public static String getAppExtRingtonesPath() {
return Utils.getApp().getExternalFilesDir(Environment.DIRECTORY_RINGTONES)
.getAbsolutePath();
}
/**
* 获取此应用的 Obb 目录
* <pre>path: /storage/emulated/0/Android/obb/package</pre>
* <pre>一般用来存放游戏数据包</pre>
*
* @return 此应用的 Obb 目录
*/
public static String getObbPath() {
return Utils.getApp().getObbDir().getAbsolutePath();
}
}
......@@ -24,6 +24,5 @@ public class TestUtils {
@Test
public void test() throws Exception {
}
}
\ No newline at end of file
* 18/04/16 完善 AppUtils#installAppSilent 路径包含空格问题,发布 1.13.11 版本
* 18/04/10 完善 OnCrashListener 回调崩溃信息,发布 1.13.10 版本
* 18/04/09 修复静默安装重载错误,发布 1.13.9 版本
* 18/04/08 修复获取栈顶 Activity 链表为空的异常,获取栈顶 Activity 放到 Utils 中,发布 1.13.8 版本
......@@ -8,7 +9,7 @@
* 18/03/20 修复 PermissionUtils 子进程的问题,发布 1.13.5 版本
* 18/03/16 新增 gradle 插件来格式化 README
* 18/03/14 修复 KeyboardUtils#getContentViewInvisibleHeight,发布 1.13.4 版本
* 18/03/10 完善 Utils#installAppSilent 和 DeviceUtils#getMacAddress,发布 1.13.3 版本
* 18/03/10 完善 AppUtils#installAppSilent 和 DeviceUtils#getMacAddress,发布 1.13.3 版本
* 18/03/09 完善 ActivityUtils#getTopActivity
* 18/03/08 新增反射获取栈顶 Activity 的方法,发布 1.13.2 版本
* 18/03/07 修复 PermissionUtils 请求权限为 0 的 崩溃
......
......@@ -2,7 +2,7 @@
Gradle:
```groovy
compile 'com.blankj:utilcode:1.13.10'
implementation 'com.blankj:utilcode:1.13.11'
```
......
......@@ -2,7 +2,7 @@
Gradle:
```groovy
compile 'com.blankj:utilcode:1.13.10'
implementation 'com.blankj:utilcode:1.13.11'
```
......
......@@ -151,7 +151,7 @@ public final class AppUtils {
public static boolean installAppSilent(final File file, final String params) {
if (!isFileExists(file)) return false;
boolean isRoot = isDeviceRooted();
String filePath = file.getAbsolutePath();
String filePath = '"' + file.getAbsolutePath() + '"';
String command = "LD_LIBRARY_PATH=/vendor/lib*:/system/lib* pm install " +
(params == null ? "" : params + " ")
+ filePath;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册