-
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
a9424f3
commit a71768f
Showing
9 changed files
with
77 additions
and
37 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
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
68 changes: 47 additions & 21 deletions
68
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,67 @@ | ||
package com.allenliu.versionchecklib.utils; | ||
|
||
import android.content.Context; | ||
import android.os.Environment; | ||
|
||
import java.io.File; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
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
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