Change the system's Bluetooth WiFi hotspot message notification sleep add never option

Source: Internet
Author: User
Tags sleep

today to get a customer new order requirements, about 40 needs, today first change the system's Bluetooth/WIFI hot/message notification/sleep add never options, respectively:


Bluetooth: Connect the display name, the system interface display name, the default name before renaming

WiFi hotspot: Connect name, rename before default Network name

Notification Popup: System Notification Popup Default unchecked

hibernate add never option, default 30s: Add never hibernate, default 30s


first we want to know the system default Bluetooth name ANDROID BT

Linux Input ...> Find your source root directory/-type f|xargs grep "ANDROID BT"-l

This command is to find out the source code all with the string of ANDROID BT files, search without fruit, direct access to the source code

Packages\apps\settings\src\com\android\settings\bluetooth\bluetoothsettins.java

Trace Source to find the following code

    @Override public
    void Onresume () {
        ...

        if (mlocaladapter! = null) {
            updatecontent (mlocaladapter.getbluetoothstate ());}
    }

trace the Updatecontent function, modify the following code
                if (mmydevicepreference = = null) {
                    mmydevicepreference = new Preference (getactivity ());
                }

                engineer-jsp add default bluetooth name
            	if (android.os.SystemProperties.isWalPadVersion ()) {  
            		Mmydevicepreference.setsummary (Getresources (). getString (
            				r.string.bluetooth_is_visible_message, "Walpad C") );
            	} else{
            		mmydevicepreference.setsummary (getresources () getString (
            				r.string.bluetooth_is_visible_message , Mlocaladapter.getname ()));
            	} 
            	
                Mmydevicepreference.setselectable (FALSE);

where the Iswalpadversion function is the one I defined in Frameworks/base/core/java/android/os/systemproperties.java
	public static Boolean iswalpadversion () {  
    return Systemproperties.get ("Ro.product.model"). Contains ("Walpad");  
   }  
customized products based on the customer's flat model set by the compiled file, it's possible that someone might feel superfluous and obvious trouble, but as a system it would be better to make it compatible.

because the next time there is a system to customize the order requirements, we only need to modify the configuration file and branch is enough, easy and convenient, and no need to go to the new code

setsummary (...,...) function is the effect that Bluetooth settings display on the interface after Bluetooth is turned on

r.string.bluetooth.is.visible_message Content:

<string name= "Bluetooth_is_visible_message" ><xliff:g id= "device_name" >%1$s</xliff:g> is visible To nearby devices while the Bluetooth Settings is open.</string>
Device_name is the name we replace, that is Walpad C

Next Modify the name of the Bluetooth device with the duplicate option, onoptionsitemselected (MenuItem Item) finds the following logic according to the Dialog of the item tracking rename:

    @Override public
    Dialog oncreatedialog (Bundle savedinstancestate) {
	
	   ...

        Malertdialog = new Alertdialog.builder (getactivity ())
                . Settitle (R.string.bluetooth_rename_device)
                . Setview (Createdialogview (devicename))//Continue to follow the Createdialogview (devicename) method ...


        return malertdialog;
    }

According to the logic, modify the following:
    Private View Createdialogview (String devicename) {
         ...
        engineer-jsp add default bluetooth name
    	if (android.os.SystemProperties.isWalPadVersion ()) {//Display name according to model
    		mdevicenameview.settext ("Walpad C");
    	} else{
    		Mdevicenameview.settext (devicename);    Set initial value before adding listener
    	} ...
        return view;
    }


Connection Display Name modification:

                engineer-jsp add default bluetooth name
            	if (android.os.SystemProperties.isWalPadVersion ()) {  
            		Mmydevicepreference.setsummary (Getresources (). getString (
            				r.string.bluetooth_is_visible_message, "Walpad C")) ;
            		Mlocaladapter.setname ("Walpad C");//The modifications mentioned earlier add this sentence
            	}else{
            		mmydevicepreference.setsummary (getresources () . getString (
            				r.string.bluetooth_is_visible_message, Mlocaladapter.getname ()));
            	

Modify the name of the WiFi before renaming, according to the information to search the source Packages\apps\settings\src\com\android\settings\wifi\wifiapdialog.java

based on the logic, find the following code:

    @Override
    protected void onCreate (Bundle savedinstancestate) {
        Context context = GetContext ();
        ......
        if (mwificonfig! = null) {
            //engineer-jsp Add default bluetooth name
        	if ( Android.os.SystemProperties.isWalPadVersion ()) {  //display SSID
        		mssid.settext ("Walpad C") according to model number;
        	} else{
        		Mssid.settext (MWIFICONFIG.SSID);
        	} 

            M:set selection
            msecurity.setselection (Mext.getselection (Msecuritytypeindex));

            if (Msecuritytypeindex = = Wpa2_index) {
                  mpassword.settext (mwificonfig.presharedkey);
            }
            M:get configured channel @{
            mchannel = Mwificonfig.channel;
            Mchannelwidth = Mwificonfig.channelwidth;
            /// @}
        }
      ......
    }


Modify System Notification Popup is not checked by default

Search keywords: source directory ... >find./-name ". xml" | xargs grep "POPUP notification"

After locating the XML file, find the corresponding string name name and find that he was called by a layout file, Packages\apps\mms\res\xml\notificationpreferences.xml-pref_summary_ Popup_notification-
Defaultvalue= "false" to put this default false, you can

Modify Hibernate option default 30s add never hibernate option:

default Hibernate 30s modified: Frameworks\base\packages\settingsprovider\res\values\defaults.xml

<integer name= "Def_screen_off_timeout" >30000</integer>

Add never sleep option:
    Private static Final Boolean sneedscreentimeoutnever = true;

		@Override public void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);  ... if (sneedscreentimeoutnever && mscreentimeoutpreference! = null) {//RMT Add Resources res
        	= Getresources ();
            Final string[] entries = Res.getstringarray (r.array.screen_timeout_entries);
            
            Final string[] values = Res.getstringarray (r.array.screen_timeout_values);
            int entrieslength = Entries.length;
            Final string[] Newentries = new String[entrieslength + 1]; for (int i = 0; i < entrieslength + 1; i++) {if (i! = entrieslength) {Newentries[i] = Entr
            	Ies[i];
                } else {Newentries[i] = res.getstring (r.string.zen_mode_when_never);
            }} int valueslength = Values.length; Final string[] NewValues = new String[valueslength + 1]; for (int i = 0; i < valueslength + 1; i++) {if (i! = valueslength) {Newvalues[i] = values[
            	I];
                } else {newvalues[i] = "2147483647";
            }} mscreentimeoutpreference.setentries (Newentries);
            Mscreentimeoutpreference.setentryvalues (newValues);
	    ......
    }  private void Updatetimeoutpreferencedescription (long currenttimeout) {...} else if (currenttimeout = = Integer.max_value) {//engineer-jsp Add summary = Preference.getcontext (). getString (R.string.zen_mode_when_n
		EVER); }
		.......
    }


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.