当前位置: 首页 > news >正文

做app的网站有哪些功能整站seo外包

做app的网站有哪些功能,整站seo外包,创办网站公司,温州网站优化定制文章目录 需求语言设定Settings中语言切换流程检测到SIM卡,更新系统语言最终修改 需求 要求系统语言跟随SIM卡的语言变化。 语言设定 (1)系统预置语言, 即在makefile中指定的语言 (2)重启, 如果未插卡, 则系统语言为预置的语言 (3)重启插入SIM卡开机, 会自适应为…

文章目录

        • 需求
        • 语言设定
        • Settings中语言切换流程
        • 检测到SIM卡,更新系统语言
        • 最终修改

需求

要求系统语言跟随SIM卡的语言变化。

语言设定

(1)系统预置语言, 即在makefile中指定的语言
(2)重启, 如果未插卡, 则系统语言为预置的语言
(3)重启插入SIM卡开机, 会自适应为SIM卡的语言
(4)如果有手动设置语言, 以后开机, 不管插入的是哪个国家的卡, 都会显示设置的语言, 不会根据SIM卡自适应变化.

Settings中语言切换流程

当在系统设置中手动设置语言拖拽结束后,会调用updateLocalesWhenAnimationStops(ll)方法

  • vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/localepicker/LocaleDragAndDropAdapter.java
	public void updateLocalesWhenAnimationStops(final LocaleList localeList) {if (localeList.equals(mLocalesToSetNext)) {return;}// This will only update the Settings application to make things feel more responsive,// the system will be updated later, when animation stopped.LocaleList.setDefault(localeList);mLocalesToSetNext = localeList;final RecyclerView.ItemAnimator itemAnimator = mParentView.getItemAnimator();itemAnimator.isRunning(new RecyclerView.ItemAnimator.ItemAnimatorFinishedListener() {@Overridepublic void onAnimationsFinished() {if (mLocalesToSetNext == null || mLocalesToSetNext.equals(mLocalesSetLast)) {// All animations finished, but the locale list did not changereturn;}// 语言条目发生改变,调用到framework下的LocalePicker进行更新LocalePicker.updateLocales(mLocalesToSetNext);mLocalesSetLast = mLocalesToSetNext;new ShortcutsUpdateTask(mContext).execute();mLocalesToSetNext = null;mNumberFormatter = NumberFormat.getNumberInstance(Locale.getDefault());}});}

然后调用LocalePicker的updateLocales()方法进行更新

  • frameworks/base/core/java/com/android/internal/app/LocalePicker.java
    /*** Requests the system to update the list of system locales.* Note that the system looks halted for a while during the Locale migration,* so the caller need to take care of it.*/@UnsupportedAppUsagepublic static void updateLocales(LocaleList locales) {if (locales != null) {locales = removeExcludedLocales(locales);}// Note: the empty list case is covered by Configuration.setLocales().try {final IActivityManager am = ActivityManager.getService();final Configuration config = am.getConfiguration();// 切换后的语言信息更新到Configurationconfig.setLocales(locales);config.userSetLocale = true; // 手动设置的标志am.updatePersistentConfigurationWithAttribution(config,ActivityThread.currentOpPackageName(), null);// Trigger the dirty bit for the Settings Provider.BackupManager.dataChanged("com.android.providers.settings");} catch (RemoteException e) {// Intentionally left blank}}

又转入到ActivityManagerService中处理

  • frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
	@Overridepublic void updatePersistentConfigurationWithAttribution(Configuration values,String callingPackage, String callingAttributionTag) {enforceCallingPermission(CHANGE_CONFIGURATION, "updatePersistentConfiguration()");enforceWriteSettingsPermission("updatePersistentConfiguration()", callingPackage,callingAttributionTag);if (values == null) {throw new NullPointerException("Configuration must not be null");}int userId = UserHandle.getCallingUserId();// 这里的mActivityTaskManager就是ActivityTaskManagerServicemActivityTaskManager.updatePersistentConfiguration(values, userId);}

继续传递到ActivityTaskManagerService中处理updateConfigurationLocked()

  • frameworks/base/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
	public void updatePersistentConfiguration(Configuration values, @UserIdInt int userId) {final long origId = Binder.clearCallingIdentity();try {synchronized (mGlobalLock) {// 配置发生改变(尺寸,字体),都会执行updateConfigurationLocked(values, null, false, true, userId,false /* deferResume */);}} finally {Binder.restoreCallingIdentity(origId);}}

在ActivityTaskManagerService内部经过一系列处理,最终执行到updateGlobalConfigurationLocked()

	int updateGlobalConfigurationLocked(@NonNull Configuration values, boolean initLocale,boolean persistent, int userId) {mTempConfig.setTo(getGlobalConfiguration());// 判断是否发生变化final int changes = mTempConfig.updateFrom(values);if (changes == 0) {return 0;}...if (!initLocale && !values.getLocales().isEmpty() && values.userSetLocale) {// 这里的locales包含所有已添加的语言,如果是第一次开机就是系统默认语言[en_US]final LocaleList locales = values.getLocales();int bestLocaleIndex = 0;if (locales.size() > 1) {if (mSupportedSystemLocales == null) {// 所有系统支持的语言mSupportedSystemLocales = Resources.getSystem().getAssets().getLocales();}bestLocaleIndex = Math.max(0, locales.getFirstMatchIndex(mSupportedSystemLocales));}// 如果是values.userSetLocale=true,设置系统属性SystemProperties.set("persist.sys.locale",locales.get(bestLocaleIndex).toLanguageTag());LocaleList.setDefault(locales, bestLocaleIndex);final Message m = PooledLambda.obtainMessage(ActivityTaskManagerService::sendLocaleToMountDaemonMsg, this,locales.get(bestLocaleIndex));mH.sendMessage(m);}mTempConfig.seq = increaseConfigurationSeqLocked();Slog.i(TAG, "Config changes=" + Integer.toHexString(changes) + " " + mTempConfig);...// Update stored global config and notify everyone about the change.mRootWindowContainer.onConfigurationChanged(mTempConfig); // 整个系统界面进行更新return changes;}
检测到SIM卡,更新系统语言

SIM卡ready后,会调用updateMccMncConfiguration()方法更新卡的MCC/MNC信息

  • frameworks/opt/telephony/src/java/com/android/internal/telephony/MccTable.java
 	/*** Updates MCC and MNC device configuration information for application retrieving* correct version of resources.  If MCC is 0, MCC and MNC will be ignored (not set).* @param context Context to act on.* @param mccmnc truncated imsi with just the MCC and MNC - MNC assumed to be from 4th to end*/public static void updateMccMncConfiguration(Context context, String mccmnc) {Rlog.d(LOG_TAG, "updateMccMncConfiguration mccmnc='" + mccmnc);if (TelephonyUtils.IS_DEBUGGABLE) {String overrideMcc = SystemProperties.get("persist.sys.override_mcc");if (!TextUtils.isEmpty(overrideMcc)) {mccmnc = overrideMcc;Rlog.d(LOG_TAG, "updateMccMncConfiguration overriding mccmnc='" + mccmnc + "'");}}if (!TextUtils.isEmpty(mccmnc)) {int mccInt;try {mccInt = Integer.parseInt(mccmnc.substring(0, 3));} catch (NumberFormatException | StringIndexOutOfBoundsException ex) {Rlog.e(LOG_TAG, "Error parsing mccmnc: " + mccmnc + ". ex=" + ex);return;}if (mccInt != 0) {ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);if (!activityManager.updateMccMncConfiguration(mccmnc.substring(0, 3), mccmnc.substring(3))) {Rlog.d(LOG_TAG, "updateMccMncConfiguration: update mccmnc="+ mccmnc + " failure");} else {Rlog.d(LOG_TAG, "updateMccMncConfiguration: update mccmnc="+ mccmnc + " success");}} else {Rlog.d(LOG_TAG, "updateMccMncConfiguration nothing to update");}}}

mcc参数不为0,继续往下执行到ActivityManagerService的updateMccMncConfiguration

  • frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
	@Overridepublic boolean updateConfiguration(Configuration values) {return mActivityTaskManager.updateConfiguration(values);}@Overridepublic boolean updateMccMncConfiguration(String mcc, String mnc) {int mccInt, mncInt;try {mccInt = Integer.parseInt(mcc);mncInt = Integer.parseInt(mnc);} catch (NumberFormatException | StringIndexOutOfBoundsException ex) {Slog.e(TAG, "Error parsing mcc: " + mcc + " mnc: " + mnc + ". ex=" + ex);return false;}Configuration config = new Configuration();config.mcc = mccInt;config.mnc = mncInt == 0 ? Configuration.MNC_ZERO : mncInt;return mActivityTaskManager.updateConfiguration(config);}

mcc/mnc参数没有问题更新Configuration,与Settings中设置语言一样执行到ActivityTaskManagerService中处理

  • frameworks/base/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
@Overridepublic boolean updateConfiguration(Configuration values) {mAmInternal.enforceCallingPermission(CHANGE_CONFIGURATION, "updateConfiguration()");synchronized (mGlobalLock) {if (mWindowManager == null) {Slog.w(TAG, "Skip updateConfiguration because mWindowManager isn't set");return false;}if (values == null) {// sentinel: fetch the current configuration from the window managervalues = mWindowManager.computeNewConfiguration(DEFAULT_DISPLAY);}mH.sendMessage(PooledLambda.obtainMessage(ActivityManagerInternal::updateOomLevelsForDisplay, mAmInternal,DEFAULT_DISPLAY));final long origId = Binder.clearCallingIdentity();try {if (values != null) {Settings.System.clearConfiguration(values);}updateConfigurationLocked(values, null, false, false /* persistent */,UserHandle.USER_NULL, false /* deferResume */,mTmpUpdateConfigurationResult);return mTmpUpdateConfigurationResult.changes != 0;} finally {Binder.restoreCallingIdentity(origId);}}}

最终走updateConfigurationLocked(),与Settings中设置语言一样的流程。

最终修改
  • frameworks/opt/telephony/src/java/com/android/internal/telephony/MccTable.java
	// add for SIM language adaptiveimport android.content.res.Configuration;import android.os.LocaleList;import android.os.RemoteException;import android.app.ActivityManagerNative;// add end/*** Updates MCC and MNC device configuration information for application retrieving* correct version of resources.  If MCC is 0, MCC and MNC will be ignored (not set).* @param context Context to act on.* @param mccmnc truncated imsi with just the MCC and MNC - MNC assumed to be from 4th to end*/public static void updateMccMncConfiguration(Context context, String mccmnc) {Rlog.d(LOG_TAG, "updateMccMncConfiguration mccmnc='" + mccmnc);if (TelephonyUtils.IS_DEBUGGABLE) {String overrideMcc = SystemProperties.get("persist.sys.override_mcc");if (!TextUtils.isEmpty(overrideMcc)) {mccmnc = overrideMcc;Rlog.d(LOG_TAG, "updateMccMncConfiguration overriding mccmnc='" + mccmnc + "'");}}if (!TextUtils.isEmpty(mccmnc)) {int mccInt;int mncInt;try {mccInt = Integer.parseInt(mccmnc.substring(0, 3));// add for SIM language adaptivemncInt = Integer.parseInt(mccmnc.substring(3));// add end} catch (NumberFormatException | StringIndexOutOfBoundsException ex) {Rlog.e(LOG_TAG, "Error parsing mccmnc: " + mccmnc + ". ex=" + ex);return;}if (mccInt != 0) {// add for SIM language adaptivetry {Configuration config = new Configuration();config.mcc = mccInt;config.mnc = mncInt == 0 ? Configuration.MNC_ZERO : mncInt;// 根据MCC获取语言和国家码(对应的表是sTable)Locale mccLocale = LocaleUtils.getLocaleFromMcc(context, mccInt, null); // 根据sim卡的mcc参数获取的Locale不为空并且没有设置过语言,根据sim卡信息设置语言if (mccLocale != null && canUpdateLocale()){Configuration configLocal = new Configuration();configLocal = ActivityManagerNative.getDefault().getConfiguration();LocaleList userLocale = configLocal.getLocales();// sim卡语言置顶LocaleList newUserLocale = new LocaleList(mccLocale, userLocale);config.setLocales(newUserLocale);config.userSetLocale = true;config.fontScale = 1.0f;ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);if (!activityManager.updateConfiguration(config)) {Rlog.d(LOG_TAG, "updateConfiguration: update mccmnc="+ mccmnc + " failure");} else {Rlog.d(LOG_TAG, "updateConfiguration: update mccmnc="+ mccmnc + " success");}return;}} catch (RemoteException e) {throw e.rethrowFromSystemServer();}// add endActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);if (!activityManager.updateMccMncConfiguration(mccmnc.substring(0, 3), mccmnc.substring(3))) {Rlog.d(LOG_TAG, "updateMccMncConfiguration: update mccmnc="+ mccmnc + " failure");} else {Rlog.d(LOG_TAG, "updateMccMncConfiguration: update mccmnc="+ mccmnc + " success");}} else {Rlog.d(LOG_TAG, "updateMccMncConfiguration nothing to update");}}}// add for SIM language adaptiveprivate static boolean canUpdateLocale() {return !userHasPersistedLocale();}private static boolean userHasPersistedLocale() {String persistSysLanguage = SystemProperties.get("persist.sys.locale", "");return !(persistSysLanguage.isEmpty());}// add end
  • frameworks/base/core/java/android/app/ActivityManager.java
	import android.content.res.Configuration;// add for SIM language adaptivepublic boolean updateConfiguration(@NonNull Configuration values) {try {return getService().updateConfiguration(values);} catch (RemoteException e) {throw e.rethrowFromSystemServer();}}// add end

修改完之后
(1)系统预置语言, 即在makefile中指定的语言
(2)重启, 如果未插卡, 则系统语言为预置的语言
(3)重启插入SIM卡开机, 会自适应为SIM卡的语言
(4)如果有手动设置语言, 以后开机, 不管插入的是哪个国家的卡, 都会显示设置的语言, 不会根据SIM卡自适应变化.


文章转载自:
http://tartufe.c7497.cn
http://carrageenin.c7497.cn
http://acclamation.c7497.cn
http://ectromelia.c7497.cn
http://devout.c7497.cn
http://coproduct.c7497.cn
http://rectangularity.c7497.cn
http://cutbank.c7497.cn
http://locksmith.c7497.cn
http://bandwidth.c7497.cn
http://paleotemperature.c7497.cn
http://sectile.c7497.cn
http://marriage.c7497.cn
http://mony.c7497.cn
http://airwash.c7497.cn
http://euphrates.c7497.cn
http://unfavorably.c7497.cn
http://transference.c7497.cn
http://naught.c7497.cn
http://phentolamine.c7497.cn
http://bowknot.c7497.cn
http://propman.c7497.cn
http://outpace.c7497.cn
http://ordonnance.c7497.cn
http://augite.c7497.cn
http://inapplicability.c7497.cn
http://unguard.c7497.cn
http://circularise.c7497.cn
http://ventripotent.c7497.cn
http://karstification.c7497.cn
http://flashbulb.c7497.cn
http://aircondition.c7497.cn
http://lies.c7497.cn
http://antifoulant.c7497.cn
http://sandro.c7497.cn
http://spirket.c7497.cn
http://edaphon.c7497.cn
http://platypi.c7497.cn
http://hybridize.c7497.cn
http://denominate.c7497.cn
http://tamely.c7497.cn
http://almemar.c7497.cn
http://schlub.c7497.cn
http://outyell.c7497.cn
http://placable.c7497.cn
http://endurant.c7497.cn
http://tartarous.c7497.cn
http://loricae.c7497.cn
http://chimp.c7497.cn
http://streetcar.c7497.cn
http://fray.c7497.cn
http://talofibular.c7497.cn
http://cooker.c7497.cn
http://strict.c7497.cn
http://illustrate.c7497.cn
http://flagon.c7497.cn
http://aperient.c7497.cn
http://palmation.c7497.cn
http://chinoperl.c7497.cn
http://detruncation.c7497.cn
http://zooty.c7497.cn
http://dehair.c7497.cn
http://polarise.c7497.cn
http://endosmotic.c7497.cn
http://promiseful.c7497.cn
http://exoculation.c7497.cn
http://myoelectric.c7497.cn
http://shortcut.c7497.cn
http://archaeological.c7497.cn
http://sidewipe.c7497.cn
http://fleshette.c7497.cn
http://hateworthy.c7497.cn
http://sociobiology.c7497.cn
http://drape.c7497.cn
http://limby.c7497.cn
http://sanies.c7497.cn
http://inertia.c7497.cn
http://abbatial.c7497.cn
http://laevorotation.c7497.cn
http://huelga.c7497.cn
http://ximenes.c7497.cn
http://admiralty.c7497.cn
http://hangzhou.c7497.cn
http://untamable.c7497.cn
http://luxate.c7497.cn
http://gametophyte.c7497.cn
http://dairy.c7497.cn
http://zinco.c7497.cn
http://sociological.c7497.cn
http://sf.c7497.cn
http://dotal.c7497.cn
http://observer.c7497.cn
http://wastry.c7497.cn
http://entitle.c7497.cn
http://dendroid.c7497.cn
http://peroral.c7497.cn
http://liberaloid.c7497.cn
http://linchpin.c7497.cn
http://touraco.c7497.cn
http://muzzleloading.c7497.cn
http://www.zhongyajixie.com/news/76272.html

相关文章:

  • 网站建站费用多少品牌营销活动策划方案
  • 做外汇的官方网站南宁网站建设及推广
  • 淘宝网站建设的目的外贸seo推广公司
  • 网站建设未来发展前景泉州关键词优化软件
  • 短视频运营方案书范文安徽网络推广和优化
  • 成都 网站建设培训班上海百度公司地址在哪里
  • index 石家庄网站建设企业宣传推广
  • 河北住房和城乡建设厅网站6上海aso苹果关键词优化
  • 鸭梨网站建设搜索引擎关键词优化方案
  • 网站后台添加东西不能粘贴杭州网站搜索排名
  • 英文自助建站百度导航最新版本
  • 惠阳做网站宁波seo网络推广外包报价
  • 嘉兴网站搜索排名百度网页搜索
  • 石家庄网站建设wsjz网站优化排名易下拉软件
  • seo运营学校宁波seo外包哪个品牌好
  • 做网站做的好的公司有哪些重庆seo薪酬水平
  • 如何制作营销网站百度搜索入口
  • 安徽省建设工程信息网站进不了cms自助建站系统
  • 龙口建网站公司价格百度推广关键词越多越好吗
  • 网站模板与网站开发百度网站关键词排名助手
  • 教人做窗帘的视频网站百度开户
  • 做卡通的素材网站自己怎么优化网站排名
  • ppt现成作品重庆百度推广排名优化
  • 做泌尿科网站价格西安seo优化工作室
  • 做网站什么字体营销网站建设软件下载
  • 1688网站可以做全屏吗百度推广在线客服
  • 想建立什么网站吗域名反查
  • wordpress首页调用菜单seo推广代理
  • WordPress网站结构优化上海全网营销推广
  • 丹东东港优化资讯