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

国外校友网站建设的现状黄页网站推广app免费下载

国外校友网站建设的现状,黄页网站推广app免费下载,泰安网站建设与优化,现在怎么做网络推广Android5.1 壁纸设置流程浅析Ubuntu14.04 Android5.1 Source Insight3这里只是简单分析一下5.1里是如何设置壁纸的#xff1b;这个流程和4.4有一些不同。但基本都是找个地方存放壁纸文件#xff0c;需要的时候读取#xff0c;设置的时候更新这里只看设置的过程。权当参考。…Android5.1 壁纸设置流程浅析Ubuntu14.04  Android5.1  Source Insight3这里只是简单分析一下5.1里是如何设置壁纸的这个流程和4.4有一些不同。但基本都是找个地方存放壁纸文件需要的时候读取设置的时候更新这里只看设置的过程。权当参考。机器使用launcher3在桌面上长按底部显示设置壁纸的入口。进入设置壁纸界面观察log可知此界面属于Trebuchet。也是launcher3点击设置壁纸按钮发现整个标题栏都有响应。在以下文件中可以找到相关定义/*— ↓ — WallpaperPickerActivity.java *********///Action bar//Show the custom action bar viewfinal ActionBar actionBar getActionBar();actionBar.setCustomView(R.layout.actionbar_set_wallpaper);actionBar.getCustomView().setOnClickListener(newView.OnClickListener() {Overridepublic voidonClick(View v) {if (mSelectedTile ! null) {WallpaperTileInfo info(WallpaperTileInfo) mSelectedTile.getTag();info.onSave(WallpaperPickerActivity.this);}else{//no tile was selected, so we just finish the activity and go backsetResult(Activity.RESULT_OK);finish();}}});mSetWallpaperButtonfindViewById(R.id.set_wallpaper_button);/*— ↑ — (packages/apps/Trebuchet/WallpaperPicker/src/com/android/launcher3/) *********/整个 actionBar都拿来响应点击。info是 WallpaperTileInfo抽象类的对象有5个子类。这样系统能根据图片来选择使用哪一个子类。再调用 onSave方法。以FileWallpaperInfo类为例。它复写了 onSave方法/*— ↓ — WallpaperPickerActivity.java *********/Overridepublic voidonSave(WallpaperPickerActivity a) {a.setWallpaper(Uri.fromFile(mFile),true);}/*— ↑ — (packages/apps/Trebuchet/WallpaperPicker/src/com/android/launcher3/) *********/因为WallpaperPickerActivity 继承自 WallpaperCropActivitysetWallpaper方法在 WallpaperCropActivity中找到传入了Uri和一个boolean值/*↓ — WallpaperCropActivity.java *********/protected void setWallpaper(Uri uri, final booleanfinishActivityWhenDone) {int rotation getRotationFromExif(this, uri);BitmapCropTask cropTask newBitmapCropTask(this, uri, null, rotation, 0, 0, true, false, null);final Point bounds cropTask.getImageBounds();Runnable onEndCrop newRunnable() {public voidrun() {updateWallpaperDimensions(bounds.x, bounds.y);if(finishActivityWhenDone) {setResult(Activity.RESULT_OK);finish();}}};cropTask.setOnEndRunnable(onEndCrop);cropTask.setNoCrop(true);cropTask.execute();}/*↑ — (packages/apps/trebuchet/wallpaperpicker/src/com/android/launcher3) *********/以上代码可以看出它启动了一个异步任务  BitmapCropTask extends AsyncTask 把一些列参数都传入了cropTask启动一个线程onEndCrop等待任务结束进入BitmapCropTask看系统做了什么工作这是setWallpaper使用的构造方法/*↓ — WallpaperCropActivity.java *********/publicBitmapCropTask(Context c, Uri inUri,RectF cropBounds,int rotation, int outWidth, intoutHeight,boolean setWallpaper, booleansaveCroppedBitmap, Runnable onEndRunnable) {mContextc;mInUriinUri;init(cropBounds, rotation,outWidth, outHeight, setWallpaper, saveCroppedBitmap, onEndRunnable);}//……private void init(RectF cropBounds, int rotation, int outWidth, intoutHeight,boolean setWallpaper, booleansaveCroppedBitmap, Runnable onEndRunnable) {Log.d(“rust”,”init after bitmapcroptask”);mCropBoundscropBounds;mRotation rotation; //传入各项参数mOutWidth outWidth;mOutHeightoutHeight;mSetWallpapersetWallpaper;mSaveCroppedBitmapsaveCroppedBitmap;mOnEndRunnableonEndRunnable;}//…… 在这里处理任务启动 cropBitmap()OverrideprotectedBoolean doInBackground(Void… params) {returncropBitmap();}//……public booleancropBitmap() {boolean failure false;WallpaperManager wallpaperManager null;if(mSetWallpaper) {wallpaperManagerWallpaperManager.getInstance(mContext.getApplicationContext());}if (mSetWallpaper mNoCrop) {try{InputStream is regenerateInputStream(); //获得InputStreamif (is ! null) {wallpaperManager.setStream(is);//把is写进去从这里进入到wallpaperManagerUtils.closeSilently(is);}}catch(IOException e) {Log.w(LOGTAG,“cannot write stream to wallpaper”, e);failure true;}return !failure;}else { //顺利的话不会进入这里//……//Helper to setup input streamprivateInputStream regenerateInputStream() {if (mInUri null mInResId 0 mInFilePath null mInImageBytes null) {Log.w(LOGTAG,“cannot read original file, no input URI, resource ID, or ” “image byte array given”);}else{try{String filepathmInFilePath;if(mInUri ! null){filepathDrmHelper.getFilePath(mContext, mInUri);}if(DrmHelper.isDrmFile(filepath)){byte[] bytes DrmHelper.getDrmImageBytes(filepath);return new ByteArrayInputStream(bytes); //返回一个ByteArray}/*↑ — (packages/apps/trebuchet/wallpaperpicker/src/com/android/launcher3) *********/调用了wallpaperManager.setStream(is);进入 WallpaperManager.java 看看/*↓ — WallpaperManager.java *********/public void setStream(InputStream data) throws IOException { //luncher3 里直接调用了这个方法if (sGlobals.mService null) { //WallpaperCropActivity 调用Log.w(TAG, “WallpaperService not running”);return;}try{ParcelFileDescriptor fd sGlobals.mService.setWallpaper(null); //利用service得到fdif (fd null) { //这里要去WallpaperManagerService里找到对应方法return;}FileOutputStream fos null;try{fos newParcelFileDescriptor.AutoCloseOutputStream(fd);setWallpaper(data, fos);//写入壁纸数据} finally{if (fos ! null) {fos.close();}}}catch(RemoteException e) {//Ignore}}//…… 在这里写入壁纸写入过程结束Manager完成任务private voidsetWallpaper(InputStream data, FileOutputStream fos)throwsIOException {byte[] buffer new byte[32768];intamt;while ((amtdata.read(buffer)) 0) {fos.write(buffer,0, amt);}}/*↑ — (framework/base/core/java/android/app) *********/再来看Globals extends IWallpaperManagerCallback.Stub包含成员变量 IWallpaperManager mService通过Globals(Looper looper) {IBinder bServiceManager.getService(Context.WALLPAPER_SERVICE);mServiceIWallpaperManager.Stub.asInterface(b);}调用 WallpaperManagerService.java 里的setWallpaper方法Service的作用进入WallpaperManagerService看看是如何返回ParcelFileDescriptor值的/*↓ — WallpaperManagerService.java *********/public ParcelFileDescriptor setWallpaper(String name) { //供 WallpaperManager 调用checkPermission(android.Manifest.permission.SET_WALLPAPER);synchronized(mLock) {if (DEBUG) Slog.v(TAG, “setWallpaper”);int userId UserHandle.getCallingUserId();WallpaperData wallpapermWallpaperMap.get(userId);if (wallpaper null) {throw new IllegalStateException(“Wallpaper not yet initialized for user ” userId);}final long ident Binder.clearCallingIdentity();try{ParcelFileDescriptor pfdupdateWallpaperBitmapLocked(name, wallpaper);if (pfd ! null) {//启动下面的方法wallpaper.imageWallpaperPending true;}return pfd; //返回ParcelFileDescriptor值给WallpaperManager} finally{Binder.restoreCallingIdentity(ident);}}}ParcelFileDescriptor updateWallpaperBitmapLocked(String name, WallpaperData wallpaper) {if (name null) name “”;try{File dir getWallpaperDir(wallpaper.userId); //找到壁纸if (!dir.exists()) {dir.mkdir();FileUtils.setPermissions(dir.getPath(),FileUtils.S_IRWXU|FileUtils.S_IRWXG|FileUtils.S_IXOTH,-1, -1);}File file new File(dir, WALLPAPER); //创建一个新的文件ParcelFileDescriptor fd ParcelFileDescriptor.open(file,MODE_CREATE|MODE_READ_WRITE|MODE_TRUNCATE);if (!SELinux.restorecon(file)) {return null;}wallpaper.namename;return fd; //返回ParcelFileDescriptor值} catch(FileNotFoundException e) {Slog.w(TAG,“Error setting wallpaper”, e);}return null;}private static File getWallpaperDir(int userId) { //取得壁纸文件returnEnvironment.getUserSystemDirectory(userId);}/*↑ — (framework/base/services/core/java/com/android/server/wallpaper/) *********/至此一个简单的流程就结束了我们可反过来看壁纸文件是存在 Environment.getUserSystemDirectory(userId) 这个路径下WallpaperManagerService取到这个文件后将其打开为ParcelFileDescriptor形式交给WallpaperManagerWallpaperManager把launcher传来的数据写入这个文件中小结一下选定壁纸点击按钮launcher把壁纸信息给WallpaperManagerWallpaperManagerService把存放壁纸的文件打开交给WallpaperManagerWallpaperManager把壁纸信息写入一次设置壁纸的动作就完成了这里传输数据使用到engine一个挺有意思的东西。
http://www.sadfv.cn/news/138611/

相关文章:

  • 建设局招标办网站学习网站建设论文
  • dw可以做有后台的网站么erp企业管理系统软件有哪些
  • 499可以做网站网络运营者应当为()
  • 不孕不育网站建设总结wordpress主要插件
  • 长春网站开发senluowx手机下载微信电脑版官方免费下载
  • 百度网站排名优化工具眉山市住房和城乡建设部网站
  • 成都网站品牌设计策划404做的好的网站
  • 网站规划与建设ppt模板下载南宁专业网站开发
  • seo网站推广优化费用企业注册号怎么查询
  • 翔宇定制app下载seo搜索引擎优化是什么
  • 厦门网站制作方案中国企业信息公示网登录官网
  • 如何在淘宝开网站建设wap蓝天建站
  • 南宁网站制作企业微信网站建设开发
  • 长宁苏州网站建设广西住房与城乡建设部网站
  • 做一份完整的网站规划书都有哪些做二手挖机的网站
  • 有做盆景的网站想做水果外卖怎么做网站
  • 如何建设好英文网站做网站优化好的网络公司
  • 广州专业手机网站建设设计深圳网站制作
  • 济南优化网站的哪家好网站建设官网制作平台
  • 官方智慧团建网站asp网站生成
  • 网站一年要多少钱百度企业网站建设费用
  • 网站开发定价学而思网校官网
  • 毕业设计做网站还是系统nginx 网站开发
  • 网页此站点不安全什么页游好玩
  • 上海普陀区企业网站建设wordpress拖动建站
  • 唐山网站制作方案wordpress单页主题
  • 江苏建发建设项目咨询有限公司网站网站seo优化工具
  • 专业定制网站系统wordpress 非80端口
  • 陕西建设机械股份有限公司网站济南建设工程交易中心网站
  • 东莞市建设网站金湖建设局网站