[core] Remove useless codes (#441)
This commit is contained in:
parent
a384697655
commit
caa1bef21f
|
|
@ -133,46 +133,26 @@ public:
|
||||||
return mLocalRef != nullptr;
|
return mLocalRef != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
operator bool() const {
|
||||||
|
return mLocalRef;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
JNIEnv *mEnv;
|
JNIEnv *mEnv;
|
||||||
T mLocalRef;
|
T mLocalRef;
|
||||||
DISALLOW_COPY_AND_ASSIGN(ScopedLocalRef);
|
DISALLOW_COPY_AND_ASSIGN(ScopedLocalRef);
|
||||||
};
|
};
|
||||||
|
|
||||||
[[maybe_unused]]
|
inline ScopedLocalRef<jstring> ClearException(JNIEnv *env) {
|
||||||
inline void JNIExceptionClear(JNIEnv *env) {
|
|
||||||
if (env->ExceptionCheck()) {
|
|
||||||
env->ExceptionClear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[[maybe_unused]]
|
|
||||||
inline bool JNIExceptionCheck(JNIEnv *env) {
|
|
||||||
if (env->ExceptionCheck()) {
|
|
||||||
jthrowable e = env->ExceptionOccurred();
|
|
||||||
env->Throw(e);
|
|
||||||
env->DeleteLocalRef(e);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[maybe_unused]]
|
|
||||||
inline void JNIExceptionClearAndDescribe(JNIEnv *env) {
|
|
||||||
if (env->ExceptionCheck()) {
|
|
||||||
env->ExceptionDescribe();
|
|
||||||
env->ExceptionClear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline jstring ClearException(JNIEnv *env) {
|
|
||||||
static jmethodID toString = env->GetMethodID(env->FindClass("java/lang/Object"), "toString",
|
|
||||||
"()Ljava/lang/String;");
|
|
||||||
if (auto exception = env->ExceptionOccurred()) {
|
if (auto exception = env->ExceptionOccurred()) {
|
||||||
env->ExceptionClear();
|
env->ExceptionClear();
|
||||||
return (jstring) env->CallObjectMethod(exception, toString);
|
static jmethodID toString = env->GetMethodID(env->FindClass("java/lang/Object"), "toString",
|
||||||
|
"()Ljava/lang/String;");
|
||||||
|
auto str = (jstring) env->CallObjectMethod(exception, toString);
|
||||||
|
env->DeleteLocalRef(exception);
|
||||||
|
return {env, str};
|
||||||
}
|
}
|
||||||
return nullptr;
|
return {env, nullptr};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
@ -191,7 +171,7 @@ inline auto JNI_SafeInvoke(JNIEnv *env, Func f, Args &&... args) {
|
||||||
|
|
||||||
~finally() {
|
~finally() {
|
||||||
if (auto exception = ClearException(env_)) {
|
if (auto exception = ClearException(env_)) {
|
||||||
LOGE("%s", JUTFString(env_, exception).get());
|
LOGE("%s", JUTFString(env_, exception.get()).get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -266,7 +266,7 @@ public class BridgeService {
|
||||||
String processName = data.readString();
|
String processName = data.readString();
|
||||||
IBinder heartBeat = data.readStrongBinder();
|
IBinder heartBeat = data.readStrongBinder();
|
||||||
var applicationService = service.requestApplicationService(Binder.getCallingUid(), Binder.getCallingPid(), processName, heartBeat);
|
var applicationService = service.requestApplicationService(Binder.getCallingUid(), Binder.getCallingPid(), processName, heartBeat);
|
||||||
if (applicationService != null) binder = service.asBinder();
|
if (applicationService != null) binder = applicationService.asBinder();
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, Log.getStackTraceString(e));
|
Log.e(TAG, Log.getStackTraceString(e));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue