调整SysApi的实现

serial
BlueMatthew 1 year ago
parent a211c88a61
commit 257b6fb554

@ -20,6 +20,7 @@
#include "Camera.h"
#include "Camera2Reader.h"
#include "GPIOControl.h"
#ifdef USING_BREAK_PAD
bool DumpCallback(const google_breakpad::MinidumpDescriptor& descriptor,
@ -462,3 +463,22 @@ Java_com_xypower_mpapp_MicroPhotoService_recordingFinished(
env->ReleaseStringUTFChars(path, pathStr);
}
}
extern "C" JNIEXPORT void JNICALL
Java_com_xypower_mpapp_MicroPhotoService_setOtgState(
JNIEnv* env,
jclass cls, jboolean enabled) {
GpioControl::setOtgState(enabled != JNI_FALSE);
}
extern "C" JNIEXPORT void JNICALL
Java_com_xypower_mpapp_MicroPhotoService_setCam3V3Enable(
JNIEnv* env,
jclass cls, jboolean enabled) {
GpioControl::setCam3V3Enable(enabled != JNI_FALSE);
}

@ -905,8 +905,6 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat)
return false;
}
mPhotoInfo.photoTime = time(NULL);
int baseline = 0;
cv::Size textSize, textSize2;

@ -247,6 +247,8 @@ protected:
protected:
std::mutex mCameraPowerLocker;
JavaVM* m_vm;
jobject m_javaService;
jclass m_sysApiClass;
@ -287,7 +289,7 @@ protected:
long mCameraPowerCount;
long mOtgCount;
std::mutex mCameraPowerLocker;
};

@ -474,10 +474,10 @@ public class MainActivity extends AppCompatActivity {
binding.btnCameraInfo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
SysApi.setOtgState(true);
MicroPhotoService.setOtgState(true);
// SysApi.setOtgState(true);
SysApi.setCam3V3Enable(true);
MicroPhotoService.setCam3V3Enable(true);
Runnable runnable = new Runnable() {
@Override
@ -486,8 +486,8 @@ public class MainActivity extends AppCompatActivity {
Log.d(TAG, cameraInfo);
SysApi.setCam3V3Enable(false);
SysApi.setOtgState(false);
MicroPhotoService.setCam3V3Enable(false);
MicroPhotoService.setOtgState(false);
Toast.makeText(view.getContext(), cameraInfo, Toast.LENGTH_LONG).show();
}

@ -170,7 +170,8 @@ public class MicroPhotoService extends Service {
intentFilter.addAction(ACTION_MSG_BROADCAST);
intentFilter.addAction(ACTION_VIDEO_FINISHED);
intentFilter.addAction(ACTION_STOP);
getApplicationContext().registerReceiver(mAlarmReceiver, intentFilter);
// intentFilter.addCategory(Intent.CATEGORY_DEFAULT);
getApplicationContext().registerReceiver(mAlarmReceiver, intentFilter, Context.RECEIVER_EXPORTED | Context.RECEIVER_VISIBLE_TO_INSTANT_APPS);
// IntentFilter intentFilter2 = new IntentFilter(ACTION_MSG_BROADCAST);
// registerReceiver(mAlarmReceiver, intentFilter2);
@ -555,22 +556,27 @@ public class MicroPhotoService extends Service {
public static void sendHeartbeat(Context context) {
Intent alarmIntent = new Intent();
// if(Build.VERSION.SDK_INT >= 26) {
// alarmIntent.addFlags(0x01000000);
//}
alarmIntent.setComponent(new ComponentName(context.getPackageName(),AlarmReceiver.class.getName()));
// String className = AlarmReceiver.class.getName();
// alarmIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
// context.startService(alarmIntent);
// alarmIntent.setComponent(new ComponentName(context.getPackageName(), className));
// alarmIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// alarmIntent.setPackage(context.getPackageName());
alarmIntent.setAction(ACTION_HEARTBEAT_MANUALLY);
// PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, 0);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, 0);
context.sendBroadcast(alarmIntent);
// context.sendBroadcast(alarmIntent);
// context.sendBroadcast(alarmIntent);
// LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context);
// localBroadcastManager.sendBroadcast(alarmIntent);
// AlarmManager alarmManager = (AlarmManager) context.getSystemService(ALARM_SERVICE);
// alarmManager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 100, pendingIntent);
AlarmManager alarmManager = (AlarmManager) context.getSystemService(ALARM_SERVICE);
alarmManager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 100, pendingIntent);
}
@Override
@ -1078,6 +1084,8 @@ cellSignalStrengthGsm.getDbm();
protected native void updatePosition(long handler, double lon, double lat, long ts);
protected native boolean uninit(long handler);
protected native void recordingFinished(long handler, boolean result, String path, long videoId);
public static native void setOtgState(boolean enabled);
public static native void setCam3V3Enable(boolean enabled);
////////////////////////GPS////////////////////
private static final String GPS_LOCATION_NAME = android.location.LocationManager.GPS_PROVIDER;

Loading…
Cancel
Save