Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit f8b42cb

Browse files
MortimerGorobluemarvin
authored andcommitted
Fix BuildConfig.Flavor equality checks (#1381)
1 parent f22769d commit f8b42cb

File tree

8 files changed

+29
-13
lines changed

8 files changed

+29
-13
lines changed

app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
import org.mozilla.vrbrowser.crashreporting.CrashReporterService;
4343
import org.mozilla.vrbrowser.crashreporting.GlobalExceptionHandler;
4444
import org.mozilla.vrbrowser.geolocation.GeolocationWrapper;
45-
import org.mozilla.vrbrowser.input.DeviceType;
45+
import org.mozilla.vrbrowser.utils.DeviceType;
4646
import org.mozilla.vrbrowser.input.MotionEventGenerator;
4747
import org.mozilla.vrbrowser.search.SearchEngineWrapper;
4848
import org.mozilla.vrbrowser.telemetry.TelemetryWrapper;
@@ -186,7 +186,7 @@ protected void onCreate(Bundle savedInstanceState) {
186186
// Set a global exception handler as soon as possible
187187
GlobalExceptionHandler.register(this.getApplicationContext());
188188

189-
if (BuildConfig.FLAVOR_platform == "oculusvr") {
189+
if (DeviceType.isOculusBuild()) {
190190
workaroundGeckoSigAction();
191191
}
192192
mUiThread = Thread.currentThread();
@@ -497,7 +497,7 @@ public void onBackPressed() {
497497

498498
@Override
499499
public boolean dispatchKeyEvent(KeyEvent event) {
500-
if (BuildConfig.FLAVOR_platform == "oculusvr") {
500+
if (DeviceType.isOculusBuild()) {
501501
int action = event.getAction();
502502
if (action != KeyEvent.ACTION_DOWN) {
503503
return super.dispatchKeyEvent(event);

app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.mozilla.vrbrowser.BuildConfig;
1212
import org.mozilla.vrbrowser.R;
1313
import org.mozilla.vrbrowser.telemetry.TelemetryWrapper;
14+
import org.mozilla.vrbrowser.utils.DeviceType;
1415
import org.mozilla.vrbrowser.utils.LocaleUtils;
1516
import org.mozilla.vrbrowser.utils.StringUtils;
1617

@@ -362,7 +363,7 @@ public void setMSAALevel(int level) {
362363
}
363364

364365
public boolean getLayersEnabled() {
365-
if (BuildConfig.FLAVOR_platform.equalsIgnoreCase("oculusvr")) {
366+
if (DeviceType.isOculusBuild()) {
366367
return true;
367368
}
368369
return false;

app/src/common/shared/org/mozilla/vrbrowser/telemetry/TelemetryWrapper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.mozilla.vrbrowser.R;
2424
import org.mozilla.vrbrowser.browser.SettingsStore;
2525
import org.mozilla.vrbrowser.search.SearchEngineWrapper;
26+
import org.mozilla.vrbrowser.utils.DeviceType;
2627
import org.mozilla.vrbrowser.utils.UrlUtils;
2728

2829
import java.net.URI;
@@ -100,7 +101,7 @@ public static void init(Context aContext) {
100101
final JSONPingSerializer serializer = new JSONPingSerializer();
101102
final FileTelemetryStorage storage = new FileTelemetryStorage(configuration, serializer);
102103
TelemetryScheduler scheduler;
103-
if (BuildConfig.FLAVOR_platform.equals("oculusvr") || BuildConfig.FLAVOR_platform.equals("oculusvrStore")) {
104+
if (DeviceType.isOculus6DOFBuild()) {
104105
scheduler = new FxRTelemetryScheduler();
105106
} else {
106107
scheduler = new JobSchedulerTelemetryScheduler();

app/src/common/shared/org/mozilla/vrbrowser/ui/views/HoneycombButton.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import android.widget.LinearLayout;
1313
import android.widget.TextView;
1414

15-
import org.mozilla.vrbrowser.input.DeviceType;
15+
import org.mozilla.vrbrowser.utils.DeviceType;
1616
import org.mozilla.vrbrowser.R;
1717

1818
import androidx.annotation.Nullable;

app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/VoiceSearchWidget.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@
2626
import org.mozilla.vrbrowser.R;
2727
import org.mozilla.vrbrowser.audio.AudioEngine;
2828
import org.mozilla.vrbrowser.browser.SettingsStore;
29-
import org.mozilla.vrbrowser.input.DeviceType;
29+
import org.mozilla.vrbrowser.utils.DeviceType;
3030
import org.mozilla.vrbrowser.ui.views.UIButton;
31-
import org.mozilla.vrbrowser.ui.widgets.UIWidget;
3231
import org.mozilla.vrbrowser.ui.widgets.WidgetManagerDelegate;
3332
import org.mozilla.vrbrowser.ui.widgets.WidgetPlacement;
3433

35-
import androidx.annotation.IdRes;
3634
import androidx.core.app.ActivityCompat;
3735

3836
public class VoiceSearchWidget extends UIDialog implements WidgetManagerDelegate.PermissionListener,

app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DisplayOptionsView.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.mozilla.vrbrowser.ui.views.settings.SingleEditSetting;
2222
import org.mozilla.vrbrowser.ui.views.settings.SwitchSetting;
2323
import org.mozilla.vrbrowser.ui.widgets.WidgetManagerDelegate;
24+
import org.mozilla.vrbrowser.utils.DeviceType;
2425

2526
class DisplayOptionsView extends SettingsView {
2627
private AudioEngine mAudio;
@@ -245,8 +246,7 @@ protected void onDismiss() {
245246
if (!mMSAARadio.getValueForId(mMSAARadio.getCheckedRadioButtonId()).equals(SettingsStore.MSAA_DEFAULT_LEVEL)) {
246247
setMSAAMode(mMSAARadio.getIdForValue(SettingsStore.MSAA_DEFAULT_LEVEL), true);
247248
}
248-
if (BuildConfig.FLAVOR_platform == "oculusvr" ||
249-
BuildConfig.FLAVOR_platform == "wavevr") {
249+
if (DeviceType.isOculusBuild() || DeviceType.isWaveBuild()) {
250250
if (!mFoveatedAppRadio.getValueForId(mFoveatedAppRadio.getCheckedRadioButtonId()).equals(SettingsStore.FOVEATED_APP_DEFAULT_LEVEL)) {
251251
setFoveatedLevel(mFoveatedAppRadio, mFoveatedAppRadio.getIdForValue(SettingsStore.FOVEATED_APP_DEFAULT_LEVEL), true);
252252
}

app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/PrivacyOptionsView.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.mozilla.vrbrowser.ui.views.settings.ButtonSetting;
2323
import org.mozilla.vrbrowser.ui.views.settings.SwitchSetting;
2424
import org.mozilla.vrbrowser.ui.widgets.WidgetManagerDelegate;
25+
import org.mozilla.vrbrowser.utils.DeviceType;
2526

2627
import java.util.ArrayList;
2728

@@ -91,8 +92,9 @@ private void initialize(Context aContext) {
9192
mPermissionButtons.add(Pair.create(findViewById(R.id.locationPermissionButton), Manifest.permission.ACCESS_FINE_LOCATION));
9293
mPermissionButtons.add(Pair.create(findViewById(R.id.storagePermissionButton), Manifest.permission.READ_EXTERNAL_STORAGE));
9394

94-
if (BuildConfig.FLAVOR_platform == "oculusvr3dof" || BuildConfig.FLAVOR_platform == "oculusvr")
95+
if (DeviceType.isOculusBuild()) {
9596
findViewById(R.id.cameraPermissionButton).setVisibility(View.GONE);
97+
}
9698

9799
for (Pair<ButtonSetting, String> button: mPermissionButtons) {
98100
if (mWidgetManager.isPermissionGranted(button.second)) {

app/src/common/shared/org/mozilla/vrbrowser/input/DeviceType.java renamed to app/src/common/shared/org/mozilla/vrbrowser/utils/DeviceType.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
package org.mozilla.vrbrowser.input;
1+
package org.mozilla.vrbrowser.utils;
22

33
import android.util.Log;
44

5+
import org.mozilla.vrbrowser.BuildConfig;
6+
57
public class DeviceType {
68
// These values need to match those in Device.h
79
public static final int Unknown = 0;
@@ -21,4 +23,16 @@ public static void setType(int aType) {
2123
public static int getType() {
2224
return mType;
2325
}
26+
27+
public static boolean isOculusBuild() {
28+
return BuildConfig.FLAVOR_platform.toLowerCase().contains("oculusvr");
29+
}
30+
31+
public static boolean isOculus6DOFBuild() {
32+
return BuildConfig.FLAVOR_platform.equalsIgnoreCase("oculusvr") || BuildConfig.FLAVOR_platform.equalsIgnoreCase("oculusvrStore");
33+
}
34+
35+
public static boolean isWaveBuild() {
36+
return BuildConfig.FLAVOR_platform.toLowerCase().contains("wavevr");
37+
}
2438
}

0 commit comments

Comments
 (0)