Skip to content

Commit

Permalink
Log error but do not fail if mock location setting fails (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
imurchie committed Aug 22, 2017
1 parent fcbc21c commit de27a6c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/android-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,14 @@ helpers.initUnicodeKeyboard = async function (adb) {
};

helpers.setMockLocationApp = async function (adb, app) {
if (parseInt(await adb.getApiLevel(), 10) < 23) {
await adb.shell(['settings', 'put', 'secure', 'mock_location', '1']);
} else {
await adb.shell(['appops', 'set', app, 'android:mock_location', 'allow']);
try {
if (parseInt(await adb.getApiLevel(), 10) < 23) {
await adb.shell(['settings', 'put', 'secure', 'mock_location', '1']);
} else {
await adb.shell(['appops', 'set', app, 'android:mock_location', 'allow']);
}
} catch (err) {
logger.warn(`Unable to set mock location for app '${app}': ${err.message}`);
}
};

Expand Down

0 comments on commit de27a6c

Please sign in to comment.