Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4bbf8524 authored by Daichi Hirono's avatar Daichi Hirono
Browse files

Add config resource specifying WallpaperManagerService

The config resource can be used by a vendor to override
WallpaperManagerService.

Bug: 69299523
Test: WallpaperServiceTests, WallpaperManagerTest, WallpaperColorTest,
      WallpaperInfoTest.

Change-Id: I9a38117c5b6fdc01aabb8293cde75485023970cd
parent 3952e256
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1387,6 +1387,9 @@
    <!-- True if WallpaperService is enabled -->
    <bool name="config_enableWallpaperService">true</bool>

    <!-- Class name of WallpaperManagerService. -->
    <string name="config_wallpaperManagerServiceName">com.android.server.wallpaper.WallpaperManagerService</string>

    <!-- Enables the TimeZoneRuleManager service. This is the master switch for the updateable time
         zone update mechanism. -->
    <bool name="config_enableUpdateableTimeZoneRules">false</bool>
+1 −0
Original line number Diff line number Diff line
@@ -287,6 +287,7 @@
  <java-symbol type="bool" name="split_action_bar_is_narrow" />
  <java-symbol type="bool" name="config_useVolumeKeySounds" />
  <java-symbol type="bool" name="config_enableWallpaperService" />
  <java-symbol type="string" name="config_wallpaperManagerServiceName" />
  <java-symbol type="bool" name="config_enableUpdateableTimeZoneRules" />
  <java-symbol type="bool" name="config_timeZoneRulesUpdateTrackingEnabled" />
  <java-symbol type="string" name="config_timeZoneRulesUpdaterPackage" />
+35 −0
Original line number Diff line number Diff line
/*
 * 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
+31 −10
Original line number Diff line number Diff line
@@ -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,24 +137,32 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {

        @Override
        public void onStart() {
            mService = new WallpaperManagerService(getContext());
            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) {
            if (mService != null) {
                mService.onUnlockUser(userHandle);
            }
        }
    }

    final Object mLock = new Object();

@@ -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) {