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

Commit e58a49e4 authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Merge commit '817ec49e' into manualmerge

Conflicts:
	services/print/java/com/android/server/print/PrintManagerService.java

Change-Id: I1b9bf364ca50ee3c48f53d87ae0ce23e7f3c2bc2
parents 3c8a529b 817ec49e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES :=

# TODO: Move this to the product makefiles
REQUIRED_SERVICES := core appwidget backup devicepolicy accessibility print
REQUIRED_SERVICES := core accessibility appwidget backup devicepolicy print

include $(patsubst %,$(LOCAL_PATH)/%/java/service.mk,$(REQUIRED_SERVICES))

+271 −250
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import com.android.internal.appwidget.IAppWidgetHost;
import com.android.internal.appwidget.IAppWidgetService;
import com.android.internal.os.BackgroundThread;
import com.android.internal.util.IndentingPrintWriter;
import com.android.server.SystemService;

import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -46,21 +47,19 @@ import java.util.Locale;


/**
 * Redirects calls to this service to the instance of the service for the appropriate user.
 * SystemService that publishes an IAppWidgetService.
 */
public class AppWidgetService extends IAppWidgetService.Stub
{
    private static final String TAG = "AppWidgetService";
public class AppWidgetService extends SystemService {

    static final String TAG = "AppWidgetService";

    Context mContext;
    Locale mLocale;
    PackageManager mPackageManager;
    boolean mSafeMode;
    private final Handler mSaveStateHandler;
    Handler mSaveStateHandler;

    private final SparseArray<AppWidgetServiceImpl> mAppWidgetServices;
    SparseArray<AppWidgetServiceImpl> mAppWidgetServices;

    public AppWidgetService(Context context) {
    @Override
    public void onCreate(Context context) {
        mContext = context;

        mSaveStateHandler = BackgroundThread.getHandler();
@@ -70,6 +69,26 @@ public class AppWidgetService extends IAppWidgetService.Stub
        mAppWidgetServices.append(0, primary);
    }

    @Override
    public void onStart() {
        publishBinderService(Context.APPWIDGET_SERVICE, mServiceImpl);
    }

    @Override
    public void onBootPhase(int phase) {
        if (phase == PHASE_THIRD_PARTY_APPS_CAN_START) {
            mServiceImpl.systemRunning(isSafeMode());
        }
    }

    private final AppWidgetServiceStub mServiceImpl = new AppWidgetServiceStub();

    private class AppWidgetServiceStub extends IAppWidgetService.Stub {

        private boolean mSafeMode;
        private Locale mLocale;
        private PackageManager mPackageManager;

        public void systemRunning(boolean safeMode) {
            mSafeMode = safeMode;

@@ -146,15 +165,15 @@ public class AppWidgetService extends IAppWidgetService.Stub
        }

        @Override
    public void bindAppWidgetId(int appWidgetId, ComponentName provider, Bundle options, int userId)
            throws RemoteException {
        public void bindAppWidgetId(int appWidgetId, ComponentName provider, Bundle options,
                int userId) throws RemoteException {
            getImplForUser(userId).bindAppWidgetId(appWidgetId, provider, options);
        }

        @Override
        public boolean bindAppWidgetIdIfAllowed(
            String packageName, int appWidgetId, ComponentName provider, Bundle options, int userId)
                    throws RemoteException {
                String packageName, int appWidgetId, ComponentName provider, Bundle options,
                int userId) throws RemoteException {
            return getImplForUser(userId).bindAppWidgetIdIfAllowed(
                    packageName, appWidgetId, provider, options);
        }
@@ -226,7 +245,8 @@ public class AppWidgetService extends IAppWidgetService.Stub
            synchronized (mAppWidgetServices) {
                service = mAppWidgetServices.get(userId);
                if (service == null) {
                Slog.i(TAG, "Unable to find AppWidgetServiceImpl for user " + userId + ", adding");
                    Slog.i(TAG, "Unable to find AppWidgetServiceImpl for user " + userId
                            + ", adding");
                    // TODO: Verify that it's a valid user
                    service = new AppWidgetServiceImpl(mContext, userId, mSaveStateHandler);
                    service.systemReady(mSafeMode);
@@ -361,3 +381,4 @@ public class AppWidgetService extends IAppWidgetService.Stub
            }
        };
    }
}
+3 −1
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ import com.android.internal.backup.BackupConstants;
import com.android.internal.backup.IBackupTransport;
import com.android.internal.backup.IObbBackupService;
import com.android.server.EventLogTags;
import com.android.server.SystemService;
import com.android.server.backup.PackageManagerBackupAgent.Metadata;

import java.io.BufferedInputStream;
@@ -136,6 +137,7 @@ import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.SecretKeySpec;

public class BackupManagerService extends IBackupManager.Stub {

    private static final String TAG = "BackupManagerService";
    private static final boolean DEBUG = true;
    private static final boolean MORE_DEBUG = false;
@@ -6089,7 +6091,7 @@ public class BackupManagerService extends IBackupManager.Stub {
                    }
                }

                // clean up the BackupManagerService side of the bookkeeping
                // clean up the BackupManagerImpl side of the bookkeeping
                // and cancel any pending timeout message
                mBackupManager.clearRestoreSession(mSession);
            }
+36 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2013 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.backup;

import android.content.Context;

import com.android.server.SystemService;

public class BackupManagerSystemService extends SystemService {
    private BackupManagerService mBackupManagerImpl;

    @Override
    public void onCreate(Context context) {
        mBackupManagerImpl = new BackupManagerService(context);
    }

    @Override
    public void onStart() {
        publishBinderService(Context.BACKUP_SERVICE, mBackupManagerImpl);
    }
}
+20 −35
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.media.AudioService;
import android.os.Environment;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.Looper;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -52,11 +53,8 @@ import com.android.server.accessibility.AccessibilityManagerService;
import com.android.server.accounts.AccountManagerService;
import com.android.server.am.ActivityManagerService;
import com.android.server.am.BatteryStatsService;
import com.android.server.appwidget.AppWidgetService;
import com.android.server.backup.BackupManagerService;
import com.android.server.clipboard.ClipboardService;
import com.android.server.content.ContentService;
import com.android.server.devicepolicy.DevicePolicyManagerService;
import com.android.server.display.DisplayManagerService;
import com.android.server.dreams.DreamManagerService;
import com.android.server.input.InputManagerService;
@@ -72,7 +70,6 @@ import com.android.server.pm.PackageManagerService;
import com.android.server.pm.UserManagerService;
import com.android.server.power.PowerManagerService;
import com.android.server.power.ShutdownThread;
import com.android.server.print.PrintManagerService;
import com.android.server.search.SearchManagerService;
import com.android.server.statusbar.StatusBarManagerService;
import com.android.server.storage.DeviceStorageMonitorService;
@@ -98,6 +95,19 @@ class ServerThread {

    ContentResolver mContentResolver;

    /*
     * Implementation class names. TODO: Move them to a codegen class or load
     * them from the build system somehow.
     */
    private static final String BACKUP_MANAGER_SERVICE_CLASS =
            "com.android.server.backup.BackupManagerSystemService";
    private static final String DEVICE_POLICY_MANAGER_SERVICE_CLASS =
            "com.android.server.devicepolicy.DevicePolicyManagerSystemService";
    private static final String APPWIDGET_SERVICE_CLASS =
            "com.android.server.appwidget.AppWidgetService";
    private static final String PRINT_MANAGER_SERVICE_CLASS =
            "com.android.server.print.PrintManagerService";

    void reportWtf(String msg, Throwable e) {
        Slog.w(TAG, "***********************************************");
        Log.wtf(TAG, "BOOT FAILURE " + msg, e);
@@ -357,11 +367,9 @@ class ServerThread {
            Slog.e("System", "************ Failure starting core service", e);
        }

        DevicePolicyManagerService devicePolicy = null;
        StatusBarManagerService statusBar = null;
        INotificationManager notification = null;
        InputMethodManagerService imm = null;
        AppWidgetService appWidget = null;
        WallpaperManagerService wallpaper = null;
        LocationManagerService location = null;
        CountryDetectorService countryDetector = null;
@@ -369,7 +377,6 @@ class ServerThread {
        LockSettingsService lockSettings = null;
        DreamManagerService dreamy = null;
        AssetAtlasService atlas = null;
        PrintManagerService printManager = null;
        MediaRouterService mediaRouter = null;

        // Bring up services needed for UI.
@@ -441,8 +448,7 @@ class ServerThread {

                try {
                    Slog.i(TAG, "Device Policy");
                    devicePolicy = new DevicePolicyManagerService(context);
                    ServiceManager.addService(Context.DEVICE_POLICY_SERVICE, devicePolicy);
                    systemServiceManager.startService(DEVICE_POLICY_MANAGER_SERVICE_CLASS);
                } catch (Throwable e) {
                    reportWtf("starting DevicePolicyService", e);
                }
@@ -692,16 +698,14 @@ class ServerThread {
            if (!disableNonCoreServices) {
                try {
                    Slog.i(TAG, "Backup Service");
                    ServiceManager.addService(Context.BACKUP_SERVICE,
                            new BackupManagerService(context));
                    systemServiceManager.startService(BACKUP_MANAGER_SERVICE_CLASS);
                } catch (Throwable e) {
                    Slog.e(TAG, "Failure starting Backup Service", e);
                }

                try {
                    Slog.i(TAG, "AppWidget Service");
                    appWidget = new AppWidgetService(context);
                    ServiceManager.addService(Context.APPWIDGET_SERVICE, appWidget);
                    systemServiceManager.startService(APPWIDGET_SERVICE_CLASS);
                } catch (Throwable e) {
                    reportWtf("starting AppWidget Service", e);
                }
@@ -792,8 +796,7 @@ class ServerThread {

            try {
                Slog.i(TAG, "Print Service");
                printManager = new PrintManagerService(context);
                ServiceManager.addService(Context.PRINT_SERVICE, printManager);
                systemServiceManager.startService(PRINT_MANAGER_SERVICE_CLASS);
            } catch (Throwable e) {
                reportWtf("starting Print Service", e);
            }
@@ -839,13 +842,8 @@ class ServerThread {
            }
        }

        if (devicePolicy != null) {
            try {
                devicePolicy.systemReady();
            } catch (Throwable e) {
                reportWtf("making Device Policy Service ready", e);
            }
        }
        // Needed by DevicePolicyManager for initialization
        systemServiceManager.startBootPhase(SystemService.PHASE_LOCK_SETTINGS_READY);

        systemServiceManager.startBootPhase(SystemService.PHASE_SYSTEM_SERVICES_READY);

@@ -896,7 +894,6 @@ class ServerThread {
        final ConnectivityService connectivityF = connectivity;
        final DockObserver dockF = dock;
        final UsbService usbF = usb;
        final AppWidgetService appWidgetF = appWidget;
        final WallpaperManagerService wallpaperF = wallpaper;
        final InputMethodManagerService immF = imm;
        final RecognitionManagerService recognitionF = recognition;
@@ -910,7 +907,6 @@ class ServerThread {
        final AssetAtlasService atlasF = atlas;
        final InputManagerService inputManagerF = inputManager;
        final TelephonyRegistry telephonyRegistryF = telephonyRegistry;
        final PrintManagerService printManagerF = printManager;
        final MediaRouterService mediaRouterF = mediaRouter;

        // We now tell the activity manager it is okay to run third party
@@ -983,11 +979,6 @@ class ServerThread {
                // third party code...
                systemServiceManager.startBootPhase(SystemService.PHASE_THIRD_PARTY_APPS_CAN_START);

                try {
                    if (appWidgetF != null) appWidgetF.systemRunning(safeMode);
                } catch (Throwable e) {
                    reportWtf("Notifying AppWidgetService running", e);
                }
                try {
                    if (wallpaperF != null) wallpaperF.systemRunning();
                } catch (Throwable e) {
@@ -1047,12 +1038,6 @@ class ServerThread {
                    reportWtf("Notifying TelephonyRegistry running", e);
                }

                try {
                    if (printManagerF != null) printManagerF.systemRuning();
                } catch (Throwable e) {
                    reportWtf("Notifying PrintManagerService running", e);
                }

                try {
                    if (mediaRouterF != null) mediaRouterF.systemRunning();
                } catch (Throwable e) {
Loading