Skip to content

Commit

Permalink
Merge pull request #12 from lillialexis/51522
Browse files Browse the repository at this point in the history
[51522] Fix nullPointerException caused by removing static modifier to rviService.requestAll(Request()) when changing the uuid code in the unlock demo and removes hard-coded timeout and vehicleVIN from rvi service invocations
  • Loading branch information
lillialexis committed Nov 4, 2015
2 parents 08de4ac + 25a01a0 commit 9b047c9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public boolean onOptionsItemSelected(MenuItem item) {

return super.onOptionsItemSelected(item);
}

// public void clickedStart(View v){
// SharedPreferences.Editor ed = sharedPref.edit();
// ed.putBoolean(LockActivityFragment.STOPPED_LBL, true);
Expand All @@ -189,7 +189,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
@Override
public void onButtonCommand(String cmd) {
//TODO send to RVI service
rviService.service(cmd, LockActivity.this);
RviService.service(cmd, LockActivity.this);
}

public void keyUpdate(final String authServ, final String userType) {
Expand Down Expand Up @@ -231,8 +231,18 @@ public void keyShareCommand(String key) {
break;
case "keychange":
try {
rviService.requestAll(Request());
RviService.requestAll(Request(), LockActivity.this);
requestProgress = ProgressDialog.show(LockActivity.this, "","Retrieving keys...",true);

requestProgress.setCancelable(true);
requestProgress.setOnCancelListener(new DialogInterface.OnCancelListener()
{
@Override
public void onCancel(DialogInterface dialog) {
// TODO: ?
}
});

startRequest();
} catch (Exception e) {
e.printStackTrace();
Expand All @@ -241,8 +251,10 @@ public void keyShareCommand(String key) {
}
}
public JSONArray Request() throws JSONException {
SharedPreferences sharedpref = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor e = sharedpref.edit();
JSONObject request = new JSONObject();
request.put("vehicleVIN", "1234567890ABCDEFG");
request.put("vehicleVIN", lock_fragment.JSONParser(sharedpref.getString("Userdata", "Nothing There!!"), "vehicleVIN"));//"1234567890ABCDEFG");

JSONArray jsonArray = new JSONArray();
jsonArray.put(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static JSONObject createAuth(int tid, String addr, int port, String cert,
public static JSONObject createReceiveData(int tid, String service, JSONArray params, String cert, String sig) throws JSONException {
JSONObject payload = new JSONObject();
payload.put("service", service);
payload.put("timeout", 1433266704); //TODO
payload.put("timeout", System.currentTimeMillis() + 20000); //TODO
payload.put("parameters", params);
payload.put("certificate", cert);
payload.put("signature", sig);
Expand All @@ -82,7 +82,7 @@ public static JSONObject createReceiveData(int tid, String service, JSONArray pa
public static JSONObject createRequestData(int tid, String service, JSONObject params, String cert, String sig) throws JSONException {
JSONObject payload = new JSONObject();
payload.put("service", service);
payload.put("timeout", 1433266704); //TODO
payload.put("timeout", System.currentTimeMillis() + 20000); //TODO
payload.put("parameters", params);
payload.put("certificate", cert);
payload.put("signature", sig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ private void _connectConnect() {
int rviPort = Integer.parseInt(prefs.getString("pref_rvi_server_port","8807"));

//Create service vector
final String certProv = "jlr.com/mobile/" + getLocalNodeIdentifier() + "/dm/cert_provision";
final String certRsp = "jlr.com/mobile/"+ getLocalNodeIdentifier() +"/dm/cert_response";
final String certAccountDetails = "jlr.com/mobile/"+ getLocalNodeIdentifier() +"/dm/cert_accountdetails";
final String serviceInvokedByGuest = "jlr.com/mobile/"+ getLocalNodeIdentifier() +"/report/serviceinvokedbyguest";
final String certProv = "jlr.com/mobile/" + getLocalNodeIdentifier(this) + "/dm/cert_provision";
final String certRsp = "jlr.com/mobile/"+ getLocalNodeIdentifier(this) +"/dm/cert_response";
final String certAccountDetails = "jlr.com/mobile/"+ getLocalNodeIdentifier(this) +"/dm/cert_accountdetails";
final String serviceInvokedByGuest = "jlr.com/mobile/"+ getLocalNodeIdentifier(this) +"/report/serviceinvokedbyguest";
final String[] ss = {certProv, certRsp, certAccountDetails, serviceInvokedByGuest};

//final PublishSubject<JSONObject> cloudSender = PublishSubject.create();
Expand Down Expand Up @@ -995,7 +995,7 @@ public static void sendaKey(JSONArray json){
send = RviProtocol.createReceiveData(3,"jlr.com/backend/dm/cert_create",json,"","");
// Testing for dupe service invokes
//send = RviProtocol.createRequestData(3, "jlr.com/backend/dm/cert_create", json.getJSONObject(0), "", "");
Log.d(TAG,"Successfully sent"+send.toString());
Log.d(TAG, "Successfully sent" + send.toString());
// Testing for dupe service invokes
Log.d("stack cloud send: ", Thread.currentThread().getStackTrace().toString());
Thread.currentThread().getStackTrace();
Expand All @@ -1007,11 +1007,11 @@ public static void sendaKey(JSONArray json){

}

public void requestAll(JSONArray json){
public static void requestAll(JSONArray json, Context ctx){
JSONObject request;
JSONObject uuid = new JSONObject();
try{
uuid.put("mobileUUID", getLocalNodeIdentifier());
uuid.put("mobileUUID", getLocalNodeIdentifier(ctx));
json.put(uuid);
request = RviProtocol.createReceiveData(4, "jlr.com/backend/dm/cert_requestall", json, "", "");
// Testing for dupe service invokes
Expand Down Expand Up @@ -1080,8 +1080,9 @@ private static String uuidB58String() {
* @param context the application context
* @return the local prefix
*/
public String getLocalNodeIdentifier() { // TODO: There is no easy way to reset this once it's stored, is there? Maybe an app version check?
public static String getLocalNodeIdentifier(Context context) { // TODO: There is no easy way to reset this once it's stored, is there? Maybe an app version check?

SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
String localServicePrefix;

if ((localServicePrefix = prefs.getString(LOCAL_SERVICE_PREFIX_STRING, null)) == null)
Expand Down

0 comments on commit 9b047c9

Please sign in to comment.