summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/current.txt2
-rw-r--r--api/system-current.txt2
-rw-r--r--api/test-current.txt2
-rw-r--r--core/java/android/service/wallpaper/WallpaperService.java2
-rw-r--r--packages/SettingsLib/res/drawable/ic_lockscreen_ime.xml2
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/Utils.java9
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/wifi/WifiStatusTracker.java36
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java51
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java16
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java18
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java119
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CallbackHandlerTest.java1
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java11
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java3
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java6
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerWifiTest.java114
-rw-r--r--services/core/java/com/android/server/connectivity/tethering/OffloadController.java3
-rw-r--r--services/core/java/com/android/server/connectivity/tethering/OffloadHardwareInterface.java14
-rw-r--r--services/core/java/com/android/server/notification/NotificationManagerService.java58
-rw-r--r--services/core/jni/com_android_server_connectivity_tethering_OffloadHardwareInterface.cpp11
-rw-r--r--services/tests/notification/src/com/android/server/notification/NotificationManagerServiceTest.java37
-rw-r--r--telephony/java/android/telephony/TelephonyManager.java14
-rw-r--r--tests/net/java/com/android/server/connectivity/tethering/OffloadControllerTest.java9
23 files changed, 148 insertions, 392 deletions
diff --git a/api/current.txt b/api/current.txt
index 5dd3839b48a9..a533ff6784b7 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -37581,12 +37581,10 @@ package android.service.wallpaper {
method public int getDesiredMinimumHeight();
method public int getDesiredMinimumWidth();
method public android.view.SurfaceHolder getSurfaceHolder();
- method public void invalidateColors();
method public boolean isPreview();
method public boolean isVisible();
method public void onApplyWindowInsets(android.view.WindowInsets);
method public android.os.Bundle onCommand(java.lang.String, int, int, int, android.os.Bundle, boolean);
- method public android.app.WallpaperColors onComputeWallpaperColors();
method public void onCreate(android.view.SurfaceHolder);
method public void onDesiredSizeChanged(int, int);
method public void onDestroy();
diff --git a/api/system-current.txt b/api/system-current.txt
index dfad7a2d6883..fa1ef49c6162 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -40793,12 +40793,10 @@ package android.service.wallpaper {
method public int getDesiredMinimumHeight();
method public int getDesiredMinimumWidth();
method public android.view.SurfaceHolder getSurfaceHolder();
- method public void invalidateColors();
method public boolean isPreview();
method public boolean isVisible();
method public void onApplyWindowInsets(android.view.WindowInsets);
method public android.os.Bundle onCommand(java.lang.String, int, int, int, android.os.Bundle, boolean);
- method public android.app.WallpaperColors onComputeWallpaperColors();
method public void onCreate(android.view.SurfaceHolder);
method public void onDesiredSizeChanged(int, int);
method public void onDestroy();
diff --git a/api/test-current.txt b/api/test-current.txt
index 9bafd5f74b14..fe04b8b04b31 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -37788,12 +37788,10 @@ package android.service.wallpaper {
method public int getDesiredMinimumHeight();
method public int getDesiredMinimumWidth();
method public android.view.SurfaceHolder getSurfaceHolder();
- method public void invalidateColors();
method public boolean isPreview();
method public boolean isVisible();
method public void onApplyWindowInsets(android.view.WindowInsets);
method public android.os.Bundle onCommand(java.lang.String, int, int, int, android.os.Bundle, boolean);
- method public android.app.WallpaperColors onComputeWallpaperColors();
method public void onCreate(android.view.SurfaceHolder);
method public void onDesiredSizeChanged(int, int);
method public void onDestroy();
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java
index 539278fd47f1..da6b1f5f460e 100644
--- a/core/java/android/service/wallpaper/WallpaperService.java
+++ b/core/java/android/service/wallpaper/WallpaperService.java
@@ -548,6 +548,7 @@ public abstract class WallpaperService extends Service {
/**
* Notifies the engine that wallpaper colors changed significantly.
* This will trigger a {@link #onComputeWallpaperColors()} call.
+ * @hide
*/
public void invalidateColors() {
try {
@@ -564,6 +565,7 @@ public abstract class WallpaperService extends Service {
* you might want to call {@link #invalidateColors()} in a near future.
*
* @return List of wallpaper colors and their weights.
+ * @hide
*/
public @Nullable WallpaperColors onComputeWallpaperColors() {
return null;
diff --git a/packages/SettingsLib/res/drawable/ic_lockscreen_ime.xml b/packages/SettingsLib/res/drawable/ic_lockscreen_ime.xml
index 4aa8569466f1..4b81a3c9c460 100644
--- a/packages/SettingsLib/res/drawable/ic_lockscreen_ime.xml
+++ b/packages/SettingsLib/res/drawable/ic_lockscreen_ime.xml
@@ -18,7 +18,7 @@
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
- android:tint="?android:attr/colorAccent">
+ android:tint="?android:attr/colorControlNormal">
<path
android:fillColor="#FF000000"
android:pathData="M20,5L4,5c-1.1,0 -1.99,0.9 -1.99,2L2,17c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9
diff --git a/packages/SettingsLib/src/com/android/settingslib/Utils.java b/packages/SettingsLib/src/com/android/settingslib/Utils.java
index b21f2fa860b1..576782319e1e 100644
--- a/packages/SettingsLib/src/com/android/settingslib/Utils.java
+++ b/packages/SettingsLib/src/com/android/settingslib/Utils.java
@@ -35,7 +35,7 @@ public class Utils {
private static String sServicesSystemSharedLibPackageName;
private static String sSharedSystemSharedLibPackageName;
- public static final int[] WIFI_PIE_FOR_BADGING = {
+ static final int[] WIFI_PIE_FOR_BADGING = {
com.android.internal.R.drawable.ic_signal_wifi_badged_0_bars,
com.android.internal.R.drawable.ic_signal_wifi_badged_1_bar,
com.android.internal.R.drawable.ic_signal_wifi_badged_2_bars,
@@ -294,12 +294,7 @@ public class Utils {
});
}
- /**
- * Returns the resource id for the given badge or {@link View.NO_ID} if no badge is to be shown.
- *
- * @throws IllegalArgumentException if the given badge value is not supported.
- */
- public static int getWifiBadgeResource(int badge) {
+ private static int getWifiBadgeResource(int badge) {
switch (badge) {
case NetworkBadging.BADGING_NONE:
return View.NO_ID;
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiStatusTracker.java b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiStatusTracker.java
index ec94841c7d0d..0d67ad03cb10 100644
--- a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiStatusTracker.java
+++ b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiStatusTracker.java
@@ -12,17 +12,13 @@ package com.android.settingslib.wifi;
import android.content.Intent;
import android.net.NetworkInfo;
-import android.net.NetworkKey;
-import android.net.WifiKey;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
-import android.util.Log;
import java.util.List;
public class WifiStatusTracker {
- private static final String TAG = "WifiStatusTracker";
private final WifiManager mWifiManager;
public boolean enabled;
@@ -32,7 +28,6 @@ public class WifiStatusTracker {
public String ssid;
public int rssi;
public int level;
- public NetworkKey networkKey;
public WifiStatusTracker(WifiManager wifiManager) {
mWifiManager = wifiManager;
@@ -54,32 +49,19 @@ public class WifiStatusTracker {
connecting = networkInfo != null && !networkInfo.isConnected()
&& networkInfo.isConnectedOrConnecting();
connected = networkInfo != null && networkInfo.isConnected();
- WifiInfo info = intent.getParcelableExtra(WifiManager.EXTRA_WIFI_INFO) != null
- ? (WifiInfo) intent.getParcelableExtra(WifiManager.EXTRA_WIFI_INFO)
- : mWifiManager.getConnectionInfo();
-
// If Connected grab the signal strength and ssid.
- if (connected && info != null) {
- ssid = getSsid(info);
- String bssid = info.getBSSID();
- if ((ssid != null) && (bssid != null)) {
- // Reuse existing network key object if possible.
- if ((networkKey == null)
- || !networkKey.wifiKey.ssid.equals(ssid)
- || !networkKey.wifiKey.bssid.equals(bssid)) {
- try {
- networkKey = new NetworkKey(
- new WifiKey(ssid, bssid));
- } catch (IllegalArgumentException e) {
- Log.e(TAG, "Cannot create NetworkKey", e);
- }
- }
+ if (connected) {
+ // try getting it out of the intent first
+ WifiInfo info = intent.getParcelableExtra(WifiManager.EXTRA_WIFI_INFO) != null
+ ? (WifiInfo) intent.getParcelableExtra(WifiManager.EXTRA_WIFI_INFO)
+ : mWifiManager.getConnectionInfo();
+ if (info != null) {
+ ssid = getSsid(info);
} else {
- networkKey = null;
+ ssid = null;
}
- } else {
+ } else if (!connected) {
ssid = null;
- networkKey = null;
}
} else if (action.equals(WifiManager.RSSI_CHANGED_ACTION)) {
// Default to -200 as its below WifiManager.MIN_RSSI.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
index 169019f2cdb3..25f3e25f2051 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
@@ -16,19 +16,15 @@
package com.android.systemui.statusbar;
-import android.annotation.ColorInt;
import android.annotation.DrawableRes;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
-import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.Drawable;
-import android.graphics.drawable.LayerDrawable;
-import android.net.NetworkBadging;
import android.telephony.SubscriptionInfo;
import android.util.ArraySet;
import android.util.AttributeSet;
@@ -80,10 +76,8 @@ public class SignalClusterView extends LinearLayout implements NetworkController
private boolean mEthernetVisible = false;
private int mEthernetIconId = 0;
private int mLastEthernetIconId = -1;
- private int mWifiBadgeId = -1;
private boolean mWifiVisible = false;
private int mWifiStrengthId = 0;
- private int mLastWifiBadgeId = -1;
private int mLastWifiStrengthId = -1;
private boolean mWifiIn;
private boolean mWifiOut;
@@ -291,7 +285,6 @@ public class SignalClusterView extends LinearLayout implements NetworkController
boolean activityIn, boolean activityOut, String description, boolean isTransient) {
mWifiVisible = statusIcon.visible && !mBlockWifi;
mWifiStrengthId = statusIcon.icon;
- mWifiBadgeId = statusIcon.iconOverlay;
mWifiDescription = statusIcon.contentDescription;
mWifiIn = activityIn && mActivityEnabled && mWifiVisible;
mWifiOut = activityOut && mActivityEnabled && mWifiVisible;
@@ -428,7 +421,6 @@ public class SignalClusterView extends LinearLayout implements NetworkController
mWifi.setImageDrawable(null);
mWifiDark.setImageDrawable(null);
mLastWifiStrengthId = -1;
- mLastWifiBadgeId = -1;
}
for (PhoneState state : mPhoneStates) {
@@ -484,16 +476,10 @@ public class SignalClusterView extends LinearLayout implements NetworkController
(mEthernetVisible ? "VISIBLE" : "GONE")));
if (mWifiVisible) {
- if (mWifiStrengthId != mLastWifiStrengthId || mWifiBadgeId != mLastWifiBadgeId) {
- if (mWifiBadgeId == -1) {
- setIconForView(mWifi, mWifiStrengthId);
- setIconForView(mWifiDark, mWifiStrengthId);
- } else {
- setBadgedWifiIconForView(mWifi, mWifiStrengthId, mWifiBadgeId);
- setBadgedWifiIconForView(mWifiDark, mWifiStrengthId, mWifiBadgeId);
- }
+ if (mWifiStrengthId != mLastWifiStrengthId) {
+ setIconForView(mWifi, mWifiStrengthId);
+ setIconForView(mWifiDark, mWifiStrengthId);
mLastWifiStrengthId = mWifiStrengthId;
- mLastWifiBadgeId = mWifiBadgeId;
}
mWifiGroup.setContentDescription(mWifiDescription);
mWifiGroup.setVisibility(View.VISIBLE);
@@ -558,10 +544,6 @@ public class SignalClusterView extends LinearLayout implements NetworkController
// Using the imageView's context to retrieve the Drawable so that theme is preserved.
Drawable icon = imageView.getContext().getDrawable(iconId);
- setScaledIcon(imageView, icon);
- }
-
- private void setScaledIcon(ImageView imageView, Drawable icon) {
if (mIconScaleFactor == 1.f) {
imageView.setImageDrawable(icon);
} else {
@@ -569,33 +551,6 @@ public class SignalClusterView extends LinearLayout implements NetworkController
}
}
- /**
- * Creates and sets a LayerDrawable from the given ids on the given view.
- *
- * <p>This method will also scale the icon by {@link #mIconScaleFactor} if appropriate.
- */
- private void setBadgedWifiIconForView(ImageView imageView, @DrawableRes int wifiPieId,
- @DrawableRes int badgeId) {
- // TODO(sghuman): Delete this method and revert to N badging logic
- // Using the imageView's context to retrieve the Drawable so that theme is preserved.;
- LayerDrawable icon = new LayerDrawable(new Drawable[] {
- imageView.getContext().getDrawable(wifiPieId),
- imageView.getContext().getDrawable(NetworkBadging.BADGING_NONE)});
-
- // The LayerDrawable shares an underlying state so we must mutate the object to change the
- // color between the light and dark themes.
- icon.mutate().setTint(getColorAttr(imageView.getContext(), R.attr.singleToneColor));
-
- setScaledIcon(imageView, icon);
- }
-
- /** Returns the given color attribute value, or white if not defined. */
- @ColorInt private static int getColorAttr(Context context, int attr) {
- TypedArray ta = context.obtainStyledAttributes(new int[] {attr});
- @ColorInt int colorAccent = ta.getColor(0, Color.WHITE);
- ta.recycle();
- return colorAccent;
- }
@Override
public void onDarkChanged(Rect tintArea, float darkIntensity, int tint) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
index c02ce0ea6335..2771011c6997 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
@@ -67,29 +67,15 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
public static class IconState {
public final boolean visible;
-
public final int icon;
-
- /**
- * Optional iconOverlay resource id.
- *
- * <p>Set to -1 if not present.
- */
- public final int iconOverlay;
-
public final String contentDescription;
- public IconState(boolean visible, int icon, int iconOverlay, String contentDescription) {
+ public IconState(boolean visible, int icon, String contentDescription) {
this.visible = visible;
this.icon = icon;
- this.iconOverlay = iconOverlay;
this.contentDescription = contentDescription;
}
- public IconState(boolean visible, int icon, String contentDescription) {
- this(visible, icon, -1 /* iconOverlay */, contentDescription);
- }
-
public IconState(boolean visible, int icon, int contentDescription,
Context context) {
this(visible, icon, context.getString(contentDescription));
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
index c21f444d0bf3..39f7d1295d1b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
@@ -24,7 +24,6 @@ import android.content.res.Configuration;
import android.content.res.Resources;
import android.net.ConnectivityManager;
import android.net.NetworkCapabilities;
-import android.net.NetworkScoreManager;
import android.net.wifi.WifiManager;
import android.os.AsyncTask;
import android.os.Bundle;
@@ -92,7 +91,6 @@ public class NetworkControllerImpl extends BroadcastReceiver
private final DataSaverController mDataSaverController;
private final CurrentUserTracker mUserTracker;
private Config mConfig;
- private final NetworkScoreManager mNetworkScoreManager;
// Subcontrollers.
@VisibleForTesting
@@ -149,12 +147,9 @@ public class NetworkControllerImpl extends BroadcastReceiver
public NetworkControllerImpl(Context context, Looper bgLooper,
DeviceProvisionedController deviceProvisionedController) {
this(context, (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE),
- context.getSystemService(NetworkScoreManager.class),
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE),
(WifiManager) context.getSystemService(Context.WIFI_SERVICE),
- SubscriptionManager.from(context),
- Config.readConfig(context),
- bgLooper,
+ SubscriptionManager.from(context), Config.readConfig(context), bgLooper,
new CallbackHandler(),
new AccessPointControllerImpl(context, bgLooper),
new DataUsageController(context),
@@ -165,12 +160,8 @@ public class NetworkControllerImpl extends BroadcastReceiver
@VisibleForTesting
NetworkControllerImpl(Context context, ConnectivityManager connectivityManager,
- NetworkScoreManager networkScoreManager,
- TelephonyManager telephonyManager,
- WifiManager wifiManager,
- SubscriptionManager subManager,
- Config config,
- Looper bgLooper,
+ TelephonyManager telephonyManager, WifiManager wifiManager,
+ SubscriptionManager subManager, Config config, Looper bgLooper,
CallbackHandler callbackHandler,
AccessPointControllerImpl accessPointController,
DataUsageController dataUsageController,
@@ -193,7 +184,6 @@ public class NetworkControllerImpl extends BroadcastReceiver
// wifi
mWifiManager = wifiManager;
- mNetworkScoreManager = networkScoreManager;
mLocale = mContext.getResources().getConfiguration().locale;
mAccessPoints = accessPointController;
@@ -207,7 +197,7 @@ public class NetworkControllerImpl extends BroadcastReceiver
}
});
mWifiSignalController = new WifiSignalController(mContext, mHasMobileDataFeature,
- mCallbackHandler, this, mNetworkScoreManager);
+ mCallbackHandler, this);
mEthernetSignalController = new EthernetSignalController(mContext, mCallbackHandler, this);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java
index 2104cb1421aa..28196246f44c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java
@@ -17,50 +17,33 @@ package com.android.systemui.statusbar.policy;
import android.content.Context;
import android.content.Intent;
-import android.database.ContentObserver;
-import android.net.NetworkBadging;
import android.net.NetworkCapabilities;
-import android.net.NetworkKey;
-import android.net.NetworkScoreManager;
-import android.net.ScoredNetwork;
import android.net.wifi.WifiManager;
-import android.net.wifi.WifiNetworkScoreCache;
-import android.net.wifi.WifiNetworkScoreCache.CacheListener;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.Messenger;
-import android.provider.Settings;
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.AsyncChannel;
-import com.android.settingslib.Utils;
import com.android.settingslib.wifi.WifiStatusTracker;
+import com.android.systemui.R;
import com.android.systemui.statusbar.policy.NetworkController.IconState;
import com.android.systemui.statusbar.policy.NetworkController.SignalCallback;
-import com.android.systemui.R;
-
import java.util.Objects;
-import java.util.List;
public class WifiSignalController extends
SignalController<WifiSignalController.WifiState, SignalController.IconGroup> {
-
private final WifiManager mWifiManager;
private final AsyncChannel mWifiChannel;
private final boolean mHasMobileData;
- private final NetworkScoreManager mNetworkScoreManager;
- private final WifiNetworkScoreCache mScoreCache;
private final WifiStatusTracker mWifiTracker;
- private boolean mScoringUiEnabled = false;
-
public WifiSignalController(Context context, boolean hasMobileData,
- CallbackHandler callbackHandler, NetworkControllerImpl networkController,
- NetworkScoreManager networkScoreManager) {
+ CallbackHandler callbackHandler, NetworkControllerImpl networkController) {
super("WifiSignalController", context, NetworkCapabilities.TRANSPORT_WIFI,
callbackHandler, networkController);
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
@@ -85,44 +68,6 @@ public class WifiSignalController extends
AccessibilityContentDescriptions.WIFI_NO_CONNECTION
);
- mScoreCache = new WifiNetworkScoreCache(context, new CacheListener(handler) {
- @Override
- public void networkCacheUpdated(List<ScoredNetwork> networks) {
- mCurrentState.badgeEnum = getWifiBadgeEnum();
- notifyListenersIfNecessary();
- }
- });
-
- // Setup scoring
- mNetworkScoreManager = networkScoreManager;
- configureScoringGating();
- registerScoreCache();
- }
-
- private void configureScoringGating() {
- ContentObserver observer = new ContentObserver(new Handler(Looper.getMainLooper())) {
- @Override
- public void onChange(boolean selfChange) {
- mScoringUiEnabled =
- Settings.Global.getInt(
- mContext.getContentResolver(),
- Settings.Global.NETWORK_SCORING_UI_ENABLED, 0) == 1;
- }
- };
- mContext.getContentResolver().registerContentObserver(
- Settings.Global.getUriFor(Settings.Global.NETWORK_SCORING_UI_ENABLED),
- false /* notifyForDescendants */,
- observer);
-
- observer.onChange(false /* selfChange */); // Set the initial values
- }
-
- private void registerScoreCache() {
- Log.d(mTag, "Registered score cache");
- mNetworkScoreManager.registerNetworkScoreCache(
- NetworkKey.TYPE_WIFI,
- mScoreCache,
- NetworkScoreManager.CACHE_FILTER_CURRENT_NETWORK);
}
@Override
@@ -143,77 +88,27 @@ public class WifiSignalController extends
("," + mContext.getString(R.string.accessibility_quick_settings_no_internet));
}
- IconState statusIcon = new IconState(wifiVisible, getCurrentIconId(),
- Utils.getWifiBadgeResource(mCurrentState.badgeEnum), contentDescription);
- IconState qsIcon = new IconState(
- mCurrentState.connected, getQsCurrentIconId(),
- Utils.getWifiBadgeResource(mCurrentState.badgeEnum), contentDescription);
+ IconState statusIcon = new IconState(wifiVisible, getCurrentIconId(), contentDescription);
+ IconState qsIcon = new IconState(mCurrentState.connected, getQsCurrentIconId(),
+ contentDescription);
callback.setWifiIndicators(mCurrentState.enabled, statusIcon, qsIcon,
ssidPresent && mCurrentState.activityIn, ssidPresent && mCurrentState.activityOut,
wifiDesc, mCurrentState.isTransient);
}
- @Override
- public int getCurrentIconId() {
- if (mCurrentState.badgeEnum != NetworkBadging.BADGING_NONE) {
- return Utils.WIFI_PIE_FOR_BADGING[mCurrentState.level];
- }
- return super.getCurrentIconId();
- }
-
/**
* Extract wifi state directly from broadcasts about changes in wifi state.
*/
public void handleBroadcast(Intent intent) {
- // Update the WifiStatusTracker with the new information and update the score cache.
- NetworkKey previousNetworkKey = mWifiTracker.networkKey;
mWifiTracker.handleBroadcast(intent);
- updateScoreCacheIfNecessary(previousNetworkKey);
-
- mCurrentState.isTransient = mWifiTracker.state == WifiManager.WIFI_STATE_ENABLING
- || mWifiTracker.state == WifiManager.WIFI_AP_STATE_DISABLING
- || mWifiTracker.connecting;
mCurrentState.enabled = mWifiTracker.enabled;
mCurrentState.connected = mWifiTracker.connected;
mCurrentState.ssid = mWifiTracker.ssid;
mCurrentState.rssi = mWifiTracker.rssi;
mCurrentState.level = mWifiTracker.level;
- mCurrentState.badgeEnum = getWifiBadgeEnum();
notifyListenersIfNecessary();
}
- /**
- * Clears old scores out of the cache and requests new scores if the network key has changed.
- *
- * <p>New scores are requested asynchronously.
- */
- private void updateScoreCacheIfNecessary(NetworkKey previousNetworkKey) {
- if (mWifiTracker.networkKey == null) {
- return;
- }
- if ((previousNetworkKey == null) || !mWifiTracker.networkKey.equals(previousNetworkKey)) {
- mScoreCache.clearScores();
- mNetworkScoreManager.requestScores(new NetworkKey[]{mWifiTracker.networkKey});
- }
- }
-
- /**
- * Returns the wifi badge enum for the current {@link #mWifiTracker} state.
- *
- * <p>{@link #updateScoreCacheIfNecessary} should be called prior to this method.
- */
- private int getWifiBadgeEnum() {
- if (!mScoringUiEnabled || mWifiTracker.networkKey == null) {
- return NetworkBadging.BADGING_NONE;
- }
- ScoredNetwork score = mScoreCache.getScoredNetwork(mWifiTracker.networkKey);
-
- if (score != null) {
- return score.calculateBadge(mWifiTracker.rssi);
- }
- return NetworkBadging.BADGING_NONE;
- }
-
@VisibleForTesting
void setActivity(int wifiActivity) {
mCurrentState.activityIn = wifiActivity == WifiManager.DATA_ACTIVITY_INOUT
@@ -254,7 +149,6 @@ public class WifiSignalController extends
static class WifiState extends SignalController.State {
String ssid;
- int badgeEnum;
boolean isTransient;
@Override
@@ -262,7 +156,6 @@ public class WifiSignalController extends
super.copyFrom(s);
WifiState state = (WifiState) s;
ssid = state.ssid;
- badgeEnum = state.badgeEnum;
isTransient = state.isTransient;
}
@@ -270,7 +163,6 @@ public class WifiSignalController extends
protected void toString(StringBuilder builder) {
super.toString(builder);
builder.append(',').append("ssid=").append(ssid);
- builder.append(',').append("badgeEnum=").append(badgeEnum);
builder.append(',').append("isTransient=").append(isTransient);
}
@@ -278,7 +170,6 @@ public class WifiSignalController extends
public boolean equals(Object o) {
return super.equals(o)
&& Objects.equals(((WifiState) o).ssid, ssid)
- && (((WifiState) o).badgeEnum == badgeEnum)
&& (((WifiState) o).isTransient == isTransient);
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CallbackHandlerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CallbackHandlerTest.java
index cb2063967639..51bd7bccbe71 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CallbackHandlerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CallbackHandlerTest.java
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.policy;
import android.os.HandlerThread;
import android.support.test.runner.AndroidJUnit4;
import android.telephony.SubscriptionInfo;
+import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java
index 505e1d8346fd..a8319a8ee538 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java
@@ -19,7 +19,6 @@ package com.android.systemui.statusbar.policy;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkCapabilities;
-import android.net.NetworkScoreManager;
import android.net.wifi.WifiManager;
import android.os.Looper;
import android.telephony.PhoneStateListener;
@@ -84,7 +83,6 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
protected Config mConfig;
protected CallbackHandler mCallbackHandler;
protected SubscriptionDefaults mMockSubDefaults;
- protected NetworkScoreManager mMockNetworkScoreManager;
protected DeviceProvisionedController mMockProvisionController;
protected DeviceProvisionedListener mUserCallback;
@@ -113,8 +111,6 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
mMockCm = mock(ConnectivityManager.class);
mMockSubDefaults = mock(SubscriptionDefaults.class);
mNetCapabilities = new NetworkCapabilities();
- mMockNetworkScoreManager = mock(NetworkScoreManager.class);
-
when(mMockCm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)).thenReturn(true);
when(mMockCm.getDefaultNetworkCapabilitiesForUser(0)).thenReturn(
new NetworkCapabilities[] { mNetCapabilities });
@@ -135,8 +131,7 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
return null;
}).when(mMockProvisionController).addCallback(any());
- mNetworkController = new NetworkControllerImpl(mContext, mMockCm, mMockNetworkScoreManager,
- mMockTm, mMockWm, mMockSm,
+ mNetworkController = new NetworkControllerImpl(mContext, mMockCm, mMockTm, mMockWm, mMockSm,
mConfig, Looper.getMainLooper(), mCallbackHandler,
mock(AccessPointControllerImpl.class), mock(DataUsageController.class),
mMockSubDefaults, mMockProvisionController);
@@ -177,8 +172,8 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
protected NetworkControllerImpl setUpNoMobileData() {
when(mMockCm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)).thenReturn(false);
NetworkControllerImpl networkControllerNoMobile
- = new NetworkControllerImpl(mContext, mMockCm, mMockNetworkScoreManager, mMockTm,
- mMockWm, mMockSm, mConfig, mContext.getMainLooper(), mCallbackHandler,
+ = new NetworkControllerImpl(mContext, mMockCm, mMockTm, mMockWm, mMockSm,
+ mConfig, mContext.getMainLooper(), mCallbackHandler,
mock(AccessPointControllerImpl.class),
mock(DataUsageController.class), mMockSubDefaults,
mock(DeviceProvisionedController.class));
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java
index dfe00f95fe4d..8d106b4b9616 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java
@@ -91,8 +91,7 @@ public class NetworkControllerDataTest extends NetworkControllerBaseTest {
public void test4gDataIcon() {
// Switch to showing 4g icon and re-initialize the NetworkController.
mConfig.show4gForLte = true;
- mNetworkController = new NetworkControllerImpl(mContext, mMockCm, mMockNetworkScoreManager,
- mMockTm, mMockWm, mMockSm,
+ mNetworkController = new NetworkControllerImpl(mContext, mMockCm, mMockTm, mMockWm, mMockSm,
mConfig, Looper.getMainLooper(), mCallbackHandler,
mock(AccessPointControllerImpl.class),
mock(DataUsageController.class), mMockSubDefaults,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java
index 1627925ae1bc..be3802bd68ed 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java
@@ -54,8 +54,7 @@ public class NetworkControllerSignalTest extends NetworkControllerBaseTest {
// Turn off mobile network support.
Mockito.when(mMockCm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)).thenReturn(false);
// Create a new NetworkController as this is currently handled in constructor.
- mNetworkController = new NetworkControllerImpl(mContext, mMockCm, mMockNetworkScoreManager,
- mMockTm, mMockWm, mMockSm,
+ mNetworkController = new NetworkControllerImpl(mContext, mMockCm, mMockTm, mMockWm, mMockSm,
mConfig, Looper.getMainLooper(), mCallbackHandler,
mock(AccessPointControllerImpl.class), mock(DataUsageController.class),
mMockSubDefaults, mock(DeviceProvisionedController.class));
@@ -117,8 +116,7 @@ public class NetworkControllerSignalTest extends NetworkControllerBaseTest {
// Turn off mobile network support.
Mockito.when(mMockCm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)).thenReturn(false);
// Create a new NetworkController as this is currently handled in constructor.
- mNetworkController = new NetworkControllerImpl(mContext, mMockCm, mMockNetworkScoreManager,
- mMockTm, mMockWm, mMockSm,
+ mNetworkController = new NetworkControllerImpl(mContext, mMockCm, mMockTm, mMockWm, mMockSm,
mConfig, Looper.getMainLooper(), mCallbackHandler,
mock(AccessPointControllerImpl.class), mock(DataUsageController.class),
mMockSubDefaults, mock(DeviceProvisionedController.class));
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerWifiTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerWifiTest.java
index dbaa2c5fea0a..ffd0165195e5 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerWifiTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerWifiTest.java
@@ -1,47 +1,24 @@
package com.android.systemui.statusbar.policy;
import android.content.Intent;
-import android.net.NetworkBadging;
import android.net.NetworkCapabilities;
import android.net.NetworkInfo;
-import android.net.NetworkKey;
-import android.net.RssiCurve;
-import android.net.ScoredNetwork;
-import android.net.WifiKey;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
-import android.net.wifi.WifiNetworkScoreCache;
-import android.os.Bundle;
-import android.provider.Settings;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
-import com.android.settingslib.Utils;
import com.android.systemui.statusbar.policy.NetworkController.IconState;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
-import org.mockito.Matchers;
import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
import static junit.framework.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyBoolean;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.util.Arrays;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
@SmallTest
@RunWith(AndroidJUnit4.class)
@@ -50,13 +27,6 @@ public class NetworkControllerWifiTest extends NetworkControllerBaseTest {
private static final int MIN_RSSI = -100;
private static final int MAX_RSSI = -55;
- private static final int LATCH_TIMEOUT = 2000;
- private static final String TEST_SSID = "\"Test SSID\"";
- private static final String TEST_BSSID = "00:00:00:00:00:00";
-
- private final List<NetworkKey> mRequestedKeys = new ArrayList<>();
- private CountDownLatch mRequestScoresLatch;
-
@Test
public void testWifiIcon() {
String testSsid = "Test SSID";
@@ -77,79 +47,6 @@ public class NetworkControllerWifiTest extends NetworkControllerBaseTest {
}
@Test
- public void testBadgedWifiIcon() throws Exception {
- // TODO(sghuman): Refactor this setup code when creating a test for the badged QsIcon.
- int testLevel = 1;
- RssiCurve mockBadgeCurve = mock(RssiCurve.class);
- Bundle attr = new Bundle();
- attr.putParcelable(ScoredNetwork.ATTRIBUTES_KEY_BADGING_CURVE, mockBadgeCurve);
- ScoredNetwork score =
- new ScoredNetwork(
- new NetworkKey(new WifiKey(TEST_SSID, TEST_BSSID)),
- null,
- false /* meteredHint */,
- attr);
-
- // Must set the Settings value before instantiating the NetworkControllerImpl due to bugs in
- // TestableSettingsProvider.
- Settings.Global.putString(mContext.getContentResolver(),
- Settings.Global.NETWORK_SCORING_UI_ENABLED,
- "1");
- super.setUp(); // re-instantiate NetworkControllImpl now that setting has been updated
- setupNetworkScoreManager();
-
- // Test Requesting Scores
- mRequestScoresLatch = new CountDownLatch(1);
- setWifiEnabled(true);
- setWifiState(true, TEST_SSID, TEST_BSSID);
- mRequestScoresLatch.await(LATCH_TIMEOUT, TimeUnit.MILLISECONDS);
-
- when(mockBadgeCurve.lookupScore(anyInt())).thenReturn((byte) NetworkBadging.BADGING_SD);
-
- ArgumentCaptor<WifiNetworkScoreCache> scoreCacheCaptor =
- ArgumentCaptor.forClass(WifiNetworkScoreCache.class);
- verify(mMockNetworkScoreManager).registerNetworkScoreCache(
- anyInt(),
- scoreCacheCaptor.capture(),
- Matchers.anyInt());
- scoreCacheCaptor.getValue().updateScores(Arrays.asList(score));
-
- // Test badge is set
- setWifiLevel(testLevel);
-
- ArgumentCaptor<IconState> iconArg = ArgumentCaptor.forClass(IconState.class);
- Mockito.verify(mCallbackHandler, Mockito.atLeastOnce()).setWifiIndicators(
- anyBoolean(), iconArg.capture(), any(), anyBoolean(), anyBoolean(),
- any(), anyBoolean());
- IconState iconState = iconArg.getValue();
-
- assertEquals("Badged Wifi Resource is set",
- Utils.WIFI_PIE_FOR_BADGING[testLevel],
- iconState.icon);
- assertEquals("SD Badge is set",
- Utils.getWifiBadgeResource(NetworkBadging.BADGING_SD),
- iconState.iconOverlay);
- }
-
- private void setupNetworkScoreManager() {
- // Capture requested keys and count down latch if present
- doAnswer(
- new Answer<Boolean>() {
- @Override
- public Boolean answer(InvocationOnMock input) {
- if (mRequestScoresLatch != null) {
- mRequestScoresLatch.countDown();
- }
- NetworkKey[] keys = (NetworkKey[]) input.getArguments()[0];
- for (NetworkKey key : keys) {
- mRequestedKeys.add(key);
- }
- return true;
- }
- }).when(mMockNetworkScoreManager).requestScores(Matchers.<NetworkKey[]>any());
- }
-
- @Test
public void testQsWifiIcon() {
String testSsid = "Test SSID";
@@ -200,7 +97,7 @@ public class NetworkControllerWifiTest extends NetworkControllerBaseTest {
@Test
public void testRoamingIconDuringWifi() {
// Setup normal connection
- String testSsid = "\"Test SSID\"";
+ String testSsid = "Test SSID";
int testLevel = 2;
setWifiEnabled(true);
setWifiState(true, testSsid);
@@ -241,19 +138,12 @@ public class NetworkControllerWifiTest extends NetworkControllerBaseTest {
}
protected void setWifiState(boolean connected, String ssid) {
- setWifiState(connected, ssid, null);
- }
-
- protected void setWifiState(boolean connected, String ssid, String bssid) {
Intent i = new Intent(WifiManager.NETWORK_STATE_CHANGED_ACTION);
NetworkInfo networkInfo = Mockito.mock(NetworkInfo.class);
Mockito.when(networkInfo.isConnected()).thenReturn(connected);
WifiInfo wifiInfo = Mockito.mock(WifiInfo.class);
Mockito.when(wifiInfo.getSSID()).thenReturn(ssid);
- if (bssid != null) {
- Mockito.when(wifiInfo.getBSSID()).thenReturn(bssid);
- }
i.putExtra(WifiManager.EXTRA_NETWORK_INFO, networkInfo);
i.putExtra(WifiManager.EXTRA_WIFI_INFO, wifiInfo);
@@ -278,7 +168,7 @@ public class NetworkControllerWifiTest extends NetworkControllerBaseTest {
Mockito.verify(mCallbackHandler, Mockito.atLeastOnce()).setWifiIndicators(
enabledArg.capture(), any(), iconArg.capture(), anyBoolean(),
- anyBoolean(), descArg.capture(), anyBoolean());
+ anyBoolean(), descArg.capture(), anyBoolean());
IconState iconState = iconArg.getValue();
assertEquals("WiFi enabled, in quick settings", enabled, (boolean) enabledArg.getValue());
assertEquals("WiFi connected, in quick settings", connected, iconState.visible);
diff --git a/services/core/java/com/android/server/connectivity/tethering/OffloadController.java b/services/core/java/com/android/server/connectivity/tethering/OffloadController.java
index 3aca45f8bd9a..ce6b8be77d44 100644
--- a/services/core/java/com/android/server/connectivity/tethering/OffloadController.java
+++ b/services/core/java/com/android/server/connectivity/tethering/OffloadController.java
@@ -161,6 +161,7 @@ public class OffloadController {
}
}
- return mHwInterface.setUpstreamParameters(iface, v4addr, v4gateway, v6gateways);
+ return mHwInterface.setUpstreamParameters(
+ iface, v4addr, v4gateway, (v6gateways.isEmpty() ? null : v6gateways));
}
}
diff --git a/services/core/java/com/android/server/connectivity/tethering/OffloadHardwareInterface.java b/services/core/java/com/android/server/connectivity/tethering/OffloadHardwareInterface.java
index 3ecf0d1d0c71..1fc16841e355 100644
--- a/services/core/java/com/android/server/connectivity/tethering/OffloadHardwareInterface.java
+++ b/services/core/java/com/android/server/connectivity/tethering/OffloadHardwareInterface.java
@@ -16,6 +16,8 @@
package com.android.server.connectivity.tethering;
+import static com.android.internal.util.BitUtils.uint16;
+
import android.hardware.tetheroffload.control.V1_0.IOffloadControl;
import android.hardware.tetheroffload.control.V1_0.ITetheringOffloadCallback;
import android.hardware.tetheroffload.control.V1_0.NatTimeoutUpdate;
@@ -33,6 +35,9 @@ import java.util.ArrayList;
*/
public class OffloadHardwareInterface {
private static final String TAG = OffloadHardwareInterface.class.getSimpleName();
+ private static final String NO_INTERFACE_NAME = "";
+ private static final String NO_IPV4_ADDRESS = "";
+ private static final String NO_IPV4_GATEWAY = "";
private static native boolean configOffload();
@@ -107,6 +112,11 @@ public class OffloadHardwareInterface {
public boolean setUpstreamParameters(
String iface, String v4addr, String v4gateway, ArrayList<String> v6gws) {
+ iface = iface != null ? iface : NO_INTERFACE_NAME;
+ v4addr = v4addr != null ? v4addr : NO_IPV4_ADDRESS;
+ v4gateway = v4gateway != null ? v4gateway : NO_IPV4_GATEWAY;
+ v6gws = v6gws != null ? v6gws : new ArrayList<>();
+
final CbResults results = new CbResults();
try {
mOffloadControl.setUpstreamParameters(
@@ -143,8 +153,8 @@ public class OffloadHardwareInterface {
handler.post(() -> {
controlCb.onNatTimeoutUpdate(
params.proto,
- params.src.addr, params.src.port,
- params.dst.addr, params.dst.port);
+ params.src.addr, uint16(params.src.port),
+ params.dst.addr, uint16(params.dst.port));
});
}
}
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 029790beaac1..5ee7ac4d16d1 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -307,11 +307,15 @@ public class NotificationManagerService extends SystemService {
// used as a mutex for access to all active notifications & listeners
final Object mNotificationLock = new Object();
+ @GuardedBy("mNotificationLock")
final ArrayList<NotificationRecord> mNotificationList =
new ArrayList<NotificationRecord>();
+ @GuardedBy("mNotificationLock")
final ArrayMap<String, NotificationRecord> mNotificationsByKey =
new ArrayMap<String, NotificationRecord>();
+ @GuardedBy("mNotificationLock")
final ArrayList<NotificationRecord> mEnqueuedNotifications = new ArrayList<>();
+ @GuardedBy("mNotificationLock")
final ArrayMap<Integer, ArrayMap<String, String>> mAutobundledSummaries = new ArrayMap<>();
final ArrayList<ToastRecord> mToastQueue = new ArrayList<ToastRecord>();
final ArrayMap<String, NotificationRecord> mSummaryByGroupKey = new ArrayMap<>();
@@ -2806,7 +2810,8 @@ public class NotificationManagerService extends SystemService {
// Clear summary.
final NotificationRecord removed = findNotificationByKeyLocked(summaries.remove(pkg));
if (removed != null) {
- cancelNotificationLocked(removed, false, REASON_UNAUTOBUNDLED);
+ boolean wasPosted = removeFromNotificationListsLocked(removed);
+ cancelNotificationLocked(removed, false, REASON_UNAUTOBUNDLED, wasPosted);
}
}
}
@@ -3420,7 +3425,8 @@ public class NotificationManagerService extends SystemService {
.setType(MetricsEvent.TYPE_CLOSE)
.addTaggedData(MetricsEvent.NOTIFICATION_SNOOZED_CRITERIA,
mSnoozeCriterionId == null ? 0 : 1));
- cancelNotificationLocked(r, false, REASON_SNOOZED);
+ boolean wasPosted = removeFromNotificationListsLocked(r);
+ cancelNotificationLocked(r, false, REASON_SNOOZED, wasPosted);
updateLightsLocked();
if (mSnoozeCriterionId != null) {
mNotificationAssistants.notifyAssistantSnoozedLocked(r.sbn, mSnoozeCriterionId);
@@ -4206,15 +4212,18 @@ public class NotificationManagerService extends SystemService {
manager.sendAccessibilityEvent(event);
}
+ /**
+ * Removes all NotificationsRecords with the same key as the given notification record
+ * from both lists. Do not call this method while iterating over either list.
+ */
@GuardedBy("mNotificationLock")
- private void cancelNotificationLocked(NotificationRecord r, boolean sendDelete, int reason) {
- final String canceledKey = r.getKey();
-
- // Remove from both lists, either list could have a separate Record for what is effectively
- // the same notification.
+ private boolean removeFromNotificationListsLocked(NotificationRecord r) {
+ // Remove from both lists, either list could have a separate Record for what is
+ // effectively the same notification.
boolean wasPosted = false;
NotificationRecord recordInList = null;
- if ((recordInList = findNotificationByListLocked(mNotificationList, r.getKey())) != null) {
+ if ((recordInList = findNotificationByListLocked(mNotificationList, r.getKey()))
+ != null) {
mNotificationList.remove(recordInList);
mNotificationsByKey.remove(recordInList.sbn.getKey());
wasPosted = true;
@@ -4223,6 +4232,13 @@ public class NotificationManagerService extends SystemService {
!= null) {
mEnqueuedNotifications.remove(recordInList);
}
+ return wasPosted;
+ }
+
+ @GuardedBy("mNotificationLock")
+ private void cancelNotificationLocked(NotificationRecord r, boolean sendDelete, int reason,
+ boolean wasPosted) {
+ final String canceledKey = r.getKey();
// Record caller.
recordCallerLocked(r);
@@ -4363,7 +4379,8 @@ public class NotificationManagerService extends SystemService {
}
// Cancel the notification.
- cancelNotificationLocked(r, sendDelete, reason);
+ boolean wasPosted = removeFromNotificationListsLocked(r);
+ cancelNotificationLocked(r, sendDelete, reason, wasPosted);
cancelGroupChildrenLocked(r, callingUid, callingPid, listenerName,
sendDelete);
updateLightsLocked();
@@ -4440,11 +4457,11 @@ public class NotificationManagerService extends SystemService {
cancelAllNotificationsByListLocked(mNotificationList, callingUid, callingPid,
pkg, true /*nullPkgIndicatesUserSwitch*/, channelId, flagChecker,
false /*includeCurrentProfiles*/, userId, false /*sendDelete*/, reason,
- listenerName);
+ listenerName, true /* wasPosted */);
cancelAllNotificationsByListLocked(mEnqueuedNotifications, callingUid,
callingPid, pkg, true /*nullPkgIndicatesUserSwitch*/, channelId,
flagChecker, false /*includeCurrentProfiles*/, userId,
- false /*sendDelete*/, reason, listenerName);
+ false /*sendDelete*/, reason, listenerName, false /* wasPosted */);
mSnoozeHelper.cancel(userId, pkg);
}
}
@@ -4460,7 +4477,7 @@ public class NotificationManagerService extends SystemService {
private void cancelAllNotificationsByListLocked(ArrayList<NotificationRecord> notificationList,
int callingUid, int callingPid, String pkg, boolean nullPkgIndicatesUserSwitch,
String channelId, FlagChecker flagChecker, boolean includeCurrentProfiles, int userId,
- boolean sendDelete, int reason, String listenerName) {
+ boolean sendDelete, int reason, String listenerName, boolean wasPosted) {
ArrayList<NotificationRecord> canceledNotifications = null;
for (int i = notificationList.size() - 1; i >= 0; --i) {
NotificationRecord r = notificationList.get(i);
@@ -4488,8 +4505,9 @@ public class NotificationManagerService extends SystemService {
if (canceledNotifications == null) {
canceledNotifications = new ArrayList<>();
}
+ notificationList.remove(i);
canceledNotifications.add(r);
- cancelNotificationLocked(r, sendDelete, reason);
+ cancelNotificationLocked(r, sendDelete, reason, wasPosted);
}
if (canceledNotifications != null) {
final int M = canceledNotifications.size();
@@ -4548,11 +4566,11 @@ public class NotificationManagerService extends SystemService {
cancelAllNotificationsByListLocked(mNotificationList, callingUid, callingPid,
null, false /*nullPkgIndicatesUserSwitch*/, null, flagChecker,
includeCurrentProfiles, userId, true /*sendDelete*/, reason,
- listenerName);
+ listenerName, true);
cancelAllNotificationsByListLocked(mEnqueuedNotifications, callingUid,
callingPid, null, false /*nullPkgIndicatesUserSwitch*/, null,
flagChecker, includeCurrentProfiles, userId, true /*sendDelete*/,
- reason, listenerName);
+ reason, listenerName, false);
mSnoozeHelper.cancel(userId, includeCurrentProfiles);
}
}
@@ -4569,7 +4587,6 @@ public class NotificationManagerService extends SystemService {
}
String pkg = r.sbn.getPackageName();
- int userId = r.getUserId();
if (pkg == null) {
if (DBG) Log.e(TAG, "No package for group summary: " + r.getKey());
@@ -4577,15 +4594,15 @@ public class NotificationManagerService extends SystemService {
}
cancelGroupChildrenByListLocked(mNotificationList, r, callingUid, callingPid, listenerName,
- sendDelete);
+ sendDelete, true);
cancelGroupChildrenByListLocked(mEnqueuedNotifications, r, callingUid, callingPid,
- listenerName, sendDelete);
+ listenerName, sendDelete, false);
}
@GuardedBy("mNotificationLock")
private void cancelGroupChildrenByListLocked(ArrayList<NotificationRecord> notificationList,
NotificationRecord parentNotification, int callingUid, int callingPid,
- String listenerName, boolean sendDelete) {
+ String listenerName, boolean sendDelete, boolean wasPosted) {
final String pkg = parentNotification.sbn.getPackageName();
final int userId = parentNotification.getUserId();
final int reason = REASON_GROUP_SUMMARY_CANCELED;
@@ -4597,7 +4614,8 @@ public class NotificationManagerService extends SystemService {
&& (childR.getFlags() & Notification.FLAG_FOREGROUND_SERVICE) == 0) {
EventLogTags.writeNotificationCancel(callingUid, callingPid, pkg, childSbn.getId(),
childSbn.getTag(), userId, 0, 0, reason, listenerName);
- cancelNotificationLocked(childR, sendDelete, reason);
+ notificationList.remove(i);
+ cancelNotificationLocked(childR, sendDelete, reason, wasPosted);
}
}
}
diff --git a/services/core/jni/com_android_server_connectivity_tethering_OffloadHardwareInterface.cpp b/services/core/jni/com_android_server_connectivity_tethering_OffloadHardwareInterface.cpp
index 241ccf6ed166..4e5c27fca784 100644
--- a/services/core/jni/com_android_server_connectivity_tethering_OffloadHardwareInterface.cpp
+++ b/services/core/jni/com_android_server_connectivity_tethering_OffloadHardwareInterface.cpp
@@ -71,7 +71,7 @@ int conntrackSocket(unsigned groups) {
// auto-close it (otherwise there would be double-close problems).
//
// Rely upon the compiler to eliminate the constexprs used for clarity.
-hidl_handle&& handleFromFileDescriptor(base::unique_fd fd) {
+hidl_handle handleFromFileDescriptor(base::unique_fd fd) {
hidl_handle h;
NATIVE_HANDLE_DECLARE_STORAGE(storage, 0, 0);
@@ -83,7 +83,7 @@ hidl_handle&& handleFromFileDescriptor(base::unique_fd fd) {
static constexpr bool kTakeOwnership = true;
h.setTo(nh, kTakeOwnership);
- return std::move(h);
+ return h;
}
} // namespace
@@ -116,13 +116,14 @@ static jboolean android_server_connectivity_tethering_OffloadHardwareInterface_c
bool rval;
hidl_string msg;
- configInterface->setHandles(h1, h2,
+ const auto status = configInterface->setHandles(h1, h2,
[&rval, &msg](bool success, const hidl_string& errMsg) {
rval = success;
msg = errMsg;
});
- if (!rval) {
- ALOGE("IOffloadConfig::setHandles() error: %s", msg.c_str());
+ if (!status.isOk() || !rval) {
+ ALOGE("IOffloadConfig::setHandles() error: '%s' / '%s'",
+ status.description().c_str(), msg.c_str());
}
return rval;
diff --git a/services/tests/notification/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/notification/src/com/android/server/notification/NotificationManagerServiceTest.java
index 0a4cb1080b04..6090e35ac8c2 100644
--- a/services/tests/notification/src/com/android/server/notification/NotificationManagerServiceTest.java
+++ b/services/tests/notification/src/com/android/server/notification/NotificationManagerServiceTest.java
@@ -359,6 +359,43 @@ public class NotificationManagerServiceTest extends NotificationTestCase {
}
@Test
+ public void testCancelAllNotificationsMultipleEnqueuedDoesNotCrash() throws Exception {
+ final StatusBarNotification sbn = generateNotificationRecord(null).sbn;
+ for (int i = 0; i < 10; i++) {
+ mBinderService.enqueueNotificationWithTag(PKG, "opPkg", "tag",
+ sbn.getId(), sbn.getNotification(), sbn.getUserId());
+ }
+ mBinderService.cancelAllNotifications(PKG, sbn.getUserId());
+ waitForIdle();
+ }
+
+ @Test
+ public void testCancelGroupSummaryMultipleEnqueuedChildrenDoesNotCrash() throws Exception {
+ final NotificationRecord parent = generateNotificationRecord(
+ mTestNotificationChannel, 1, "group1", true);
+ final NotificationRecord parentAsChild = generateNotificationRecord(
+ mTestNotificationChannel, 1, "group1", false);
+ final NotificationRecord child = generateNotificationRecord(
+ mTestNotificationChannel, 2, "group1", false);
+
+ // fully post parent notification
+ mBinderService.enqueueNotificationWithTag(PKG, "opPkg", "tag",
+ parent.sbn.getId(), parent.sbn.getNotification(), parent.sbn.getUserId());
+ waitForIdle();
+
+ // enqueue the child several times
+ for (int i = 0; i < 10; i++) {
+ mBinderService.enqueueNotificationWithTag(PKG, "opPkg", "tag",
+ child.sbn.getId(), child.sbn.getNotification(), child.sbn.getUserId());
+ }
+ // make the parent a child, which will cancel the child notification
+ mBinderService.enqueueNotificationWithTag(PKG, "opPkg", "tag",
+ parentAsChild.sbn.getId(), parentAsChild.sbn.getNotification(),
+ parentAsChild.sbn.getUserId());
+ waitForIdle();
+ }
+
+ @Test
public void testCancelAllNotifications_IgnoreForegroundService() throws Exception {
final StatusBarNotification sbn = generateNotificationRecord(null).sbn;
sbn.getNotification().flags |= Notification.FLAG_FOREGROUND_SERVICE;
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 74327cef6bd3..4f78087c4c97 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -869,6 +869,20 @@ public class TelephonyManager {
public static final String EVENT_NOTIFY_INTERNATIONAL_CALL_ON_WFC =
"android.telephony.event.EVENT_NOTIFY_INTERNATIONAL_CALL_ON_WFC";
+ /**
+ * {@link android.telecom.Connection} event used to indicate that an outgoing call has been
+ * forwarded to another number.
+ * <p>
+ * Sent in response to an IMS supplementary service notification indicating the call has been
+ * forwarded.
+ * <p>
+ * Sent via {@link android.telecom.Connection#sendConnectionEvent(String, Bundle)}.
+ * The {@link Bundle} parameter is expected to be null when this connection event is used.
+ * @hide
+ */
+ public static final String EVENT_CALL_FORWARDED =
+ "android.telephony.event.EVENT_CALL_FORWARDED";
+
/* Visual voicemail protocols */
/**
diff --git a/tests/net/java/com/android/server/connectivity/tethering/OffloadControllerTest.java b/tests/net/java/com/android/server/connectivity/tethering/OffloadControllerTest.java
index 4d340d1eff33..14284d661744 100644
--- a/tests/net/java/com/android/server/connectivity/tethering/OffloadControllerTest.java
+++ b/tests/net/java/com/android/server/connectivity/tethering/OffloadControllerTest.java
@@ -155,8 +155,7 @@ public class OffloadControllerTest {
lp.setInterfaceName(testIfName);
offload.setUpstreamLinkProperties(lp);
inOrder.verify(mHardware, times(1)).setUpstreamParameters(
- eq(testIfName), eq(null), eq(null), mStringArrayCaptor.capture());
- assertTrue(mStringArrayCaptor.getValue().isEmpty());
+ eq(testIfName), eq(null), eq(null), eq(null));
inOrder.verifyNoMoreInteractions();
final String ipv4Addr = "192.0.2.5";
@@ -164,16 +163,14 @@ public class OffloadControllerTest {
lp.addLinkAddress(new LinkAddress(linkAddr));
offload.setUpstreamLinkProperties(lp);
inOrder.verify(mHardware, times(1)).setUpstreamParameters(
- eq(testIfName), eq(ipv4Addr), eq(null), mStringArrayCaptor.capture());
- assertTrue(mStringArrayCaptor.getValue().isEmpty());
+ eq(testIfName), eq(ipv4Addr), eq(null), eq(null));
inOrder.verifyNoMoreInteractions();
final String ipv4Gateway = "192.0.2.1";
lp.addRoute(new RouteInfo(InetAddress.getByName(ipv4Gateway)));
offload.setUpstreamLinkProperties(lp);
inOrder.verify(mHardware, times(1)).setUpstreamParameters(
- eq(testIfName), eq(ipv4Addr), eq(ipv4Gateway), mStringArrayCaptor.capture());
- assertTrue(mStringArrayCaptor.getValue().isEmpty());
+ eq(testIfName), eq(ipv4Addr), eq(ipv4Gateway), eq(null));
inOrder.verifyNoMoreInteractions();
final String ipv6Gw1 = "fe80::cafe";