[MTCD Software Development] nico84:
No apps or services will be killed in "standby"

---------- Post added at 22:27 ---------- Previous post was at 22:21 ----------

this is class d from MTCManager.apk

package android.microntek;

import android.app.ActivityManager;
import android.app.ActivityManager.MemoryInfo;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.app.ActivityManager.RunningServiceInfo;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.microntek.service.R;
import android.text.TextUtils;
import android.text.format.Formatter;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.Toast;
import java.util.ArrayList;

public class d {
static String de;
private static boolean df = false;
static Context dg;
private static int dh = -1;
static Toast di;
private static final String[] dj = new String[]{"com.android.externalstorage", "android.microntek.", "com.murtas.", "com.microntek.", "com.goodocom.gocsdk", "android.rockchip.update.service", "com.android.systemui", "com.hct.obd.OBDActivity", "com.unisound", "com.dpadnavi.assist", "com.intel.thermal", "cn.manstep.phonemirror", "com.hiworld.", "com.carboy.launch", "com.android.bluetooth", "net.easyconn", "com.android.launcher", "com.google.android", "com.vayosoft.carsystem"};
static Object dk = new Object();
static d dl;
private static final String[] dm = new String[]{"com.android.externalstorage", "android.microntek.", "com.murtas.", "com.microntek.", "com.goodocom.gocsdk", "android.rockchip.update.service", "com.android.systemui", "com.hct.obdservice.OBDService", "com.unisound", "com.intel.thermal", "com.dpadnavi.assist", "cn.manstep.phonemirror", "com.android.bluetooth", "com.hiworld.", "net.easyconn", "android.cn.ecar.cds.process.CoreService", "com.google.android", "com.vayosoft.carsystem"};

private d(Context context) {
dg = context;
}

public static d fq(Context context) {
d dVar;
synchronized (dk) {
if (dl == null) {
dl = new d(context);
}
dh = -1;
dVar = dl;
}
return dVar;
}

private int fu(Context context) {
int i = 0;
Iterable<e> arrayList = new ArrayList();
ActivityManager activityManager = (ActivityManager) context.getSystemService("activity");
for (RunningAppProcessInfo runningAppProcessInfo : activityManager.getRunningAppProcesses()) {
int i2 = runningAppProcessInfo.pid;
int i3 = runningAppProcessInfo.uid;
String str = runningAppProcessInfo.processName;
int i4 = activityManager.getProcessMemoryInfo(new int[]{i2})[0].dalvikPrivateDirty;
e eVar = new e();
eVar.gb(i2);
eVar.gc(i3);
eVar.gd(i4);
eVar.ge(str);
eVar.dn = runningAppProcessInfo.pkgList;
arrayList.add(eVar);
String[] strArr = runningAppProcessInfo.pkgList;
}
for (e eVar2 : arrayList) {
int i5;
if (eVar2.gf() < 10000) {
i5 = i;
} else {
String gg = eVar2.gg();
if (gg.indexOf(".") == -1) {
i5 = i;
} else if (fy(gg) || fz(context, gg) || ga(context, gg)) {
i5 = i;
} else if (dh != 0 || fx(gg)) {
try {
activityManager.killBackgroundProcesses(gg);
i5 = i + 1;
} catch (Exception e) {
System.out.println(" deny the permission");
i5 = i;
}
} else {
ft(gg);
i5 = i + 1;
}
}
i = i5;
}
return i;
}

private void fv(Context context) {
Iterable<RunningServiceInfo> runningServices = ((ActivityManager) context.getSystemService("activity")).getRunningServices(100);
System.out.println(runningServices.size());
Iterable<b> arrayList = new ArrayList();
for (RunningServiceInfo runningServiceInfo : runningServices) {
int i = runningServiceInfo.pid;
int i2 = runningServiceInfo.uid;
String str = runningServiceInfo.process;
long j = runningServiceInfo.activeSince;
int i3 = runningServiceInfo.clientCount;
ComponentName componentName = runningServiceInfo.service;
String shortClassName = componentName.getShortClassName();
String packageName = componentName.getPackageName();
PackageManager packageManager = context.getPackageManager();
try {
ApplicationInfo applicationInfo = packageManager.getApplicationInfo(packageName, 0);
b bVar = new b();
bVar.fc(applicationInfo.loadIcon(packageManager));
bVar.fd(applicationInfo.loadLabel(packageManager).toString());
bVar.fi(shortClassName);
bVar.fg(packageName);
Intent intent = new Intent();
intent.setComponent(componentName);
bVar.fe(intent);
bVar.ff(i);
bVar.fj(i2);
bVar.fh(str);
arrayList.add(bVar);
} catch (NameNotFoundException e) {
e.printStackTrace();
}
}
for (b bVar2 : arrayList) {
if (bVar2.fb() >= 10000) {
String fa = bVar2.fa();
if (!(fx(fa) || fz(context, fa) || ga(context, fa))) {
if (dh != 0 || fy(fa)) {
try {
context.stopService(bVar2.ez());
} catch (SecurityException e2) {
System.out.println(" deny the permission");
}
} else {
ft(fa);
}
}
}
}
}

private long fw(Context context) {
ActivityManager activityManager = (ActivityManager) context.getSystemService("activity");
MemoryInfo memoryInfo = new MemoryInfo();
activityManager.getMemoryInfo(memoryInfo);
return memoryInfo.availMem;
}

private boolean fx(String str) {
for (String startsWith : dm) {
if (str.startsWith(startsWith)) {
return true;
}
}
return de != null && str.equals(de);
}

private boolean fy(String str) {
for (String startsWith : dj) {
if (str.startsWith(startsWith)) {
return true;
}
}
return de != null && str.equals(de);
}

private boolean fz(Context context, String str) {
if (context == null || TextUtils.isEmpty(str)) {
return false;
}
for (InputMethodInfo packageName : ((InputMethodManager) context.getSystemService("input_method")).getInputMethodList()) {
if (str.equalsIgnoreCase(packageName.getPackageName())) {
return true;
}
}
return false;
}

private boolean ga(Context context, String str) {
try {
for (ResolveInfo resolveInfo : context.getPackageManager().queryIntentServices(new Intent("android.service.wallpaper.WallpaperService"), 128)) {
if (str.equalsIgnoreCase(resolveInfo.serviceInfo.packageName)) {
return true;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}

public boolean fr() {
return df;
}

public void fs(int i, String str) {
dh = i;
df = true;
de = str;
long fw = fw(dg);
fv(dg);
int fu = fu(dg);
long fw2 = fw(dg);
if (i == 1) {
fw = Math.abs(fw2 - fw);
CharSequence string = dg.getString(R.string.clear_message, new Object[]{Integer.valueOf(fu), Formatter.formatFileSize(dg, fw)});
if (di == null) {
di = Toast.makeText(dg, string, 0);
} else {
di.cancel();
di = Toast.makeText(dg, string, 1);
}
di.show();
}
df = false;
}

public void ft(String str) {
if (str != null && str.length() != 0) {
try {
((ActivityManager) dg.getSystemService("activity")).forceStopPackage(str);
} catch (SecurityException e) {
System.out.println(" deny the permission");
}
}
}
}

Method fv(context) and fu(context) is called before the HU goes into "standby"