--- /dev/null
+/*
+ * 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
import com.android.server.FgThread;
import com.android.server.SystemService;
+import java.lang.reflect.InvocationTargetException;
import libcore.io.IoUtils;
import org.xmlpull.v1.XmlPullParser;
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);
@Override
public void onStart() {
- mService = new WallpaperManagerService(getContext());
- publishBinderService(Context.WALLPAPER_SERVICE, mService);
+ try {
+ final Class<? extends IWallpaperManagerService> klass =
+ (Class<? extends IWallpaperManagerService>)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);
+ }
}
}
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) {