Skip to content

Commit

Permalink
[Meta] Remove specific code for handling volume keys
Browse files Browse the repository at this point in the history
Meta flavour has specific code for handling volume keys. This seems
to be legacy code from FxR. It isn't really needed as they work
fine without any special treatment. What's more, volume slider
used to dissapear under some circumstances in the past. I could
not reproduce that behaviour any more after applying this patch.
  • Loading branch information
svillar committed Oct 3, 2024
1 parent 6d8007f commit 01d7b61
Showing 1 changed file with 0 additions and 44 deletions.
44 changes: 0 additions & 44 deletions app/src/common/shared/com/igalia/wolvic/VRBrowserActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.SurfaceTexture;
import android.media.AudioManager;
import android.net.Uri;
import android.opengl.GLES11Ext;
import android.opengl.GLES20;
Expand Down Expand Up @@ -229,7 +228,6 @@ public void run() {
private SettingsStore mSettings;
private SharedPreferences mPrefs;
private boolean mConnectionAvailable = true;
private AudioManager mAudioManager;
private Widget mActiveDialog;
private Set<String> mPoorPerformanceAllowList;
private float mCurrentCylinderDensity = 0;
Expand All @@ -249,21 +247,6 @@ public void run() {
private int mLastMotionEventWidgetHandle;
private boolean mIsEyeTrackingSupported;

private boolean callOnAudioManager(Consumer<AudioManager> fn) {
if (mAudioManager == null) {
mAudioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
}
if (mAudioManager != null) {
try {
fn.accept(mAudioManager);
return true;
} catch (Exception e) {
Log.e(LOGTAG, "Caught exception calling AudioManager: " + e.toString());
}
}
return false;
}

private ViewTreeObserver.OnGlobalFocusChangeListener globalFocusListener = new ViewTreeObserver.OnGlobalFocusChangeListener() {
@Override
public void onGlobalFocusChanged(View oldFocus, View newFocus) {
Expand Down Expand Up @@ -1025,33 +1008,6 @@ public boolean dispatchKeyEvent(KeyEvent event) {
if (isNotSpecialKey(event) && mKeyboard.dispatchKeyEvent(event)) {
return true;
}
final int keyCode = event.getKeyCode();
if (DeviceType.isOculusBuild()) {
if (event.getKeyCode() == KeyEvent.KEYCODE_SEARCH) {
// Eat search key, otherwise it causes a crash on Oculus
return true;
}
int action = event.getAction();
if (action != KeyEvent.ACTION_DOWN) {
return super.dispatchKeyEvent(event);
}
boolean result;
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
result = callOnAudioManager((AudioManager aManager) -> aManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI));
break;
case KeyEvent.KEYCODE_VOLUME_DOWN:
result = callOnAudioManager((AudioManager aManager) -> aManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI));
break;
case KeyEvent.KEYCODE_VOLUME_MUTE:
result = callOnAudioManager((AudioManager aManager) -> aManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_MUTE, AudioManager.FLAG_SHOW_UI));
break;
default:
return super.dispatchKeyEvent(event);
}
return result || super.dispatchKeyEvent(event);

}
return super.dispatchKeyEvent(event);
}

Expand Down

0 comments on commit 01d7b61

Please sign in to comment.