blob: 7c89127a41846c86c9e3d5593b77f9eb7636bf4f (
plain)
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
|
package com.cyanogenmod.AriesParts;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceManager;
public class Hspa implements OnPreferenceChangeListener {
private static final String APK_FILE = "/system/app/SamsungServiceMode.apk";
private Context mCtx;
public Hspa(Context context) {
mCtx = context;
}
public static boolean isSupported() {
return Utils.fileExists(APK_FILE);
}
/**
* Restore HSPA setting from SharedPreferences. (Write to kernel.)
* @param context The context to read the SharedPreferences from
*/
public static void restore(Context context) {
if (!isSupported()) {
return;
}
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
sendIntent(context, sharedPrefs.getString(AriesParts.KEY_HSPA, "23"));
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
sendIntent(mCtx, (String) newValue);
return true;
}
private static void sendIntent(Context context, String value) {
Intent i = new Intent("com.cyanogenmod.SamsungServiceMode.EXECUTE");
i.putExtra("sub_type", 20); // HSPA Setting
i.putExtra("data", value);
context.sendBroadcast(i);
}
}
|