diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 78e34f1e77642..9a26229d59462 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -1381,6 +1381,9 @@ true + + com.android.server.wallpaper.WallpaperManagerService + false diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 08686152845bc..69d27fc7059f8 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -287,6 +287,7 @@ + diff --git a/services/core/java/com/android/server/wallpaper/IWallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/IWallpaperManagerService.java new file mode 100644 index 0000000000000..60b08dd3093ce --- /dev/null +++ b/services/core/java/com/android/server/wallpaper/IWallpaperManagerService.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wallpaper; + +import android.app.IWallpaperManager; +import android.os.IBinder; + +/** + * Extended IWallpaperManager which can receive SystemService's lifetime events. + */ +interface IWallpaperManagerService extends IWallpaperManager, IBinder { + /** + * @see com.android.server.SystemService#onBootPhase(int) + */ + void onBootPhase(int phase); + + /** + * @see com.android.server.SystemService#onUnlockUser(int) + */ + void onUnlockUser(final int userId); +} \ No newline at end of file diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java index b888ec21e7086..7b0ed0d06739a 100644 --- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java @@ -99,6 +99,7 @@ import com.android.server.EventLogTags; import com.android.server.FgThread; import com.android.server.SystemService; +import java.lang.reflect.InvocationTargetException; import libcore.io.IoUtils; import org.xmlpull.v1.XmlPullParser; @@ -119,14 +120,16 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Objects; +import com.android.internal.R; -public class WallpaperManagerService extends IWallpaperManager.Stub { +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; public static class Lifecycle extends SystemService { - private WallpaperManagerService mService; + private IWallpaperManagerService mService; public Lifecycle(Context context) { super(context); @@ -134,22 +137,30 @@ public class WallpaperManagerService extends IWallpaperManager.Stub { @Override public void onStart() { - mService = new WallpaperManagerService(getContext()); - publishBinderService(Context.WALLPAPER_SERVICE, mService); + try { + final Class klass = + (Class)Class.forName( + getContext().getResources().getString( + R.string.config_wallpaperManagerServiceName)); + mService = klass.getConstructor(Context.class).newInstance(getContext()); + publishBinderService(Context.WALLPAPER_SERVICE, mService); + } catch (Exception exp) { + Slog.wtf(TAG, "Failed to instantiate WallpaperManagerService", exp); + } } @Override public void onBootPhase(int phase) { - if (phase == SystemService.PHASE_ACTIVITY_MANAGER_READY) { - mService.systemReady(); - } else if (phase == SystemService.PHASE_THIRD_PARTY_APPS_CAN_START) { - mService.switchUser(UserHandle.USER_SYSTEM, null); + if (mService != null) { + mService.onBootPhase(phase); } } @Override public void onUnlockUser(int userHandle) { - mService.onUnlockUser(userHandle); + if (mService != null) { + mService.onUnlockUser(userHandle); + } } } @@ -1255,7 +1266,17 @@ public class WallpaperManagerService extends IWallpaperManager.Stub { mLockWallpaperMap.remove(userId); } - void onUnlockUser(final int userId) { + @Override + public void onBootPhase(int phase) { + if (phase == SystemService.PHASE_ACTIVITY_MANAGER_READY) { + systemReady(); + } else if (phase == SystemService.PHASE_THIRD_PARTY_APPS_CAN_START) { + switchUser(UserHandle.USER_SYSTEM, null); + } + } + + @Override + public void onUnlockUser(final int userId) { synchronized (mLock) { if (mCurrentUserId == userId) { if (mWaitingForUnlock) {