Solve the shortage of internal storage space, do not load desktop wallpaper, desktop wallpaper display, and load desktop Wallpaper

Source: Internet
Author: User

Solve the shortage of internal storage space, do not load desktop wallpaper, desktop wallpaper display, and load desktop Wallpaper
Note:

When the internal storage space is insufficient, do not load wallpaper to save resources.


Method of modification: modify the content in WallpaperManagerService. java. Train of Thought: Before loading the wallpaper, we need to determine whether the current storage space is insufficient. The Code is as follows: (Source Code address)
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 defacomponcomponent =
0835 mContext. getString (com. android. internal. R. string. default_wallpaper_component );
0836 if (defacomponcomponent! = 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_wall paper;
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}

Note!

The red part adds code.



When I change my computer desktop background, can I handle commands if I have insufficient storage space? Why?

I don't know if I didn't understand it, or you didn't explain it. Why ??? The answer is generally a question about disk C space! If you haven't set it, the virtual memory will also be under drive C! Normally, you need to separate the virtual memory from the system in different partitions. For example, the TEMP Temporary Folder should be opened separately! And I personally think the C drive should be at least 10 Gb! The same size must be set for the virtual memory (that is, the minimum and maximum values must be equal )! Answer: "My Computer" right-click "properties"-"advanced"-"performance" Settings-"advanced"-"Virtual Memory" Change

How to Set and display w7 desktop wallpapers with internal errors

Right-click the blank area on the desktop and select "next desktop background". The computer does not respond. 2. Select an image and click "set as desktop background". "internal error" is displayed and cannot be set successfully. 3. Choose another theme in personalization. The computer has the sound of changing theme, but the desktop background image remains unchanged. So I posted my post on Baidu, hoping that my friends who encountered the same problem could see it and save valuable time.
Solution: Open the following path to find the path of the operating system drive letter. I am a drive C. We recommend that you first open the operating system folder in the folder option to hide and protect and display all Folder Options, allows you to quickly locate folders. In C: \ Users \ YourUserName \ AppData \ Roaming \ Microsoft \ Windows \ themes, find transcodedwallpaper.jpg and delete it. Just switch a topic again.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.