Loading policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +24 −1 Original line number Original line Diff line number Diff line Loading @@ -124,6 +124,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_BOOT_PROGRESS; import android.view.WindowManagerImpl; import android.view.WindowManagerImpl; import android.view.WindowManagerPolicy; import android.view.WindowManagerPolicy; import android.view.KeyCharacterMap.FallbackAction; import android.view.KeyCharacterMap.FallbackAction; import android.view.accessibility.AccessibilityEvent; import android.view.animation.Animation; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.view.animation.AnimationUtils; import android.media.IAudioService; import android.media.IAudioService; Loading Loading @@ -3104,7 +3105,29 @@ public class PhoneWindowManager implements WindowManagerPolicy { mHandler.post(new Runnable() { mHandler.post(new Runnable() { @Override public void run() { @Override public void run() { if (mBootMsgDialog == null) { if (mBootMsgDialog == null) { mBootMsgDialog = new ProgressDialog(mContext); mBootMsgDialog = new ProgressDialog(mContext) { // This dialog will consume all events coming in to // it, to avoid it trying to do things too early in boot. @Override public boolean dispatchKeyEvent(KeyEvent event) { return true; } @Override public boolean dispatchKeyShortcutEvent(KeyEvent event) { return true; } @Override public boolean dispatchTouchEvent(MotionEvent ev) { return true; } @Override public boolean dispatchTrackballEvent(MotionEvent ev) { return true; } @Override public boolean dispatchGenericMotionEvent(MotionEvent ev) { return true; } @Override public boolean dispatchPopulateAccessibilityEvent( AccessibilityEvent event) { return true; } }; mBootMsgDialog.setTitle(R.string.android_upgrading_title); mBootMsgDialog.setTitle(R.string.android_upgrading_title); mBootMsgDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); mBootMsgDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); mBootMsgDialog.setIndeterminate(true); mBootMsgDialog.setIndeterminate(true); Loading services/java/com/android/server/SystemServer.java +7 −5 Original line number Original line Diff line number Diff line Loading @@ -182,7 +182,7 @@ class ServerThread extends Thread { // only initialize the power service after we have started the // only initialize the power service after we have started the // lights service, content providers and the battery service. // lights service, content providers and the battery service. power.init(context, lights, ActivityManagerService.getDefault(), battery); power.init(context, lights, ActivityManagerService.self(), battery); Slog.i(TAG, "Alarm Manager"); Slog.i(TAG, "Alarm Manager"); alarm = new AlarmManagerService(context); alarm = new AlarmManagerService(context); Loading @@ -197,8 +197,7 @@ class ServerThread extends Thread { factoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL); factoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL); ServiceManager.addService(Context.WINDOW_SERVICE, wm); ServiceManager.addService(Context.WINDOW_SERVICE, wm); ((ActivityManagerService)ServiceManager.getService("activity")) ActivityManagerService.self().setWindowManager(wm); .setWindowManager(wm); // Skip Bluetooth if we have an emulator kernel // Skip Bluetooth if we have an emulator kernel // TODO: Use a more reliable check to see if this product should // TODO: Use a more reliable check to see if this product should Loading Loading @@ -266,6 +265,10 @@ class ServerThread extends Thread { reportWtf("making display ready", e); reportWtf("making display ready", e); } } try { ActivityManagerNative.getDefault().showBootMessage("DEXOPT!", true); } catch (RemoteException e) { } try { try { pm.performBootDexOpt(); pm.performBootDexOpt(); } catch (Throwable e) { } catch (Throwable e) { Loading Loading @@ -618,8 +621,7 @@ class ServerThread extends Thread { // where third party code can really run (but before it has actually // where third party code can really run (but before it has actually // started launching the initial applications), for us to complete our // started launching the initial applications), for us to complete our // initialization. // initialization. ((ActivityManagerService)ActivityManagerNative.getDefault()) ActivityManagerService.self().systemReady(new Runnable() { .systemReady(new Runnable() { public void run() { public void run() { Slog.i(TAG, "Making services ready"); Slog.i(TAG, "Making services ready"); Loading services/java/com/android/server/am/ActivityManagerService.java +92 −48 Original line number Original line Diff line number Diff line Loading @@ -91,7 +91,6 @@ import android.os.Environment; import android.os.FileObserver; import android.os.FileObserver; import android.os.FileUtils; import android.os.FileUtils; import android.os.Handler; import android.os.Handler; import android.os.HandlerThread; import android.os.IBinder; import android.os.IBinder; import android.os.IPermissionController; import android.os.IPermissionController; import android.os.Looper; import android.os.Looper; Loading Loading @@ -5518,6 +5517,48 @@ public final class ActivityManagerService extends ActivityManagerNative return msg; return msg; } } boolean incProviderCount(ProcessRecord r, ContentProviderRecord cpr) { if (r != null) { Integer cnt = r.conProviders.get(cpr); if (DEBUG_PROVIDER) Slog.v(TAG, "Adding provider requested by " + r.processName + " from process " + cpr.info.processName + ": " + cpr.name.flattenToShortString() + " cnt=" + (cnt == null ? 1 : cnt)); if (cnt == null) { cpr.clients.add(r); r.conProviders.put(cpr, new Integer(1)); return true; } else { r.conProviders.put(cpr, new Integer(cnt.intValue()+1)); } } else { cpr.externals++; } return false; } boolean decProviderCount(ProcessRecord r, ContentProviderRecord cpr) { if (r != null) { Integer cnt = r.conProviders.get(cpr); if (DEBUG_PROVIDER) Slog.v(TAG, "Removing provider requested by " + r.processName + " from process " + cpr.info.processName + ": " + cpr.name.flattenToShortString() + " cnt=" + cnt); if (cnt == null || cnt.intValue() <= 1) { cpr.clients.remove(r); r.conProviders.remove(cpr); return true; } else { r.conProviders.put(cpr, new Integer(cnt.intValue()-1)); } } else { cpr.externals++; } return false; } private final ContentProviderHolder getContentProviderImpl( private final ContentProviderHolder getContentProviderImpl( IApplicationThread caller, String name) { IApplicationThread caller, String name) { ContentProviderRecord cpr; ContentProviderRecord cpr; Loading @@ -5537,7 +5578,8 @@ public final class ActivityManagerService extends ActivityManagerNative // First check if this content provider has been published... // First check if this content provider has been published... cpr = mProvidersByName.get(name); cpr = mProvidersByName.get(name); if (cpr != null) { boolean providerRunning = cpr != null; if (providerRunning) { cpi = cpr.info; cpi = cpr.info; String msg; String msg; if ((msg=checkContentProviderPermissionLocked(cpi, r)) != null) { if ((msg=checkContentProviderPermissionLocked(cpi, r)) != null) { Loading @@ -5561,18 +5603,8 @@ public final class ActivityManagerService extends ActivityManagerNative // In this case the provider instance already exists, so we can // In this case the provider instance already exists, so we can // return it right away. // return it right away. if (r != null) { final boolean countChanged = incProviderCount(r, cpr); if (DEBUG_PROVIDER) Slog.v(TAG, if (countChanged) { "Adding provider requested by " + r.processName + " from process " + cpr.info.processName); Integer cnt = r.conProviders.get(cpr); if (cnt == null) { r.conProviders.put(cpr, new Integer(1)); } else { r.conProviders.put(cpr, new Integer(cnt.intValue()+1)); } cpr.clients.add(r); if (cpr.app != null && r.setAdj <= ProcessList.PERCEPTIBLE_APP_ADJ) { if (cpr.app != null && r.setAdj <= ProcessList.PERCEPTIBLE_APP_ADJ) { // If this is a perceptible app accessing the provider, // If this is a perceptible app accessing the provider, // make sure to count it as being accessed and thus // make sure to count it as being accessed and thus Loading @@ -5580,17 +5612,46 @@ public final class ActivityManagerService extends ActivityManagerNative // content providers are often expensive to start. // content providers are often expensive to start. updateLruProcessLocked(cpr.app, false, true); updateLruProcessLocked(cpr.app, false, true); } } } else { cpr.externals++; } } if (cpr.app != null) { if (cpr.app != null) { updateOomAdjLocked(cpr.app); if (false) { if (cpr.name.flattenToShortString().equals( "com.android.providers.calendar/.CalendarProvider2")) { Slog.v(TAG, "****************** KILLING " + cpr.name.flattenToShortString()); Process.killProcess(cpr.app.pid); } } boolean success = updateOomAdjLocked(cpr.app); if (DEBUG_PROVIDER) Slog.i(TAG, "Adjust success: " + success); // NOTE: there is still a race here where a signal could be // pending on the process even though we managed to update its // adj level. Not sure what to do about this, but at least // the race is now smaller. if (!success) { // Uh oh... it looks like the provider's process // has been killed on us. We need to wait for a new // process to be started, and make sure its death // doesn't kill our process. Slog.i(TAG, "Existing provider " + cpr.name.flattenToShortString() + " is crashing; detaching " + r); boolean lastRef = decProviderCount(r, cpr); appDiedLocked(cpr.app, cpr.app.pid, cpr.app.thread); if (!lastRef) { // This wasn't the last ref our process had on // the provider... we have now been killed, bail. return null; } providerRunning = false; } } } Binder.restoreCallingIdentity(origId); Binder.restoreCallingIdentity(origId); } } else { if (!providerRunning) { try { try { cpi = AppGlobals.getPackageManager(). cpi = AppGlobals.getPackageManager(). resolveContentProvider(name, resolveContentProvider(name, Loading Loading @@ -5701,22 +5762,7 @@ public final class ActivityManagerService extends ActivityManagerNative mProvidersByClass.put(comp, cpr); mProvidersByClass.put(comp, cpr); } } mProvidersByName.put(name, cpr); mProvidersByName.put(name, cpr); incProviderCount(r, cpr); if (r != null) { if (DEBUG_PROVIDER) Slog.v(TAG, "Adding provider requested by " + r.processName + " from process " + cpr.info.processName); Integer cnt = r.conProviders.get(cpr); if (cnt == null) { r.conProviders.put(cpr, new Integer(1)); } else { r.conProviders.put(cpr, new Integer(cnt.intValue()+1)); } cpr.clients.add(r); } else { cpr.externals++; } } } } } Loading Loading @@ -5780,24 +5826,16 @@ public final class ActivityManagerService extends ActivityManagerNative //update content provider record entry info //update content provider record entry info ComponentName comp = new ComponentName(cpr.info.packageName, cpr.info.name); ComponentName comp = new ComponentName(cpr.info.packageName, cpr.info.name); ContentProviderRecord localCpr = mProvidersByClass.get(comp); ContentProviderRecord localCpr = mProvidersByClass.get(comp); if (DEBUG_PROVIDER) Slog.v(TAG, "Removing provider requested by " + r.info.processName + " from process " + localCpr.appInfo.processName); if (localCpr.app == r) { if (localCpr.app == r) { //should not happen. taken care of as a local provider //should not happen. taken care of as a local provider Slog.w(TAG, "removeContentProvider called on local provider: " Slog.w(TAG, "removeContentProvider called on local provider: " + cpr.info.name + " in process " + r.processName); + cpr.info.name + " in process " + r.processName); return; return; } else { } else { Integer cnt = r.conProviders.get(localCpr); if (decProviderCount(r, localCpr)) { if (cnt == null || cnt.intValue() <= 1) { updateOomAdjLocked(); localCpr.clients.remove(r); r.conProviders.remove(localCpr); } else { r.conProviders.put(localCpr, new Integer(cnt.intValue()-1)); } } } } updateOomAdjLocked(); } } } } Loading Loading @@ -13458,16 +13496,18 @@ public final class ActivityManagerService extends ActivityManagerNative } } } } private final void updateOomAdjLocked( private final boolean updateOomAdjLocked( ProcessRecord app, int hiddenAdj, ProcessRecord TOP_APP) { ProcessRecord app, int hiddenAdj, ProcessRecord TOP_APP) { app.hiddenAdj = hiddenAdj; app.hiddenAdj = hiddenAdj; if (app.thread == null) { if (app.thread == null) { return; return false; } } final boolean wasKeeping = app.keeping; final boolean wasKeeping = app.keeping; boolean success = true; computeOomAdjLocked(app, hiddenAdj, TOP_APP, false); computeOomAdjLocked(app, hiddenAdj, TOP_APP, false); if (app.curRawAdj != app.setRawAdj) { if (app.curRawAdj != app.setRawAdj) { Loading Loading @@ -13504,6 +13544,7 @@ public final class ActivityManagerService extends ActivityManagerNative " oom adj to " + app.curAdj + " because " + app.adjType); " oom adj to " + app.curAdj + " because " + app.adjType); app.setAdj = app.curAdj; app.setAdj = app.curAdj; } else { } else { success = false; Slog.w(TAG, "Failed setting oom adj of " + app + " to " + app.curAdj); Slog.w(TAG, "Failed setting oom adj of " + app + " to " + app.curAdj); } } } } Loading @@ -13518,6 +13559,7 @@ public final class ActivityManagerService extends ActivityManagerNative EventLog.writeEvent(EventLogTags.AM_KILL, app.pid, EventLog.writeEvent(EventLogTags.AM_KILL, app.pid, app.processName, app.setAdj, app.waitingToKill); app.processName, app.setAdj, app.waitingToKill); Process.killProcessQuiet(app.pid); Process.killProcessQuiet(app.pid); success = false; } else { } else { if (true) { if (true) { long oldId = Binder.clearCallingIdentity(); long oldId = Binder.clearCallingIdentity(); Loading @@ -13540,6 +13582,7 @@ public final class ActivityManagerService extends ActivityManagerNative } } } } } } return success; } } private final ActivityRecord resumedAppLocked() { private final ActivityRecord resumedAppLocked() { Loading @@ -13553,7 +13596,7 @@ public final class ActivityManagerService extends ActivityManagerNative return resumedActivity; return resumedActivity; } } private final void updateOomAdjLocked(ProcessRecord app) { private final boolean updateOomAdjLocked(ProcessRecord app) { final ActivityRecord TOP_ACT = resumedAppLocked(); final ActivityRecord TOP_ACT = resumedAppLocked(); final ProcessRecord TOP_APP = TOP_ACT != null ? TOP_ACT.app : null; final ProcessRecord TOP_APP = TOP_ACT != null ? TOP_ACT.app : null; int curAdj = app.curAdj; int curAdj = app.curAdj; Loading @@ -13562,7 +13605,7 @@ public final class ActivityManagerService extends ActivityManagerNative mAdjSeq++; mAdjSeq++; updateOomAdjLocked(app, app.hiddenAdj, TOP_APP); boolean success = updateOomAdjLocked(app, app.hiddenAdj, TOP_APP); final boolean nowHidden = app.curAdj >= ProcessList.HIDDEN_APP_MIN_ADJ final boolean nowHidden = app.curAdj >= ProcessList.HIDDEN_APP_MIN_ADJ && app.curAdj <= ProcessList.HIDDEN_APP_MAX_ADJ; && app.curAdj <= ProcessList.HIDDEN_APP_MAX_ADJ; if (nowHidden != wasHidden) { if (nowHidden != wasHidden) { Loading @@ -13570,6 +13613,7 @@ public final class ActivityManagerService extends ActivityManagerNative // list may also be changed. // list may also be changed. updateOomAdjLocked(); updateOomAdjLocked(); } } return success; } } final void updateOomAdjLocked() { final void updateOomAdjLocked() { services/java/com/android/server/am/ProcessList.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -163,7 +163,7 @@ class ProcessList { int minSize = 320*480; // 153600 int minSize = 320*480; // 153600 int maxSize = 1280*800; // 1024000 230400 870400 .264 int maxSize = 1280*800; // 1024000 230400 870400 .264 float scaleDisp = ((float)(displayWidth*displayHeight)-minSize)/(maxSize-minSize); float scaleDisp = ((float)(displayWidth*displayHeight)-minSize)/(maxSize-minSize); Slog.i("XXXXXX", "scaleDisp=" + scaleDisp + " dw=" + displayWidth + " dh=" + displayHeight); //Slog.i("XXXXXX", "scaleDisp=" + scaleDisp + " dw=" + displayWidth + " dh=" + displayHeight); StringBuilder adjString = new StringBuilder(); StringBuilder adjString = new StringBuilder(); StringBuilder memString = new StringBuilder(); StringBuilder memString = new StringBuilder(); Loading Loading
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +24 −1 Original line number Original line Diff line number Diff line Loading @@ -124,6 +124,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_BOOT_PROGRESS; import android.view.WindowManagerImpl; import android.view.WindowManagerImpl; import android.view.WindowManagerPolicy; import android.view.WindowManagerPolicy; import android.view.KeyCharacterMap.FallbackAction; import android.view.KeyCharacterMap.FallbackAction; import android.view.accessibility.AccessibilityEvent; import android.view.animation.Animation; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.view.animation.AnimationUtils; import android.media.IAudioService; import android.media.IAudioService; Loading Loading @@ -3104,7 +3105,29 @@ public class PhoneWindowManager implements WindowManagerPolicy { mHandler.post(new Runnable() { mHandler.post(new Runnable() { @Override public void run() { @Override public void run() { if (mBootMsgDialog == null) { if (mBootMsgDialog == null) { mBootMsgDialog = new ProgressDialog(mContext); mBootMsgDialog = new ProgressDialog(mContext) { // This dialog will consume all events coming in to // it, to avoid it trying to do things too early in boot. @Override public boolean dispatchKeyEvent(KeyEvent event) { return true; } @Override public boolean dispatchKeyShortcutEvent(KeyEvent event) { return true; } @Override public boolean dispatchTouchEvent(MotionEvent ev) { return true; } @Override public boolean dispatchTrackballEvent(MotionEvent ev) { return true; } @Override public boolean dispatchGenericMotionEvent(MotionEvent ev) { return true; } @Override public boolean dispatchPopulateAccessibilityEvent( AccessibilityEvent event) { return true; } }; mBootMsgDialog.setTitle(R.string.android_upgrading_title); mBootMsgDialog.setTitle(R.string.android_upgrading_title); mBootMsgDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); mBootMsgDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); mBootMsgDialog.setIndeterminate(true); mBootMsgDialog.setIndeterminate(true); Loading
services/java/com/android/server/SystemServer.java +7 −5 Original line number Original line Diff line number Diff line Loading @@ -182,7 +182,7 @@ class ServerThread extends Thread { // only initialize the power service after we have started the // only initialize the power service after we have started the // lights service, content providers and the battery service. // lights service, content providers and the battery service. power.init(context, lights, ActivityManagerService.getDefault(), battery); power.init(context, lights, ActivityManagerService.self(), battery); Slog.i(TAG, "Alarm Manager"); Slog.i(TAG, "Alarm Manager"); alarm = new AlarmManagerService(context); alarm = new AlarmManagerService(context); Loading @@ -197,8 +197,7 @@ class ServerThread extends Thread { factoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL); factoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL); ServiceManager.addService(Context.WINDOW_SERVICE, wm); ServiceManager.addService(Context.WINDOW_SERVICE, wm); ((ActivityManagerService)ServiceManager.getService("activity")) ActivityManagerService.self().setWindowManager(wm); .setWindowManager(wm); // Skip Bluetooth if we have an emulator kernel // Skip Bluetooth if we have an emulator kernel // TODO: Use a more reliable check to see if this product should // TODO: Use a more reliable check to see if this product should Loading Loading @@ -266,6 +265,10 @@ class ServerThread extends Thread { reportWtf("making display ready", e); reportWtf("making display ready", e); } } try { ActivityManagerNative.getDefault().showBootMessage("DEXOPT!", true); } catch (RemoteException e) { } try { try { pm.performBootDexOpt(); pm.performBootDexOpt(); } catch (Throwable e) { } catch (Throwable e) { Loading Loading @@ -618,8 +621,7 @@ class ServerThread extends Thread { // where third party code can really run (but before it has actually // where third party code can really run (but before it has actually // started launching the initial applications), for us to complete our // started launching the initial applications), for us to complete our // initialization. // initialization. ((ActivityManagerService)ActivityManagerNative.getDefault()) ActivityManagerService.self().systemReady(new Runnable() { .systemReady(new Runnable() { public void run() { public void run() { Slog.i(TAG, "Making services ready"); Slog.i(TAG, "Making services ready"); Loading
services/java/com/android/server/am/ActivityManagerService.java +92 −48 Original line number Original line Diff line number Diff line Loading @@ -91,7 +91,6 @@ import android.os.Environment; import android.os.FileObserver; import android.os.FileObserver; import android.os.FileUtils; import android.os.FileUtils; import android.os.Handler; import android.os.Handler; import android.os.HandlerThread; import android.os.IBinder; import android.os.IBinder; import android.os.IPermissionController; import android.os.IPermissionController; import android.os.Looper; import android.os.Looper; Loading Loading @@ -5518,6 +5517,48 @@ public final class ActivityManagerService extends ActivityManagerNative return msg; return msg; } } boolean incProviderCount(ProcessRecord r, ContentProviderRecord cpr) { if (r != null) { Integer cnt = r.conProviders.get(cpr); if (DEBUG_PROVIDER) Slog.v(TAG, "Adding provider requested by " + r.processName + " from process " + cpr.info.processName + ": " + cpr.name.flattenToShortString() + " cnt=" + (cnt == null ? 1 : cnt)); if (cnt == null) { cpr.clients.add(r); r.conProviders.put(cpr, new Integer(1)); return true; } else { r.conProviders.put(cpr, new Integer(cnt.intValue()+1)); } } else { cpr.externals++; } return false; } boolean decProviderCount(ProcessRecord r, ContentProviderRecord cpr) { if (r != null) { Integer cnt = r.conProviders.get(cpr); if (DEBUG_PROVIDER) Slog.v(TAG, "Removing provider requested by " + r.processName + " from process " + cpr.info.processName + ": " + cpr.name.flattenToShortString() + " cnt=" + cnt); if (cnt == null || cnt.intValue() <= 1) { cpr.clients.remove(r); r.conProviders.remove(cpr); return true; } else { r.conProviders.put(cpr, new Integer(cnt.intValue()-1)); } } else { cpr.externals++; } return false; } private final ContentProviderHolder getContentProviderImpl( private final ContentProviderHolder getContentProviderImpl( IApplicationThread caller, String name) { IApplicationThread caller, String name) { ContentProviderRecord cpr; ContentProviderRecord cpr; Loading @@ -5537,7 +5578,8 @@ public final class ActivityManagerService extends ActivityManagerNative // First check if this content provider has been published... // First check if this content provider has been published... cpr = mProvidersByName.get(name); cpr = mProvidersByName.get(name); if (cpr != null) { boolean providerRunning = cpr != null; if (providerRunning) { cpi = cpr.info; cpi = cpr.info; String msg; String msg; if ((msg=checkContentProviderPermissionLocked(cpi, r)) != null) { if ((msg=checkContentProviderPermissionLocked(cpi, r)) != null) { Loading @@ -5561,18 +5603,8 @@ public final class ActivityManagerService extends ActivityManagerNative // In this case the provider instance already exists, so we can // In this case the provider instance already exists, so we can // return it right away. // return it right away. if (r != null) { final boolean countChanged = incProviderCount(r, cpr); if (DEBUG_PROVIDER) Slog.v(TAG, if (countChanged) { "Adding provider requested by " + r.processName + " from process " + cpr.info.processName); Integer cnt = r.conProviders.get(cpr); if (cnt == null) { r.conProviders.put(cpr, new Integer(1)); } else { r.conProviders.put(cpr, new Integer(cnt.intValue()+1)); } cpr.clients.add(r); if (cpr.app != null && r.setAdj <= ProcessList.PERCEPTIBLE_APP_ADJ) { if (cpr.app != null && r.setAdj <= ProcessList.PERCEPTIBLE_APP_ADJ) { // If this is a perceptible app accessing the provider, // If this is a perceptible app accessing the provider, // make sure to count it as being accessed and thus // make sure to count it as being accessed and thus Loading @@ -5580,17 +5612,46 @@ public final class ActivityManagerService extends ActivityManagerNative // content providers are often expensive to start. // content providers are often expensive to start. updateLruProcessLocked(cpr.app, false, true); updateLruProcessLocked(cpr.app, false, true); } } } else { cpr.externals++; } } if (cpr.app != null) { if (cpr.app != null) { updateOomAdjLocked(cpr.app); if (false) { if (cpr.name.flattenToShortString().equals( "com.android.providers.calendar/.CalendarProvider2")) { Slog.v(TAG, "****************** KILLING " + cpr.name.flattenToShortString()); Process.killProcess(cpr.app.pid); } } boolean success = updateOomAdjLocked(cpr.app); if (DEBUG_PROVIDER) Slog.i(TAG, "Adjust success: " + success); // NOTE: there is still a race here where a signal could be // pending on the process even though we managed to update its // adj level. Not sure what to do about this, but at least // the race is now smaller. if (!success) { // Uh oh... it looks like the provider's process // has been killed on us. We need to wait for a new // process to be started, and make sure its death // doesn't kill our process. Slog.i(TAG, "Existing provider " + cpr.name.flattenToShortString() + " is crashing; detaching " + r); boolean lastRef = decProviderCount(r, cpr); appDiedLocked(cpr.app, cpr.app.pid, cpr.app.thread); if (!lastRef) { // This wasn't the last ref our process had on // the provider... we have now been killed, bail. return null; } providerRunning = false; } } } Binder.restoreCallingIdentity(origId); Binder.restoreCallingIdentity(origId); } } else { if (!providerRunning) { try { try { cpi = AppGlobals.getPackageManager(). cpi = AppGlobals.getPackageManager(). resolveContentProvider(name, resolveContentProvider(name, Loading Loading @@ -5701,22 +5762,7 @@ public final class ActivityManagerService extends ActivityManagerNative mProvidersByClass.put(comp, cpr); mProvidersByClass.put(comp, cpr); } } mProvidersByName.put(name, cpr); mProvidersByName.put(name, cpr); incProviderCount(r, cpr); if (r != null) { if (DEBUG_PROVIDER) Slog.v(TAG, "Adding provider requested by " + r.processName + " from process " + cpr.info.processName); Integer cnt = r.conProviders.get(cpr); if (cnt == null) { r.conProviders.put(cpr, new Integer(1)); } else { r.conProviders.put(cpr, new Integer(cnt.intValue()+1)); } cpr.clients.add(r); } else { cpr.externals++; } } } } } Loading Loading @@ -5780,24 +5826,16 @@ public final class ActivityManagerService extends ActivityManagerNative //update content provider record entry info //update content provider record entry info ComponentName comp = new ComponentName(cpr.info.packageName, cpr.info.name); ComponentName comp = new ComponentName(cpr.info.packageName, cpr.info.name); ContentProviderRecord localCpr = mProvidersByClass.get(comp); ContentProviderRecord localCpr = mProvidersByClass.get(comp); if (DEBUG_PROVIDER) Slog.v(TAG, "Removing provider requested by " + r.info.processName + " from process " + localCpr.appInfo.processName); if (localCpr.app == r) { if (localCpr.app == r) { //should not happen. taken care of as a local provider //should not happen. taken care of as a local provider Slog.w(TAG, "removeContentProvider called on local provider: " Slog.w(TAG, "removeContentProvider called on local provider: " + cpr.info.name + " in process " + r.processName); + cpr.info.name + " in process " + r.processName); return; return; } else { } else { Integer cnt = r.conProviders.get(localCpr); if (decProviderCount(r, localCpr)) { if (cnt == null || cnt.intValue() <= 1) { updateOomAdjLocked(); localCpr.clients.remove(r); r.conProviders.remove(localCpr); } else { r.conProviders.put(localCpr, new Integer(cnt.intValue()-1)); } } } } updateOomAdjLocked(); } } } } Loading Loading @@ -13458,16 +13496,18 @@ public final class ActivityManagerService extends ActivityManagerNative } } } } private final void updateOomAdjLocked( private final boolean updateOomAdjLocked( ProcessRecord app, int hiddenAdj, ProcessRecord TOP_APP) { ProcessRecord app, int hiddenAdj, ProcessRecord TOP_APP) { app.hiddenAdj = hiddenAdj; app.hiddenAdj = hiddenAdj; if (app.thread == null) { if (app.thread == null) { return; return false; } } final boolean wasKeeping = app.keeping; final boolean wasKeeping = app.keeping; boolean success = true; computeOomAdjLocked(app, hiddenAdj, TOP_APP, false); computeOomAdjLocked(app, hiddenAdj, TOP_APP, false); if (app.curRawAdj != app.setRawAdj) { if (app.curRawAdj != app.setRawAdj) { Loading Loading @@ -13504,6 +13544,7 @@ public final class ActivityManagerService extends ActivityManagerNative " oom adj to " + app.curAdj + " because " + app.adjType); " oom adj to " + app.curAdj + " because " + app.adjType); app.setAdj = app.curAdj; app.setAdj = app.curAdj; } else { } else { success = false; Slog.w(TAG, "Failed setting oom adj of " + app + " to " + app.curAdj); Slog.w(TAG, "Failed setting oom adj of " + app + " to " + app.curAdj); } } } } Loading @@ -13518,6 +13559,7 @@ public final class ActivityManagerService extends ActivityManagerNative EventLog.writeEvent(EventLogTags.AM_KILL, app.pid, EventLog.writeEvent(EventLogTags.AM_KILL, app.pid, app.processName, app.setAdj, app.waitingToKill); app.processName, app.setAdj, app.waitingToKill); Process.killProcessQuiet(app.pid); Process.killProcessQuiet(app.pid); success = false; } else { } else { if (true) { if (true) { long oldId = Binder.clearCallingIdentity(); long oldId = Binder.clearCallingIdentity(); Loading @@ -13540,6 +13582,7 @@ public final class ActivityManagerService extends ActivityManagerNative } } } } } } return success; } } private final ActivityRecord resumedAppLocked() { private final ActivityRecord resumedAppLocked() { Loading @@ -13553,7 +13596,7 @@ public final class ActivityManagerService extends ActivityManagerNative return resumedActivity; return resumedActivity; } } private final void updateOomAdjLocked(ProcessRecord app) { private final boolean updateOomAdjLocked(ProcessRecord app) { final ActivityRecord TOP_ACT = resumedAppLocked(); final ActivityRecord TOP_ACT = resumedAppLocked(); final ProcessRecord TOP_APP = TOP_ACT != null ? TOP_ACT.app : null; final ProcessRecord TOP_APP = TOP_ACT != null ? TOP_ACT.app : null; int curAdj = app.curAdj; int curAdj = app.curAdj; Loading @@ -13562,7 +13605,7 @@ public final class ActivityManagerService extends ActivityManagerNative mAdjSeq++; mAdjSeq++; updateOomAdjLocked(app, app.hiddenAdj, TOP_APP); boolean success = updateOomAdjLocked(app, app.hiddenAdj, TOP_APP); final boolean nowHidden = app.curAdj >= ProcessList.HIDDEN_APP_MIN_ADJ final boolean nowHidden = app.curAdj >= ProcessList.HIDDEN_APP_MIN_ADJ && app.curAdj <= ProcessList.HIDDEN_APP_MAX_ADJ; && app.curAdj <= ProcessList.HIDDEN_APP_MAX_ADJ; if (nowHidden != wasHidden) { if (nowHidden != wasHidden) { Loading @@ -13570,6 +13613,7 @@ public final class ActivityManagerService extends ActivityManagerNative // list may also be changed. // list may also be changed. updateOomAdjLocked(); updateOomAdjLocked(); } } return success; } } final void updateOomAdjLocked() { final void updateOomAdjLocked() {
services/java/com/android/server/am/ProcessList.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -163,7 +163,7 @@ class ProcessList { int minSize = 320*480; // 153600 int minSize = 320*480; // 153600 int maxSize = 1280*800; // 1024000 230400 870400 .264 int maxSize = 1280*800; // 1024000 230400 870400 .264 float scaleDisp = ((float)(displayWidth*displayHeight)-minSize)/(maxSize-minSize); float scaleDisp = ((float)(displayWidth*displayHeight)-minSize)/(maxSize-minSize); Slog.i("XXXXXX", "scaleDisp=" + scaleDisp + " dw=" + displayWidth + " dh=" + displayHeight); //Slog.i("XXXXXX", "scaleDisp=" + scaleDisp + " dw=" + displayWidth + " dh=" + displayHeight); StringBuilder adjString = new StringBuilder(); StringBuilder adjString = new StringBuilder(); StringBuilder memString = new StringBuilder(); StringBuilder memString = new StringBuilder(); Loading