- Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathSystemDeviceUtil.java
More file actions
Latest commit
88 lines (67 loc) · 2.52 KB
/
Copy pathSystemDeviceUtil.java
File metadata and controls
88 lines (67 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
packagecom.hht.uc.Quicksetting.utils;
importandroid.content.Context;
importjava.lang.reflect.Method;
importandroid.media.AudioManager;
publicclassSystemDeviceUtil {
publicstaticvoidsetMute(booleanmute,AudioManageraudiomanger){
Class<?> c = null;
try {
c = Class.forName("android.media.AudioManager");
Methodm1 = c.getMethod("setMasterMute", boolean.class);
m1.invoke(audiomanger,mute);
} catch (Exceptione){
e.printStackTrace();
}
}
// public static void setMute(boolean mute,Context context){
// Class<?> c = null;
// AudioManager mAudioManager = null;
// try {
// c = Class.forName("android.media.AudioManager");
//
// java.lang.reflect.Constructor<?> con = c.getConstructor(Context.class);
//
// mAudioManager = (AudioManager) con.newInstance(context);
//
// Method m1 = c.getMethod("setMasterMute", boolean.class);
//
// m1.invoke(mAudioManager,mute);
// } catch (Exception e){
// e.printStackTrace();
// }
//
// }
publicstaticvoidsetWifiP2pDeviceName(StringdevName,Contextcontext) {
WifiP2pManagermanager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
WifiP2pManager.Channelchannel = manager.initialize(context, context.getMainLooper(), null);
try {
Class[] paramTypes = newClass[3];
paramTypes[0] = WifiP2pManager.Channel.class;
paramTypes[1] = String.class;
paramTypes[2] = WifiP2pManager.ActionListener.class;
MethodsetDeviceName = manager.getClass().getMethod(
"setDeviceName", paramTypes);
setDeviceName.setAccessible(true);
Objectarglist[] = newObject[3];
arglist[0] = channel;
arglist[1] = devName;
arglist[2] = newWifiP2pManager.ActionListener() {
@Override
publicvoidonSuccess() {
}
@Override
publicvoidonFailure(intreason) {
}
};
setDeviceName.invoke(manager, arglist);
} catch (NoSuchMethodExceptione) {
e.printStackTrace();
} catch (IllegalAccessExceptione) {
e.printStackTrace();
} catch (IllegalArgumentExceptione) {
e.printStackTrace();
} catch (InvocationTargetExceptione) {
e.printStackTrace();
}
}
}