-
Notifications
You must be signed in to change notification settings - Fork 488
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix request external storage permission error on android Q
fix okhttp ssl factory error on android q
- Loading branch information
1 parent
cd3389b
commit 88b1ce8
Showing
8 changed files
with
71 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,7 @@ allprojects { | |
task clean(type: Delete) { | ||
delete rootProject.buildDir | ||
} | ||
|
||
ext{ | ||
BUILD_VERSION=29 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 48 additions & 21 deletions
69
library/src/main/java/com/allenliu/versionchecklib/utils/FileHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,68 @@ | ||
package com.allenliu.versionchecklib.utils; | ||
|
||
import android.content.Context; | ||
import android.os.Environment; | ||
import android.support.annotation.NonNull; | ||
|
||
import java.io.File; | ||
|
||
|
||
|
||
public class FileHelper { | ||
@Deprecated | ||
public static String getDownloadApkCachePath() { | ||
|
||
String appCachePath = null; | ||
|
||
|
||
if (checkSDCard()) { | ||
|
||
appCachePath = Environment.getExternalStorageDirectory() + "/AllenVersionPath/"; | ||
} else { | ||
appCachePath = Environment.getDataDirectory().getPath() + "/AllenVersionPath/"; | ||
} | ||
File file = new File(appCachePath); | ||
if (!file.exists()) { | ||
file.mkdirs(); | ||
} | ||
return appCachePath; | ||
} | ||
|
||
public static String getDownloadApkCachePath() { | ||
public static String getDownloadApkCachePath(Context context) { | ||
String appCachePath; | ||
if (checkSDCard()) { | ||
appCachePath = context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath() + "/AllenVersionPath/"; | ||
|
||
String appCachePath = null; | ||
} else { | ||
appCachePath = context.getFilesDir().getAbsolutePath() + "/AllenVersionPath/"; | ||
|
||
} | ||
|
||
if (checkSDCard()) { | ||
appCachePath = Environment.getExternalStorageDirectory() + "/AllenVersionPath/" ; | ||
} else { | ||
appCachePath = Environment.getDataDirectory().getPath() + "/AllenVersionPath/" ; | ||
} | ||
File file = new File(appCachePath); | ||
if (!file.exists()) { | ||
file.mkdirs(); | ||
} | ||
return appCachePath; | ||
} | ||
|
||
File file = new File(appCachePath); | ||
if (!file.exists()) { | ||
file.mkdirs(); | ||
} | ||
return appCachePath; | ||
} | ||
|
||
|
||
/** | ||
* | ||
*/ | ||
public static boolean checkSDCard() { | ||
boolean sdCardExist = Environment.getExternalStorageState().equals( | ||
Environment.MEDIA_MOUNTED); | ||
/** | ||
* | ||
*/ | ||
private static boolean checkSDCard() { | ||
|
||
return sdCardExist; | ||
return Environment.getExternalStorageState().equals( | ||
Environment.MEDIA_MOUNTED); | ||
|
||
} | ||
} | ||
|
||
|
||
public static String dealDownloadPath(@NonNull String downloadAPKPath) { | ||
if (!downloadAPKPath.endsWith(File.separator)) { | ||
downloadAPKPath += File.separator; | ||
} | ||
return downloadAPKPath; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters