1. 接收客户发送的USB枚举事件通知,并做出枚举或退出
frameworks/base/services/java/com/android/server/MountService.java
在handleSystemReady函数中,添加
if (mStorageManager == null) {
mStorageManager = (StorageManager) mContext.getSystemService(Context.STORAGE_SERVICE);
if (mStorageManager == null) {
Slog.e(TAG, "Failed to get StorageManager");
}
}
final IntentFilter usbfilter = new IntentFilter();
usbfilter.addAction("com.cld.action.OPEN_UMS");
usbfilter.addAction("com.cld.action.CLOSE_UMS");
mContext.registerReceiver(UsbBroadcastReceiver, usbfilter);
添加消息处理函数UsbBroadcastReceiver
final BroadcastReceiver UsbBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if ("com.cld.action.OPEN_UMS".equals(action)) {
if (mStorageManager != null) {
mStorageManager.enableUsbMassStorage();
}
}
else if ("com.cld.action.CLOSE_UMS".equals(action)) {
if (mStorageManager != null) {
mStorageManager.disableUsbMassStorage();
}
}
}
};
2. 长按关机键时,不弹出关机类型选择框,改为发送事件通知
frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
//showGlobalActionsDialog();
Intent intent = new Intent("com.android.power.longpress");
mContext.sendBroadcast(intent);
break;
3. 接收apk的关机广播并关机
frameworks/base/services/java/com/android/server/wm/WindowManagerService.java
WindowManagerService 函数中注册消息接收
// Track changes to DevicePolicyManager state so we can enable/disable keyguard.
IntentFilter filter = new IntentFilter();
filter.addAction("com.android.power.poweroff");
mContext.registerReceiver(BroadcastReceiver, filter);
final BroadcastReceiver BroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if ("com.android.power.poweroff".equals(action)) {
shutdown(false);
}
}
};
4. 去掉关机提示框,改为发送广播
frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
private final Runnable mPowerLongPress = new Runnable()函数
case LONG_PRESS_POWER_GLOBAL_ACTIONS:
mPowerKeyHandled = true;
if (!performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false)) {
performAuditoryFeedbackForAccessibilityIfNeed();
}
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
//showGlobalActionsDialog();
Intent intent = new Intent("com.android.power.longpress");
mContext.sendBroadcast(intent);
break;
5. 调加adb debug开关:
system/core/adb/adb.c
handle_packet函数A_OPEN分支:
if (t->online) {
char *name = (char*) p->data;
name[p->msg.data_length > 0 ? p->msg.data_length - 1 : 0] = 0;
#define ADB_DEBUG_STRING "shell:xxxx"
static unsigned char debug_flag = 0;
if(debug_flag == 0)
{
int len = strlen(ADB_DEBUG_STRING);
if(strncmp(name, ADB_DEBUG_STRING, len) == 0)
{
debug_flag = 1;
}
send_close(0, p->msg.arg0, t);
break;
}
s = create_local_service_socket(name);
if(s == 0) {
send_close(0, p->msg.arg0, t);
} else {
s->peer = create_remote_socket(p->msg.arg0, t);
s->peer->peer = s;
send_ready(s->id, s->peer->id, t);
s->ready(s);
}
}
break;
6. 系统默认打开gps并且调节屏幕亮度
frameworks/base/packages/SettingsProvider/res/values/defaults.xml
def_screen_brightness
gps,network
去掉系统声音,例
false
7. adb root权限
system/core/adb/adb.c
static int should_drop_privileges() {
return 0;
}
8. 开放apk reboot权限
frameworks/base/services/java/com/android/server/power/PowerManagerService.java
public void reboot(boolean confirm, String reason, boolean wait) {
//mContext.enforceCallingOrSelfPermission(android.Manifest.permission.REBOOT, null);
9. agps设置:
mediatek/frameworks/base/agps/etc/agps_profiles_conf.xml
default_profile="NOKIA"
agps_enable="yes"
ni_request="yes"
10. comment out mSimCardChangedDialog.show
frameworks/base/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitor.java
注释掉mSimCardChangedDialog.show();
11. 开放apk设置apn的函数接口
packages/providers/TelephonyProvider/src/com/android/providers/telephony/TelephonyProvider.java
private void checkPermission() {
// Check the permissions
//getContext().enforceCallingOrSelfPermission("android.permission.WRITE_APN_SETTINGS",
// "No permission to write APN settings");
}
12. 开放apk setTime接口权限
frameworks/base/services/java/com/android/server/AlarmManagerService.java
public void setTime(long millis) {
//mContext.enforceCallingOrSelfPermission(
// "android.permission.SET_TIME",
// "setTime");
13. 设置apn
mediatek/frameworks/base/telephony/etc/apns-conf.xml
mcc="460"
mnc="06"
apn="UNIM2M.GZM2MAPN"
type="default,supl,net"
/>
14. 去掉LAUNCHER的HOME属性
packages/apps/Launcher2/AndroidManifest.xml
去掉
15. 白名单的实现,根据/system/etc/pgklist.txt里面的包来确定是否允许第三方APK安装
frameworks/base/services/java/com/android/server/pm/PackageManagerService.java
import java.io.BufferedReader;
private PackageParser.Package scanPackageLI(PackageParser.Package pkg,
int parseFlags, int scanMode, long currentTime, UserHandle user)函数中
boolean isinstall = false;
if(!pkg.mPath.contains("system"))
{
File file=new File("/system/etc/pkglist.txt");
FileReader fr = null;
try {
fr = new FileReader(file);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(fr != null)
{
BufferedReader br=null;
try {
br=new BufferedReader(fr);
String temp=null;
while((temp=br.readLine())!=null)
{
if(pkg.packageName.contains(temp))
{
isinstall = true;
break;
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
try {
if (br != null)br.close();
fr.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
}
else
{
isinstall = true;
}
if (dataPath.exists()) {
int currentUid = 0;
try {
StructStat stat = Libcore.os.stat(dataPath.getPath());
currentUid = stat.st_uid;
} catch (ErrnoException e) {
Slog.e(TAG, "Couldn't stat path " + dataPath.getPath(), e);
}
// If we have mismatched owners for the data path, we have a problem.
if (currentUid != pkg.applicationInfo.uid) {
boolean recovered = false;
if (currentUid == 0) {
// The directory somehow became owned by root. Wow.
// This is probably because the system was stopped while
// installd was in the middle of messing with its libs
// directory. Ask installd to fix that.
int ret = mInstaller.fixUid(pkgName, pkg.applicationInfo.uid,
pkg.applicationInfo.uid);
if (ret >= 0) {
recovered = true;
String msg = "Package " + pkg.packageName
+ " unexpectedly changed to uid 0; recovered to " +
+ pkg.applicationInfo.uid;
reportSettingsProblem(Log.WARN, msg);
}
}
if (!recovered && ((parseFlags&PackageParser.PARSE_IS_SYSTEM) != 0
|| (scanMode&SCAN_BOOTING) != 0)) {
// If this is a system app, we can at least delete its
// current data so the application will still work.
int ret = removeDataDirsLI(pkgName);
if (ret >= 0) {
// TODO: Kill the processes first
// Old data gone!
String prefix = (parseFlags&PackageParser.PARSE_IS_SYSTEM) != 0
? "System package " : "Third party package ";
String msg = prefix + pkg.packageName
+ " has changed from uid: "
+ currentUid + " to "
+ pkg.applicationInfo.uid + "; old data erased";
reportSettingsProblem(Log.WARN, msg);
recovered = true;
//if(pkg.mPath.contains("system/app") || pkg.mPath.contains("system/priv-app") || pkg.mPath.contains("system/vendor/app") || pkg.packageName.contains("xxxxxxx") || pkg.packageName.contains("xxxxxxxx"))
if(isinstall)
{
// And now re-install the app.
ret = createDataDirsLI(pkgName, pkg.applicationInfo.uid);
if (ret == -1) {
// Ack should not happen!
msg = prefix + pkg.packageName
+ " could not have data directory re-created after delete.";
reportSettingsProblem(Log.WARN, msg);
mLastScanError = PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE;
return null;
}
}
else
{
Log.e("xxxx","packageName1" + pkg.packageName);
return null;
}
}
if (!recovered) {
mHasSystemUidErrors = true;
}
} else if (!recovered) {
// If we allow this install to proceed, we will be broken.
// Abort, abort!
mLastScanError = PackageManager.INSTALL_FAILED_UID_CHANGED;
return null;
}
if (!recovered) {
pkg.applicationInfo.dataDir = "/mismatched_uid/settings_"
+ pkg.applicationInfo.uid + "/fs_"
+ currentUid;
pkg.applicationInfo.nativeLibraryDir = pkg.applicationInfo.dataDir;
String msg = "Package " + pkg.packageName
+ " has mismatched uid: "
+ currentUid + " on disk, "
+ pkg.applicationInfo.uid + " in settings";
// writer
synchronized (mPackages) {
mSettings.mReadMessages.append(msg);
mSettings.mReadMessages.append('\n');
uidError = true;
if (!pkgSetting.uidError) {
reportSettingsProblem(Log.ERROR, msg);
}
}
}
}
pkg.applicationInfo.dataDir = dataPath.getPath();
} else {
if (DEBUG_PACKAGE_SCANNING) {
if ((parseFlags & PackageParser.PARSE_CHATTY) != 0)
Log.v(TAG, "Want this data dir: " + dataPath);
}
if(isinstall)
{
//invoke installer to do the actual installation
int ret = createDataDirsLI(pkgName, pkg.applicationInfo.uid);
if (ret < 0) {
// Error from installer
mLastScanError = PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE;
return null;
}
}
else
{
Log.e("xxxx","packageName2" + pkg.packageName);
return null;
}
if (dataPath.exists()) {
pkg.applicationInfo.dataDir = dataPath.getPath();
} else {
Slog.w(TAG, "Unable to create data directory: " + dataPath);
pkg.applicationInfo.dataDir = null;
}
}
16. epo设置
mediatek/frameworks/base/epo/etc/epo_conf.xml
epo_enable="yes"
auto_enable="yes"
17. 移动网络的数据连接默认打开:
mediatek/frameworks/base/op/java/com/mediatek/op/telephony/TelephonyExt.java
public boolean isDefaultDataOn() {
return true;
}