package com.bigcharge.framework;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.bigcharge.core.SysLog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.ParceledListSlice;
import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.UserHandle;
public final class ProxyPackageManagerServcie extends Binder {
private static final String TAG = "ProxyPackageManagerServcie";
private static final String DESCRIPTOR = "android.content.pm.IPackageManager";
private static TransActionPackage mTransAction;
private Context mContext;
static {
mTransAction = new TransActionPackage();
mTransAction.updateCodes();
}
private IBinder mBinder;
public ProxyPackageManagerServcie(IBinder binder, Context context) {
mBinder = binder;
mContext = context;
}
@SuppressWarnings("unchecked")
@Override
protected boolean onTransact(int code, Parcel data, Parcel reply, int flags)
throws RemoteException {
boolean bk = false;
mTransAction.checkCode(code);
if (mTransAction.isCode(code,
TransActionPackage.TRANSACTION_getInstalledApplications)) {
ParceledListSlice<ApplicationInfo> _result;
List<ApplicationInfo> list;
ArrayList<ApplicationInfo> newlist;
bk = mBinder.transact(code, data, reply, flags);
int pos = reply.dataPosition();
SysLog.logD(TAG, "[+]old dataPosition:"+pos);
reply.readException();
if ((0 != reply.readInt())) {
_result = android.content.pm.ParceledListSlice.CREATOR.createFromParcel(reply);
list = _result.getList();
int length = list.size();
SysLog.logD(TAG, "[+]old size:"+length);
int hidesize = 0;
int newsize = 0;
for(int i=0;i<length;++i){
ApplicationInfo info = list.get(i);
if (isHideProcess(info.packageName)) {
hidesize++;
}
}
newsize = length - hidesize;
SysLog.logD(TAG, "[+]new size:"+newsize);
newlist = new ArrayList<ApplicationInfo>(newsize);
for(int i=0;i<length;++i){
ApplicationInfo info = list.get(i);
if (!isHideProcess(info.packageName)) {
newlist.add(info);
}
}
ParceledListSlice<ApplicationInfo> plist = new ParceledListSlice<ApplicationInfo>(
newlist);
//只要执行下面这部分,重新打包Parcel的过程就出异常,下面会贴上异常的log。
reply.setDataPosition(pos);
reply.setDataSize(0);
// reply.setDataPosition(0);
reply.writeNoException();
if((plist!=null)){
reply.writeInt(1);
plist.writeToParcel(reply, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
SysLog.logD(TAG, "[+]new reply over");
}else{
reply.writeInt(0);
}
return true;
} else {
reply.setDataPosition(0);
return bk;
}
} else {
bk = mBinder.transact(code, data, reply, flags);
}
return bk;
}
private boolean isHideProcess(String packageName) {
if ("com.myhide.app".equals(packageName)) {
return true;
}
return false;
}
}
下面是异常的log
F/libc ( 682): @@@ ABORTING: invalid address or address of corrupt block 0x60d0e4c0 passed to dlfree
F/libc ( 682): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 1658 (Binder_7)
F/libc ( 682): Unable to open connection to debuggerd: Connection refused
W/Sensors ( 1149): sensorservice died [0x5c307618]
W/Sensors ( 3259): sensorservice died [0x5c2f3988]
W/AudioFlinger( 267): power manager service died !!!
I/Atfwd_Sendcmd( 319): AtCmdFwd : binderDied
W/Sensors ( 1032): sensorservice died [0x5c125a10]
W/Sensors ( 1161): sensorservice died [0x5c135fc8]
E/WifiManager( 1225): Channel connection lost
E/WifiManager( 2254): Channel connection lost
W/Sensors ( 2954): sensorservice died [0x5c1402f0]
E/WifiManager( 1032): Channel connection lost
V/AudioPolicyManagerBase( 267): releaseOutput() 2
V/AudioPolicyManagerBase( 267): releaseOutput() 2
E/WifiManager( 2745): Channel connection lost
E/WifiManager( 2788): Channel connection lost
I/ServiceManager( 253): service 'LEDService' died
I/ServiceManager( 253): service 'dbinfo' died
I/ServiceManager( 253): service 'telephony.registry' died
I/ServiceManager( 253): service 'scheduling_policy' died
I/ServiceManager( 253): service 'power' died
I/ServiceManager( 253): service 'appops' died
I/ServiceManager( 253): service 'multiwindow' died
I/ServiceManager( 253): service 'usagestats' died
I/ServiceManager( 253): service 'wfd' died
I/ServiceManager( 253): service 'wifi' died
I/ServiceManager( 253): service 'wifip2p' died
I/ServiceManager( 253): service 'sec_analytics' died
I/ServiceManager( 253): service 'connectivity' died
I/ServiceManager( 253): service 'content' died
I/ServiceManager( 253): service 'user' died
I/ServiceManager( 253): service 'vibrator' died
I/ServiceManager( 253): service 'meminfo' died
I/ServiceManager( 253): service 'sensorservice' died
I/ServiceManager( 253): service 'battery' died
I/ServiceManager( 253): service 'cpuinfo' died
I/ServiceManager( 253): service 'batteryinfo' died
I/ServiceManager( 253): service 'container_service' died
I/ServiceManager( 253): service 'permission' died
I/ServiceManager( 253): service 'account' died
I/ServiceManager( 253): service 'DirEncryptService' died
I/ServiceManager( 253): service 'CustomFrequencyManagerService' died
I/ServiceManager( 253): service 'entropy' died
I/ServiceManager( 253): service 'samsung.smartfaceservice' died
I/ServiceManager( 253): service 'dreams' died
I/ServiceManager( 253): service 'edmnativehelper' died
I/ServiceManager( 253): service 'window' died
E/WifiManager( 1149): Channel connection lost
E/WifiManager( 1124): Channel connection lost