[T-Mobile LG V10 Android Development] Eliminater74:
Exampled of code:

package com.lge.signboard.baseservice.layer;

import com.lge.signboard.baseservice.layer.blackout.SBBlackOutLayer;
import com.lge.signboard.baseservice.layer.content.SBContentLayer;
import com.lge.signboard.baseservice.layercontroller.ISBLayer;
import com.lge.signboard.baseservice.layercontroller.ISBLayerController;
import com.lge.signboard.common.ISBContext;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class SBLayerContainer
{
private static List<ISBLayer> mLayers;

public static void loadLayers(ISBContext paramISBContext, ISBLayerController paramISBLayerController)
{
if (mLayers == null)
{
mLayers = new ArrayList();
mLayers.add(new SBBlackOutLayer(paramISBContext));
mLayers.add(new SBContentLayer(paramISBContext));
paramISBContext = mLayers.iterator();
while (paramISBContext.hasNext()) {
paramISBLayerController.addLayer((ISBLayer)paramISBContext.next());
}
}
}

public static void unloadLayers(ISBContext paramISBContext, ISBLayerController paramISBLayerController)
{
if (mLayers != null)
{
if (paramISBLayerController != null)
{
paramISBContext = mLayers.iterator();
while (paramISBContext.hasNext()) {
paramISBLayerController.removeLayer((ISBLayer)paramISBContext.next());
}
}
mLayers.clear();
mLayers = null;
}
}
}

package com.lge.signboard.application;

import android.app.ActivityManagerNative;
import android.app.Application;
import android.app.IActivityManager;
import android.app.IUserSwitchObserver;
import android.app.IUserSwitchObserver.Stub;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.UserInfo;
import android.os.IRemoteCallback;
import android.os.RemoteException;
import android.os.UserHandle;
import android.support.v4.content.LocalBroadcastManager;
import com.lge.app.MiniActivity;
import com.lge.signboard.DriveModeObserver;
import com.lge.signboard.NotificationHistoryReceiver;
import com.lge.signboard.PackageResourceAccessor;
import com.lge.signboard.SBDPMListener;
import com.lge.signboard.SBPowerSaverListener;
import com.lge.signboard.SignBoardSupport;
import com.lge.signboard.SmartCoverHandler;
import com.lge.signboard.TimeChangeAlarm;
import com.lge.signboard.TimeTickManager;
import com.lge.signboard.aod.AodService;
import com.lge.signboard.baseservice.SBBaseService;
import com.lge.signboard.common.ISBContext;
import com.lge.signboard.common.ISBManagerContainer;
import com.lge.signboard.common.SBContext;
import com.lge.signboard.eventlistener.EventListenerService;
import com.lge.signboard.lib.util.SBLog;
import com.lge.signboard.los.LOS_SharedPreferenceConverter;
import com.lge.signboard.manager.SBManagerContainer;

public class SBApplication
extends Application
{
private ISBManagerContainer mManager;
private IUserSwitchObserver mUserSwitchObserver;

private IUserSwitchObserver getUserSwitchObserver()
{
if (this.mUserSwitchObserver == null) {
this.mUserSwitchObserver = new IUserSwitchObserver.Stub()
{
public void onForegroundProfileSwitch(int paramAnonymousInt)
throws RemoteException
{}

public void onUserSwitchComplete(int paramAnonymousInt)
throws RemoteException
{}

public void onUserSwitching(int paramAnonymousInt, IRemoteCallback paramAnonymousIRemoteCallback)
{
SBApplication.this.startServices();
}
};
}
return this.mUserSwitchObserver;
}

private void registerUserSwitchObserver()
{
try
{
int i = ActivityManagerNative.getDefault().getCurrentUser().id;
IUserSwitchObserver localIUserSwitchObserver = getUserSwitchObserver();
if ((i == 0) && (localIUserSwitchObserver != null)) {
ActivityManagerNative.getDefault().registerUserSwitchObserver(localIUserSwitchObserver);
}
return;
}
catch (Exception localException)
{
SBLog.w("Cannot register UserSwitchObserver");
}
}

private void startServices()
{
Context localContext = SBContext.getInstance().get();
localContext.startServiceAsUser(new Intent(localContext, EventListenerService.class), new UserHandle(-2));
if (MiniActivity.isExternal())
{
localContext.startServiceAsUser(new Intent(localContext, SBBaseService.class).setAction("com.lge.signboard.intent.action.ACTION_START_SERVICE"), new UserHandle(-2));
return;
}
localContext.startServiceAsUser(new Intent(localContext, AodService.class), new UserHandle(-2));
}

public Context createPackageContext(String paramString, int paramInt)
throws PackageManager.NameNotFoundException
{
return super.createPackageContext(paramString, 3);
}

public void onCreate()
{
super.onCreate();
Context localContext = getApplicationContext();
SignBoardSupport.start(localContext);
LocalBroadcastManager.getInstance(localContext);
if (LOS_SharedPreferenceConverter.hasSharedPreference(localContext)) {
LOS_SharedPreferenceConverter.convertSharedPreferenceToDatabase(localContext);
}
SBContext.create(localContext);
ISBContext localISBContext = SBContext.getInstance();
this.mManager = new SBManagerContainer(localISBContext);
localISBContext.setManagerContainer(this.mManager);
this.mManager.start();
SBPowerSaverListener.getInstance(localContext).start();
SBDPMListener.getInstance(localContext).start();
registerUserSwitchObserver();
TimeChangeAlarm.getInstance(localContext);
NotificationHistoryReceiver.start(localContext);
SmartCoverHandler.start(localContext);
DriveModeObserver.start(localContext);
PackageResourceAccessor.start(localContext);
TimeTickManager.start(localContext);
startServices();
}

public void onTerminate()
{
SBContext.getInstance().setManagerContainer(null);
SBContext.destroy();
this.mManager.stop();
this.mManager = null;
SBPowerSaverListener.getInstance(getApplicationContext()).stop();
SBDPMListener.getInstance(getApplicationContext()).stop();
NotificationHistoryReceiver.stop();
SmartCoverHandler.stop();
DriveModeObserver.stop();
PackageResourceAccessor.stop();
TimeTickManager.stop();
super.onTerminate();
}
}