解決內部儲存空間緊張,不載入案頭壁紙,案頭壁紙顯示,載入案頭壁紙

來源:互聯網
上載者:User

解決內部儲存空間緊張,不載入案頭壁紙,案頭壁紙顯示,載入案頭壁紙
說明:

當內部儲存空間不足的情況下不載入壁紙,以節省資源。


修改方式:在WallpaperManagerService.java中進行修改;思路:首先在載入壁紙之前我們需要判斷當前儲存空間是否緊張。代碼如下:(源碼地址)
public boolean isStorageLow(){  try{      if(mIpackageManager!=null){          return mIPackageManager.isStorageLow();      }
  }catch(RemoteException e){      }  return false;}


     boolean bindWallpaperComponentLocked(ComponentName componentName, boolean force,
0813             boolean fromUser, WallpaperData wallpaper, IRemoteCallback reply) {
0814         if (DEBUG) Slog.v(TAG, "bindWallpaperComponentLocked: componentName=" + componentName);
if(isStorageLow()){    return false;}

0815         // Has the component changed?
0816         if (!force) {
0817             if (wallpaper.connection != null) {
0818                 if (wallpaper.wallpaperComponent == null) {
0819                     if (componentName == null) {
0820                         if (DEBUG) Slog.v(TAG, "bindWallpaperComponentLocked: still using default");
0821                         // Still using default wallpaper.
0822                         return true;
0823                     }
0824                 } else if (wallpaper.wallpaperComponent.equals(componentName)) {
0825                     // Changing to same wallpaper.
0826                     if (DEBUG) Slog.v(TAG, "same wallpaper");
0827                     return true;
0828                 }
0829             }
0830         }
0831         
0832         try {
0833             if (componentName == null) {
0834                 String defaultComponent = 
0835                     mContext.getString(com.android.internal.R.string.default_wallpaper_component);
0836                 if (defaultComponent != null) {
0837                     // See if there is a default wallpaper component specified
0838                     componentName = ComponentName.unflattenFromString(defaultComponent);
0839                     if (DEBUG) Slog.v(TAG, "Use default component wallpaper:" + componentName);
0840                 }
0841                 if (componentName == null) {
0842                     // Fall back to static image wallpaper
0843                     componentName = IMAGE_WALLPAPER;
0844                     //clearWallpaperComponentLocked();
0845                     //return;
0846                     if (DEBUG) Slog.v(TAG, "Using image wallpaper");
0847                 }
0848             }
0849             int serviceUserId = wallpaper.userId;
0850             ServiceInfo si = mIPackageManager.getServiceInfo(componentName,
0851                     PackageManager.GET_META_DATA | PackageManager.GET_PERMISSIONS, serviceUserId);
0852             if (si == null) {
0853                 // The wallpaper component we're trying to use doesn't exist
0854                 Slog.w(TAG, "Attempted wallpaper " + componentName + " is unavailable");
0855                 return false;
0856             }
0857             if (!android.Manifest.permission.BIND_WALLPAPER.equals(si.permission)) {
0858                 String msg = "Selected service does not require "
0859                         + android.Manifest.permission.BIND_WALLPAPER
0860                         + ": " + componentName;
0861                 if (fromUser) {
0862                     throw new SecurityException(msg);
0863                 }
0864                 Slog.w(TAG, msg);
0865                 return false;
0866             }
0867             
0868             WallpaperInfo wi = null;
0869             
0870             Intent intent = new Intent(WallpaperService.SERVICE_INTERFACE);
0871             if (componentName != null && !componentName.equals(IMAGE_WALLPAPER)) {
0872                 // Make sure the selected service is actually a wallpaper service.
0873                 List<ResolveInfo> ris =
0874                         mIPackageManager.queryIntentServices(intent,
0875                                 intent.resolveTypeIfNeeded(mContext.getContentResolver()),
0876                                 PackageManager.GET_META_DATA, serviceUserId);
0877                 for (int i=0; i<ris.size(); i++) {
0878                     ServiceInfo rsi = ris.get(i).serviceInfo;
0879                     if (rsi.name.equals(si.name) &&
0880                             rsi.packageName.equals(si.packageName)) {
0881                         try {
0882                             wi = new WallpaperInfo(mContext, ris.get(i));
0883                         } catch (XmlPullParserException e) {
0884                             if (fromUser) {
0885                                 throw new IllegalArgumentException(e);
0886                             }
0887                             Slog.w(TAG, e);
0888                             return false;
0889                         } catch (IOException e) {
0890                             if (fromUser) {
0891                                 throw new IllegalArgumentException(e);
0892                             }
0893                             Slog.w(TAG, e);
0894                             return false;
0895                         }
0896                         break;
0897                     }
0898                 }
0899                 if (wi == null) {
0900                     String msg = "Selected service is not a wallpaper: "
0901                             + componentName;
0902                     if (fromUser) {
0903                         throw new SecurityException(msg);
0904                     }
0905                     Slog.w(TAG, msg);
0906                     return false;
0907                 }
0908             }
0909             
0910             // Bind the service!
0911             if (DEBUG) Slog.v(TAG, "Binding to:" + componentName);
0912             WallpaperConnection newConn = new WallpaperConnection(wi, wallpaper);
0913             intent.setComponent(componentName);
0914             intent.putExtra(Intent.EXTRA_CLIENT_LABEL,
0915                     com.android.internal.R.string.wallpaper_binding_label);
0916             intent.putExtra(Intent.EXTRA_CLIENT_INTENT, PendingIntent.getActivityAsUser(
0917                     mContext, 0,
0918                     Intent.createChooser(new Intent(Intent.ACTION_SET_WALLPAPER),
0919                             mContext.getText(com.android.internal.R.string.chooser_wallpaper)),
0920                     0, null, new UserHandle(serviceUserId)));
0921             if (!mContext.bindServiceAsUser(intent, newConn,
0922                     Context.BIND_AUTO_CREATE | Context.BIND_SHOWING_UI,
0923                     new UserHandle(serviceUserId))) {
0924                 String msg = "Unable to bind service: "
0925                         + componentName;
0926                 if (fromUser) {
0927                     throw new IllegalArgumentException(msg);
0928                 }
0929                 Slog.w(TAG, msg);
0930                 return false;
0931             }
0932             if (wallpaper.userId == mCurrentUserId && mLastWallpaper != null) {
0933                 detachWallpaperLocked(mLastWallpaper);
0934             }
0935             wallpaper.wallpaperComponent = componentName;
0936             wallpaper.connection = newConn;
0937             wallpaper.lastDiedTime = SystemClock.uptimeMillis();
0938             newConn.mReply = reply;
0939             try {
0940                 if (wallpaper.userId == mCurrentUserId) {
0941                     if (DEBUG)
0942                         Slog.v(TAG, "Adding window token: " + newConn.mToken);
0943                     mIWindowManager.addWindowToken(newConn.mToken,
0944                             WindowManager.LayoutParams.TYPE_WALLPAPER);
0945                     mLastWallpaper = wallpaper;
0946                 }
0947             } catch (RemoteException e) {
0948             }
0949         } catch (RemoteException e) {
0950             String msg = "Remote exception for " + componentName + "\n" + e;
0951             if (fromUser) {
0952                 throw new IllegalArgumentException(msg);
0953             }
0954             Slog.w(TAG, msg);
0955             return false;
0956         }
0957         return true;
0958     }

注!

紅色部分為增加代碼。



我在換電腦案頭背景得時都會出現,儲存空間不足不可以處理命令?是什回事?

不知是我沒看明白,還是你沒有說明白.不解??? 答案補充 一般就是C盤空間的問題!如果你沒有進行設定的話,虛擬記憶體也是在C盤下!正常是要把虛擬記憶體和系統分開放在不同的分區中.像TEMP臨時檔案夾等都要分開放!而且C盤我個人認為最少要分10G的!虛擬記憶體也要設定同一大小(也就是最小值和最大值要相等)! 答案補充 "我的電腦"右鍵-"屬性"-"進階"-"效能"設定-"進階"-"虛擬記憶體"更改
 
w7案頭壁紙怎設定 顯示出現內部錯誤

在案頭空白處點擊滑鼠右鍵,選擇“下一個案頭背景”,電腦沒反應。2,選擇一張圖片,點擊“設為案頭背景”,顯示“出現內部錯誤”不能成功設定.3,在個人化中選擇其他主題,電腦有換主題的聲音但是案頭背景圖片還是沒有變化。於是我百度之,現將方法帖出來,希望遇到同樣問題的朋友能夠看到,節約寶貴的時間。
解決方案為:開啟以下路徑找到作業系統盤符所在路徑,我的是C盤,建議先開啟檔案夾選項中的作業系統檔案夾隱藏保護和顯示所有檔案夾選項,可以更快的定位檔案夾目錄。在C:\Users\YourUserName\AppData\Roaming\Microsoft\Windows\Themes,找到TranscodedWallpaper.jpg並刪除之,再次切換一個主題就好了。
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.