Skip to content

Commit c1f6519

Browse files
committed
fix(android): more native-api-usage improvements
1 parent 6c48bb6 commit c1f6519

File tree

2 files changed

+1
-14
lines changed

2 files changed

+1
-14
lines changed

packages/ble/platforms/android/native-api-usage.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
"android.bluetooth:BluetoothProfile",
44
"android.bluetooth:BluetoothGatt",
55
"androidx.core.content:ContextCompat",
6-
"java.lang:Class",
7-
"java.lang.reflect:Method",
86
"android.bluetooth.le:ScanSettings",
97
"android.bluetooth:BluetoothDevice",
108
"java.nio.charset:Charset",

src/ble/index.android.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,7 @@ export class Bluetooth extends BluetoothCommon {
12161216
public locationPermissionGranted() {
12171217
let hasPermission = sdkVersion < MARSHMALLOW;
12181218
if (!hasPermission) {
1219-
const ctx = this._getContext();
1219+
const ctx = Utils.android.getApplicationContext();
12201220
// CLog(CLogTypes.info, 'app context', ctx);
12211221
const neededPermission = sdkVersion < ANDROID10 ? android.Manifest.permission.ACCESS_COARSE_LOCATION : android.Manifest.permission.ACCESS_FINE_LOCATION;
12221222

@@ -2848,17 +2848,6 @@ export class Bluetooth extends BluetoothCommon {
28482848
return adapter && adapter.isEnabled();
28492849
}
28502850

2851-
private _getContext() {
2852-
//noinspection JSUnresolvedVariable,JSUnresolvedFunction
2853-
const ctx = java.lang.Class.forName('android.app.AppGlobals').getMethod('getInitialApplication', null).invoke(null, null);
2854-
if (ctx) {
2855-
return ctx;
2856-
}
2857-
2858-
//noinspection JSUnresolvedVariable,JSUnresolvedFunction
2859-
return java.lang.Class.forName('android.app.ActivityThread').getMethod('currentApplication', null).invoke(null, null);
2860-
}
2861-
28622851
private _getActivity() {
28632852
const activity = andApp.foregroundActivity || andApp.startActivity;
28642853
if (activity === null) {

0 commit comments

Comments
 (0)