auto import from //branches/cupcake/...@126645
This commit is contained in:
@@ -25,9 +25,12 @@ import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import com.android.internal.app.AlertActivity;
|
||||
import com.android.internal.app.AlertController;
|
||||
@@ -39,10 +42,10 @@ public class SettingsLicenseActivity extends AlertActivity {
|
||||
|
||||
private static final String TAG = "SettingsLicenseActivity";
|
||||
private static final boolean LOGV = false || Config.LOGV;
|
||||
|
||||
private static final String DEFAULT_LICENSE_PATH = "/system/etc/NOTICE.html";
|
||||
|
||||
private static final String DEFAULT_LICENSE_PATH = "/system/etc/NOTICE.html.gz";
|
||||
private static final String PROPERTY_LICENSE_PATH = "ro.config.license_path";
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -54,14 +57,19 @@ public class SettingsLicenseActivity extends AlertActivity {
|
||||
return;
|
||||
}
|
||||
|
||||
FileReader fileReader = null;
|
||||
InputStreamReader inputReader = null;
|
||||
StringBuilder data = null;
|
||||
try {
|
||||
data = new StringBuilder(2048);
|
||||
data = new StringBuilder(2048);
|
||||
char tmp[] = new char[2048];
|
||||
int numRead;
|
||||
fileReader = new FileReader(fileName);
|
||||
while ((numRead = fileReader.read(tmp)) >= 0) {
|
||||
if (fileName.endsWith(".gz")) {
|
||||
inputReader = new InputStreamReader(
|
||||
new GZIPInputStream(new FileInputStream(fileName)));
|
||||
} else {
|
||||
inputReader = new FileReader(fileName);
|
||||
}
|
||||
while ((numRead = inputReader.read(tmp)) >= 0) {
|
||||
data.append(tmp, 0, numRead);
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
@@ -74,19 +82,19 @@ public class SettingsLicenseActivity extends AlertActivity {
|
||||
return;
|
||||
} finally {
|
||||
try {
|
||||
if (fileReader != null) {
|
||||
fileReader.close();
|
||||
if (inputReader != null) {
|
||||
inputReader.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (TextUtils.isEmpty(data)) {
|
||||
Log.e(TAG, "License HTML is empty (from " + fileName + ")");
|
||||
showErrorAndFinish();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
WebView webView = new WebView(this);
|
||||
|
||||
// Begin the loading. This will be done in a separate thread in WebView.
|
||||
@@ -98,7 +106,7 @@ public class SettingsLicenseActivity extends AlertActivity {
|
||||
mAlert.setTitle(getString(R.string.settings_license_activity_title));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
final AlertController.AlertParams p = mAlertParams;
|
||||
p.mTitle = getString(R.string.settings_license_activity_loading);
|
||||
p.mView = webView;
|
||||
@@ -111,5 +119,5 @@ public class SettingsLicenseActivity extends AlertActivity {
|
||||
.show();
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -24,6 +24,8 @@ import android.bluetooth.BluetoothHeadset;
|
||||
import android.bluetooth.BluetoothClass;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -141,9 +143,7 @@ public abstract class LocalBluetoothProfileManager {
|
||||
|
||||
public A2dpProfileManager(LocalBluetoothManager localManager) {
|
||||
super(localManager);
|
||||
|
||||
mService = new BluetoothA2dp(localManager.getContext());
|
||||
// TODO: block until connection?
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -213,37 +213,32 @@ public abstract class LocalBluetoothProfileManager {
|
||||
/**
|
||||
* HeadsetProfileManager is an abstraction for the {@link BluetoothHeadset} service.
|
||||
*/
|
||||
private static class HeadsetProfileManager extends LocalBluetoothProfileManager {
|
||||
private static class HeadsetProfileManager extends LocalBluetoothProfileManager
|
||||
implements BluetoothHeadset.ServiceListener {
|
||||
private BluetoothHeadset mService;
|
||||
private Handler mUiHandler = new Handler();
|
||||
|
||||
public HeadsetProfileManager(LocalBluetoothManager localManager) {
|
||||
super(localManager);
|
||||
|
||||
// final boolean[] isServiceConnected = new boolean[1];
|
||||
// BluetoothHeadset.ServiceListener l = new BluetoothHeadset.ServiceListener() {
|
||||
// public void onServiceConnected() {
|
||||
// synchronized (this) {
|
||||
// isServiceConnected[0] = true;
|
||||
// notifyAll();
|
||||
// }
|
||||
// }
|
||||
// public void onServiceDisconnected() {
|
||||
// mService = null;
|
||||
// }
|
||||
// };
|
||||
|
||||
// TODO: block, but can't on UI thread
|
||||
mService = new BluetoothHeadset(localManager.getContext(), null);
|
||||
mService = new BluetoothHeadset(localManager.getContext(), this);
|
||||
}
|
||||
|
||||
// synchronized (l) {
|
||||
// while (!isServiceConnected[0]) {
|
||||
// try {
|
||||
// l.wait(100);
|
||||
// } catch (InterruptedException e) {
|
||||
// throw new IllegalStateException(e);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
public void onServiceConnected() {
|
||||
// This could be called on a non-UI thread, funnel to UI thread.
|
||||
mUiHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
/*
|
||||
* We just bound to the service, so refresh the UI of the
|
||||
* headset device.
|
||||
*/
|
||||
String address = mService.getHeadsetAddress();
|
||||
if (TextUtils.isEmpty(address)) return;
|
||||
mLocalManager.getLocalDeviceManager().onProfileStateChanged(address);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onServiceDisconnected() {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -59,14 +59,15 @@ public class QuickLaunchSettings extends PreferenceActivity implements
|
||||
|
||||
private static final int COLUMN_SHORTCUT = 0;
|
||||
private static final int COLUMN_TITLE = 1;
|
||||
private static final int COLUMN_INTENT = 2;
|
||||
private static final String[] sProjection = new String[] {
|
||||
Bookmarks.SHORTCUT, Bookmarks.TITLE
|
||||
Bookmarks.SHORTCUT, Bookmarks.TITLE, Bookmarks.INTENT
|
||||
};
|
||||
private static final String sShortcutSelection = Bookmarks.SHORTCUT + "=?";
|
||||
|
||||
private Handler mUiHandler = new Handler();
|
||||
|
||||
private static final String DEFAULT_BOOKMARK_FOLDER = "@default";
|
||||
private static final String DEFAULT_BOOKMARK_FOLDER = "@quicklaunch";
|
||||
/** Cursor for Bookmarks provider. */
|
||||
private Cursor mBookmarksCursor;
|
||||
/** Listens for changes to Bookmarks provider. */
|
||||
@@ -225,18 +226,18 @@ public class QuickLaunchSettings extends PreferenceActivity implements
|
||||
|
||||
String title = data.getStringExtra(BookmarkPicker.EXTRA_TITLE);
|
||||
char shortcut = data.getCharExtra(BookmarkPicker.EXTRA_SHORTCUT, (char) 0);
|
||||
updateShortcut(shortcut, title, data);
|
||||
updateShortcut(shortcut, data);
|
||||
|
||||
} else {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateShortcut(char shortcut, String title, Intent intent) {
|
||||
|
||||
private void updateShortcut(char shortcut, Intent intent) {
|
||||
// Update the bookmark for a shortcut
|
||||
Bookmarks.add(getContentResolver(), intent, title.toString(), DEFAULT_BOOKMARK_FOLDER,
|
||||
shortcut, 0);
|
||||
// Pass an empty title so it gets resolved each time this bookmark is
|
||||
// displayed (since the locale could change after we insert into the provider).
|
||||
Bookmarks.add(getContentResolver(), intent, "", DEFAULT_BOOKMARK_FOLDER, shortcut, 0);
|
||||
}
|
||||
|
||||
private ShortcutPreference getOrCreatePreference(char shortcut) {
|
||||
@@ -300,7 +301,7 @@ public class QuickLaunchSettings extends PreferenceActivity implements
|
||||
if (shortcut == 0) continue;
|
||||
|
||||
ShortcutPreference pref = getOrCreatePreference(shortcut);
|
||||
pref.setTitle(c.getString(COLUMN_TITLE));
|
||||
pref.setTitle(Bookmarks.getTitle(this, c));
|
||||
pref.setSummary(getString(R.string.quick_launch_shortcut,
|
||||
String.valueOf(shortcut)));
|
||||
pref.setHasBookmark(true);
|
||||
|
@@ -27,6 +27,7 @@ import android.preference.EditTextPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.provider.Settings;
|
||||
import android.provider.Settings.System;
|
||||
import android.text.TextUtils;
|
||||
import android.view.KeyEvent;
|
||||
@@ -34,11 +35,13 @@ import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class IpSettings extends PreferenceActivity implements Preference.OnPreferenceChangeListener {
|
||||
public class AdvancedSettings extends PreferenceActivity
|
||||
implements Preference.OnPreferenceChangeListener {
|
||||
|
||||
private static final String KEY_MAC_ADDRESS = "mac_address";
|
||||
private static final String KEY_USE_STATIC_IP = "use_static_ip";
|
||||
private static final String KEY_NUM_CHANNELS = "num_channels";
|
||||
private static final String KEY_SLEEP_POLICY = "sleep_policy";
|
||||
|
||||
private String[] mSettingNames = {
|
||||
System.WIFI_STATIC_IP, System.WIFI_STATIC_GATEWAY, System.WIFI_STATIC_NETMASK,
|
||||
@@ -58,7 +61,7 @@ public class IpSettings extends PreferenceActivity implements Preference.OnPrefe
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
addPreferencesFromResource(R.xml.ip_settings);
|
||||
addPreferencesFromResource(R.xml.wifi_advanced_settings);
|
||||
|
||||
mUseStaticIpCheckBox = (CheckBoxPreference) findPreference(KEY_USE_STATIC_IP);
|
||||
|
||||
@@ -74,6 +77,7 @@ public class IpSettings extends PreferenceActivity implements Preference.OnPrefe
|
||||
|
||||
updateUi();
|
||||
initNumChannelsPreference();
|
||||
initSleepPolicyPreference();
|
||||
refreshMacAddress();
|
||||
}
|
||||
|
||||
@@ -108,6 +112,14 @@ public class IpSettings extends PreferenceActivity implements Preference.OnPrefe
|
||||
pref.setValue(String.valueOf(numChannels));
|
||||
}
|
||||
}
|
||||
|
||||
private void initSleepPolicyPreference() {
|
||||
ListPreference pref = (ListPreference) findPreference(KEY_SLEEP_POLICY);
|
||||
pref.setOnPreferenceChangeListener(this);
|
||||
int value = Settings.System.getInt(getContentResolver(),
|
||||
Settings.System.WIFI_SLEEP_POLICY,Settings. System.WIFI_SLEEP_POLICY_DEFAULT);
|
||||
pref.setValue(String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
@@ -137,6 +149,16 @@ public class IpSettings extends PreferenceActivity implements Preference.OnPrefe
|
||||
return false;
|
||||
}
|
||||
|
||||
} else if (key.equals(KEY_SLEEP_POLICY)) {
|
||||
try {
|
||||
Settings.System.putInt(getContentResolver(),
|
||||
Settings.System.WIFI_SLEEP_POLICY, Integer.parseInt(((String) newValue)));
|
||||
} catch (NumberFormatException e) {
|
||||
Toast.makeText(this, R.string.wifi_setting_sleep_policy_error,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
} else {
|
||||
String value = (String) newValue;
|
||||
|
@@ -192,7 +192,7 @@ public class WifiSettings extends PreferenceActivity implements WifiLayer.Callba
|
||||
return true;
|
||||
|
||||
case MENU_ID_ADVANCED:
|
||||
Intent intent = new Intent(this, IpSettings.class);
|
||||
Intent intent = new Intent(this, AdvancedSettings.class);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
|
||||
|
Reference in New Issue
Block a user