package co.lvdou.showshow.floatwindow;
import java.util.List;
import android.app.ActivityManager;
import android.app.ActivityManager.RecentTaskInfo;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.app.ActivityManager.RunningServiceInfo;
import android.app.ActivityManager.RunningTaskInfo;
import android.content.Context;
/**
* @description 用于 获得进程,服务,应用的状态
* @author by
* @time 2013.08.02
*/
public class ApkToolHelper
{
/**
* 获取系统正在运行的进程
* @param context
* @return
*/
public static List<RunningAppProcessInfo> getSystemProcess(Context context)
{
ActivityManager manager = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE) ;
List<RunningAppProcessInfo> processInfos = manager.getRunningAppProcesses();
return processInfos;
}
/**
* 获取系统正在运行的服务
* @param context
* @return
*/
public static List<RunningServiceInfo> getServiceProcess(Context context)
{
ActivityManager manager = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE) ;
List<RunningServiceInfo> serviceInfos = manager.getRunningServices(100);
return serviceInfos;
}
/**
* 获取系统正在运行的Activity
* @param context
* @return
*/
public static List<RunningTaskInfo> getActivityProcess(Context context)
{
ActivityManager manager = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE) ;
List<RunningTaskInfo> activityInfos = manager.getRunningTasks(1000);
return activityInfos;
}
/**
* 获取最近打开的应用
* @param context
* @return
*/
public static List<RecentTaskInfo> getLatestApp(Context context)
{
ActivityManager manager = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE) ;
List<RecentTaskInfo> latestAppInfos = manager.getRecentTasks(100, 1);
return latestAppInfos;
}
}
package co.lvdou.showshow.floatwindow;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.location.LocationManager;
import android.media.AudioManager;
import android.net.ConnectivityManager;
import android.net.wifi.WifiManager;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import android.view.Window;
import android.view.WindowManager;
/**
* @description 用于获取各种开关的状态,以及设置开关状态
* @author by
* @time 2013.07.31
*/
public class ToolSwitchHelper
{
/**
* 获取WIFI状态
* @param context
* @return
*/
public static boolean getWifiStatu(Context context)
{
WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
return wifiManager.isWifiEnabled();
}
/**
* 设置WIFI状态
* @param context
* @param isopen
*/
public static void setWifiStatu(Context context,boolean isopen)
{
WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
wifiManager.setWifiEnabled(isopen);
}
/**
* 获取GPRS状态
* @param context
* @return
*/
public static boolean getGprsStatu(Context context)
{
boolean isopen=false;
ConnectivityManager conMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
Class<?> conMgrClass = null;
Field iConMgrField = null;
Object iConMgr = null;
Class<?> iConMgrClass = null;
Method getMobileDataEnabledMethod = null;
try
{
conMgrClass = Class.forName(conMgr.getClass().getName());
iConMgrField = conMgrClass.getDeclaredField("mService");
iConMgrField.setAccessible(true);
iConMgr = iConMgrField.get(conMgr);
iConMgrClass = Class.forName(iConMgr.getClass().getName());
getMobileDataEnabledMethod = iConMgrClass.getDeclaredMethod("getMobileDataEnabled");
getMobileDataEnabledMethod.setAccessible(true);
isopen=(Boolean) getMobileDataEnabledMethod.invoke(iConMgr);
}
catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
return isopen;
}
/**
* 设置GPRS状态
* @param context
* @param isopen
*/
public static void setGprsStatu(Context context,boolean isopen)
{
ConnectivityManager conMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
Class<?> conMgrClass = null;
Field iConMgrField = null;
Object iConMgr = null;
Class<?> iConMgrClass = null;
Method setMobileDataEnabledMethod = null;
try
{
conMgrClass = Class.forName(conMgr.getClass().getName());
iConMgrField = conMgrClass.getDeclaredField("mService");
iConMgrField.setAccessible(true);
iConMgr = iConMgrField.get(conMgr);
iConMgrClass = Class.forName(iConMgr.getClass().getName());
setMobileDataEnabledMethod = iConMgrClass.getDeclaredMethod("setMobileDataEnabled", Boolean.TYPE);
setMobileDataEnabledMethod.setAccessible(true);
setMobileDataEnabledMethod.invoke(iConMgr, isopen);
}
catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
/**
* 获取GPS状态
* @param context
* @return
*/
public static boolean getGpsStatu(Context context)
{
LocationManager alm = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
return alm.isProviderEnabled(android.location.LocationManager.GPS_PROVIDER);
}
/**
* 设置GPS状态
* @param caller
*/
public static void setGpsStatu(Activity caller)
{
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
caller.startActivityForResult(intent,0);
}
/**
* 获取蓝牙状态
* @return
*/
public static boolean getBluetoothStatu()
{
BluetoothAdapter bluetoothAdapter=BluetoothAdapter.getDefaultAdapter();
return bluetoothAdapter.isEnabled();
}
/**
* 设置蓝牙状态
* @param isOpen
*/
public static void setBluetoothStatu(boolean isOpen)
{
BluetoothAdapter bluetoothAdapter=BluetoothAdapter.getDefaultAdapter();
if(isOpen)
{
bluetoothAdapter.enable();
}
else
{
bluetoothAdapter.disable();
}
}
/**
* 获取飞行模式状态
* @return
*/
public static boolean getFlightMode(Context context)
{
boolean isOpen=false;
ContentResolver resolver=context.getContentResolver();
if(Settings.System.getString(resolver,Settings.System.AIRPLANE_MODE_ON).equals("0"))
{
isOpen=false;
}
else
{
isOpen=true;
}
return isOpen;
}
/**
* 设置飞行模式状态
* @param context
* @param isOpen
*/
public static void setFiightMode(Context context,boolean isOpen)
{
ContentResolver resolver = context.getContentResolver();
if(isOpen)
{
Settings.System.putString(resolver,Settings.System.AIRPLANE_MODE_ON, "1");
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
context.sendBroadcast(intent);
}
else
{
Settings.System.putString(resolver,Settings.System.AIRPLANE_MODE_ON, "0");
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
context.sendBroadcast(intent);
}
}
/**
* 获取屏幕旋转状态
* @return
*/
public static boolean getScreenRotation(Context context)
{
boolean isOpen=false;
try
{
int status = Settings.System.getInt(context.getContentResolver(), "accelerometer_rotation");
if(status == 1)
{
isOpen=true;
}
else
{
isOpen=false;
}
}
catch (SettingNotFoundException e)
{
e.printStackTrace();
}
return isOpen;
}
/**
* 设置屏幕旋转状态
* @param context
* @param isOpen
*/
public static void setScreenRotation(Context context,boolean isOpen)
{
if(isOpen)
{
Settings.System.putInt(context.getContentResolver(), "accelerometer_rotation",1);
}
else
{
Settings.System.putInt(context.getContentResolver(), "accelerometer_rotation",0);
}
}
/**
* 关机
* @param context
* @param time
*/
public static void Shutdown(Context context,long time)
{
}
/**
* 获得当前屏幕亮度的模式
* SCREEN_BRIGHTNESS_MODE_AUTOMATIC=1 为自动调节屏幕亮度
* SCREEN_BRIGHTNESS_MODE_MANUAL=0 为手动调节屏幕亮度
*/
public static int getScreenMode(Context context)
{
int screenMode=0;
try
{
screenMode = Settings.System.getInt(context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE);
}
catch (Exception e)
{
e.printStackTrace();
}
return screenMode;
}
/**
* 获得当前屏幕亮度值 0--255
*/
public static int getScreenBrightness(Context context)
{
int screenBrightness=255;
try
{
screenBrightness = Settings.System.getInt(context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS);
}
catch (Exception e)
{
e.printStackTrace();
}
return screenBrightness;
}
/**
* 设置当前屏幕亮度的模式
* SCREEN_BRIGHTNESS_MODE_AUTOMATIC=1 为自动调节屏幕亮度
* SCREEN_BRIGHTNESS_MODE_MANUAL=0 为手动调节屏幕亮度
*/
public static void setScreenMode(int paramInt,Context context)
{
try
{
Settings.System.putInt(context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, paramInt);
}
catch (Exception e)
{
e.printStackTrace();
}
}
/**
* 设置当前屏幕亮度值 0--255
*/
public static void saveScreenBrightness(int paramInt,Context context){
try
{
Settings.System.putInt(context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, paramInt);
}
catch (Exception localException)
{
localException.printStackTrace();
}
}
/**
* 保存当前的屏幕亮度值
*/
public static void setScreenBrightness(int paramInt,Activity caller)
{
Window window = caller.getWindow();
WindowManager.LayoutParams params = window.getAttributes();
float f = paramInt / 255.0F;
params.screenBrightness = f;
window.setAttributes(params);
}
/**
* 获取当前通话音量
*/
public static int getCallSound(Context context)
{
int current=0;
try
{
AudioManager manager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
current = manager.getStreamVolume(AudioManager.STREAM_VOICE_CALL );
}
catch (Exception e)
{}
return current;
}
/**
* 获取通话最大音量
*/
public static int getCallMaxSound(Context context)
{
int max=0;
try
{
AudioManager manager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
max = manager.getStreamMaxVolume( AudioManager.STREAM_VOICE_CALL);
}
catch (Exception e)
{}
return max;
}
/**
* 获取当前系统音量
*/
public static int getSystemSound(Context context)
{
int current=0;
try
{
AudioManager manager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
current = manager.getStreamVolume( AudioManager.STREAM_SYSTEM );
}
catch (Exception e)
{}
return current;
}
/**
* 获取系统最大音量
*/
public static int getSystemMaxSound(Context context)
{
int max=0;
try
{
AudioManager manager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
max = manager.getStreamMaxVolume(AudioManager.STREAM_SYSTEM );
}
catch (Exception e)
{}
return max;
}
/**
* 获取当前铃声音量
*/
public static int getRingtoneSound(Context context)
{
int current=0;
try
{
AudioManager manager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
current = manager.getStreamVolume( AudioManager.STREAM_RING );
}
catch (Exception e)
{}
return current;
}
/**
* 获取铃声最大音量
*/
public static int getRingtoneMaxSound(Context context)
{
int max=0;
try
{
AudioManager manager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
max = manager.getStreamMaxVolume( AudioManager.STREAM_RING);
}
catch (Exception e)
{}
return max;
}
/**
* 获取当前音乐音量
*/
public static int getMusicSound(Context context)
{
int current=0;
try
{
AudioManager manager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
current = manager.getStreamVolume( AudioManager.STREAM_MUSIC );
}
catch (Exception e)
{}
return current;
}
/**
* 获取音乐最大音量
*/
public static int getMusicMaxSound(Context context)
{
int max=0;
try
{
AudioManager manager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
max = manager.getStreamMaxVolume( AudioManager.STREAM_MUSIC);
}
catch (Exception e)
{}
return max;
}
/**
* 获取当前提示音音量
*/
public static int getAlarmSound(Context context)
{
int current=0;
try
{
AudioManager manager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
current = manager.getStreamVolume( AudioManager.STREAM_ALARM );
}
catch (Exception e)
{}
return current;
}
/**
* 获取提示音最大音量
*/
public static int getAlarmMaxSound(Context context)
{
int max=0;
try
{
AudioManager manager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
max = manager.getStreamMaxVolume( AudioManager.STREAM_ALARM );
}
catch (Exception e)
{}
return max;
}
/**
* 设置音量
* @param systemsound 系统音量
* @param callsound 通话音量
* @param ringtonesound 铃声音量
* @param musicsound 音乐音量
* @param alarmsound 提示音量
*/
public static void setAllSound(Context context,int systemsound,int callsound,int ringtonesound,int musicsound,int alarmsound)
{
AudioManager manager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
try
{
manager.setStreamVolume(AudioManager.STREAM_SYSTEM, systemsound, 0);
manager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, callsound, 0);
manager.setStreamVolume(AudioManager.STREAM_RING, ringtonesound, 0);
manager.setStreamVolume(AudioManager.STREAM_MUSIC, musicsound, 0);
manager.setStreamVolume(AudioManager.STREAM_ALARM, alarmsound, 0);
}
catch (Exception e)
{}
}
/**
* 获取情景模式
* @param mode 0 静音模式 1 振动模式 2 正常模式
*/
public static int getSceneMode(Context context)
{
AudioManager manager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
return manager.getRingerMode();
}
/**
* 设置情景模式
* @param mode 0 静音模式 1 振动模式 2 正常模式
*/
public static void setSceneMode(Context context,int mode)
{
AudioManager manager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
switch (mode)
{
case 0:
manager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
break;
case 1:
manager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
break;
case 2:
manager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
break;
default:
break;
}
}
}
1.ToolSwitchHelper.java 用于获取各种开关的状态,以及设置开关状态,如WIFI,GPS,GPRS等等
2.ApkToolHelper.java 用于 获得进程,服务,应用的状态
android.permission.ACCESS_CHECKIN_PROPERTIES 允许读写访问”properties”表在checkin数据库中,改值可以修改上传
android.permission.ACCESS_COARSE_LOCATION 允许一个程序访问CellID或WiFi热点来获取粗略的位置
android.permission.ACCESS_FINE_LOCATION 允许一个程序访问精良位置(如GPS)
android.permission.ACCESS_LOCATION_EXTRA_COMMANDS 允许应用程序访问额外的位置提供命令
android.permission.ACCESS_MOCK_LOCATION 允许程序创建模拟位置提供用于测试
android.permission.ACCESS_NETWORK_STATE 允许程序访问有关GSM网络信息
android.permission.ACCESS_SURFACE_FLINGER 允许程序使用SurfaceFlinger底层特性
android.permission.ACCESS_WIFI_STATE 允许程序访问Wi-Fi网络状态信息
android.permission.ADD_SYSTEM_SERVICE 允许程序发布系统级服务
android.permission.BATTERY_STATS 允许程序更新手机电池统计信息
android.permission.BLUETOOTH 允许程序连接到已配对的蓝牙设备
android.permission.BLUETOOTH_ADMIN 允许程序发现和配对蓝牙设备
android.permission.BRICK 请求能够禁用设备(非常危险)
android.permission.BROADCAST_PACKAGE_REMOVED 允许程序广播一个提示消息在一个应用程序包已经移除后
android.permission.BROADCAST_STICKY 允许一个程序广播常用intents
android.permission.CALL_PHONE 允许一个程序初始化一个电话拨号不需通过拨号用户界面需要用户确认
android.permission.CALL_PRIVILEGED 允许一个程序拨打任何号码,包含紧急号码无需通过拨号用户界面需要用户确认
android.permission.CAMERA 请求访问使用照相设备
android.permission.CHANGE_COMPONENT_ENABLED_STATE 允许一个程序是否改变一个组件或其他的启用或禁用
android.permission.CHANGE_CONFIGURATION 允许一个程序修改当前设置,如本地化
android.permission.CHANGE_NETWORK_STATE 允许程序改变网络连接状态
android.permission.CHANGE_WIFI_STATE 允许程序改变Wi-Fi连接状态
android.permission.CLEAR_APP_CACHE 允许一个程序清楚缓存从所有安装的程序在设备中
android.permission.CLEAR_APP_USER_DATA 允许一个程序清除用户设置
android.permission.CONTROL_LOCATION_UPDATES 允许启用禁止位置更新提示从无线模块
android.permission.DELETE_CACHE_FILES 允许程序删除缓存文件
android.permission.DELETE_PACKAGES 允许一个程序删除包
android.permission.DEVICE_POWER 允许访问底层电源管理
android.permission.DIAGNOSTIC 允许程序RW诊断资源
android.permission.DISABLE_KEYGUARD 允许程序禁用键盘锁
android.permission.DUMP 允许程序返回状态抓取信息从系统服务
android.permission.EXPAND_STATUS_BAR 允许一个程序扩展收缩在状态栏
android.permission.FACTORY_TEST 作为一个工厂测试程序,运行在root用户
android.permission.FLASHLIGHT 访问闪光灯
android.permission.FORCE_BACK 允许程序强行一个后退操作是否在顶层activities
android.permission.FOTA_UPDATE 暂时不了解这是做什么使用的
android.permission.GET_ACCOUNTS 访问一个帐户列表在Accounts Service中
android.permission.GET_PACKAGE_SIZE 允许一个程序获取任何package占用空间容量
android.permission.GET_TASKS 允许一个程序获取信息有关当前或最近运行的任务,一个缩略的任务状态,是否活动等等
android.permission.HARDWARE_TEST 允许访问硬件
android.permission.INJECT_EVENTS 允许一个程序截获用户事件如按键、触摸、轨迹球等等到一个时间流
android.permission.INSTALL_PACKAGES 允许一个程序安装packages
android.permission.INTERNAL_SYSTEM_WINDOW 允许打开窗口使用系统用户界面
android.permission.INTERNET 允许程序打开网络套接字
android.permission.MANAGE_APP_TOKENS 允许程序管理(创建、催后、z-order默认向z轴推移)程序引用在窗口管理器中
android.permission.MASTER_CLEAR 目前还没有明确的解释
android.permission.MODIFY_AUDIO_SETTINGS 允许程序修改全局音频设置
android.permission.MODIFY_PHONE_STATE 允许修改话机状态,如电源,人机接口等
android.permission.MOUNT_UNMOUNT_FILESYSTEMS 允许挂载和反挂载文件系统可移动存储
android.permission.PERSISTENT_ACTIVITY 允许一个程序设置他的activities显示
android.permission.PROCESS_OUTGOING_CALLS 允许程序监视、修改有关播出电话
android.permission.READ_CALENDAR 允许程序读取用户日历数据
android.permission.READ_CONTACTS 允许程序读取用户联系人数据
android.permission.READ_FRAME_BUFFER 允许程序屏幕波或和更多常规的访问帧缓冲数据
android.permission.READ_INPUT_STATE 允许程序返回当前按键状态
android.permission.READ_LOGS 允许程序读取底层系统日志文件
android.permission.READ_OWNER_DATA 允许程序读取所有者数据
android.permission.READ_SMS 允许程序读取短信息
android.permission.READ_SYNC_SETTINGS 允许程序读取同步设置
android.permission.READ_SYNC_STATS 允许程序读取同步状态
android.permission.REBOOT 请求能够重新启动设备
android.permission.RECEIVE_BOOT_COMPLETED 允许程序接收到 ACTION_BOOT_COMPLETED广播在系统完成启动
android.permission.RECEIVE_MMS 允许一个程序监控将收到MMS彩信,记录或处理
android.permission.RECEIVE_SMS 允许程序监控一个将收到短信息,记录或处理
android.permission.RECEIVE_WAP_PUSH 允许程序监控将收到WAP PUSH信息
android.permission.RECORD_AUDIO 允许程序录制音频
android.permission.REORDER_TASKS 允许程序改变Z轴排列任务
android.permission.RESTART_PACKAGES 允许程序重新启动其他程序
android.permission.SEND_SMS 允许程序发送SMS短信
android.permission.SET_ACTIVITY_WATCHER 允许程序监控或控制activities已经启动全局系统中
android.permission.SET_ALWAYS_FINISH 允许程序控制是否活动间接完成在处于后台时
android.permission.SET_ANIMATION_SCALE 修改全局信息比例
android.permission.SET_DEBUG_APP 配置一个程序用于调试
android.permission.SET_ORIENTATION 允许底层访问设置屏幕方向和实际旋转
android.permission.SET_PREFERRED_APPLICATIONS 允许一个程序修改列表参数PackageManager.addPackageToPreferred()和PackageManager.removePackageFromPreferred()方法
android.permission.SET_PROCESS_FOREGROUND 允许程序当前运行程序强行到前台
android.permission.SET_PROCESS_LIMIT 允许设置最大的运行进程数量
android.permission.SET_TIME_ZONE 允许程序设置时间区域
android.permission.SET_WALLPAPER 允许程序设置壁纸
android.permission.SET_WALLPAPER_HINTS 允许程序设置壁纸hits
android.permission.SIGNAL_PERSISTENT_PROCESSES 允许程序请求发送信号到所有显示的进程中
android.permission.STATUS_BAR 允许程序打开、关闭或禁用状态栏及图标
android.permission.SUBSCRIBED_FEEDS_READ 允许一个程序访问订阅RSS Feed内容提供
android.permission.SUBSCRIBED_FEEDS_WRITE 系统暂时保留改设置
android.permission.SYSTEM_ALERT_WINDOW 允许程序打开窗口使用TYPE_SYSTEM_ALERT,显示在其他所有程序的顶层
android.permission.VIBRATE 允许访问振动设备
android.permission.WAKE_LOCK 允许使用PowerManager的 WakeLocks保持进程在休眠时从屏幕消失
android.permission.WRITE_APN_SETTINGS 允许程序写入APN设置
android.permission.WRITE_CALENDAR 允许一个程序写入但不读取用户日历数据
android.permission.WRITE_CONTACTS 允许程序写入但不读取用户联系人数据
android.permission.WRITE_GSERVICES 允许程序修改Google服务地图
android.permission.WRITE_OWNER_DATA 允许一个程序写入但不读取所有者数据
android.permission.WRITE_SETTINGS 允许程序读取或写入系统设置
android.permission.WRITE_SMS 允许程序写短信
android.permission.WRITE_SYNC_SETTINGS 允许程序写入同步设置