|
|
@ -12,6 +12,7 @@ import android.text.TextUtils;
|
|
|
|
import android.util.Base64;
|
|
|
|
import android.util.Base64;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.util.Log;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.dowse.devicesdk.DsDeviceSdk;
|
|
|
|
import com.xypower.common.FilesUtils;
|
|
|
|
import com.xypower.common.FilesUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import org.json.JSONObject;
|
|
|
|
import org.json.JSONObject;
|
|
|
@ -56,9 +57,47 @@ public class BridgeProvider extends ContentProvider {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean onCreate() {
|
|
|
|
public boolean onCreate() {
|
|
|
|
// TODO: Implement this to initialize your content provider on startup.
|
|
|
|
// TODO: Implement this to initialize your content provider on startup.
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initNrsec() {
|
|
|
|
|
|
|
|
boolean bres = false;
|
|
|
|
|
|
|
|
int res = 0;
|
|
|
|
|
|
|
|
DsDeviceSdk dsSdk = DsDeviceSdk.getInstance();
|
|
|
|
|
|
|
|
dsSdk.init();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
res = dsSdk.mcuInit();
|
|
|
|
|
|
|
|
res = dsSdk.mcuOpen();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bres = dsSdk.mcuPowerOffCPR();
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Thread.sleep(100);
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bres = dsSdk.mcuPowerOnCPR();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Thread.sleep(50);
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void uninitNrsec() {
|
|
|
|
|
|
|
|
DsDeviceSdk dsSdk = DsDeviceSdk.getInstance();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int res = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean bres = dsSdk.mcuPowerOffCPR();
|
|
|
|
|
|
|
|
res = dsSdk.mcuClose();
|
|
|
|
|
|
|
|
res = dsSdk.mcuUnInit();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dsSdk.release();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Cursor query(Uri uri, String[] projection, String selection,
|
|
|
|
public Cursor query(Uri uri, String[] projection, String selection,
|
|
|
|
String[] selectionArgs, String sortOrder) {
|
|
|
|
String[] selectionArgs, String sortOrder) {
|
|
|
@ -67,6 +106,8 @@ public class BridgeProvider extends ContentProvider {
|
|
|
|
Log.i(TAG, uri.toString());
|
|
|
|
Log.i(TAG, uri.toString());
|
|
|
|
matcher.addURI(AUTHORITY, PATH_QUERY_SEC_VERSION, 1);
|
|
|
|
matcher.addURI(AUTHORITY, PATH_QUERY_SEC_VERSION, 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initNrsec();
|
|
|
|
|
|
|
|
|
|
|
|
Cursor cursor = null;
|
|
|
|
Cursor cursor = null;
|
|
|
|
int matched = matcher.match(uri);
|
|
|
|
int matched = matcher.match(uri);
|
|
|
|
switch (matched) {
|
|
|
|
switch (matched) {
|
|
|
@ -77,6 +118,7 @@ public class BridgeProvider extends ContentProvider {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uninitNrsec();
|
|
|
|
return cursor;
|
|
|
|
return cursor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -90,6 +132,7 @@ public class BridgeProvider extends ContentProvider {
|
|
|
|
matcher.addURI(AUTHORITY, PATH_GEN_KEYS, 3);
|
|
|
|
matcher.addURI(AUTHORITY, PATH_GEN_KEYS, 3);
|
|
|
|
matcher.addURI(AUTHORITY, PATH_GEN_CERT_REQ, 4);
|
|
|
|
matcher.addURI(AUTHORITY, PATH_GEN_CERT_REQ, 4);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initNrsec();
|
|
|
|
int res = 0;
|
|
|
|
int res = 0;
|
|
|
|
int matched = matcher.match(uri);
|
|
|
|
int matched = matcher.match(uri);
|
|
|
|
switch (matched) {
|
|
|
|
switch (matched) {
|
|
|
@ -109,6 +152,8 @@ public class BridgeProvider extends ContentProvider {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uninitNrsec();
|
|
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|