mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 01:23:52 +00:00
Merge remote-tracking branch 'origin/master' into dlech
This commit is contained in:
@@ -55,6 +55,7 @@ import {
|
||||
import { RootState } from '../reducers';
|
||||
import { defined, hex, maybe } from '../utils';
|
||||
import { fmod, sumComplement32 } from '../utils/math';
|
||||
import { isAndroid } from '../utils/os';
|
||||
import {
|
||||
FailToFinishReasonType,
|
||||
FlashFirmwareActionType,
|
||||
@@ -376,8 +377,9 @@ function* flashFirmware(action: FlashFirmwareFlashAction): Generator {
|
||||
yield* disconnectAndCancel();
|
||||
}
|
||||
|
||||
// 14 is "safe" size for all hubs
|
||||
const maxDataSize = MaxProgramFlashSize.get(info.hubType) || 14;
|
||||
// 14 is "safe" size for all hubs and Android
|
||||
const maxDataSize =
|
||||
(!isAndroid() && MaxProgramFlashSize.get(info.hubType)) || 14;
|
||||
|
||||
let runningChecksum = 0xff;
|
||||
|
||||
|
||||
+12
-1
@@ -1,12 +1,23 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2021 The Pybricks Authors
|
||||
|
||||
import { isMacOS, isWindows, prefersDarkMode } from './os';
|
||||
import { isAndroid, isMacOS, isWindows, prefersDarkMode } from './os';
|
||||
|
||||
afterEach(() => {
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
describe('isAndroid', () => {
|
||||
test('is true', () => {
|
||||
jest.spyOn(navigator, 'userAgent', 'get').mockReturnValue('Android');
|
||||
expect(isAndroid()).toBeTruthy();
|
||||
});
|
||||
test('is false', () => {
|
||||
jest.spyOn(navigator, 'userAgent', 'get').mockReturnValue('Linux');
|
||||
expect(isAndroid()).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('isMacOS', () => {
|
||||
test('is true', () => {
|
||||
jest.spyOn(navigator, 'platform', 'get').mockReturnValue('MacIntel');
|
||||
|
||||
@@ -3,6 +3,17 @@
|
||||
|
||||
// Utility functions for dealing with operating systems.
|
||||
|
||||
// TODO: replace with navigator.userAgentData when it is more widely available
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/User-Agent_Client_Hints_API
|
||||
|
||||
/**
|
||||
* Tests if we are running on Android.
|
||||
* @returns `true` if running on Android, otherwise `false`.
|
||||
*/
|
||||
export function isAndroid(): boolean {
|
||||
return /android/i.test(navigator.userAgent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if we are running on macOS.
|
||||
* @returns `true` if running on macOS, otherwise `false`.
|
||||
|
||||
Reference in New Issue
Block a user