summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2019-11-04 07:41:20 -0800
committerRoshan Pius <rpius@google.com>2019-11-04 20:00:36 +0000
commit2b32e129f6d8bdcc379a69259f7ead31ab2bb195 (patch)
treead30f1bee086fc915cef0959ab9bb3a5a1c87838 /service
parentd958b3ebbed305a867d7ee55e01c7ae413e2a3f9 (diff)
WifiStack: Miscellaneous @hide dependency cleanups
a) JarJar HandlerExecutor b) Stop using HandlerThread.getHandlerThread() and instead created a new handler on the associated looper. c) Stop using withCleanCallingIdentity and instead use the regular clearCallingIdentity & restoreCallingIdentity. d) Stop using Bundle.setDefusable() and instead handle the BadParcelableException. e) Stop using Intent.getExtra and instead use Intent.getStringExtra. Bug: 142935310 Test: Compiles Change-Id: Ie17cf3524815b75607b7ac0b6d4720d5da8abbdb
Diffstat (limited to 'service')
-rw-r--r--service/jarjar-rules-shared.txt2
-rw-r--r--service/java/com/android/server/wifi/AvailableNetworkNotifier.java2
-rw-r--r--service/java/com/android/server/wifi/WifiInjector.java4
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java23
-rw-r--r--service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java77
5 files changed, 80 insertions, 28 deletions
diff --git a/service/jarjar-rules-shared.txt b/service/jarjar-rules-shared.txt
index bdfb825ab..8fa2b1a1e 100644
--- a/service/jarjar-rules-shared.txt
+++ b/service/jarjar-rules-shared.txt
@@ -17,6 +17,8 @@ rule android.util.Rational* com.android.server.wifi.util.Rational@1
rule android.util.proto.ProtoStream* com.android.server.wifi.util.proto.ProtoStream@1
rule android.util.proto.ProtoOutputStream* com.android.server.wifi.util.proto.ProtoOutputStream@1
+rule android.os.HandlerExecutor* com.android.server.wifi.os.HandlerExecutor@1
+
# Use our statically linked bouncy castle library
rule org.bouncycastle.** com.android.server.wifi.bouncycastle.@1
# Use our statically linked protobuf library
diff --git a/service/java/com/android/server/wifi/AvailableNetworkNotifier.java b/service/java/com/android/server/wifi/AvailableNetworkNotifier.java
index bbfedaf91..eabc689a1 100644
--- a/service/java/com/android/server/wifi/AvailableNetworkNotifier.java
+++ b/service/java/com/android/server/wifi/AvailableNetworkNotifier.java
@@ -198,7 +198,7 @@ public class AvailableNetworkNotifier {
new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- if (!mTag.equals(intent.getExtra(AVAILABLE_NETWORK_NOTIFIER_TAG))) {
+ if (!mTag.equals(intent.getStringExtra(AVAILABLE_NETWORK_NOTIFIER_TAG))) {
return;
}
switch (intent.getAction()) {
diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java
index def635a45..219373501 100644
--- a/service/java/com/android/server/wifi/WifiInjector.java
+++ b/service/java/com/android/server/wifi/WifiInjector.java
@@ -188,7 +188,7 @@ public class WifiInjector {
mWifiHandlerThread = new HandlerThread("WifiHandlerThread");
mWifiHandlerThread.start();
Looper wifiLooper = mWifiHandlerThread.getLooper();
- Handler wifiHandler = mWifiHandlerThread.getThreadHandler();
+ Handler wifiHandler = new Handler(wifiLooper);
mWifiThreadRunner = new WifiThreadRunner(wifiHandler);
mWifiP2pServiceHandlerThread = new HandlerThread("WifiP2pService");
mWifiP2pServiceHandlerThread.start();
@@ -587,7 +587,7 @@ public class WifiInjector {
mWifiConfigManager, clientModeImpl.getWifiInfo(),
mWifiNetworkSelector, mWifiConnectivityHelper,
mWifiLastResortWatchdog, mOpenNetworkNotifier,
- mCarrierNetworkConfig, mWifiMetrics, mWifiHandlerThread.getThreadHandler(),
+ mCarrierNetworkConfig, mWifiMetrics, new Handler(mWifiHandlerThread.getLooper()),
mClock, mConnectivityLocalLog);
}
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index b459bb2f6..d9174d194 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -1361,10 +1361,14 @@ public class WifiServiceImpl extends BaseWifiService {
return LocalOnlyHotspotCallback.ERROR_GENERIC;
}
enforceLocationPermission(packageName, uid);
- // also need to verify that Locations services are enabled.
- if (!Binder.withCleanCallingIdentity(
- () -> mWifiPermissionsUtil.isLocationModeEnabled())) {
- throw new SecurityException("Location mode is not enabled.");
+ long ident = Binder.clearCallingIdentity();
+ try {
+ // also need to verify that Locations services are enabled.
+ if (!mWifiPermissionsUtil.isLocationModeEnabled()) {
+ throw new SecurityException("Location mode is not enabled.");
+ }
+ } finally {
+ Binder.restoreCallingIdentity(ident);
}
} else {
if (!isSettingsOrSuw(Binder.getCallingPid(), Binder.getCallingUid())) {
@@ -1379,9 +1383,14 @@ public class WifiServiceImpl extends BaseWifiService {
}
// the app should be in the foreground
- if (!Binder.withCleanCallingIdentity(
- () -> mFrameworkFacade.isAppForeground(mContext, uid))) {
- return LocalOnlyHotspotCallback.ERROR_INCOMPATIBLE_MODE;
+ long ident = Binder.clearCallingIdentity();
+ try {
+ // also need to verify that Locations services are enabled.
+ if (!mFrameworkFacade.isAppForeground(mContext, uid)) {
+ return LocalOnlyHotspotCallback.ERROR_INCOMPATIBLE_MODE;
+ }
+ } finally {
+ Binder.restoreCallingIdentity(ident);
}
// check if we are currently tethering
diff --git a/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java b/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java
index 1319ea5ae..3adf26f49 100644
--- a/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java
+++ b/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java
@@ -31,6 +31,7 @@ import android.net.wifi.WifiScanner.ScanData;
import android.net.wifi.WifiScanner.ScanSettings;
import android.net.wifi.WifiScanner.WifiBand;
import android.net.wifi.WifiStackClient;
+import android.os.BadParcelableException;
import android.os.BatteryStatsManager;
import android.os.Binder;
import android.os.Bundle;
@@ -872,11 +873,23 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
replyFailed(msg, WifiScanner.REASON_INVALID_REQUEST, "params null");
return HANDLED;
}
- scanParams.setDefusable(true);
- ScanSettings scanSettings =
- scanParams.getParcelable(WifiScanner.SCAN_PARAMS_SCAN_SETTINGS_KEY);
- WorkSource workSource =
- scanParams.getParcelable(WifiScanner.SCAN_PARAMS_WORK_SOURCE_KEY);
+ ScanSettings scanSettings = null;
+ WorkSource workSource = null;
+ try {
+ scanSettings =
+ scanParams.getParcelable(
+ WifiScanner.SCAN_PARAMS_SCAN_SETTINGS_KEY);
+ workSource =
+ scanParams.getParcelable(
+ WifiScanner.SCAN_PARAMS_WORK_SOURCE_KEY);
+ } catch (BadParcelableException e) {
+ Log.e(TAG, "Failed to get parcelable params", e);
+ logCallback("singleScanInvalidRequest", ci, handler,
+ "bad parcel params");
+ replyFailed(msg, WifiScanner.REASON_INVALID_REQUEST,
+ "bad parcel params");
+ return HANDLED;
+ }
if (validateScanRequest(ci, handler, scanSettings)) {
mWifiMetrics.incrementOneshotScanCount();
if (scanSettings.band == WifiScanner.WIFI_BAND_5_GHZ_DFS_ONLY
@@ -1449,11 +1462,21 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
replyFailed(msg, WifiScanner.REASON_INVALID_REQUEST, "params null");
return HANDLED;
}
- scanParams.setDefusable(true);
- ScanSettings scanSettings =
- scanParams.getParcelable(WifiScanner.SCAN_PARAMS_SCAN_SETTINGS_KEY);
- WorkSource workSource =
- scanParams.getParcelable(WifiScanner.SCAN_PARAMS_WORK_SOURCE_KEY);
+ ScanSettings scanSettings = null;
+ WorkSource workSource = null;
+ try {
+ scanSettings =
+ scanParams.getParcelable(
+ WifiScanner.SCAN_PARAMS_SCAN_SETTINGS_KEY);
+ workSource =
+ scanParams.getParcelable(
+ WifiScanner.SCAN_PARAMS_WORK_SOURCE_KEY);
+ } catch (BadParcelableException e) {
+ Log.e(TAG, "Failed to get parcelable params", e);
+ replyFailed(msg, WifiScanner.REASON_INVALID_REQUEST,
+ "bad parcel params");
+ return HANDLED;
+ }
if (addBackgroundScanRequest(ci, msg.arg2, scanSettings, workSource)) {
replySucceeded(msg);
} else {
@@ -1941,9 +1964,17 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
replyFailed(msg, WifiScanner.REASON_INVALID_REQUEST, "params null");
return HANDLED;
}
- pnoParams.setDefusable(true);
- PnoSettings pnoSettings =
- pnoParams.getParcelable(WifiScanner.PNO_PARAMS_PNO_SETTINGS_KEY);
+ PnoSettings pnoSettings = null;
+ try {
+ pnoSettings =
+ pnoParams.getParcelable(
+ WifiScanner.PNO_PARAMS_PNO_SETTINGS_KEY);
+ } catch (BadParcelableException e) {
+ Log.e(TAG, "Failed to get parcelable params", e);
+ replyFailed(msg, WifiScanner.REASON_INVALID_REQUEST,
+ "bad parcel params");
+ return HANDLED;
+ }
if (mScannerImplsTracker.isHwPnoSupported(pnoSettings.isConnected)) {
deferMessage(msg);
transitionTo(mHwPnoScanState);
@@ -1984,11 +2015,21 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
replyFailed(msg, WifiScanner.REASON_INVALID_REQUEST, "params null");
return HANDLED;
}
- pnoParams.setDefusable(true);
- PnoSettings pnoSettings =
- pnoParams.getParcelable(WifiScanner.PNO_PARAMS_PNO_SETTINGS_KEY);
- ScanSettings scanSettings =
- pnoParams.getParcelable(WifiScanner.PNO_PARAMS_SCAN_SETTINGS_KEY);
+ PnoSettings pnoSettings = null;
+ ScanSettings scanSettings = null;
+ try {
+ pnoSettings =
+ pnoParams.getParcelable(
+ WifiScanner.PNO_PARAMS_PNO_SETTINGS_KEY);
+ scanSettings =
+ pnoParams.getParcelable(
+ WifiScanner.PNO_PARAMS_SCAN_SETTINGS_KEY);
+ } catch (BadParcelableException e) {
+ Log.e(TAG, "Failed to get parcelable params", e);
+ replyFailed(msg, WifiScanner.REASON_INVALID_REQUEST,
+ "bad parcel params");
+ return HANDLED;
+ }
if (addHwPnoScanRequest(ci, msg.arg2, scanSettings, pnoSettings)) {
replySucceeded(msg);
} else {