Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions app/src/main/java/it/smg/hu/manager/HondaConnectManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private static class ModeMgrMode {
// SteeringWheel service
private ISteeringMenuService steeringMenuServiceIface_;
private final ServiceConnection steeringMenuServiceConnection_;
// private SteeringMenuServiceCallback steeringMenuServiceCallback_;
// private SteeringMenuServiceCallback steeringMenuServiceCallback_;
private boolean boundToWheelService_;

private final Context context_;
Expand All @@ -73,7 +73,7 @@ private static class ModeMgrMode {
private boolean hasAudioFocus_;
private boolean boundToModeMgrService_;
private ProcessControl pControl_;
// private CountDownLatch waitCond_;
// private CountDownLatch waitCond_;

private final Handler mainHandler_;

Expand Down Expand Up @@ -278,6 +278,18 @@ public void releaseAudioFocus(){
}
}

public void reRegisterWheel(){
if (settings_.advanced.swMode().equalsIgnoreCase(SWMode.SW_SERVICE)) {
if (Log.isVerbose()) Log.v(TAG, "increaseVolume -> swMode SW_SERVICE -> bind HC sw service");
unbindToWheelService();
bindToWheelService();
} else if (settings_.advanced.swMode().equalsIgnoreCase(SWMode.MODEMGR_KEY_CALLBACK)) {
if (Log.isWarn()) Log.w(TAG, "increaseVolume -> swMode MODEMGR_KEY_CALLBACK -> USE MODEMGR_KEY_CALLBACK ONLY WITH PREINSTALL");
unregisterModeMgrSWEvent();
registerModeMgrSWEvent();
}
}

public void increaseVolume(){
if (Log.isVerbose()) Log.v(TAG, "increaseVolume");
modeMgrManager_.reqModeMgrSteeringVolCmd(true);
Expand All @@ -295,6 +307,17 @@ public void initAudioBinding(){
if (pControl_.authType == Constants.AUTH_TYPE_PREINSTALL){
if (Log.isVerbose()) Log.v(TAG, "initAudioBinding -> app auth = preinstall");
bindToModeMgrService();
if (settings_.advanced.swMode().equalsIgnoreCase(SWMode.SW_SERVICE)) {
if (Log.isVerbose()) Log.v(TAG, "initAudioBinding -> using authType PREINSTALL and swMode SW_SERVICE -> bind HC sw service");
bindToWheelService();
} else if (settings_.advanced.swMode().equalsIgnoreCase(SWMode.MODEMGR_KEY_CALLBACK)) {
if (Log.isWarn()) Log.w(TAG, "initAudioBinding -> using authType PREINSTALL and swMode MODEMGR_KEY_CALLBACK -> USE MODEMGR_KEY_CALLBACK ONLY WITH PREINSTALL");
registerModeMgrSWEvent();
} else {
if (Log.isWarn()) Log.w(TAG, "initAudioBinding -> wrong steeringwheel mode " + settings_.advanced.swMode());
}


} else {
if (Log.isVerbose()) Log.v(TAG, "initAudioBinding -> app auth not preinstall");

Expand All @@ -318,6 +341,7 @@ public void sendToBackground(){
unbindToWheelService();
} else if (settings_.advanced.swMode().equalsIgnoreCase(SWMode.MODEMGR_KEY_CALLBACK)) {
if (Log.isVerbose()) Log.v(TAG, "sendToBackground -> using authType PREINSTALL and swMode MODEMGR_KEY_CALLBACK -> do nothing");
unregisterModeMgrSWEvent();
} else {
if (Log.isWarn()) Log.w(TAG, "sendToBackground -> wrong steeringwheel mode " + settings_.advanced.swMode());
}
Expand Down Expand Up @@ -550,6 +574,11 @@ public boolean onFinishView(boolean flg, boolean anime) {

public boolean onSteeringSWDown(int keytype) {
Log.v(TAG, "onSteeringSWDown " + keytype);
if (Log.isDebug()) {
mainHandler_.post(() -> {
Toast.makeText(context_, "onSteeringSWDown keytype: " + keytype, Toast.LENGTH_SHORT).show();
});
}
return true;
}
};
Expand Down
16 changes: 12 additions & 4 deletions app/src/main/java/it/smg/hu/projection/InputDevice.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public InputDevice(Context ctx, SurfaceView surfaceView, InputDevice.OnKeyHolder
screenGeometry_ = new Rect(1280, 720);
break;
case 3: // 1080p
screenGeometry_ = new Rect(1920, 1080);;
screenGeometry_ = new Rect(1920, 1080);
break;
case 4: // 1440p
screenGeometry_ = new Rect(2560, 1440);;
screenGeometry_ = new Rect(2560, 1440);
break;
default: // 480p
screenGeometry_ = new Rect(800, 480);
Expand Down Expand Up @@ -111,6 +111,7 @@ public void gainFocus() {
if (keyHolder_ != null){
keyHolder_.setOnKeyListener(this);
}
HondaConnectManager.instance().reRegisterWheel();
}

@Keep
Expand All @@ -123,6 +124,7 @@ public void releaseFocus() {
if (keyHolder_ != null){
keyHolder_.setOnKeyListener(null);
}
HondaConnectManager.instance().reRegisterWheel();
}

@Keep
Expand Down Expand Up @@ -168,6 +170,7 @@ public boolean onTouch(View v, MotionEvent event) {
}
sendTouchEvent(event.getActionMasked(), event.getActionIndex(), ta);
}
HondaConnectManager.instance().reRegisterWheel();
return true;
}

Expand All @@ -193,10 +196,15 @@ public boolean onKey(View v, int keyCode, KeyEvent event) {
int action = event.getAction(); // 1 - UP, 0 - DOWN
sendButtonEvent(action, button);
}

HondaConnectManager.instance().reRegisterWheel();
return true;
}

if (Log.isDebug()) {
new Handler(Looper.getMainLooper()).post(() -> {
Toast.makeText(context_, "Unknown event button key: " + keyCode + " action: " + event.getAction(), Toast.LENGTH_SHORT).show();
});
}
HondaConnectManager.instance().reRegisterWheel();
return false;
}

Expand Down