-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop'
- Loading branch information
Showing
34 changed files
with
448 additions
and
24 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
Binary file not shown.
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
55 changes: 55 additions & 0 deletions
55
MeteoriteLibrary/src/main/java/com/firelotus/meteoritelibrary/utils/CleanLeakUtils.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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.firelotus.meteoritelibrary.utils; | ||
|
||
import android.content.Context; | ||
import android.view.inputmethod.InputMethodManager; | ||
|
||
import java.lang.reflect.Field; | ||
|
||
/** | ||
* InputMethodManager内存泄露现象及解决 | ||
*/ | ||
public class CleanLeakUtils { | ||
public static void fixInputMethodManagerLeak(Context context) { | ||
if (context == null) { | ||
return; | ||
} | ||
try { | ||
// 对 mCurRootView mServedView mNextServedView 进行置空... | ||
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); | ||
if (imm == null) { | ||
return; | ||
}// author:sodino mail:[email protected] | ||
|
||
Object obj_get = null; | ||
Field f_mCurRootView = imm.getClass().getDeclaredField("mCurRootView"); | ||
Field f_mServedView = imm.getClass().getDeclaredField("mServedView"); | ||
Field f_mNextServedView = imm.getClass().getDeclaredField("mNextServedView"); | ||
|
||
if (f_mCurRootView.isAccessible() == false) { | ||
f_mCurRootView.setAccessible(true); | ||
} | ||
obj_get = f_mCurRootView.get(imm); | ||
if (obj_get != null) { // 不为null则置为空 | ||
f_mCurRootView.set(imm, null); | ||
} | ||
|
||
if (f_mServedView.isAccessible() == false) { | ||
f_mServedView.setAccessible(true); | ||
} | ||
obj_get = f_mServedView.get(imm); | ||
if (obj_get != null) { // 不为null则置为空 | ||
f_mServedView.set(imm, null); | ||
} | ||
|
||
if (f_mNextServedView.isAccessible() == false) { | ||
f_mNextServedView.setAccessible(true); | ||
} | ||
obj_get = f_mNextServedView.get(imm); | ||
if (obj_get != null) { // 不为null则置为空 | ||
f_mNextServedView.set(imm, null); | ||
} | ||
} catch (Throwable t) { | ||
t.printStackTrace(); | ||
} | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
MeteoriteLibrary/src/main/java/com/firelotus/meteoritelibrary/utils/Tls12SocketFactory.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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.firelotus.meteoritelibrary.utils; | ||
|
||
import java.io.IOException; | ||
import java.net.InetAddress; | ||
import java.net.Socket; | ||
|
||
import javax.net.ssl.SSLSocket; | ||
import javax.net.ssl.SSLSocketFactory; | ||
|
||
/** | ||
* 解决Android4.x系统访问网络时可能出现TLS版本不支持异常报错的问题。 | ||
* https://blog.csdn.net/s003603u/article/details/53907910 | ||
* Android4.x系统对TLS的支持存在版本差异, | ||
* TLSv1.0从API 1+就被默认打开 | ||
* TLSv1.1和TLSv1.2只有在API 20+ 才会被默认打开 | ||
* 也就是说低于API 20+的版本是默认关闭对TLSv1.1和TLSv1.2的支持,若要支持则必须自己打开 | ||
*/ | ||
public class Tls12SocketFactory extends SSLSocketFactory { | ||
private static final String[] TLS_SUPPORT_VERSION = {"TLSv1.1", "TLSv1.2"}; | ||
|
||
final SSLSocketFactory delegate; | ||
|
||
public Tls12SocketFactory(SSLSocketFactory base) { | ||
this.delegate = base; | ||
} | ||
|
||
@Override | ||
public String[] getDefaultCipherSuites() { | ||
return delegate.getDefaultCipherSuites(); | ||
} | ||
|
||
@Override | ||
public String[] getSupportedCipherSuites() { | ||
return delegate.getSupportedCipherSuites(); | ||
} | ||
|
||
@Override | ||
public Socket createSocket(Socket s, String host, int port, boolean autoClose) throws IOException { | ||
return patch(delegate.createSocket(s, host, port, autoClose)); | ||
} | ||
|
||
@Override | ||
public Socket createSocket(String host, int port) throws IOException { | ||
return patch(delegate.createSocket(host, port)); | ||
} | ||
|
||
@Override | ||
public Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException { | ||
return patch(delegate.createSocket(host, port, localHost, localPort)); | ||
} | ||
|
||
@Override | ||
public Socket createSocket(InetAddress host, int port) throws IOException { | ||
return patch(delegate.createSocket(host, port)); | ||
} | ||
|
||
@Override | ||
public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException { | ||
return patch(delegate.createSocket(address, port, localAddress, localPort)); | ||
} | ||
|
||
private Socket patch(Socket s) { | ||
if (s instanceof SSLSocket) { | ||
((SSLSocket) s).setEnabledProtocols(TLS_SUPPORT_VERSION); | ||
} | ||
return s; | ||
} | ||
} |
Oops, something went wrong.