优化代码

streaming
Matthew 4 months ago
parent 76e63a8808
commit 2be8a53a67

@ -1189,6 +1189,8 @@ void CPhoneDevice::RestartApp(int resetType, long timeout, const std::string& re
jreason = env->NewStringUTF(reason.c_str());
}
env->CallVoidMethod(m_javaService, mRebootMid, resetType, (jlong)timeout, jreason);
if (jreason != NULL) env->DeleteLocalRef(jreason);
if (didAttachThread)
{
m_vm->DetachCurrentThread();
@ -3838,10 +3840,10 @@ void CPhoneDevice::SetStaticIp(const std::string& iface, const std::string& ip,
jstring jnetmask = env->NewStringUTF(netmask.c_str());
jstring jgw = env->NewStringUTF(gateway.c_str());
env->CallVoidMethod(m_javaService, mSetStaticIpMid, jiface, jip, jnetmask, jgw);
// env->DeleteLocalRef(jgw);
// env->DeleteLocalRef(jnetmask);
// env->DeleteLocalRef(jip);
// env->DeleteLocalRef(jiface);
env->DeleteLocalRef(jgw);
env->DeleteLocalRef(jnetmask);
env->DeleteLocalRef(jip);
env->DeleteLocalRef(jiface);
if (didAttachThread)
{
@ -3863,6 +3865,8 @@ void CPhoneDevice::ConvertDngToPng(const std::string& dngPath, const std::string
jstring jdngPath = env->NewStringUTF(dngPath.c_str());
jstring jpngPath = env->NewStringUTF(pngPath.c_str());
env->CallVoidMethod(m_javaService, mConvertDngToPngMid, jdngPath, jpngPath);
env->DeleteLocalRef(jdngPath);
env->DeleteLocalRef(jpngPath);
if (didAttachThread)
{

@ -102,7 +102,8 @@ public class MicroPhotoService extends Service {
public final static int BROADCAST_REQUEST_CODE_HEARTBEAT = 1;
public final static int BROADCAST_REQUEST_CODE_TAKING_PHOTO = 2;
public final static int BROADCAST_REQUEST_CODE_GPS = 2;
public final static int BROADCAST_REQUEST_CODE_GPS = 3;
public final static int BROADCAST_REQUEST_CODE_STOP_SERVICE = 4;
public static final int NOTIFICATION_ID_FOREGROUND_SERVICE = 8466503;
public static final String ACTION_MSG_BROADCAST = "ACT_MSG_BROADCAST";
@ -1139,7 +1140,7 @@ public class MicroPhotoService extends Service {
alarmIntent.setPackage(context.getPackageName());
alarmIntent.setAction(ACTION_STOP);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context.getApplicationContext(), mPendingIntentFeed.getAndIncrement(), alarmIntent, 0);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context.getApplicationContext(), BROADCAST_REQUEST_CODE_STOP_SERVICE, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmManager = (AlarmManager) context.getApplicationContext().getSystemService(ALARM_SERVICE);
alarmManager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 100, pendingIntent);

Loading…
Cancel
Save