可以使用 mmm进行编译的话,还可以使用 mm,但是 mm 是在当前目录下实行编译的,也就是模块目录下使用此命令。
实例 2: 实现 Android 启动后不进入锁屏状态。
修改 KeyguardViewMediator.java 文件下的变量,将其赋值改为 false 即可。
步骤如下: 1、 cd frameworks/base/policy/src/com/android/internal/policy/impl/ //在下载的
Android源码目录下输入此命令,进入到 impl 目录下 2、 gedit KeyguardViewMediator.java //是用文本编辑器打开 java 文件 3、将 private boolean mExternallyEnabled true代码中的 true 改为 false,保存退出 4、 cd ../../../../../../ ../../../ //返回到源码目录下 5、 source ./build/envsetup.sh //环境初始化 6、 mmm frameworks/base/policy/ //对 policy 模块进行编译 7、 make snod //重新打包 system.img注意:如果在进行模块代码编译了,报出少了一个 odex 后缀名的文件的错误时,总结了下,导致报错的原因可能是 Android 版本的差异,不过没事,即使模块编译通不过,还是可以对整个源码进行编译的(直接在源码目录下执行 make 命令即可) ,只是时间会相对较长,同样会将修改的模块整合到 system.img 文件中。
Android 4.0 下防止用户对安装程序进行卸载打开源码目录找到 packages/apps/PackageInstaller/src/com/android/packageinstaller/下的两个文件:1、UninstallAppProgress.Java //程序卸载过程2、UninstallerActivity.java //程序卸载界面方法是在 UninstallerActivity.java 对应位置加上一段代码即可:Override public void onCreateBundle icicle super.onCreateicicle // Get intent information. // We expect an intent with URI of the form package://ltpackageNamegtltclassNamegt // className is optional if specified it is the activity the user chose to uninstall final Intent intent getIntent Uri packageURI intent.getData String packageName packageURI.getEncodedSchemeSpecificPart ifpackageName null Log.eTAG quotInvalid package name:quot packageName showDialogDLG_APP_NOT_FOUND return ifpackageName.equalsquotcn.android.managerappquot /AlertDialog.Builder builder new AlertDialog.Builderthis //builder.setIconandroid.R.drawable.ic_dialog_info builder.setTitlequotMessagequot builder.setMessagequotCannot be uninstallquot builder.setPositiveButtonquot确认quot null //builder.create.show builder.show //showDialogDLG_APP_NOT_FOUND //return finish/ new AlertDialog.Builderthis .setTitlequot游戏控制quot .setMessagequot对不起,此程序不允许卸载!quot .setPositiveButtonquot确定quot new DialogInterface.OnClickListener public void onClickDialogInterface dialoginterface int i //这里设置点击后执行 finish .show mPm getPackageManager boolean errFlag false加上红色部分的代码,就可以对特定的安装程序进行控制了。
其中 cn.android.managerapp 是指安装程序的进程名,效果就是弹出提示框,提醒用户程序不允许卸载。
Android 4.0 下防止用户对安装程序进行强行停止打 开 源 码 目 录 , 到 frameworks/base/services/java/com/android/server/am/ 目 录 下 找 到ActivityManagerService.java 文件,并打开它。
可以对代码中两个地方进行控制,都可以达到强行停止的目的:1、 在 forceStopPackage 函数中,加上一段代码2、 public void forceStopPackagefinal String packageName 3、 if checkCallingPermissionandroid.Manifest.permission.FORCE_STOP_PACKAGES4、 PackageManager.PERMISSION_GRANTED 5、 String msg quotPermission Denial: forceStopPackage from pidquot6、 Binder.getCallingPid7、 quot uidquot Binder.getCallingUid8、 quot requires quot android.Manifest.permission.FORCE_STOP_PACKAGES9、 Slog.wTAG msg10、 throw new SecurityExceptionmsg11、 12、 final int userId UserId.getCallingUserId13、 long callingId Binder.clearCallingIdentity14、 try 15、 IPackageManager pm AppGlobals.getPackageManager16、 int pkgUid -117、 synchronizedthis 18、 try 19、 pkgUid pm.getPackageUidpackageName userId20、 catch RemoteException e 21、 22、 if packageName -1 23、 Slog.wTAG quotInvalid packageName: quot packageName24、 return25、 26、 //添加判断代码27、 ifpackageName.equalsquotcn.android.managerappquot28、 return29、 30、 //31、 forceStopPackageLockedpackageName pkgUid32、 try 33、 pm.setPackageStoppedStatepackageName true userId34、 catch RemoteException e 35、 catch IllegalArgumentException e 36、 Slog.wTAG quotFailed trying to unstop package quot37、 packageName quot: quot e38、 39、 40、 finally 41、 Binder.restoreCallingIdentitycallingId42、 43、 方法二:这是在网上看到的方法,尝试了下,编译通过了,但是在模拟器上面运行的时候出问题2、修改 clearApplicationUserData 函数44、 public boolean clearApplicationUserDatafinal String packageName45、 final IPackageDataObserver observer final int userId 46、 enforceNotIsolatedCallerquotclearApplicationUserDataquot47、 int uid Binder.getCallingUid48、 int pid Binder.getCallingPid49、 long callingId Binder.clearCallingIdentity50、 try 51、 IPackageManager pm AppGlobals.getPackageManager52、 int pkgUid -153、 synchronizedthis 54、 try 55、 pkgUid pm.getPackageUidpackageName userId56、 catch RemoteException e 57、 58、 if pkgUid -1 59、 Slog.wTAG quotInvalid packageName:quot packageName60、 return false61、 62、 ifpackageName.equalsquotcn.android.managerappquot63、 AlertDialog.Builder builder new AlertDialog.BuildermContent64、 builder.setTitle65、 builder.setMessagemsg66、 builder.setPositiveButtonquotOKquotnew DialogInterface.OnClickListener67、 public void onClickDialogInterface dialoginterface int i68、 //Click event69、 70、 71、 72、 builder.create.show73、 return false74、 75、 if uid pkgUid checkComponentPermission76、 android.Manifest.permission.CLEAR_APP_USER_DATA77、 pid uid -1 true78、 PackageManager.PERMISSION_GRANTED 79、 forceStopPackageLockedpackageName pkgUid80、 else 81、 throw new SecurityExceptionpidquot does not have permission:quot82、 android.Manifest.permission.CLEAR_APP_USER_DATAquot to clear dataquot 83、 quotfor process:quotpackageName84、 85、 86、87、 try 88、 //clear application user data89、 pm.clearApplicationUserDatapackageName observer userId90、 Intent intent new IntentIntent.ACTION_PACKAGE_DATA_CLEARED91、 Uri.fromPartsquotpackagequot packageName null92、 intent.putExtraIntent.EXTRA_UID pkgUid93、 broadcastIntentInPackagequotandroidquot Process.SYSTEM_UID intent94、 null null 0 null null null false false userId95、 catch RemoteException e 96、 97、 finally 98、 Binder.restoreCallingIdentitycallingId99、 100、 return true101、 Launcher 桌面定制方法一:将系统的 Launcher 进行删除,使用自己编写的 Launcher。
实现步骤:1、 编写自己的 Launcher。
例如: 建立 Jhome 工程, 修改工程下的 AndroidManifest.xml 文件, 如下所示: // 主屏 activity 属性设置 // Android activity 属性设置大全 http://apps.hi.baidu.com/share/detail/44749420 ltactivity android:namequotcom.launcher.jhome.Laucherquot android:launchModequotsingleTaskquot android:clearTaskOnLaunchquottruequot android:stateNotNeededquottruequot android:windowSoftInputModequotadjustPanquot android:screenOrientationquotnosensorquot android:labelquotstring/title_activity_laucherquot gt ltintent-filtergt ltaction android:namequotandroid.intent.action.MAINquot /gt //以下两条代码一定要加上,表示 Home Screen ltcategory android:namequotandroid.intent.category.LAUNCHERquot /gt ltcategory android:namequotandroid.intent.category.HOMEquot /gt ltcategory androi.
上一篇:
Windows平台下Android源码的下载
下一篇:
英语论文网([网学网]):英语专业本科生毕业论文写作