Skip to content

Commit 39edebd

Browse files
committed
see 01/21 log
1 parent cb6283c commit 39edebd

File tree

4 files changed

+25
-23
lines changed

4 files changed

+25
-23
lines changed

subutil/lib/src/main/java/com/blankj/subutil/util/HttpsUtil renamed to subutil/lib/src/main/java/com/blankj/subutil/util/HttpsUtil.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
public class HttpsUtil {
1414

1515
private static final int CONNECT_TIMEOUT_TIME = 15000;
16-
private static final int READ_TIMEOUT_TIME = 19000;
16+
private static final int READ_TIMEOUT_TIME = 19000;
1717

1818
/**
1919
* POST + JSON
2020
*
2121
* @param data send data
22-
* @param url target url
22+
* @param url target url
2323
* @return data receive from server
2424
* @author MilkZS
2525
*/
@@ -31,7 +31,7 @@ public static String postJson(String data, String url) {
3131
* POST + FORM
3232
*
3333
* @param data send data
34-
* @param url target url
34+
* @param url target url
3535
* @return data receive from serv
3636
* @author MilkZS
3737
*/
@@ -43,7 +43,7 @@ public static String postForm(String data, String url) {
4343
* GET + JSON
4444
*
4545
* @param data send data
46-
* @param url target url
46+
* @param url target url
4747
* @return data receive from server
4848
* @author MilkZS
4949
*/
@@ -55,7 +55,7 @@ public static String getJson(String data, String url) {
5555
* GET + FORM
5656
*
5757
* @param data send data
58-
* @param url target url
58+
* @param url target url
5959
* @return data receive from server
6060
* @author MilkZS
6161
*/

utilcode/lib/src/main/java/com/blankj/utilcode/util/ColorUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public static int getRandomColor() {
201201
* @return the random color
202202
*/
203203
public static int getRandomColor(final boolean supportAlpha) {
204-
int high = supportAlpha ? (int) (Math.random() * 0xFF) << 24 : 0xFF000000;
205-
return high | (int) (Math.random() * 0xFFFFFF);
204+
int high = supportAlpha ? (int) (Math.random() * 0x100) << 24 : 0xFF000000;
205+
return high | (int) (Math.random() * 0x1000000);
206206
}
207207
}

utilcode/lib/src/main/java/com/blankj/utilcode/util/DeviceUtils.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,15 @@ public static String getMacAddress() {
120120
*/
121121
@RequiresPermission(allOf = {ACCESS_WIFI_STATE, INTERNET})
122122
public static String getMacAddress(final String... excepts) {
123-
String macAddress = getMacAddressByWifiInfo();
123+
String macAddress = getMacAddressByNetworkInterface();
124124
if (isAddressNotInExcepts(macAddress, excepts)) {
125125
return macAddress;
126126
}
127-
macAddress = getMacAddressByNetworkInterface();
127+
macAddress = getMacAddressByInetAddress();
128128
if (isAddressNotInExcepts(macAddress, excepts)) {
129129
return macAddress;
130130
}
131-
macAddress = getMacAddressByInetAddress();
131+
macAddress = getMacAddressByWifiInfo();
132132
if (isAddressNotInExcepts(macAddress, excepts)) {
133133
return macAddress;
134134
}
@@ -151,12 +151,13 @@ private static boolean isAddressNotInExcepts(final String address, final String.
151151
return true;
152152
}
153153

154-
@SuppressLint({"HardwareIds", "MissingPermission", "WifiManagerLeak"})
154+
@SuppressLint({"MissingPermission", "HardwareIds"})
155155
private static String getMacAddressByWifiInfo() {
156156
try {
157-
WifiManager wifi = (WifiManager) Utils.getApp().getSystemService(Context.WIFI_SERVICE);
157+
final WifiManager wifi = (WifiManager) Utils.getApp()
158+
.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
158159
if (wifi != null) {
159-
WifiInfo info = wifi.getConnectionInfo();
160+
final WifiInfo info = wifi.getConnectionInfo();
160161
if (info != null) return info.getMacAddress();
161162
}
162163
} catch (Exception e) {

utilcode/lib/src/main/java/com/blankj/utilcode/util/UriUtils.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static File uri2File(@NonNull final Uri uri) {
6060
Log.d("UriUtils", uri.toString() + " parse failed. -> 0");
6161
return null;
6262
} else if (ContentResolver.SCHEME_CONTENT.equals(scheme)) {
63-
return getFileFromUri(uri);
63+
return getFileFromUri(uri, 1);
6464
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
6565
&& DocumentsContract.isDocumentUri(Utils.getApp(), uri)) {
6666
if ("com.android.externalstorage.documents".equals(authority)) {
@@ -78,7 +78,7 @@ public static File uri2File(@NonNull final Uri uri) {
7878
Uri.parse("content://downloads/public_downloads"),
7979
Long.valueOf(id)
8080
);
81-
return getFileFromUri(contentUri);
81+
return getFileFromUri(contentUri, 3);
8282
} else if ("com.android.providers.media.documents".equals(authority)) {
8383
final String docId = DocumentsContract.getDocumentId(uri);
8484
final String[] split = docId.split(":");
@@ -91,29 +91,30 @@ public static File uri2File(@NonNull final Uri uri) {
9191
} else if ("audio".equals(type)) {
9292
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
9393
} else {
94-
Log.d("UriUtils", uri.toString() + " parse failed. -> 3");
94+
Log.d("UriUtils", uri.toString() + " parse failed. -> 4");
9595
return null;
9696
}
9797
final String selection = "_id=?";
9898
final String[] selectionArgs = new String[]{split[1]};
99-
return getFileFromUri(contentUri, selection, selectionArgs);
99+
return getFileFromUri(contentUri, selection, selectionArgs, 5);
100100
} else {
101-
Log.d("UriUtils", uri.toString() + " parse failed. -> 4");
101+
Log.d("UriUtils", uri.toString() + " parse failed. -> 6");
102102
return null;
103103
}
104104
} else {
105-
Log.d("UriUtils", uri.toString() + " parse failed. -> 5");
105+
Log.d("UriUtils", uri.toString() + " parse failed. -> 7");
106106
return null;
107107
}
108108
}
109109

110-
private static File getFileFromUri(final Uri uri) {
111-
return getFileFromUri(uri, null, null);
110+
private static File getFileFromUri(final Uri uri, final int code) {
111+
return getFileFromUri(uri, null, null, code);
112112
}
113113

114114
private static File getFileFromUri(final Uri uri,
115115
final String selection,
116-
final String[] selectionArgs) {
116+
final String[] selectionArgs,
117+
final int code) {
117118
CursorLoader cl = new CursorLoader(Utils.getApp());
118119
cl.setUri(uri);
119120
cl.setProjection(new String[]{"_data"});
@@ -124,7 +125,7 @@ private static File getFileFromUri(final Uri uri,
124125
cursor.moveToFirst();
125126
return new File(cursor.getString(columnIndex));
126127
} catch (Exception e) {
127-
Log.d("UriUtils", uri.toString() + " parse failed. -> 1");
128+
Log.d("UriUtils", uri.toString() + " parse failed. -> " + code);
128129
return null;
129130
} finally {
130131
if (cursor != null) {

0 commit comments

Comments
 (0)