Merge "Remove unused SystemUi service"
diff --git a/api/current.txt b/api/current.txt
index 4db12ea..38bf3ab 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -41485,6 +41485,7 @@
method protected void dump(java.lang.String, java.io.FileDescriptor, java.io.PrintWriter, java.lang.String[]);
method public int getDesiredMinimumHeight();
method public int getDesiredMinimumWidth();
+ method public android.content.Context getDisplayContext();
method public android.view.SurfaceHolder getSurfaceHolder();
method public boolean isPreview();
method public boolean isVisible();
diff --git a/core/java/android/net/INetdEventCallback.aidl b/core/java/android/net/INetdEventCallback.aidl
index 4b1a08d..0877a1a4 100644
--- a/core/java/android/net/INetdEventCallback.aidl
+++ b/core/java/android/net/INetdEventCallback.aidl
@@ -45,6 +45,20 @@
in String[] ipAddresses, int ipAddressesCount, long timestamp, int uid);
/**
+ * Represents adding or removing a NAT64 prefix.
+ * This method must not block or perform long-running operations.
+ *
+ * @param netId the ID of the network the prefix was performed on.
+ * @param added true if the NAT64 prefix was added, or false if the NAT64 prefix was removed.
+ * There is only one prefix at a time for each netId. If a prefix is added, it replaces
+ * the previous-added prefix.
+ * @param prefixString the detected NAT64 prefix as a string literal.
+ * @param prefixLength the prefix length associated with this NAT64 prefix.
+ */
+ void onNat64PrefixEvent(int netId, boolean added, @utf8InCpp String prefixString,
+ int prefixLength);
+
+ /**
* Represents a private DNS validation success or failure.
* This method must not block or perform long-running operations.
*
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java
index a095b0d..f295b70 100644
--- a/core/java/android/service/wallpaper/WallpaperService.java
+++ b/core/java/android/service/wallpaper/WallpaperService.java
@@ -25,6 +25,7 @@
import android.app.WallpaperColors;
import android.app.WallpaperInfo;
import android.app.WallpaperManager;
+import android.content.Context;
import android.content.Intent;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
@@ -52,12 +53,12 @@
import android.view.InputDevice;
import android.view.InputEvent;
import android.view.InputEventReceiver;
+import android.view.InsetsState;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
-import android.view.InsetsState;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
@@ -211,7 +212,8 @@
private final Supplier<Long> mClockFunction;
private final Handler mHandler;
- Display mDisplay;
+ private Display mDisplay;
+ private Context mDisplayContext;
private int mDisplayState;
final BaseSurfaceHolder mSurfaceHolder = new BaseSurfaceHolder() {
@@ -1038,6 +1040,7 @@
mIWallpaperEngine.mDisplayManager.registerDisplayListener(mDisplayListener,
mCaller.getHandler());
mDisplay = mIWallpaperEngine.mDisplay;
+ mDisplayContext = createDisplayContext(mDisplay);
mDisplayState = mDisplay.getState();
if (DEBUG) Log.v(TAG, "onCreate(): " + this);
@@ -1050,6 +1053,18 @@
}
/**
+ * The {@link Context} with resources that match the current display the wallpaper is on.
+ * For multiple display environment, multiple engines can be created to render on each
+ * display, but these displays may have different densities. Use this context to get the
+ * corresponding resources for currently display, avoiding the context of the service.
+ *
+ * @return A {@link Context} for current display.
+ */
+ public Context getDisplayContext() {
+ return mDisplayContext;
+ }
+
+ /**
* Executes life cycle event and updates internal ambient mode state based on
* message sent from handler.
*
diff --git a/core/java/com/android/server/net/BaseNetdEventCallback.java b/core/java/com/android/server/net/BaseNetdEventCallback.java
index 97247aa..a65214a 100644
--- a/core/java/com/android/server/net/BaseNetdEventCallback.java
+++ b/core/java/com/android/server/net/BaseNetdEventCallback.java
@@ -32,6 +32,12 @@
}
@Override
+ public void onNat64PrefixEvent(int netId, boolean added, String prefixString,
+ int prefixLength) {
+ // default no-op
+ }
+
+ @Override
public void onPrivateDnsValidationEvent(int netId, String ipAddress,
String hostname, boolean validated) {
// default no-op
diff --git a/media/jni/Android.bp b/media/jni/Android.bp
index e25e6a5..7481fff 100644
--- a/media/jni/Android.bp
+++ b/media/jni/Android.bp
@@ -97,9 +97,10 @@
shared_libs: [
"android.hardware.cas@1.0", // for CasManager. VNDK???
"android.hardware.cas.native@1.0", // CasManager. VNDK???
+ "android.hidl.allocator@1.0",
+ "libhidlmemory",
"libbinder",
"libgui", // for VideoFrameScheduler
- "libhidlallocatorutils",
"libhidlbase", // VNDK???
"libpowermanager", // for JWakeLock. to be removed
diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/DrivingStateHelper.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/DrivingStateHelper.java
index 730c3e3..a442426 100644
--- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/DrivingStateHelper.java
+++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/DrivingStateHelper.java
@@ -52,6 +52,9 @@
* is idling or moving, {@code false} otherwise.
*/
public boolean isCurrentlyDriving() {
+ if (mDrivingStateManager == null) {
+ return false;
+ }
try {
CarDrivingStateEvent currentState = mDrivingStateManager.getCurrentCarDrivingState();
if (currentState != null) {
diff --git a/services/core/java/com/android/server/connectivity/NetdEventListenerService.java b/services/core/java/com/android/server/connectivity/NetdEventListenerService.java
index 422f556..e40949b 100644
--- a/services/core/java/com/android/server/connectivity/NetdEventListenerService.java
+++ b/services/core/java/com/android/server/connectivity/NetdEventListenerService.java
@@ -217,6 +217,19 @@
@Override
// Called concurrently by multiple binder threads.
// This method must not block or perform long-running operations.
+ public synchronized void onNat64PrefixEvent(int netId,
+ boolean added, String prefixString, int prefixLength)
+ throws RemoteException {
+ for (INetdEventCallback callback : mNetdEventCallbackList) {
+ if (callback != null) {
+ callback.onNat64PrefixEvent(netId, added, prefixString, prefixLength);
+ }
+ }
+ }
+
+ @Override
+ // Called concurrently by multiple binder threads.
+ // This method must not block or perform long-running operations.
public synchronized void onPrivateDnsValidationEvent(int netId,
String ipAddress, String hostname, boolean validated)
throws RemoteException {
diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
index 64ff9cf..2157c99 100644
--- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
+++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
@@ -60,6 +60,7 @@
import android.hardware.display.DisplayManager;
import android.os.Binder;
import android.os.Bundle;
+import android.os.Debug;
import android.os.Environment;
import android.os.FileObserver;
import android.os.FileUtils;
@@ -85,6 +86,7 @@
import android.util.EventLog;
import android.util.Slog;
import android.util.SparseArray;
+import android.util.SparseBooleanArray;
import android.util.Xml;
import android.view.Display;
import android.view.IWindowManager;
@@ -120,12 +122,13 @@
import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;
+import java.util.function.Predicate;
public class WallpaperManagerService extends IWallpaperManager.Stub
implements IWallpaperManagerService {
- static final String TAG = "WallpaperManagerService";
- static final boolean DEBUG = false;
- static final boolean DEBUG_LIVE = DEBUG || true;
+ private static final String TAG = "WallpaperManagerService";
+ private static final boolean DEBUG = false;
+ private static final boolean DEBUG_LIVE = true;
public static class Lifecycle extends SystemService {
private IWallpaperManagerService mService;
@@ -163,14 +166,14 @@
}
}
- final Object mLock = new Object();
+ private final Object mLock = new Object();
/**
* Minimum time between crashes of a wallpaper service for us to consider
* restarting it vs. just reverting to the static wallpaper.
*/
- static final long MIN_WALLPAPER_CRASH_TIME = 10000;
- static final int MAX_WALLPAPER_COMPONENT_LOG_LENGTH = 128;
+ private static final long MIN_WALLPAPER_CRASH_TIME = 10000;
+ private static final int MAX_WALLPAPER_COMPONENT_LOG_LENGTH = 128;
static final String WALLPAPER = "wallpaper_orig";
static final String WALLPAPER_CROP = "wallpaper";
static final String WALLPAPER_LOCK_ORIG = "wallpaper_lock_orig";
@@ -178,7 +181,7 @@
static final String WALLPAPER_INFO = "wallpaper_info.xml";
// All the various per-user state files we need to be aware of
- static final String[] sPerUserFiles = new String[] {
+ private static final String[] sPerUserFiles = new String[] {
WALLPAPER, WALLPAPER_CROP,
WALLPAPER_LOCK_ORIG, WALLPAPER_LOCK_CROP,
WALLPAPER_INFO
@@ -335,7 +338,7 @@
}
}
- void notifyLockWallpaperChanged() {
+ private void notifyLockWallpaperChanged() {
final IWallpaperManagerCallback cb = mKeyguardListener;
if (cb != null) {
try {
@@ -487,7 +490,7 @@
boolean success = false;
// Only generate crop for default display.
- final WallpaperData.DisplayData wpData = getDisplayDataOrCreate(wallpaper, DEFAULT_DISPLAY);
+ final DisplayData wpData = getDisplayDataOrCreate(DEFAULT_DISPLAY);
Rect cropHint = new Rect(wallpaper.cropHint);
if (DEBUG) {
@@ -640,11 +643,11 @@
}
}
- final Context mContext;
- final IWindowManager mIWindowManager;
- final IPackageManager mIPackageManager;
- final MyPackageMonitor mMonitor;
- final AppOpsManager mAppOpsManager;
+ private final Context mContext;
+ private final IWindowManager mIWindowManager;
+ private final IPackageManager mIPackageManager;
+ private final MyPackageMonitor mMonitor;
+ private final AppOpsManager mAppOpsManager;
private final DisplayManager mDisplayManager;
private final DisplayManager.DisplayListener mDisplayListener =
@@ -654,11 +657,23 @@
public void onDisplayAdded(int displayId) {
synchronized (mLock) {
if (mLastWallpaper != null) {
- final WallpaperConnection.DisplayConnector connector =
- mLastWallpaper.connection.getDisplayConnectorOrCreate(displayId);
- if (connector == null) return;
-
- connector.connectLocked(mLastWallpaper.connection, mLastWallpaper);
+ if (supportsMultiDisplay(mLastWallpaper.connection)) {
+ final WallpaperConnection.DisplayConnector connector =
+ mLastWallpaper.connection.getDisplayConnectorOrCreate(displayId);
+ if (connector == null) return;
+ connector.connectLocked(mLastWallpaper.connection, mLastWallpaper);
+ return;
+ }
+ // System wallpaper does not support multiple displays, attach this display to
+ // the fallback wallpaper.
+ if (mFallbackWallpaper != null) {
+ final WallpaperConnection.DisplayConnector connector = mFallbackWallpaper
+ .connection.getDisplayConnectorOrCreate(displayId);
+ if (connector == null) return;
+ connector.connectLocked(mFallbackWallpaper.connection, mFallbackWallpaper);
+ } else {
+ Slog.w(TAG, "No wallpaper can be added to the new display");
+ }
}
}
}
@@ -667,12 +682,19 @@
public void onDisplayRemoved(int displayId) {
synchronized (mLock) {
if (mLastWallpaper != null) {
- final WallpaperConnection.DisplayConnector connector =
- mLastWallpaper.connection.getDisplayConnectorOrCreate(displayId);
+ WallpaperData targetWallpaper = null;
+ if (mLastWallpaper.connection.containsDisplay(displayId)) {
+ targetWallpaper = mLastWallpaper;
+ } else if (mFallbackWallpaper.connection.containsDisplay(displayId)) {
+ targetWallpaper = mFallbackWallpaper;
+ }
+ if (targetWallpaper == null) return;
+ WallpaperConnection.DisplayConnector connector =
+ targetWallpaper.connection.getDisplayConnectorOrCreate(displayId);
if (connector == null) return;
connector.disconnectLocked();
- mLastWallpaper.connection.removeDisplayConnector(displayId);
- mLastWallpaper.removeDisplayData(displayId);
+ targetWallpaper.connection.removeDisplayConnector(displayId);
+ removeDisplayData(displayId);
}
}
}
@@ -686,35 +708,40 @@
* Map of color listeners per user id.
* The key will be the id of a user or UserHandle.USER_ALL - for wildcard listeners.
*/
- final SparseArray<RemoteCallbackList<IWallpaperManagerCallback>> mColorsChangedListeners;
- WallpaperData mLastWallpaper;
- IWallpaperManagerCallback mKeyguardListener;
- boolean mWaitingForUnlock;
- boolean mShuttingDown;
+ private final SparseArray<RemoteCallbackList<IWallpaperManagerCallback>>
+ mColorsChangedListeners;
+ private WallpaperData mLastWallpaper;
+ private IWallpaperManagerCallback mKeyguardListener;
+ private boolean mWaitingForUnlock;
+ private boolean mShuttingDown;
/**
* ID of the current wallpaper, changed every time anything sets a wallpaper.
* This is used for external detection of wallpaper update activity.
*/
- int mWallpaperId;
+ private int mWallpaperId;
/**
* Name of the component used to display bitmap wallpapers from either the gallery or
* built-in wallpapers.
*/
- final ComponentName mImageWallpaper;
+ private final ComponentName mImageWallpaper;
/**
* Name of the default wallpaper component; might be different from mImageWallpaper
*/
- final ComponentName mDefaultWallpaperComponent;
+ private final ComponentName mDefaultWallpaperComponent;
- final SparseArray<WallpaperData> mWallpaperMap = new SparseArray<WallpaperData>();
- final SparseArray<WallpaperData> mLockWallpaperMap = new SparseArray<WallpaperData>();
+ private final SparseArray<WallpaperData> mWallpaperMap = new SparseArray<WallpaperData>();
+ private final SparseArray<WallpaperData> mLockWallpaperMap = new SparseArray<WallpaperData>();
- final SparseArray<Boolean> mUserRestorecon = new SparseArray<Boolean>();
- int mCurrentUserId = UserHandle.USER_NULL;
- boolean mInAmbientMode;
+ private SparseArray<DisplayData> mDisplayDatas = new SparseArray<>();
+
+ private WallpaperData mFallbackWallpaper;
+
+ private final SparseBooleanArray mUserRestorecon = new SparseBooleanArray();
+ private int mCurrentUserId = UserHandle.USER_NULL;
+ private boolean mInAmbientMode;
static class WallpaperData {
@@ -780,18 +807,6 @@
private RemoteCallbackList<IWallpaperManagerCallback> callbacks
= new RemoteCallbackList<IWallpaperManagerCallback>();
- private static final class DisplayData {
- int mWidth = -1;
- int mHeight = -1;
- final Rect mPadding = new Rect(0, 0, 0, 0);
- final int mDisplayId;
-
- DisplayData(int displayId) {
- mDisplayId = displayId;
- }
- }
- private SparseArray<DisplayData> mDisplayDatas = new SparseArray<>();
-
/**
* The crop hint supplied for displaying a subset of the source image
*/
@@ -812,24 +827,34 @@
boolean sourceExists() {
return wallpaperFile.exists();
}
+ }
- void removeDisplayData(int displayId) {
- mDisplayDatas.remove(displayId);
+ private static final class DisplayData {
+ int mWidth = -1;
+ int mHeight = -1;
+ final Rect mPadding = new Rect(0, 0, 0, 0);
+ final int mDisplayId;
+
+ DisplayData(int displayId) {
+ mDisplayId = displayId;
}
}
- private WallpaperData.DisplayData getDisplayDataOrCreate(WallpaperData data, int displayId) {
- WallpaperData.DisplayData wpdData = data.mDisplayDatas.get(displayId);
+ private void removeDisplayData(int displayId) {
+ mDisplayDatas.remove(displayId);
+ }
+
+ private DisplayData getDisplayDataOrCreate(int displayId) {
+ DisplayData wpdData = mDisplayDatas.get(displayId);
if (wpdData == null) {
- wpdData = new WallpaperData.DisplayData(displayId);
+ wpdData = new DisplayData(displayId);
ensureSaneWallpaperDisplaySize(wpdData, displayId);
- data.mDisplayDatas.append(displayId, wpdData);
+ mDisplayDatas.append(displayId, wpdData);
}
return wpdData;
}
- private void ensureSaneWallpaperDisplaySize(WallpaperData.DisplayData wpdData,
- int displayId) {
+ private void ensureSaneWallpaperDisplaySize(DisplayData wpdData, int displayId) {
// We always want to have some reasonable width hint.
final int baseSize = getMaximumSizeDimension(displayId);
if (wpdData.mWidth < baseSize) {
@@ -842,12 +867,16 @@
private int getMaximumSizeDimension(int displayId) {
Display display = mDisplayManager.getDisplay(displayId);
+ if (display == null) {
+ Slog.w(TAG, "Invalid displayId=" + displayId + " " + Debug.getCallers(4));
+ display = mDisplayManager.getDisplay(DEFAULT_DISPLAY);
+ }
return display.getMaximumSizeDimension();
}
- void forEachDisplayData(WallpaperData data, Consumer<WallpaperData.DisplayData> action) {
- for (int i = data.mDisplayDatas.size() - 1; i >= 0; i--) {
- final WallpaperData.DisplayData wpdData = data.mDisplayDatas.valueAt(i);
+ void forEachDisplayData(Consumer<DisplayData> action) {
+ for (int i = mDisplayDatas.size() - 1; i >= 0; i--) {
+ final DisplayData wpdData = mDisplayDatas.valueAt(i);
action.accept(wpdData);
}
}
@@ -859,6 +888,36 @@
return mWallpaperId;
}
+ private boolean supportsMultiDisplay(WallpaperConnection connection) {
+ if (connection != null) {
+ return connection.mInfo == null // This is image wallpaper
+ || connection.mInfo.supportsMultipleDisplays();
+ }
+ return false;
+ }
+
+ private void updateFallbackConnection() {
+ if (mLastWallpaper == null || mFallbackWallpaper == null) return;
+ final WallpaperConnection systemConnection = mLastWallpaper.connection;
+ final WallpaperConnection fallbackConnection = mFallbackWallpaper.connection;
+ if (supportsMultiDisplay(systemConnection)
+ && fallbackConnection.getConnectedEngineSize() != 0) {
+ fallbackConnection.forEachDisplayConnector(
+ WallpaperConnection.DisplayConnector::disconnectLocked);
+ fallbackConnection.mDisplayConnector.clear();
+ } else {
+ fallbackConnection.appendConnectorWithCondition(display ->
+ fallbackConnection.isUsableDisplay(display)
+ && display.getDisplayId() != DEFAULT_DISPLAY
+ && !fallbackConnection.containsDisplay(display.getDisplayId()));
+ fallbackConnection.forEachDisplayConnector(connector -> {
+ if (connector.mEngine == null) {
+ connector.connectLocked(fallbackConnection, mFallbackWallpaper);
+ }
+ });
+ }
+ }
+
class WallpaperConnection extends IWallpaperConnection.Stub
implements ServiceConnection {
@@ -877,8 +936,7 @@
}
void ensureStatusHandled() {
- final WallpaperData.DisplayData wpdData = getDisplayDataOrCreate(mWallpaper,
- mDisplayId);
+ final DisplayData wpdData = getDisplayDataOrCreate(mDisplayId);
if (mDimensionsChanged) {
try {
mEngine.setDesiredSize(wpdData.mWidth, wpdData.mHeight);
@@ -906,8 +964,7 @@
return;
}
- final WallpaperData.DisplayData wpdData = getDisplayDataOrCreate(wallpaper,
- mDisplayId);
+ final DisplayData wpdData = getDisplayDataOrCreate(mDisplayId);
try {
connection.mService.attach(connection, mToken, TYPE_WALLPAPER, false,
wpdData.mWidth, wpdData.mHeight,
@@ -982,19 +1039,33 @@
}
private void initDisplayState() {
- final Display[] displays = mDisplayManager.getDisplays();
- for (Display display : displays) {
- if (isUsableDisplay(display)) {
- final int displayId = display.getDisplayId();
- mDisplayConnector.append(displayId, new DisplayConnector(displayId));
+ // Do not initialize fallback wallpaper
+ if (!mWallpaper.equals(mFallbackWallpaper)) {
+ if (supportsMultiDisplay(this)) {
+ // The system wallpaper is image wallpaper or it can supports multiple displays.
+ appendConnectorWithCondition(this::isUsableDisplay);
+ } else {
+ // The system wallpaper does not support multiple displays, so just attach it on
+ // default display.
+ mDisplayConnector.append(DEFAULT_DISPLAY,
+ new DisplayConnector(DEFAULT_DISPLAY));
}
}
}
- // TODO(b/115486823) Support the system decorations change at runtime.
+ private void appendConnectorWithCondition(Predicate<Display> tester) {
+ final Display[] displays = mDisplayManager.getDisplays();
+ for (Display display : displays) {
+ if (tester.test(display)) {
+ final int displayId = display.getDisplayId();
+ mDisplayConnector.append(displayId,
+ new DisplayConnector(displayId));
+ }
+ }
+ }
+
private boolean isUsableDisplay(Display display) {
return display != null && display.hasAccess(mClientUid)
- // TODO(b/114338689) Use WindowManager.supportsSystemDecorations when ready
&& (display.supportsSystemDecorations()
|| display.getDisplayId() == DEFAULT_DISPLAY);
}
@@ -1027,6 +1098,10 @@
return connector;
}
+ boolean containsDisplay(int displayId) {
+ return mDisplayConnector.get(displayId) != null;
+ }
+
void removeDisplayConnector(int displayId) {
final DisplayConnector connector = mDisplayConnector.get(displayId);
if (connector != null) {
@@ -1044,7 +1119,9 @@
// when we have an engine, but I'm not sure about
// locking there and anyway we always need to be able to
// recover if there is something wrong.
- saveSettingsLocked(mWallpaper.userId);
+ if (!mWallpaper.equals(mFallbackWallpaper)) {
+ saveSettingsLocked(mWallpaper.userId);
+ }
FgThread.getHandler().removeCallbacks(mResetRunnable);
}
}
@@ -1533,8 +1610,8 @@
// This corrects for mislabeling bugs that might have arisen from move-to
// operations involving the wallpaper files. This isn't timing-critical,
// so we do it in the background to avoid holding up the user unlock operation.
- if (mUserRestorecon.get(userId) != Boolean.TRUE) {
- mUserRestorecon.put(userId, Boolean.TRUE);
+ if (!mUserRestorecon.get(userId)) {
+ mUserRestorecon.put(userId, true);
Runnable relabeler = new Runnable() {
@Override
public void run() {
@@ -1562,7 +1639,7 @@
for (String filename : sPerUserFiles) {
new File(wallpaperDir, filename).delete();
}
- mUserRestorecon.remove(userId);
+ mUserRestorecon.delete(userId);
}
}
@@ -1789,7 +1866,7 @@
throw new IllegalArgumentException("Cannot find display with id=" + displayId);
}
- final WallpaperData.DisplayData wpdData = getDisplayDataOrCreate(wallpaper, displayId);
+ final DisplayData wpdData = getDisplayDataOrCreate(displayId);
if (width != wpdData.mWidth || height != wpdData.mHeight) {
wpdData.mWidth = width;
wpdData.mHeight = height;
@@ -1826,8 +1903,7 @@
}
WallpaperData wallpaper = mWallpaperMap.get(UserHandle.getCallingUserId());
if (wallpaper != null) {
- final WallpaperData.DisplayData wpdData = getDisplayDataOrCreate(wallpaper,
- displayId);
+ final DisplayData wpdData = getDisplayDataOrCreate(displayId);
return wpdData.mWidth;
} else {
return 0;
@@ -1845,8 +1921,7 @@
}
WallpaperData wallpaper = mWallpaperMap.get(UserHandle.getCallingUserId());
if (wallpaper != null) {
- final WallpaperData.DisplayData wpdData = getDisplayDataOrCreate(wallpaper,
- displayId);
+ final DisplayData wpdData = getDisplayDataOrCreate(displayId);
return wpdData.mHeight;
} else {
return 0;
@@ -1872,7 +1947,7 @@
throw new IllegalArgumentException("padding must be positive: " + padding);
}
- final WallpaperData.DisplayData wpdData = getDisplayDataOrCreate(wallpaper, displayId);
+ final DisplayData wpdData = getDisplayDataOrCreate(displayId);
if (!padding.equals(wpdData.mPadding)) {
wpdData.mPadding.set(padding);
if (displayId == DEFAULT_DISPLAY) saveSettingsLocked(userId);
@@ -1940,8 +2015,7 @@
return null;
}
// Only for default display.
- final WallpaperData.DisplayData wpdData = getDisplayDataOrCreate(wallpaper,
- DEFAULT_DISPLAY);
+ final DisplayData wpdData = getDisplayDataOrCreate(DEFAULT_DISPLAY);
try {
if (outParams != null) {
outParams.putInt("width", wpdData.mWidth);
@@ -2173,14 +2247,8 @@
// We know a-priori that there is no lock-only wallpaper currently
WallpaperData lockWP = new WallpaperData(userId,
WALLPAPER_LOCK_ORIG, WALLPAPER_LOCK_CROP);
- final WallpaperData.DisplayData lockWPDData = getDisplayDataOrCreate(lockWP,
- DEFAULT_DISPLAY);
- final WallpaperData.DisplayData sysWPDData = getDisplayDataOrCreate(sysWP,
- DEFAULT_DISPLAY);
lockWP.wallpaperId = sysWP.wallpaperId;
lockWP.cropHint.set(sysWP.cropHint);
- lockWPDData.mWidth = sysWPDData.mWidth;
- lockWPDData.mHeight = sysWPDData.mHeight;
lockWP.allowBackup = sysWP.allowBackup;
lockWP.primaryColors = sysWP.primaryColors;
@@ -2320,7 +2388,7 @@
return false;
}
- boolean bindWallpaperComponentLocked(ComponentName componentName, boolean force,
+ private boolean bindWallpaperComponentLocked(ComponentName componentName, boolean force,
boolean fromUser, WallpaperData wallpaper, IRemoteCallback reply) {
if (DEBUG_LIVE) {
Slog.v(TAG, "bindWallpaperComponentLocked: componentName=" + componentName);
@@ -2443,15 +2511,17 @@
Slog.w(TAG, msg);
return false;
}
- if (wallpaper.userId == mCurrentUserId && mLastWallpaper != null) {
+ if (wallpaper.userId == mCurrentUserId && mLastWallpaper != null
+ && !wallpaper.equals(mFallbackWallpaper)) {
detachWallpaperLocked(mLastWallpaper);
}
wallpaper.wallpaperComponent = componentName;
wallpaper.connection = newConn;
newConn.mReply = reply;
- if (wallpaper.userId == mCurrentUserId) {
+ if (wallpaper.userId == mCurrentUserId && !wallpaper.equals(mFallbackWallpaper)) {
mLastWallpaper = wallpaper;
}
+ updateFallbackConnection();
} catch (RemoteException e) {
String msg = "Remote exception for " + componentName + "\n" + e;
if (fromUser) {
@@ -2463,7 +2533,7 @@
return true;
}
- void detachWallpaperLocked(WallpaperData wallpaper) {
+ private void detachWallpaperLocked(WallpaperData wallpaper) {
if (wallpaper.connection != null) {
if (wallpaper.connection.mReply != null) {
try {
@@ -2473,7 +2543,8 @@
wallpaper.connection.mReply = null;
}
mContext.unbindService(wallpaper.connection);
- wallpaper.connection.forEachDisplayConnector(connector -> connector.disconnectLocked());
+ wallpaper.connection.forEachDisplayConnector(
+ WallpaperConnection.DisplayConnector::disconnectLocked);
wallpaper.connection.mService = null;
wallpaper.connection.mDisplayConnector.clear();
wallpaper.connection = null;
@@ -2481,12 +2552,12 @@
}
}
- void clearWallpaperComponentLocked(WallpaperData wallpaper) {
+ private void clearWallpaperComponentLocked(WallpaperData wallpaper) {
wallpaper.wallpaperComponent = null;
detachWallpaperLocked(wallpaper);
}
- void attachServiceLocked(WallpaperConnection conn, WallpaperData wallpaper) {
+ private void attachServiceLocked(WallpaperConnection conn, WallpaperData wallpaper) {
conn.forEachDisplayConnector(connector-> connector.connectLocked(conn, wallpaper));
}
@@ -2596,8 +2667,7 @@
if (DEBUG) {
Slog.v(TAG, "writeWallpaperAttributes id=" + wallpaper.wallpaperId);
}
- final WallpaperData.DisplayData wpdData = getDisplayDataOrCreate(wallpaper,
- DEFAULT_DISPLAY);
+ final DisplayData wpdData = getDisplayDataOrCreate(DEFAULT_DISPLAY);
out.startTag(null, tag);
out.attribute(null, "id", Integer.toString(wallpaper.wallpaperId));
out.attribute(null, "width", Integer.toString(wpdData.mWidth));
@@ -2755,10 +2825,10 @@
Slog.i(TAG, "No static wallpaper imagery; defaults will be shown");
}
}
+ initializeFallbackWallpaper();
}
boolean success = false;
- final WallpaperData.DisplayData wpdData = getDisplayDataOrCreate(wallpaper,
- DEFAULT_DISPLAY);
+ final DisplayData wpdData = getDisplayDataOrCreate(DEFAULT_DISPLAY);
try {
stream = new FileInputStream(file);
XmlPullParser parser = Xml.newPullParser();
@@ -2845,8 +2915,19 @@
}
}
+ private void initializeFallbackWallpaper() {
+ if (mFallbackWallpaper == null) {
+ if (DEBUG) Slog.d(TAG, "Initialize fallback wallpaper");
+ mFallbackWallpaper = new WallpaperData(
+ UserHandle.USER_SYSTEM, WALLPAPER, WALLPAPER_CROP);
+ mFallbackWallpaper.allowBackup = false;
+ mFallbackWallpaper.wallpaperId = makeWallpaperIdLocked();
+ bindWallpaperComponentLocked(mImageWallpaper, true, false, mFallbackWallpaper, null);
+ }
+ }
+
private void ensureSaneWallpaperData(WallpaperData wallpaper, int displayId) {
- final WallpaperData.DisplayData size = getDisplayDataOrCreate(wallpaper, displayId);
+ final DisplayData size = getDisplayDataOrCreate(displayId);
if (displayId == DEFAULT_DISPLAY) {
// crop, if not previously specified
@@ -2869,7 +2950,7 @@
wallpaper.wallpaperId = makeWallpaperIdLocked();
}
- final WallpaperData.DisplayData wpData = getDisplayDataOrCreate(wallpaper, DEFAULT_DISPLAY);
+ final DisplayData wpData = getDisplayDataOrCreate(DEFAULT_DISPLAY);
if (!keepDimensionHints) {
wpData.mWidth = Integer.parseInt(parser.getAttributeValue(null, "width"));
@@ -2963,7 +3044,7 @@
}
// Restore the named resource bitmap to both source + crop files
- boolean restoreNamedResourceLocked(WallpaperData wallpaper) {
+ private boolean restoreNamedResourceLocked(WallpaperData wallpaper) {
if (wallpaper.name.length() > 4 && "res:".equals(wallpaper.name.substring(0, 4))) {
String resName = wallpaper.name.substring(4);
@@ -3048,8 +3129,9 @@
for (int i = 0; i < mWallpaperMap.size(); i++) {
WallpaperData wallpaper = mWallpaperMap.valueAt(i);
pw.print(" User "); pw.print(wallpaper.userId);
- pw.print(": id="); pw.println(wallpaper.wallpaperId);
- forEachDisplayData(wallpaper, wpSize -> {
+ pw.print(": id="); pw.println(wallpaper.wallpaperId);
+ pw.println(" Display state:");
+ forEachDisplayData(wpSize -> {
pw.print(" displayId=");
pw.println(wpSize.mDisplayId);
pw.print(" mWidth=");
@@ -3072,11 +3154,11 @@
pw.println(conn.mInfo.getComponent());
}
conn.forEachDisplayConnector(connector -> {
- pw.print(" mDisplayId=");
+ pw.print(" mDisplayId=");
pw.println(connector.mDisplayId);
- pw.print(" mToken=");
+ pw.print(" mToken=");
pw.println(connector.mToken);
- pw.print(" mEngine=");
+ pw.print(" mEngine=");
pw.println(connector.mEngine);
});
pw.print(" mService=");
@@ -3090,18 +3172,38 @@
WallpaperData wallpaper = mLockWallpaperMap.valueAt(i);
pw.print(" User "); pw.print(wallpaper.userId);
pw.print(": id="); pw.println(wallpaper.wallpaperId);
- forEachDisplayData(wallpaper, wpSize -> {
- pw.print(" displayId=");
- pw.println(wpSize.mDisplayId);
- pw.print(" mWidth="); pw.print(wpSize.mWidth);
- pw.print(" mHeight="); pw.println(wpSize.mHeight);
- pw.print(" mPadding="); pw.println(wpSize.mPadding);
- });
pw.print(" mCropHint="); pw.println(wallpaper.cropHint);
pw.print(" mName="); pw.println(wallpaper.name);
pw.print(" mAllowBackup="); pw.println(wallpaper.allowBackup);
}
-
+ pw.println("Fallback wallpaper state:");
+ pw.print(" User "); pw.print(mFallbackWallpaper.userId);
+ pw.print(": id="); pw.println(mFallbackWallpaper.wallpaperId);
+ pw.print(" mCropHint="); pw.println(mFallbackWallpaper.cropHint);
+ pw.print(" mName="); pw.println(mFallbackWallpaper.name);
+ pw.print(" mAllowBackup="); pw.println(mFallbackWallpaper.allowBackup);
+ if (mFallbackWallpaper.connection != null) {
+ WallpaperConnection conn = mFallbackWallpaper.connection;
+ pw.print(" Fallback Wallpaper connection ");
+ pw.print(conn);
+ pw.println(":");
+ if (conn.mInfo != null) {
+ pw.print(" mInfo.component=");
+ pw.println(conn.mInfo.getComponent());
+ }
+ conn.forEachDisplayConnector(connector -> {
+ pw.print(" mDisplayId=");
+ pw.println(connector.mDisplayId);
+ pw.print(" mToken=");
+ pw.println(connector.mToken);
+ pw.print(" mEngine=");
+ pw.println(connector.mEngine);
+ });
+ pw.print(" mService=");
+ pw.println(conn.mService);
+ pw.print(" mLastDiedTime=");
+ pw.println(mFallbackWallpaper.lastDiedTime - SystemClock.uptimeMillis());
+ }
}
}
}
diff --git a/services/net/java/android/net/dhcp/DhcpServer.java b/services/net/java/android/net/dhcp/DhcpServer.java
index cee6fa9..35d29e7 100644
--- a/services/net/java/android/net/dhcp/DhcpServer.java
+++ b/services/net/java/android/net/dhcp/DhcpServer.java
@@ -39,7 +39,6 @@
import android.net.MacAddress;
import android.net.NetworkUtils;
import android.net.TrafficStats;
-import android.net.util.InterfaceParams;
import android.net.util.SharedLog;
import android.os.Handler;
import android.os.Looper;
@@ -85,7 +84,7 @@
@NonNull
private final ServerHandler mHandler;
@NonNull
- private final InterfaceParams mIface;
+ private final String mIfName;
@NonNull
private final DhcpLeaseRepository mLeaseRepo;
@NonNull
@@ -161,20 +160,20 @@
}
}
- public DhcpServer(@NonNull Looper looper, @NonNull InterfaceParams iface,
+ public DhcpServer(@NonNull Looper looper, @NonNull String ifName,
@NonNull DhcpServingParams params, @NonNull SharedLog log) {
- this(looper, iface, params, log, null);
+ this(looper, ifName, params, log, null);
}
@VisibleForTesting
- DhcpServer(@NonNull Looper looper, @NonNull InterfaceParams iface,
+ DhcpServer(@NonNull Looper looper, @NonNull String ifName,
@NonNull DhcpServingParams params, @NonNull SharedLog log,
@Nullable Dependencies deps) {
if (deps == null) {
deps = new DependenciesImpl();
}
mHandler = new ServerHandler(looper);
- mIface = iface;
+ mIfName = ifName;
mServingParams = params;
mLog = log;
mDeps = deps;
@@ -444,7 +443,7 @@
private boolean addArpEntry(@NonNull MacAddress macAddr, @NonNull Inet4Address inetAddr) {
try {
- mDeps.addArpEntry(inetAddr, macAddr, mIface.name, mSocket);
+ mDeps.addArpEntry(inetAddr, macAddr, mIfName, mSocket);
return true;
} catch (IOException e) {
mLog.e("Error adding client to ARP table", e);
@@ -526,7 +525,7 @@
// SO_BINDTODEVICE actually takes a string. This works because the first member
// of struct ifreq is a NULL-terminated interface name.
// TODO: add a setsockoptString()
- Os.setsockoptIfreq(mSocket, SOL_SOCKET, SO_BINDTODEVICE, mIface.name);
+ Os.setsockoptIfreq(mSocket, SOL_SOCKET, SO_BINDTODEVICE, mIfName);
Os.setsockoptInt(mSocket, SOL_SOCKET, SO_BROADCAST, 1);
Os.bind(mSocket, Inet4Address.ANY, DHCP_SERVER);
NetworkUtils.protectFromVpn(mSocket);
diff --git a/services/net/java/android/net/ip/IpServer.java b/services/net/java/android/net/ip/IpServer.java
index 823c0a1..493350d 100644
--- a/services/net/java/android/net/ip/IpServer.java
+++ b/services/net/java/android/net/ip/IpServer.java
@@ -138,9 +138,9 @@
return NetdService.getInstance();
}
- public DhcpServer makeDhcpServer(Looper looper, InterfaceParams iface,
+ public DhcpServer makeDhcpServer(Looper looper, String ifName,
DhcpServingParams params, SharedLog log) {
- return new DhcpServer(looper, iface, params, log);
+ return new DhcpServer(looper, ifName, params, log);
}
}
@@ -256,12 +256,6 @@
if (mUsingLegacyDhcp) {
return true;
}
-
- final InterfaceParams ifaceParams = mDeps.getInterfaceParams(mIfaceName);
- if (ifaceParams == null) {
- Log.e(TAG, "Failed to find interface params for DHCPv4");
- return false;
- }
final DhcpServingParams params;
try {
params = new DhcpServingParams.Builder()
@@ -277,7 +271,7 @@
return false;
}
- mDhcpServer = mDeps.makeDhcpServer(getHandler().getLooper(), ifaceParams, params,
+ mDhcpServer = mDeps.makeDhcpServer(getHandler().getLooper(), mIfaceName, params,
mLog.forSubComponent("DHCP"));
mDhcpServer.start();
return true;
diff --git a/tests/net/java/android/net/dhcp/DhcpServerTest.java b/tests/net/java/android/net/dhcp/DhcpServerTest.java
index df34c73..ab9bd84 100644
--- a/tests/net/java/android/net/dhcp/DhcpServerTest.java
+++ b/tests/net/java/android/net/dhcp/DhcpServerTest.java
@@ -25,7 +25,6 @@
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
@@ -48,7 +47,6 @@
import android.net.dhcp.DhcpLeaseRepository.OutOfAddressesException;
import android.net.dhcp.DhcpServer.Clock;
import android.net.dhcp.DhcpServer.Dependencies;
-import android.net.util.InterfaceParams;
import android.net.util.SharedLog;
import android.os.test.TestLooper;
import android.support.test.filters.SmallTest;
@@ -74,9 +72,6 @@
public class DhcpServerTest {
private static final String PROP_DEXMAKER_SHARE_CLASSLOADER = "dexmaker.share_classloader";
private static final String TEST_IFACE = "testiface";
- private static final MacAddress TEST_IFACE_MAC = MacAddress.fromString("11:22:33:44:55:66");
- private static final InterfaceParams TEST_IFACEPARAMS =
- new InterfaceParams(TEST_IFACE, 1, TEST_IFACE_MAC);
private static final Inet4Address TEST_SERVER_ADDR = parseAddr("192.168.0.2");
private static final LinkAddress TEST_SERVER_LINKADDR = new LinkAddress(TEST_SERVER_ADDR, 20);
@@ -149,7 +144,7 @@
.build();
mLooper = new TestLooper();
- mServer = new DhcpServer(mLooper.getLooper(), TEST_IFACEPARAMS, servingParams,
+ mServer = new DhcpServer(mLooper.getLooper(), TEST_IFACE, servingParams,
new SharedLog(DhcpServerTest.class.getSimpleName()), mDeps);
mServer.start();
diff --git a/tests/net/java/android/net/ip/IpServerTest.java b/tests/net/java/android/net/ip/IpServerTest.java
index cff0b54..2c675c6 100644
--- a/tests/net/java/android/net/ip/IpServerTest.java
+++ b/tests/net/java/android/net/ip/IpServerTest.java
@@ -404,7 +404,7 @@
private void assertDhcpStarted(IpPrefix expectedPrefix) {
verify(mDependencies, times(1)).makeDhcpServer(
- eq(mLooper.getLooper()), eq(TEST_IFACE_PARAMS), any(), eq(mSharedLog));
+ eq(mLooper.getLooper()), eq(IFACE_NAME), any(), eq(mSharedLog));
verify(mDhcpServer, times(1)).start();
final DhcpServingParams params = mDhcpParamsCaptor.getValue();
// Last address byte is random
diff --git a/tests/net/java/com/android/server/connectivity/TetheringTest.java b/tests/net/java/com/android/server/connectivity/TetheringTest.java
index bca9be7..e6b43d2 100644
--- a/tests/net/java/com/android/server/connectivity/TetheringTest.java
+++ b/tests/net/java/com/android/server/connectivity/TetheringTest.java
@@ -240,7 +240,7 @@
}
@Override
- public DhcpServer makeDhcpServer(Looper looper, InterfaceParams iface,
+ public DhcpServer makeDhcpServer(Looper looper, String ifName,
DhcpServingParams params, SharedLog log) {
return mDhcpServer;
}