1、指定默认Launch
Android自带Launch一般都不是我们想要的 ,每个产品都会定制一个自己的Launch,而且是一开机就显示,不需要选择,修改如下:
frameworks/base/services/java/com/android/server/am/ActivityManagerService.java
添加一个方法:
private void setDefaultLauncher() {
// get default component
String packageName = "com.android.vehiclecs10";//默认launcher包名
String className = "com.android.csoLanucher.LanucherActivity";默认launcher入口
Slog.i(TAG, "defautl packageName = " + packageName + ", default className = " + className);
IPackageManager pm = ActivityThread.getPackageManager();
//清除当前默认launcher
ArrayList
intentList = new ArrayList
();
ArrayList
cnList = new ArrayList
();
mContext.getPackageManager().getPreferredActivities(intentList, cnList, null);
IntentFilter dhIF;
for(int i = 0; i < cnList.size(); i++)
{
dhIF = intentList.get(i);
if(dhIF.hasAction(Intent.ACTION_MAIN) &&
dhIF.hasCategory(Intent.CATEGORY_HOME))
{
mContext.getPackageManager().clearPackagePreferredActivities(cnList.get(i).getPackageName());
}
}
//获取所有launcher activity
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
List
list = new ArrayList
(); try { list = pm.queryIntentActivities(intent, intent.resolveTypeIfNeeded(mContext.getContentResolver()), PackageManager.MATCH_DEFAULT_ONLY,UserHandle.getCallingUserId()); }catch (RemoteException e) { throw new RuntimeException("Package manager has died", e); } // get all components and the best match IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_MAIN); filter.addCategory(Intent.CATEGORY_HOME); filter.addCategory(Intent.CATEGORY_DEFAULT); final int N = list.size(); Slog.d(TAG, "N:::::hyhyhyhy:::: = " + N); ComponentName[] set = new ComponentName[N]; int bestMatch = 0; for (int i = 0; i < N; i++) { ResolveInfo r = list.get(i); set[i] = new ComponentName(r.activityInfo.packageName, r.activityInfo.name); Slog.d(TAG, "r.activityInfo.packageName:::::hyhyhyhy:::: = " + r.activityInfo.packageName); Slog.d(TAG, "r.activityInfo.name:::::hyhyhyhy:::: = " + r.activityInfo.name); if (r.match > bestMatch) bestMatch = r.match; } //设置默认launcher ComponentName launcher = new ComponentName(packageName, className); try { pm.addPreferredActivity(filter, bestMatch, set, launcher,UserHandle.getCallingUserId()); } catch (RemoteException e) { throw new RuntimeException("Package manager has died", e); } }
然后在ActivityManagerService类中的
boolean startHomeActivityLocked(int userId) {
if (mHeadless) {
// Added because none of the other calls to ensureBootCompleted seem to fire
// when running headless.
ensureBootCompleted();
return false;
}
if (mFactoryTest == SystemServer.FACTORY_TEST_LOW_LEVEL
&& mTopAction == null) {
// We are running in factory test mode, but unable to find
// the factory test app, so just sit around displaying the
// error message and don't try to start anything.
return false;
}
Intent intent = getHomeIntent();
/在此处添加上面我们定义的setDefaultLauncher
setDefaultLauncher();//By Lhongbo
/
ActivityInfo aInfo =
resolveActivityInfo(intent, STOCK_PM_FLAGS, userId);
if (aInfo != null) {
intent.setComponent(new ComponentName(
aInfo.applicationInfo.packageName, aInfo.name));
// Don't do this if the home app is currently being
// instrumented.
aInfo = new ActivityInfo(aInfo);
aInfo.applicationInfo = getAppInfoForUser(aInfo.applicationInfo, userId);
ProcessRecord app = getProcessRecordLocked(aInfo.processName,
aInfo.applicationInfo.uid, true);
if (app == null || app.instrumentationClass == null) {
intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK);
mStackSupervisor.startHomeActivity(intent, aInfo);
}
}
return true;
}
删除自带Launch,重新编译system,开机就能直接进到我们自己的Launch了
2、修改SD卡和USB路径
Android自带的SD 和USB路径都指定在 device/fsl/sabresd_6dq/fstab.freescale ,默认SD卡的命名为extsd 和extsd1 ,USB命名为udisk 和udisk1
修改sd卡和usb名称如下:
device/fsl/sabresd_6dq/fstab.freescale
/devices/platform/sdhci-esdhc-imx.2/mmc_host/mmc1 /mnt/media_rw/extsd vfat defaults voldmanaged=extsd:auto
/devices/platform/sdhci-esdhc-imx.0/mmc_host/mmc3 /mnt/media_rw/sdcard1 vfat defaults voldmanaged=sdcard1:auto
/devices/platform/fsl-ehci.0/usb1/1-1/1-1:1.0 /mnt/media_rw/udisk vfat defaults voldmanaged=udisk:auto
/devices/platform/fsl-ehci.1/usb2/2-1/2-1:1.0 /mnt/media_rw/udisk2 vfat defaults voldmanaged=udisk2:auto
device/fsl/imx6/etc/init.rc
mkdir /mnt/media_rw/extsd 0755 system system
symlink /mnt/media_rw/extsd /storage/extsd
symlink /mnt/media_rw/extsd /mnt/extsd
mkdir /mnt/media_rw/sdcard1 0755 system system
symlink /mnt/media_rw/sdcard1 /storage/sdcard1
symlink /mnt/media_rw/sdcard1 /mnt/sdcard1
mkdir /mnt/media_rw/udisk 0755 system system
symlink /mnt/media_rw/udisk /storage/udisk
symlink /mnt/media_rw/udisk /mnt/udisk
mkdir /mnt/media_rw/udisk2 0755 system system
symlink /mnt/media_rw/udisk2 /storage/udisk2
symlink /mnt/media_rw/udisk2 /mnt/udisk2
3、修改默认语言
# Whether there is default locale set in PRODUCT_PROPERTY_OVERRIDES
product_property_override_locale_language := $(strip \
$(patsubst ro.product.locale.language=%,%,\
$(filter ro.product.locale.language=%,$(PRODUCT_PROPERTY_OVERRIDES))))
product_property_overrides_locale_region := $(strip \
$(patsubst ro.product.locale.region=%,%,\
$(filter ro.product.locale.region=%,$(PRODUCT_PROPERTY_OVERRIDES))))
# Selects the first locale in the list given as the argument,
# and splits it into language and region, which each may be
# empty.
define default-locale
$(subst _, , $(firstword $(1)))
endef
# Selects the first locale in the list given as the argument
# and returns the language (or the region), if it's not set in PRODUCT_PROPERTY_OVERRIDES;
# Return empty string if it's already set in PRODUCT_PROPERTY_OVERRIDES.
define default-locale-language
$(if $(product_property_override_locale_language),,$(word 1, $(call default-locale, $(1))))
endef
define default-locale-region
$(if $(product_property_overrides_locale_region),,$(word 2, $(call default-locale, $(1))))
endef
echo “ro.product.locale.language=$PRODUCT_DEFAULT_LANGUAGE”
echo “ro.product.locale.region=$PRODUCT_DEFAULT_REGION”
PRODUCT_LOCALES := en_US zh_CN 默认语言是英语;
2、在persist.sys.language 和persist.sys.country 里指定语言,如下: PRODUCT_PROPERTY_OVERRIDES := \
persist.sys.language=zh \
persist.sys.country=CN build.prop文件的处理是在system/core/init/property_service.c。
4、修改版本号和机器型号
ro.product.model=iMX6DL-CS10 //设置--关于平板电脑--型 号
false
0
false
0
false
boolean updateOrientationFromAppTokensLocked(boolean inTransaction) {
long ident = Binder.clearCallingIdentity();
try {
int req = getOrientationFromWindowsLocked();
if (req == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
req = getOrientationFromAppTokensLocked();
}
// req = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; //强制横屏0度
// req = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; //强制竖屏左转90度
if (req != mForcedAppOrientation) {
mForcedAppOrientation = req;
//send a message to Policy indicating orientation change to take
//action like disabling/enabling sensors etc.,
mPolicy.setCurrentOrientationLw(req);
if (updateRotationUncheckedLocked(inTransaction)) {
// changed
return true;
}
}
return false;
} finally {
Binder.restoreCallingIdentity(ident);
}
}