Merge changes from topics "suggestion_no_uid_package", "wifi_key_value_list_parser", "wifi_power_profile", "wifi_service_manager_getService", "wifi_westworld"
* changes:
statsd: Allow wifi mainline module to log its metrics
wifi-services-srcs: Stop using KeyValueListParser from android.internal
WifiNetworkSuggestion: Don't store packageName/uid
WifiAwareManager: Add requestMacAddresses @hide API
UserManager: Add StringDef for all restrictionKey values
WifiActivityEnergyInfo: Use time values for energy calculation
diff --git a/Android.bp b/Android.bp
index 3dd8a0a..8daee86 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1680,16 +1680,13 @@
}
filegroup {
- name: "framework-wifistack-shared-srcs",
+ name: "framework-wifi-service-shared-srcs",
srcs: [
":framework-annotations",
"core/java/android/os/HandlerExecutor.java",
"core/java/android/util/BackupUtils.java",
- "core/java/android/util/KeyValueListParser.java",
"core/java/android/util/LocalLog.java",
"core/java/android/util/Rational.java",
- "core/java/android/util/proto/ProtoStream.java",
- "core/java/android/util/proto/ProtoOutputStream.java",
"core/java/com/android/internal/util/FastXmlSerializer.java",
"core/java/com/android/internal/util/HexDump.java",
"core/java/com/android/internal/util/IState.java",
diff --git a/api/system-current.txt b/api/system-current.txt
index 3c0923c..940da988 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -6624,7 +6624,7 @@
}
public final class WifiActivityEnergyInfo implements android.os.Parcelable {
- ctor public WifiActivityEnergyInfo(long, int, long, long, long, long, long);
+ ctor public WifiActivityEnergyInfo(long, int, long, long, long, long);
method public int describeContents();
method public long getControllerEnergyUsedMicroJoules();
method public long getControllerIdleDurationMillis();
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto
index ed49b74..e7e8995 100644
--- a/cmds/statsd/src/atoms.proto
+++ b/cmds/statsd/src/atoms.proto
@@ -112,7 +112,7 @@
TouchEventReported touch_event_reported = 34;
WakeupAlarmOccurred wakeup_alarm_occurred = 35;
KernelWakeupReported kernel_wakeup_reported = 36;
- WifiLockStateChanged wifi_lock_state_changed = 37;
+ WifiLockStateChanged wifi_lock_state_changed = 37 [(log_from_module) = "wifi"];
WifiSignalStrengthChanged wifi_signal_strength_changed = 38;
WifiScanStateChanged wifi_scan_state_changed = 39;
PhoneSignalStrengthChanged phone_signal_strength_changed = 40;
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index a003379..915e457 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -7916,7 +7916,8 @@
* for the list of keys.
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
- public void addUserRestriction(@NonNull ComponentName admin, String key) {
+ public void addUserRestriction(@NonNull ComponentName admin,
+ @UserManager.UserRestrictionKey String key) {
throwIfParentInstance("addUserRestriction");
if (mService != null) {
try {
@@ -7938,7 +7939,8 @@
* for the list of keys.
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
- public void clearUserRestriction(@NonNull ComponentName admin, String key) {
+ public void clearUserRestriction(@NonNull ComponentName admin,
+ @UserManager.UserRestrictionKey String key) {
throwIfParentInstance("clearUserRestriction");
if (mService != null) {
try {
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index 9e9cd92..137f537 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -24,6 +24,7 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
+import android.annotation.StringDef;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.TestApi;
@@ -1112,6 +1113,82 @@
*/
public static final String KEY_RESTRICTIONS_PENDING = "restrictions_pending";
+ /**
+ * List of key values that can be passed into the various user restriction related methods
+ * in {@link UserManager} & {@link DevicePolicyManager}.
+ * Note: This is slightly different from the real set of user restrictions listed in {@link
+ * com.android.server.pm.UserRestrictionsUtils#USER_RESTRICTIONS}. For example
+ * {@link #KEY_RESTRICTIONS_PENDING} is not a real user restriction, but is a a legitimate
+ * value that can be passed into {@link #hasUserRestriction(String)}.
+ * @hide
+ */
+ @StringDef(value = {
+ DISALLOW_MODIFY_ACCOUNTS,
+ DISALLOW_CONFIG_WIFI,
+ DISALLOW_CONFIG_LOCALE,
+ DISALLOW_INSTALL_APPS,
+ DISALLOW_UNINSTALL_APPS,
+ DISALLOW_SHARE_LOCATION,
+ DISALLOW_AIRPLANE_MODE,
+ DISALLOW_CONFIG_BRIGHTNESS,
+ DISALLOW_AMBIENT_DISPLAY,
+ DISALLOW_CONFIG_SCREEN_TIMEOUT,
+ DISALLOW_INSTALL_UNKNOWN_SOURCES,
+ DISALLOW_INSTALL_UNKNOWN_SOURCES_GLOBALLY,
+ DISALLOW_CONFIG_BLUETOOTH,
+ DISALLOW_BLUETOOTH,
+ DISALLOW_BLUETOOTH_SHARING,
+ DISALLOW_USB_FILE_TRANSFER,
+ DISALLOW_CONFIG_CREDENTIALS,
+ DISALLOW_REMOVE_USER,
+ DISALLOW_REMOVE_MANAGED_PROFILE,
+ DISALLOW_DEBUGGING_FEATURES,
+ DISALLOW_CONFIG_VPN,
+ DISALLOW_CONFIG_LOCATION,
+ DISALLOW_CONFIG_DATE_TIME,
+ DISALLOW_CONFIG_TETHERING,
+ DISALLOW_NETWORK_RESET,
+ DISALLOW_FACTORY_RESET,
+ DISALLOW_ADD_USER,
+ DISALLOW_ADD_MANAGED_PROFILE,
+ ENSURE_VERIFY_APPS,
+ DISALLOW_CONFIG_CELL_BROADCASTS,
+ DISALLOW_CONFIG_MOBILE_NETWORKS,
+ DISALLOW_APPS_CONTROL,
+ DISALLOW_MOUNT_PHYSICAL_MEDIA,
+ DISALLOW_UNMUTE_MICROPHONE,
+ DISALLOW_ADJUST_VOLUME,
+ DISALLOW_OUTGOING_CALLS,
+ DISALLOW_SMS,
+ DISALLOW_FUN,
+ DISALLOW_CREATE_WINDOWS,
+ DISALLOW_SYSTEM_ERROR_DIALOGS,
+ DISALLOW_CROSS_PROFILE_COPY_PASTE,
+ DISALLOW_OUTGOING_BEAM,
+ DISALLOW_WALLPAPER,
+ DISALLOW_SET_WALLPAPER,
+ DISALLOW_SAFE_BOOT,
+ DISALLOW_RECORD_AUDIO,
+ DISALLOW_RUN_IN_BACKGROUND,
+ DISALLOW_CAMERA,
+ DISALLOW_UNMUTE_DEVICE,
+ DISALLOW_DATA_ROAMING,
+ DISALLOW_SET_USER_ICON,
+ DISALLOW_OEM_UNLOCK,
+ DISALLOW_UNIFIED_PASSWORD,
+ ALLOW_PARENT_PROFILE_APP_LINKING,
+ DISALLOW_AUTOFILL,
+ DISALLOW_CONTENT_CAPTURE,
+ DISALLOW_CONTENT_SUGGESTIONS,
+ DISALLOW_USER_SWITCH,
+ DISALLOW_SHARE_INTO_MANAGED_PROFILE,
+ DISALLOW_PRINTING,
+ DISALLOW_CONFIG_PRIVATE_DNS,
+ KEY_RESTRICTIONS_PENDING,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface UserRestrictionKey {}
+
private static final String ACTION_CREATE_USER = "android.os.action.CREATE_USER";
/**
@@ -2026,7 +2103,8 @@
@SystemApi
@UserRestrictionSource
@RequiresPermission(android.Manifest.permission.MANAGE_USERS)
- public int getUserRestrictionSource(String restrictionKey, UserHandle userHandle) {
+ public int getUserRestrictionSource(@UserRestrictionKey String restrictionKey,
+ UserHandle userHandle) {
try {
return mService.getUserRestrictionSource(restrictionKey, userHandle.getIdentifier());
} catch (RemoteException re) {
@@ -2045,7 +2123,7 @@
@SystemApi
@RequiresPermission(android.Manifest.permission.MANAGE_USERS)
public List<EnforcingUser> getUserRestrictionSources(
- String restrictionKey, UserHandle userHandle) {
+ @UserRestrictionKey String restrictionKey, UserHandle userHandle) {
try {
return mService.getUserRestrictionSources(restrictionKey, userHandle.getIdentifier());
} catch (RemoteException re) {
@@ -2091,7 +2169,8 @@
* @param userHandle the UserHandle of the user for whom to retrieve the restrictions.
*/
@UnsupportedAppUsage
- public boolean hasBaseUserRestriction(String restrictionKey, UserHandle userHandle) {
+ public boolean hasBaseUserRestriction(@UserRestrictionKey String restrictionKey,
+ UserHandle userHandle) {
try {
return mService.hasBaseUserRestriction(restrictionKey, userHandle.getIdentifier());
} catch (RemoteException re) {
@@ -2162,7 +2241,7 @@
* @param restrictionKey The string key representing the restriction.
* @return {@code true} if the current user has the given restriction, {@code false} otherwise.
*/
- public boolean hasUserRestriction(String restrictionKey) {
+ public boolean hasUserRestriction(@UserRestrictionKey String restrictionKey) {
return hasUserRestrictionForUser(restrictionKey, Process.myUserHandle());
}
@@ -2174,7 +2253,8 @@
* @param userHandle the UserHandle of the user for whom to retrieve the restrictions.
*/
@UnsupportedAppUsage
- public boolean hasUserRestriction(String restrictionKey, UserHandle userHandle) {
+ public boolean hasUserRestriction(@UserRestrictionKey String restrictionKey,
+ UserHandle userHandle) {
return hasUserRestrictionForUser(restrictionKey, userHandle);
}
@@ -2194,7 +2274,7 @@
@RequiresPermission(anyOf = {
android.Manifest.permission.MANAGE_USERS,
android.Manifest.permission.INTERACT_ACROSS_USERS}, conditional = true)
- public boolean hasUserRestrictionForUser(@NonNull String restrictionKey,
+ public boolean hasUserRestrictionForUser(@NonNull @UserRestrictionKey String restrictionKey,
@NonNull UserHandle userHandle) {
try {
return mService.hasUserRestriction(restrictionKey, userHandle.getIdentifier());
@@ -2207,7 +2287,7 @@
* @hide
* Returns whether any user on the device has the given user restriction set.
*/
- public boolean hasUserRestrictionOnAnyUser(String restrictionKey) {
+ public boolean hasUserRestrictionOnAnyUser(@UserRestrictionKey String restrictionKey) {
try {
return mService.hasUserRestrictionOnAnyUser(restrictionKey);
} catch (RemoteException re) {
diff --git a/core/java/android/os/connectivity/WifiActivityEnergyInfo.java b/core/java/android/os/connectivity/WifiActivityEnergyInfo.java
index 7db003d..664b6c8 100644
--- a/core/java/android/os/connectivity/WifiActivityEnergyInfo.java
+++ b/core/java/android/os/connectivity/WifiActivityEnergyInfo.java
@@ -19,9 +19,13 @@
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.SystemApi;
+import android.app.ActivityThread;
+import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;
+import com.android.internal.os.PowerProfile;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -72,7 +76,6 @@
* @param scanDurationMillis Cumulative milliseconds when radio is awake due to scan.
* @param idleDurationMillis Cumulative milliseconds when radio is awake but not transmitting or
* receiving.
- * @param energyUsedMicroJoules Cumulative energy consumed by Wifi, in microjoules.
*/
public WifiActivityEnergyInfo(
long timeSinceBootMillis,
@@ -80,14 +83,33 @@
long txDurationMillis,
long rxDurationMillis,
long scanDurationMillis,
- long idleDurationMillis,
- long energyUsedMicroJoules) {
+ long idleDurationMillis) {
mTimeSinceBootMillis = timeSinceBootMillis;
mStackState = stackState;
mControllerTxDurationMillis = txDurationMillis;
mControllerRxDurationMillis = rxDurationMillis;
mControllerScanDurationMillis = scanDurationMillis;
mControllerIdleDurationMillis = idleDurationMillis;
+
+ final Context context = ActivityThread.currentActivityThread().getSystemContext();
+ if (context == null) {
+ mControllerEnergyUsedMicroJoules = 0L;
+ return;
+ }
+ // Calculate energy used using PowerProfile.
+ PowerProfile powerProfile = new PowerProfile(context);
+ final double rxIdleCurrent = powerProfile.getAveragePower(
+ PowerProfile.POWER_WIFI_CONTROLLER_IDLE);
+ final double rxCurrent = powerProfile.getAveragePower(
+ PowerProfile.POWER_WIFI_CONTROLLER_RX);
+ final double txCurrent = powerProfile.getAveragePower(
+ PowerProfile.POWER_WIFI_CONTROLLER_TX);
+ final double voltage = powerProfile.getAveragePower(
+ PowerProfile.POWER_WIFI_CONTROLLER_OPERATING_VOLTAGE) / 1000.0;
+ final long energyUsedMicroJoules = (long) ((mControllerTxDurationMillis * txCurrent
+ + mControllerRxDurationMillis * rxCurrent
+ + mControllerIdleDurationMillis * rxIdleCurrent)
+ * voltage);
mControllerEnergyUsedMicroJoules = energyUsedMicroJoules;
}
@@ -113,9 +135,8 @@
long rxTime = in.readLong();
long scanTime = in.readLong();
long idleTime = in.readLong();
- long energyUsed = in.readLong();
return new WifiActivityEnergyInfo(timestamp, stackState,
- txTime, rxTime, scanTime, idleTime, energyUsed);
+ txTime, rxTime, scanTime, idleTime);
}
public WifiActivityEnergyInfo[] newArray(int size) {
return new WifiActivityEnergyInfo[size];
@@ -130,7 +151,6 @@
out.writeLong(mControllerRxDurationMillis);
out.writeLong(mControllerScanDurationMillis);
out.writeLong(mControllerIdleDurationMillis);
- out.writeLong(mControllerEnergyUsedMicroJoules);
}
@Override
diff --git a/services/core/java/com/android/server/am/BatteryExternalStatsWorker.java b/services/core/java/com/android/server/am/BatteryExternalStatsWorker.java
index 38030c2..cf996a5 100644
--- a/services/core/java/com/android/server/am/BatteryExternalStatsWorker.java
+++ b/services/core/java/com/android/server/am/BatteryExternalStatsWorker.java
@@ -125,7 +125,7 @@
// Keep the last WiFi stats so we can compute a delta.
@GuardedBy("mWorkerLock")
private WifiActivityEnergyInfo mLastInfo =
- new WifiActivityEnergyInfo(0, 0, 0, 0, 0, 0, 0);
+ new WifiActivityEnergyInfo(0, 0, 0, 0, 0, 0);
/**
* Timestamp at which all external stats were last collected in
diff --git a/wifi/java/android/net/wifi/WifiNetworkSuggestion.java b/wifi/java/android/net/wifi/WifiNetworkSuggestion.java
index e78104d..9fd29ae 100644
--- a/wifi/java/android/net/wifi/WifiNetworkSuggestion.java
+++ b/wifi/java/android/net/wifi/WifiNetworkSuggestion.java
@@ -23,12 +23,10 @@
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
-import android.app.ActivityThread;
import android.net.MacAddress;
import android.net.wifi.hotspot2.PasspointConfiguration;
import android.os.Parcel;
import android.os.Parcelable;
-import android.os.Process;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
@@ -46,7 +44,6 @@
* {@link WifiManager#addNetworkSuggestions(List)}.
*/
public final class WifiNetworkSuggestion implements Parcelable {
-
/**
* Builder used to create {@link WifiNetworkSuggestion} objects.
*/
@@ -563,9 +560,7 @@
mPasspointConfiguration,
mIsAppInteractionRequired,
mIsUserInteractionRequired,
- mIsUserAllowed,
- Process.myUid(),
- ActivityThread.currentApplication().getApplicationContext().getOpPackageName());
+ mIsUserAllowed);
}
}
@@ -592,19 +587,6 @@
* @hide
*/
public final boolean isUserInteractionRequired;
-
- /**
- * The UID of the process initializing this network suggestion.
- * @hide
- */
- public final int suggestorUid;
-
- /**
- * The package name of the process initializing this network suggestion.
- * @hide
- */
- public final String suggestorPackageName;
-
/**
* Whether app share credential with the user, allow user use provided credential to
* connect network manually.
@@ -619,8 +601,6 @@
this.isAppInteractionRequired = false;
this.isUserInteractionRequired = false;
this.isUserAllowedToManuallyConnect = true;
- this.suggestorUid = -1;
- this.suggestorPackageName = null;
}
/** @hide */
@@ -628,18 +608,14 @@
@Nullable PasspointConfiguration passpointConfiguration,
boolean isAppInteractionRequired,
boolean isUserInteractionRequired,
- boolean isUserAllowedToManuallyConnect,
- int suggestorUid, @NonNull String suggestorPackageName) {
+ boolean isUserAllowedToManuallyConnect) {
checkNotNull(networkConfiguration);
- checkNotNull(suggestorPackageName);
this.wifiConfiguration = networkConfiguration;
this.passpointConfiguration = passpointConfiguration;
this.isAppInteractionRequired = isAppInteractionRequired;
this.isUserInteractionRequired = isUserInteractionRequired;
this.isUserAllowedToManuallyConnect = isUserAllowedToManuallyConnect;
- this.suggestorUid = suggestorUid;
- this.suggestorPackageName = suggestorPackageName;
}
public static final @NonNull Creator<WifiNetworkSuggestion> CREATOR =
@@ -651,9 +627,7 @@
in.readParcelable(null), // PasspointConfiguration
in.readBoolean(), // isAppInteractionRequired
in.readBoolean(), // isUserInteractionRequired
- in.readBoolean(), // isSharedCredentialWithUser
- in.readInt(), // suggestorUid
- in.readString() // suggestorPackageName
+ in.readBoolean() // isSharedCredentialWithUser
);
}
@@ -675,15 +649,12 @@
dest.writeBoolean(isAppInteractionRequired);
dest.writeBoolean(isUserInteractionRequired);
dest.writeBoolean(isUserAllowedToManuallyConnect);
- dest.writeInt(suggestorUid);
- dest.writeString(suggestorPackageName);
}
@Override
public int hashCode() {
return Objects.hash(wifiConfiguration.SSID, wifiConfiguration.BSSID,
- wifiConfiguration.allowedKeyManagement, wifiConfiguration.FQDN,
- suggestorUid, suggestorPackageName);
+ wifiConfiguration.allowedKeyManagement, wifiConfiguration.FQDN);
}
/**
@@ -706,23 +677,19 @@
&& TextUtils.equals(this.wifiConfiguration.BSSID, lhs.wifiConfiguration.BSSID)
&& Objects.equals(this.wifiConfiguration.allowedKeyManagement,
lhs.wifiConfiguration.allowedKeyManagement)
- && TextUtils.equals(this.wifiConfiguration.FQDN, lhs.wifiConfiguration.FQDN)
- && this.suggestorUid == lhs.suggestorUid
- && TextUtils.equals(this.suggestorPackageName, lhs.suggestorPackageName);
+ && TextUtils.equals(this.wifiConfiguration.FQDN, lhs.wifiConfiguration.FQDN);
}
@Override
public String toString() {
- StringBuilder sb = new StringBuilder("WifiNetworkSuggestion [")
- .append(", SSID=").append(wifiConfiguration.SSID)
+ StringBuilder sb = new StringBuilder("WifiNetworkSuggestion[ ")
+ .append("SSID=").append(wifiConfiguration.SSID)
.append(", BSSID=").append(wifiConfiguration.BSSID)
.append(", FQDN=").append(wifiConfiguration.FQDN)
.append(", isAppInteractionRequired=").append(isAppInteractionRequired)
.append(", isUserInteractionRequired=").append(isUserInteractionRequired)
.append(", isUserAllowedToManuallyConnect=").append(isUserAllowedToManuallyConnect)
- .append(", suggestorUid=").append(suggestorUid)
- .append(", suggestorPackageName=").append(suggestorPackageName)
- .append("]");
+ .append(" ]");
return sb.toString();
}
}
diff --git a/wifi/java/android/net/wifi/aware/WifiAwareManager.java b/wifi/java/android/net/wifi/aware/WifiAwareManager.java
index 65a6c4d..81bf81e 100644
--- a/wifi/java/android/net/wifi/aware/WifiAwareManager.java
+++ b/wifi/java/android/net/wifi/aware/WifiAwareManager.java
@@ -19,6 +19,7 @@
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SystemService;
@@ -396,6 +397,17 @@
}
/** @hide */
+ @RequiresPermission(android.Manifest.permission.NETWORK_STACK)
+ public void requestMacAddresses(int uid, List<Integer> peerIds,
+ IWifiAwareMacAddressProvider callback) {
+ try {
+ mService.requestMacAddresses(uid, peerIds, callback);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /** @hide */
public NetworkSpecifier createNetworkSpecifier(int clientId, int role, int sessionId,
@NonNull PeerHandle peerHandle, @Nullable byte[] pmk, @Nullable String passphrase) {
if (VDBG) {
diff --git a/wifi/tests/src/android/net/wifi/WifiManagerTest.java b/wifi/tests/src/android/net/wifi/WifiManagerTest.java
index de45149..ac33040 100644
--- a/wifi/tests/src/android/net/wifi/WifiManagerTest.java
+++ b/wifi/tests/src/android/net/wifi/WifiManagerTest.java
@@ -161,7 +161,7 @@
mRunnable.run();
}
};
- mWifiActivityEnergyInfo = new WifiActivityEnergyInfo(0, 0, 0, 0, 0, 0, 0);
+ mWifiActivityEnergyInfo = new WifiActivityEnergyInfo(0, 0, 0, 0, 0, 0);
}
/**
@@ -1713,7 +1713,7 @@
@Test
public void testGetControllerActivityEnergyInfo() throws Exception {
WifiActivityEnergyInfo activityEnergyInfo =
- new WifiActivityEnergyInfo(5, 3, 3, 5, 5, 5, 5);
+ new WifiActivityEnergyInfo(5, 3, 3, 5, 5, 5);
when(mWifiService.reportActivityInfo()).thenReturn(activityEnergyInfo);
assertEquals(activityEnergyInfo, mWifiManager.getControllerActivityEnergyInfo());
diff --git a/wifi/tests/src/android/net/wifi/WifiNetworkSuggestionTest.java b/wifi/tests/src/android/net/wifi/WifiNetworkSuggestionTest.java
index 8a5a0fd..04aaa0b 100644
--- a/wifi/tests/src/android/net/wifi/WifiNetworkSuggestionTest.java
+++ b/wifi/tests/src/android/net/wifi/WifiNetworkSuggestionTest.java
@@ -22,7 +22,6 @@
import android.net.wifi.hotspot2.PasspointConfiguration;
import android.net.wifi.hotspot2.PasspointTestUtils;
import android.os.Parcel;
-import android.os.Process;
import androidx.test.filters.SmallTest;
@@ -35,8 +34,6 @@
public class WifiNetworkSuggestionTest {
private static final int TEST_UID = 45677;
private static final int TEST_UID_OTHER = 45673;
- private static final String TEST_PACKAGE_NAME = "com.test.packagename";
- private static final String TEST_PACKAGE_NAME_OTHER = "com.test.packagenameother";
private static final String TEST_SSID = "\"Test123\"";
private static final String TEST_BSSID = "12:12:12:12:12:12";
private static final String TEST_SSID_1 = "\"Test1234\"";
@@ -55,7 +52,6 @@
.setIsAppInteractionRequired(true)
.build();
- assertEquals(Process.myUid(), suggestion.suggestorUid);
assertEquals("\"" + TEST_SSID + "\"", suggestion.wifiConfiguration.SSID);
assertTrue(suggestion.wifiConfiguration.allowedKeyManagement
.get(WifiConfiguration.KeyMgmt.NONE));
@@ -448,7 +444,7 @@
configuration.BSSID = TEST_BSSID;
configuration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
WifiNetworkSuggestion suggestion = new WifiNetworkSuggestion(
- configuration, null, false, true, true, TEST_UID, TEST_PACKAGE_NAME);
+ configuration, null, false, true, true);
Parcel parcelW = Parcel.obtain();
suggestion.writeToParcel(parcelW, 0);
@@ -515,16 +511,14 @@
configuration.BSSID = TEST_BSSID;
configuration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
WifiNetworkSuggestion suggestion =
- new WifiNetworkSuggestion(configuration, null, true, false, true, TEST_UID,
- TEST_PACKAGE_NAME);
+ new WifiNetworkSuggestion(configuration, null, true, false, true);
WifiConfiguration configuration1 = new WifiConfiguration();
configuration1.SSID = TEST_SSID;
configuration1.BSSID = TEST_BSSID;
configuration1.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
WifiNetworkSuggestion suggestion1 =
- new WifiNetworkSuggestion(configuration1, null, false, true, true, TEST_UID,
- TEST_PACKAGE_NAME);
+ new WifiNetworkSuggestion(configuration1, null, false, true, true);
assertEquals(suggestion, suggestion1);
assertEquals(suggestion.hashCode(), suggestion1.hashCode());
@@ -540,15 +534,13 @@
configuration.SSID = TEST_SSID;
configuration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
WifiNetworkSuggestion suggestion =
- new WifiNetworkSuggestion(configuration, null, false, false, true, TEST_UID,
- TEST_PACKAGE_NAME);
+ new WifiNetworkSuggestion(configuration, null, false, false, true);
WifiConfiguration configuration1 = new WifiConfiguration();
configuration1.SSID = TEST_SSID_1;
configuration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
WifiNetworkSuggestion suggestion1 =
- new WifiNetworkSuggestion(configuration1, null, false, false, true, TEST_UID,
- TEST_PACKAGE_NAME);
+ new WifiNetworkSuggestion(configuration1, null, false, false, true);
assertNotEquals(suggestion, suggestion1);
}
@@ -564,15 +556,13 @@
configuration.BSSID = TEST_BSSID;
configuration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
WifiNetworkSuggestion suggestion =
- new WifiNetworkSuggestion(configuration, null, false, false, true, TEST_UID,
- TEST_PACKAGE_NAME);
+ new WifiNetworkSuggestion(configuration, null, false, false, true);
WifiConfiguration configuration1 = new WifiConfiguration();
configuration1.SSID = TEST_SSID;
configuration1.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
WifiNetworkSuggestion suggestion1 =
- new WifiNetworkSuggestion(configuration1, null, false, false, true, TEST_UID,
- TEST_PACKAGE_NAME);
+ new WifiNetworkSuggestion(configuration1, null, false, false, true);
assertNotEquals(suggestion, suggestion1);
}
@@ -587,57 +577,18 @@
configuration.SSID = TEST_SSID;
configuration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
WifiNetworkSuggestion suggestion =
- new WifiNetworkSuggestion(configuration, null, false, false, true, TEST_UID,
- TEST_PACKAGE_NAME);
+ new WifiNetworkSuggestion(configuration, null, false, false, true);
WifiConfiguration configuration1 = new WifiConfiguration();
configuration1.SSID = TEST_SSID;
configuration1.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
WifiNetworkSuggestion suggestion1 =
- new WifiNetworkSuggestion(configuration1, null, false, false, true, TEST_UID,
- TEST_PACKAGE_NAME);
+ new WifiNetworkSuggestion(configuration1, null, false, false, true);
assertNotEquals(suggestion, suggestion1);
}
/**
- * Check NetworkSuggestion equals returns {@code false} for 2 network suggestions with the same
- * SSID, BSSID and key mgmt, but different UID.
- */
- @Test
- public void testWifiNetworkSuggestionEqualsFailsWhenUidIsDifferent() {
- WifiConfiguration configuration = new WifiConfiguration();
- configuration.SSID = TEST_SSID;
- configuration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
- WifiNetworkSuggestion suggestion =
- new WifiNetworkSuggestion(configuration, null, false, false, true, TEST_UID,
- TEST_PACKAGE_NAME);
-
- WifiNetworkSuggestion suggestion1 =
- new WifiNetworkSuggestion(configuration, null, false, false, true, TEST_UID_OTHER,
- TEST_PACKAGE_NAME);
-
- assertNotEquals(suggestion, suggestion1);
- }
-
- /**
- * Check NetworkSuggestion equals returns {@code false} for 2 network suggestions with the same
- * SSID, BSSID and key mgmt, but different package name.
- */
- @Test
- public void testWifiNetworkSuggestionEqualsFailsWhenPackageNameIsDifferent() {
- WifiConfiguration configuration = new WifiConfiguration();
- configuration.SSID = TEST_SSID;
- configuration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
- WifiNetworkSuggestion suggestion = new WifiNetworkSuggestion(
- configuration, null, false, false, true, TEST_UID, TEST_PACKAGE_NAME);
-
- WifiNetworkSuggestion suggestion1 = new WifiNetworkSuggestion(
- configuration, null, false, false, true, TEST_UID, TEST_PACKAGE_NAME_OTHER);
-
- assertNotEquals(suggestion, suggestion1);
- }
- /**
* Check NetworkSuggestion equals returns {@code true} for 2 Passpoint network suggestions with
* same FQDN.
*/