summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/FrameworkFacade.java11
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java10
2 files changed, 21 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/FrameworkFacade.java b/service/java/com/android/server/wifi/FrameworkFacade.java
index 2c3e5f7e0..ba114df8a 100644
--- a/service/java/com/android/server/wifi/FrameworkFacade.java
+++ b/service/java/com/android/server/wifi/FrameworkFacade.java
@@ -16,6 +16,7 @@
package com.android.server.wifi;
+import android.app.ActivityManager;
import android.app.AppGlobals;
import android.app.PendingIntent;
import android.content.Context;
@@ -161,4 +162,14 @@ public class FrameworkFacade {
public boolean inStorageManagerCryptKeeperBounce() {
return StorageManager.inCryptKeeperBounce();
}
+
+ /**
+ * Check if the provided uid is the app in the foreground.
+ * @param uid the uid to check
+ * @return true if the app is in the foreground, false otherwise
+ * @throws RemoteException
+ */
+ public boolean isAppForeground(int uid) throws RemoteException {
+ return ActivityManager.getService().isAppForeground(uid);
+ }
}
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index d3f5b13de..2dff54a50 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -1160,6 +1160,16 @@ public class WifiServiceImpl extends IWifiManager.Stub {
return LocalOnlyHotspotCallback.ERROR_TETHERING_DISALLOWED;
}
+ // the app should be in the foreground
+ try {
+ if (!mFrameworkFacade.isAppForeground(uid)) {
+ return LocalOnlyHotspotCallback.ERROR_INCOMPATIBLE_MODE;
+ }
+ } catch (RemoteException e) {
+ mLog.trace("RemoteException during isAppForeground when calling startLOHS");
+ return LocalOnlyHotspotCallback.ERROR_INCOMPATIBLE_MODE;
+ }
+
mLog.trace("startLocalOnlyHotspot uid=% pid=%").c(uid).c(pid).flush();
synchronized (mLocalOnlyHotspotRequests) {