调整SysApi的实现

serial
BlueMatthew 1 year ago
parent a211c88a61
commit 257b6fb554

@ -20,6 +20,7 @@
#include "Camera.h" #include "Camera.h"
#include "Camera2Reader.h" #include "Camera2Reader.h"
#include "GPIOControl.h"
#ifdef USING_BREAK_PAD #ifdef USING_BREAK_PAD
bool DumpCallback(const google_breakpad::MinidumpDescriptor& descriptor, bool DumpCallback(const google_breakpad::MinidumpDescriptor& descriptor,
@ -461,4 +462,23 @@ Java_com_xypower_mpapp_MicroPhotoService_recordingFinished(
env->ReleaseStringUTFChars(path, pathStr); 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; return false;
} }
mPhotoInfo.photoTime = time(NULL); mPhotoInfo.photoTime = time(NULL);
int baseline = 0; int baseline = 0;
cv::Size textSize, textSize2; cv::Size textSize, textSize2;

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

@ -474,10 +474,10 @@ public class MainActivity extends AppCompatActivity {
binding.btnCameraInfo.setOnClickListener(new View.OnClickListener() { binding.btnCameraInfo.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
SysApi.setOtgState(true); MicroPhotoService.setOtgState(true);
// SysApi.setOtgState(true); // SysApi.setOtgState(true);
SysApi.setCam3V3Enable(true); MicroPhotoService.setCam3V3Enable(true);
Runnable runnable = new Runnable() { Runnable runnable = new Runnable() {
@Override @Override
@ -486,8 +486,8 @@ public class MainActivity extends AppCompatActivity {
Log.d(TAG, cameraInfo); Log.d(TAG, cameraInfo);
SysApi.setCam3V3Enable(false); MicroPhotoService.setCam3V3Enable(false);
SysApi.setOtgState(false); MicroPhotoService.setOtgState(false);
Toast.makeText(view.getContext(), cameraInfo, Toast.LENGTH_LONG).show(); 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_MSG_BROADCAST);
intentFilter.addAction(ACTION_VIDEO_FINISHED); intentFilter.addAction(ACTION_VIDEO_FINISHED);
intentFilter.addAction(ACTION_STOP); 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); // IntentFilter intentFilter2 = new IntentFilter(ACTION_MSG_BROADCAST);
// registerReceiver(mAlarmReceiver, intentFilter2); // registerReceiver(mAlarmReceiver, intentFilter2);
@ -555,22 +556,27 @@ public class MicroPhotoService extends Service {
public static void sendHeartbeat(Context context) { public static void sendHeartbeat(Context context) {
Intent alarmIntent = new Intent(); Intent alarmIntent = new Intent();
// if(Build.VERSION.SDK_INT >= 26) { // if(Build.VERSION.SDK_INT >= 26) {
// alarmIntent.addFlags(0x01000000); // 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.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// alarmIntent.setPackage(context.getPackageName()); // alarmIntent.setPackage(context.getPackageName());
alarmIntent.setAction(ACTION_HEARTBEAT_MANUALLY); 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); // context.sendBroadcast(alarmIntent);
// LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context); // LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context);
// localBroadcastManager.sendBroadcast(alarmIntent); // localBroadcastManager.sendBroadcast(alarmIntent);
// AlarmManager alarmManager = (AlarmManager) context.getSystemService(ALARM_SERVICE); AlarmManager alarmManager = (AlarmManager) context.getSystemService(ALARM_SERVICE);
// alarmManager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 100, pendingIntent); alarmManager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 100, pendingIntent);
} }
@Override @Override
@ -1078,6 +1084,8 @@ cellSignalStrengthGsm.getDbm();
protected native void updatePosition(long handler, double lon, double lat, long ts); protected native void updatePosition(long handler, double lon, double lat, long ts);
protected native boolean uninit(long handler); protected native boolean uninit(long handler);
protected native void recordingFinished(long handler, boolean result, String path, long videoId); 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//////////////////// ////////////////////////GPS////////////////////
private static final String GPS_LOCATION_NAME = android.location.LocationManager.GPS_PROVIDER; private static final String GPS_LOCATION_NAME = android.location.LocationManager.GPS_PROVIDER;

Loading…
Cancel
Save