Merge branch 'master' into honeycomb-release

This commit is contained in:
The Android Automerger
2010-10-25 07:13:51 -07:00
16 changed files with 340 additions and 78 deletions

View File

@@ -14,7 +14,7 @@
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="com.trustedlogic.trustednfc.permission.NFC_ADMIN" />
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.HARDWARE_TEST" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

View File

@@ -43,9 +43,11 @@
android:layout_height="wrap_content"
android:layout_marginTop="-5dp"
android:orientation="horizontal"
android:clipChildren="false"
android:clipToPadding="false"
android:paddingTop="30dp"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:paddingBottom="1dp">
<TextView android:id="@+id/usedStorageText"
android:layout_width="0px"
@@ -58,8 +60,11 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:layout_marginTop="-20dp"
android:textAppearance="?android:attr/textAppearanceSmallInverse"
android:textColor="#000"
android:textColor="#ccc"
android:shadowColor="#000"
android:shadowRadius="5"
android:textStyle="bold"
android:singleLine="true"
android:text="@string/internal_storage" />

View File

@@ -41,9 +41,11 @@
android:layout_height="wrap_content"
android:layout_marginTop="-5dp"
android:orientation="horizontal"
android:clipChildren="false"
android:clipToPadding="false"
android:paddingTop="30dp"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:paddingBottom="1dp">
<TextView android:id="@+id/foregroundText"
android:layout_width="0px"
@@ -58,8 +60,11 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:layout_marginTop="-20dp"
android:textAppearance="?android:attr/textAppearanceSmallInverse"
android:textColor="#000"
android:textColor="#ccc"
android:shadowColor="#000"
android:shadowRadius="5"
android:textStyle="bold"
android:singleLine="true"
android:text="@string/memory" />

View File

@@ -1406,12 +1406,14 @@
<string name="sd_insert_summary" product="nosdcard">Insert USB storage for mounting</string>
<!-- SD card & phone storage settings item summary that is displayed when no SD card is inserted -->
<string name="sd_insert_summary" product="default">Insert an SD card for mounting</string>
<!-- SD card & phone storage settings item title that will result in the phone mounting the SD card. [CHAR LIMIT=25] -->
<string name="sd_mount" product="nosdcard">Mount shared storage</string>
<!-- Storage setting item that will mount USB storage if it unmounted. A user should never see this. [CHAR LIMIT=25] -->
<string name="sd_mount" product="nosdcard">Mount USB storage</string>
<!-- SD card & phone storage settings item title that will result in the phone mounting the SD card. -->
<string name="sd_mount" product="default">Mount SD card</string>
<!-- SD card & phone storage settings item title that will result in the phone mounting the SD card. [CHAR LIMIT=30] -->
<string name="sd_mount_summary" product="nosdcard">Mount the internal USB storage</string>
<!-- Subtext for Mount USB storage in Storage settings. User should never see this. -->
<string name="sd_mount_summary" product="nosdcard">Mount the USB storage</string>
<!-- SD card & phone storage settings item title that will result in the phone mounting the SD card. -->
<string name="sd_mount_summary" product="default">Mount the SD card</string>
<!-- SD card & phone storage settings item title that will result in the phone formatting the USB storage. [CHAR LIMIT=25] -->
@@ -1678,6 +1680,12 @@
<string name="assisted_gps_enabled">Use server to assist GPS (uncheck to reduce network usage)</string>
<!-- Security & location settings screen, setting summary when Assisted GPS check box is clear -->
<string name="assisted_gps_disabled">Use server to assist GPS (uncheck to improve GPS performance)</string>
<!-- [CHAR_LIMIT=100] Security & location settings screen, setting check box label if the user wants to use their location for Google Search & other Google services -->
<string name="use_location_title">Use location for Google search</string>
<!-- [CHAR_LIMIT=100] Security & location settings screen, setting summary when Use My Location for Google services is clear -->
<string name="use_location_summary_disabled">Use location for Google search and other Google services</string>
<!-- [CHAR_LIMIT=100] Security & location settings screen, setting summary when Use My Location for Google services is checked -->
<string name="use_location_summary_enabled">Location used to improve Google search results and other Google services</string>
<!-- About --> <skip />
<!-- Main settings screen, setting title for the user to go into the About phone screen -->

View File

@@ -0,0 +1,128 @@
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings;
import android.content.ActivityNotFoundException;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.database.Cursor;
import android.net.Uri;
import android.util.Log;
/**
* Helper class to read and write the 'Use My Location' setting used by Google Apps (e.g. GoogleQSB,
* VoiceSearch).
*
* This class duplicates a small amount of functionality from GSF (Google Services Framework) to
* allow the open source Settings app to interface to the 'Use My Location' setting owned by GSF.
*/
public class GoogleLocationSettingHelper {
private static final String TAG = "GoogleLocationSettingHelper";
/**
* User has disagreed to use location for Google services.
*/
public static final int USE_LOCATION_FOR_SERVICES_OFF = 0;
/**
* User has agreed to use location for Google services.
*/
public static final int USE_LOCATION_FOR_SERVICES_ON = 1;
/**
* The user has neither agreed nor disagreed to use location for Google services yet.
*/
public static final int USE_LOCATION_FOR_SERVICES_NOT_SET = 2;
private static final String GOOGLE_SETTINGS_AUTHORITY = "com.google.settings";
private static final Uri GOOGLE_SETTINGS_CONTENT_URI =
Uri.parse("content://" + GOOGLE_SETTINGS_AUTHORITY + "/partner");
private static final String NAME = "name";
private static final String VALUE = "value";
private static final String USE_LOCATION_FOR_SERVICES = "use_location_for_services";
private static final String ACTION_SET_USE_LOCATION_FOR_SERVICES =
"com.google.android.gsf.action.SET_USE_LOCATION_FOR_SERVICES";
public static final String EXTRA_DISABLE_USE_LOCATION_FOR_SERVICES = "disable";
/**
* Determine if the 'Use My Location' setting is applicable on this device, i.e. if the
* activity used to enabled/disable it is present.
*/
public static boolean isAvailable(Context context) {
ResolveInfo ri = context.getPackageManager().resolveActivity(getSetUseLocationIntent(),
PackageManager.MATCH_DEFAULT_ONLY);
return ri != null;
}
private static Intent getSetUseLocationIntent() {
Intent i = new Intent(ACTION_SET_USE_LOCATION_FOR_SERVICES);
return i;
}
/**
* Get the current value for the 'Use value for location' setting.
* @return One of {@link #USE_LOCATION_FOR_SERVICES_NOT_SET},
* {@link #USE_LOCATION_FOR_SERVICES_OFF} or {@link #USE_LOCATION_FOR_SERVICES_ON}.
*/
public static int getUseLocationForServices(Context context) {
ContentResolver resolver = context.getContentResolver();
Cursor c = null;
String stringValue = null;
try {
c = resolver.query(GOOGLE_SETTINGS_CONTENT_URI, new String[] { VALUE }, NAME + "=?",
new String[] { USE_LOCATION_FOR_SERVICES }, null);
if (c != null && c.moveToNext()) {
stringValue = c.getString(0);
}
} catch (RuntimeException e) {
Log.w(TAG, "Failed to get 'Use My Location' setting", e);
} finally {
if (c != null) {
c.close();
}
}
if (stringValue == null) {
return USE_LOCATION_FOR_SERVICES_NOT_SET;
}
int value;
try {
value = Integer.parseInt(stringValue);
} catch (NumberFormatException nfe) {
value = USE_LOCATION_FOR_SERVICES_NOT_SET;
}
return value;
}
/**
* Change the value of the 'Use My Location' setting. This launches a GSF activity which has
* the permissions to actually make the change, prompting the user if necessary.
*/
public static void setUseLocationForServices(Context context, boolean use) {
Intent i = getSetUseLocationIntent();
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.putExtra(EXTRA_DISABLE_USE_LOCATION_FOR_SERVICES, !use);
try {
context.startActivity(i);
} catch (ActivityNotFoundException e) {
}
}
}

View File

@@ -36,10 +36,11 @@ import android.os.SystemProperties;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceCategory;
import android.preference.PreferenceGroup;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import android.preference.Preference.OnPreferenceChangeListener;
import android.provider.Settings;
import android.security.Credentials;
import android.security.KeyStore;
@@ -78,15 +79,17 @@ public class SecuritySettings extends SettingsPreferenceFragment
private CheckBoxPreference mShowPassword;
// Location Settings
private static final String LOCATION_CATEGORY = "location_category";
private static final String LOCATION_NETWORK = "location_network";
private static final String LOCATION_GPS = "location_gps";
private static final String ASSISTED_GPS = "assisted_gps";
private static final String USE_LOCATION = "location_use_for_services";
private static final String LOCK_AFTER_TIMEOUT_KEY = "lock_after_timeout";
private static final int SET_OR_CHANGE_LOCK_METHOD_REQUEST = 123;
private static final int FALLBACK_LOCK_AFTER_TIMEOUT_VALUE = 5000; // compatible with pre-Froyo
// Credential storage
private CredentialStorage mCredentialStorage = new CredentialStorage();
private final CredentialStorage mCredentialStorage = new CredentialStorage();
// Encrypted file system
private CheckBoxPreference mEncryptedFSEnabled;
@@ -94,6 +97,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
private CheckBoxPreference mNetwork;
private CheckBoxPreference mGps;
private CheckBoxPreference mAssistedGps;
private CheckBoxPreference mUseLocation;
DevicePolicyManager mDPM;
@@ -158,6 +162,22 @@ public class SecuritySettings extends SettingsPreferenceFragment
mNetwork = (CheckBoxPreference) getPreferenceScreen().findPreference(LOCATION_NETWORK);
mGps = (CheckBoxPreference) getPreferenceScreen().findPreference(LOCATION_GPS);
mAssistedGps = (CheckBoxPreference) getPreferenceScreen().findPreference(ASSISTED_GPS);
if (GoogleLocationSettingHelper.isAvailable(getActivity())) {
// GSF present, Add setting for 'Use My Location'
PreferenceGroup locationCat = (PreferenceGroup) root.findPreference(LOCATION_CATEGORY);
CheckBoxPreference useLocation = new CheckBoxPreference(getActivity());
useLocation.setKey(USE_LOCATION);
useLocation.setTitle(R.string.use_location_title);
useLocation.setSummaryOn(R.string.use_location_summary_enabled);
useLocation.setSummaryOff(R.string.use_location_summary_disabled);
useLocation.setChecked(
GoogleLocationSettingHelper.getUseLocationForServices(getActivity())
== GoogleLocationSettingHelper.USE_LOCATION_FOR_SERVICES_ON);
useLocation.setPersistent(false);
useLocation.setOnPreferenceChangeListener(this);
locationCat.addPreference(useLocation);
mUseLocation = useLocation;
}
PreferenceManager pm = getPreferenceManager();
@@ -398,7 +418,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
private static final int DLG_RESET = DLG_PASSWORD + 1;
private static final int DLG_ENABLE_EFS = DLG_RESET + 1;
private KeyStore mKeyStore = KeyStore.getInstance();
private final KeyStore mKeyStore = KeyStore.getInstance();
private int mState;
private boolean mSubmit = false;
private boolean mExternal = false;
@@ -748,6 +768,14 @@ public class SecuritySettings extends SettingsPreferenceFragment
} catch (NumberFormatException e) {
Log.e("SecuritySettings", "could not persist lockAfter timeout setting", e);
}
} else if (preference == mUseLocation) {
boolean newValue = value == null ? false : (Boolean) value;
GoogleLocationSettingHelper.setUseLocationForServices(getActivity(), newValue);
// We don't want to change the value immediately here, since the user may click
// disagree in the dialog that pops up. When the activity we just launched exits, this
// activity will be restated and the new value re-read, so the checkbox will get its
// new value then.
return false;
}
return true;
}

View File

@@ -21,6 +21,7 @@ import android.os.SystemClock;
import android.text.format.Formatter;
import android.util.Log;
import java.io.File;
import java.text.Collator;
import java.text.Normalizer;
import java.text.Normalizer.Form;
@@ -66,14 +67,17 @@ public class ApplicationsState {
}
public static class AppEntry {
final String label;
final File apkFile;
final long id;
String label;
long size;
long cacheSize;
long codeSize;
long dataSize;
boolean mounted;
String getNormalizedLabel() {
if (normalizedLabel != null) {
return normalizedLabel;
@@ -92,12 +96,47 @@ public class ApplicationsState {
String normalizedLabel;
AppEntry(Context context, ApplicationInfo info, long id) {
CharSequence label = info.loadLabel(context.getPackageManager());
this.label = label != null ? label.toString() : info.packageName;
apkFile = new File(info.sourceDir);
this.id = id;
this.info = info;
this.size = SIZE_UNKNOWN;
this.sizeStale = true;
ensureLabel(context);
}
void ensureLabel(Context context) {
if (this.label == null || !this.mounted) {
if (!this.apkFile.exists()) {
this.mounted = false;
this.label = info.packageName;
} else {
this.mounted = true;
CharSequence label = info.loadLabel(context.getPackageManager());
this.label = label != null ? label.toString() : info.packageName;
}
}
}
boolean ensureIconLocked(Context context, PackageManager pm) {
if (this.icon == null) {
if (this.apkFile.exists()) {
this.icon = this.info.loadIcon(pm);
return true;
} else {
this.mounted = false;
this.icon = context.getResources().getDrawable(
com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon);
}
} else if (!this.mounted) {
// If the app wasn't mounted but is now mounted, reload
// its icon.
if (this.apkFile.exists()) {
this.mounted = true;
this.icon = this.info.loadIcon(pm);
return true;
}
}
return false;
}
}
@@ -217,9 +256,11 @@ public class ApplicationsState {
return;
}
boolean avail = Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE.equals(actionStr);
for (String pkgName : pkgList) {
if (avail) addPackage(pkgName);
else removePackage(pkgName);
if (avail) {
for (String pkgName : pkgList) {
removePackage(pkgName);
addPackage(pkgName);
}
}
}
}
@@ -312,6 +353,13 @@ public class ApplicationsState {
for (int i=0; i<mAppEntries.size(); i++) {
mAppEntries.get(i).sizeStale = true;
}
for (int i=0; i<mApplications.size(); i++) {
final ApplicationInfo info = mApplications.get(i);
final AppEntry entry = mEntriesMap.get(info.packageName);
if (entry != null) {
entry.info = info;
}
}
mCurComputingSizePkg = null;
if (!mBackgroundHandler.hasMessages(BackgroundHandler.MSG_LOAD_ENTRIES)) {
mBackgroundHandler.sendEmptyMessage(BackgroundHandler.MSG_LOAD_ENTRIES);
@@ -391,6 +439,7 @@ public class ApplicationsState {
if (filter == null || filter.filterApp(info)) {
synchronized (mEntriesMap) {
AppEntry entry = getEntryLocked(info);
entry.ensureLabel(mContext);
if (DEBUG) Log.i(TAG, "Using " + info.packageName + ": " + entry);
filteredApps.add(entry);
}
@@ -438,12 +487,10 @@ public class ApplicationsState {
return;
}
synchronized (entry) {
if (entry.icon == null) {
entry.icon = entry.info.loadIcon(mPm);
}
entry.ensureIconLocked(mContext, mPm);
}
}
void requestSize(String packageName) {
synchronized (mEntriesMap) {
AppEntry entry = mEntriesMap.get(packageName);
@@ -453,6 +500,16 @@ public class ApplicationsState {
}
}
long sumCacheSizes() {
long sum = 0;
synchronized (mEntriesMap) {
for (int i=mAppEntries.size()-1; i>=0; i--) {
sum += mAppEntries.get(i).cacheSize;
}
}
return sum;
}
int indexOfApplicationInfoLocked(String pkgName) {
for (int i=mApplications.size()-1; i>=0; i--) {
if (mApplications.get(i).packageName.equals(pkgName)) {
@@ -528,7 +585,7 @@ public class ApplicationsState {
private long getTotalSize(PackageStats ps) {
if (ps != null) {
return ps.cacheSize+ps.codeSize+ps.dataSize;
return ps.codeSize+ps.dataSize;
}
return SIZE_INVALID;
}
@@ -630,16 +687,17 @@ public class ApplicationsState {
synchronized (mEntriesMap) {
for (int i=0; i<mAppEntries.size() && numDone<2; i++) {
AppEntry entry = mAppEntries.get(i);
if (entry.icon == null) {
if (!mRunning) {
mRunning = true;
Message m = mMainHandler.obtainMessage(
MainHandler.MSG_RUNNING_STATE_CHANGED, 1);
mMainHandler.sendMessage(m);
}
numDone++;
if (entry.icon == null || !entry.mounted) {
synchronized (entry) {
entry.icon = entry.info.loadIcon(mPm);
if (entry.ensureIconLocked(mContext, mPm)) {
if (!mRunning) {
mRunning = true;
Message m = mMainHandler.obtainMessage(
MainHandler.MSG_RUNNING_STATE_CHANGED, 1);
mMainHandler.sendMessage(m);
}
numDone++;
}
}
}
}

View File

@@ -16,7 +16,7 @@ import android.widget.LinearLayout;
public class LinearColorBar extends LinearLayout {
static final int LEFT_COLOR = 0xffa0a0a0;
static final int MIDDLE_COLOR = 0xff7070ff;
static final int MIDDLE_COLOR = 0xffa0a0a0;
static final int RIGHT_COLOR = 0xffa0c0a0;
private float mRedRatio;
@@ -47,6 +47,7 @@ public class LinearColorBar extends LinearLayout {
? 2 : 1;
mEdgeGradientPaint.setStrokeWidth(mLineWidth);
mEdgeGradientPaint.setAntiAlias(true);
}
public void setRatios(float red, float yellow, float green) {
@@ -111,22 +112,33 @@ public class LinearColorBar extends LinearLayout {
mColorPath.reset();
mEdgePath.reset();
if (indicatorLeft < indicatorRight) {
final int midTopY = mRect.top;
final int midBottomY = 0;
final int xoff = 2;
mColorPath.moveTo(indicatorLeft, mRect.top);
mColorPath.lineTo(-1, 0);
mColorPath.lineTo(width, 0);
mColorPath.lineTo(indicatorRight, mRect.top);
mColorPath.cubicTo(indicatorLeft, midBottomY,
-xoff, midTopY,
-xoff, 0);
mColorPath.lineTo(width+xoff-1, 0);
mColorPath.cubicTo(width+xoff-1, midTopY,
indicatorRight, midBottomY,
indicatorRight, mRect.top);
mColorPath.close();
float lineOffset = mLineWidth+.5f;
mEdgePath.moveTo(indicatorLeft+lineOffset, mRect.top);
mEdgePath.lineTo(-1+lineOffset, 0);
mEdgePath.moveTo(indicatorRight-lineOffset, mRect.top);
mEdgePath.lineTo(width-lineOffset, 0);
final float lineOffset = mLineWidth+.5f;
mEdgePath.moveTo(-xoff+lineOffset, 0);
mEdgePath.cubicTo(-xoff+lineOffset, midTopY,
indicatorLeft+lineOffset, midBottomY,
indicatorLeft+lineOffset, mRect.top);
mEdgePath.moveTo(width+xoff-1-lineOffset, 0);
mEdgePath.cubicTo(width+xoff-1-lineOffset, midTopY,
indicatorRight-lineOffset, midBottomY,
indicatorRight-lineOffset, mRect.top);
}
mLastInterestingLeft = indicatorLeft;
mLastInterestingRight = indicatorRight;
}
if (!mColorPath.isEmpty()) {
if (!mEdgePath.isEmpty()) {
canvas.drawPath(mEdgePath, mEdgeGradientPaint);
canvas.drawPath(mColorPath, mColorGradientPaint);
}

View File

@@ -36,6 +36,7 @@ import android.os.StatFs;
import android.provider.Settings;
import android.text.format.Formatter;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
@@ -43,6 +44,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.animation.AnimationUtils;
import android.view.inputmethod.InputMethodManager;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
@@ -57,7 +59,6 @@ import android.widget.AdapterView.OnItemClickListener;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
final class CanBeOnSdCardChecker {
final IPackageManager mPm;
@@ -118,7 +119,7 @@ public class ManageApplications extends TabActivity implements
// constant value that can be used to check return code from sub activity.
private static final int INSTALLED_APP_DETAILS = 1;
// sort order that can be changed through the menu can be sorted alphabetically
// or size(descending)
private static final int MENU_OPTIONS_BASE = 0;
@@ -676,6 +677,18 @@ public class ManageApplications extends TabActivity implements
}
return true;
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_SEARCH && event.isTracking()) {
if (mCurView != VIEW_RUNNING) {
((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE))
.showSoftInputUnchecked(0, null);
}
return true;
}
return super.onKeyUp(keyCode, event);
}
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
@@ -738,8 +751,8 @@ public class ManageApplications extends TabActivity implements
for (int i=0; i<N; i++) {
ApplicationsState.AppEntry ae = mApplicationsAdapter.getAppEntry(i);
appStorage += ae.codeSize + ae.dataSize;
freeStorage += ae.cacheSize;
}
freeStorage += mApplicationsState.sumCacheSizes();
}
if (newLabel != null) {
mStorageChartLabel.setText(newLabel);
@@ -831,6 +844,8 @@ public class ManageApplications extends TabActivity implements
} else if (TAB_SDCARD.equalsIgnoreCase(tabId)) {
newOption = FILTER_APPS_SDCARD;
} else if (TAB_RUNNING.equalsIgnoreCase(tabId)) {
((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE))
.hideSoftInputFromWindow(getWindow().getDecorView().getWindowToken(), 0);
selectView(VIEW_RUNNING);
return;
} else {

View File

@@ -300,7 +300,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
LocalBluetoothProfileManager profileManager =
LocalBluetoothProfileManager.getProfileManager(mLocalManager, profile);
CachedBluetoothDeviceManager cachedDeviceManager = mLocalManager.getCachedDeviceManager();
Set<BluetoothDevice> devices = profileManager.getConnectedDevices();
List<BluetoothDevice> devices = profileManager.getConnectedDevices();
if (devices == null) return;
for (BluetoothDevice btDevice : devices) {
CachedBluetoothDevice cachedDevice = cachedDeviceManager.findDevice(btDevice);

View File

@@ -196,10 +196,9 @@ public class LocalBluetoothManager {
// If we are playing music, don't scan unless forced.
if (mBluetoothA2dp != null) {
Set<BluetoothDevice> sinks = mBluetoothA2dp.getConnectedDevices();
List<BluetoothDevice> sinks = mBluetoothA2dp.getConnectedDevices();
if (sinks.size() > 0) {
BluetoothDevice sink = sinks.toArray(new BluetoothDevice[sinks.size()])[0];
if (mBluetoothA2dp.isA2dpPlaying(sink)) return;
if (mBluetoothA2dp.isA2dpPlaying(sinks.get(0))) return;
}
}
}

View File

@@ -197,7 +197,7 @@ public abstract class LocalBluetoothProfileManager {
mLocalManager = localManager;
}
public abstract Set<BluetoothDevice> getConnectedDevices();
public abstract List<BluetoothDevice> getConnectedDevices();
public abstract boolean connect(BluetoothDevice device);
@@ -261,7 +261,7 @@ public abstract class LocalBluetoothProfileManager {
}
@Override
public Set<BluetoothDevice> getConnectedDevices() {
public List<BluetoothDevice> getConnectedDevices() {
return mService.getDevicesMatchingConnectionStates(
new int[] {BluetoothProfile.STATE_CONNECTED,
BluetoothProfile.STATE_CONNECTING,
@@ -270,7 +270,7 @@ public abstract class LocalBluetoothProfileManager {
@Override
public boolean connect(BluetoothDevice device) {
Set<BluetoothDevice> sinks = getConnectedDevices();
List<BluetoothDevice> sinks = getConnectedDevices();
if (sinks != null) {
for (BluetoothDevice sink : sinks) {
mService.disconnect(sink);
@@ -378,14 +378,11 @@ public abstract class LocalBluetoothProfileManager {
* We just bound to the service, so refresh the UI of the
* headset device.
*/
Set<BluetoothDevice> deviceSet = mService.getConnectedDevices();
if (deviceSet.size() == 0) return;
BluetoothDevice[] devices =
deviceSet.toArray(new BluetoothDevice[deviceSet.size()]);
List<BluetoothDevice> deviceList = mService.getConnectedDevices();
if (deviceList.size() == 0) return;
mLocalManager.getCachedDeviceManager()
.onProfileStateChanged(devices[0], Profile.HEADSET,
.onProfileStateChanged(deviceList.get(0), Profile.HEADSET,
BluetoothProfile.STATE_CONNECTED);
}
});
@@ -415,7 +412,7 @@ public abstract class LocalBluetoothProfileManager {
}
@Override
public Set<BluetoothDevice> getConnectedDevices() {
public List<BluetoothDevice> getConnectedDevices() {
return mService.getConnectedDevices();
}
@@ -426,9 +423,8 @@ public abstract class LocalBluetoothProfileManager {
@Override
public boolean disconnect(BluetoothDevice device) {
Set<BluetoothDevice> deviceSet = getConnectedDevices();
BluetoothDevice[] devices = deviceSet.toArray(new BluetoothDevice[deviceSet.size()]);
if (devices.length != 0 && devices[0].equals(device)) {
List<BluetoothDevice> deviceList = getConnectedDevices();
if (deviceList.size() != 0 && deviceList.get(0).equals(device)) {
// Downgrade prority as user is disconnecting the headset.
if (mService.getPriority(device) > BluetoothProfile.PRIORITY_ON) {
mService.setPriority(device, BluetoothProfile.PRIORITY_ON);
@@ -441,10 +437,9 @@ public abstract class LocalBluetoothProfileManager {
@Override
public int getConnectionStatus(BluetoothDevice device) {
Set<BluetoothDevice> deviceSet = getConnectedDevices();
BluetoothDevice[] devices = deviceSet.toArray(new BluetoothDevice[deviceSet.size()]);
List<BluetoothDevice> deviceList = getConnectedDevices();
return devices.length > 0 && devices[0].equals(device)
return deviceList.size() > 0 && deviceList.get(0).equals(device)
? convertState(mService.getConnectionState(device))
: SettingsBtStatus.CONNECTION_STATUS_DISCONNECTED;
}
@@ -506,7 +501,7 @@ public abstract class LocalBluetoothProfileManager {
}
@Override
public Set<BluetoothDevice> getConnectedDevices() {
public List<BluetoothDevice> getConnectedDevices() {
return null;
}
@@ -605,7 +600,7 @@ public abstract class LocalBluetoothProfileManager {
}
@Override
public Set<BluetoothDevice> getConnectedDevices() {
public List<BluetoothDevice> getConnectedDevices() {
return mService.getConnectedInputDevices();
}
@@ -703,7 +698,7 @@ public abstract class LocalBluetoothProfileManager {
}
@Override
public Set<BluetoothDevice> getConnectedDevices() {
public List<BluetoothDevice> getConnectedDevices() {
return mService.getConnectedDevices();
}

View File

@@ -59,7 +59,7 @@ public class BatteryHistoryChart extends View {
void init(int width) {
if (width > 0) {
mTicks = new int[width+2];
mTicks = new int[width*2];
} else {
mTicks = null;
}
@@ -68,7 +68,7 @@ public class BatteryHistoryChart extends View {
}
void addTick(int x, int bin) {
if (bin != mLastBin) {
if (bin != mLastBin && mNumTicks < mTicks.length) {
mTicks[mNumTicks] = x | bin << CHART_DATA_BIN_SHIFT;
mNumTicks++;
mLastBin = bin;
@@ -285,6 +285,8 @@ public class BatteryHistoryChart extends View {
}
}
a.recycle();
mTextPaint.setColor(textColor.getDefaultColor());
mTextPaint.setTextSize(textSize);

View File

@@ -77,8 +77,7 @@ public class NfcEnabler implements Preference.OnPreferenceChangeListener {
}
mContext.registerReceiver(mReceiver, mIntentFilter);
mCheckbox.setOnPreferenceChangeListener(this);
mNfcState = Settings.System.getInt(mContext.getContentResolver(),
Settings.System.NFC_ON, 0) != 0;
mNfcState = mNfcAdapter.isEnabled();
mCheckbox.setChecked(mNfcState);
}
@@ -103,9 +102,9 @@ public class NfcEnabler implements Preference.OnPreferenceChangeListener {
Log.d(TAG, "Setting NFC enabled state to: " + desiredState);
boolean success = false;
if (desiredState) {
success = mNfcAdapter.enableTagDiscovery();
success = mNfcAdapter.enable();
} else {
success = mNfcAdapter.disableTagDiscovery();
success = mNfcAdapter.disable();
}
if (success) {
Log.d(TAG, "Successfully changed NFC enabled state to " + desiredState);

View File

@@ -732,4 +732,8 @@ public class WifiSettings extends SettingsPreferenceFragment
return 0;
}
}
/* package */ void disableWifi() {
mWifiManager.setWifiEnabled(false);
}
}

View File

@@ -19,11 +19,10 @@ package com.android.settings.wifi;
import com.android.settings.R;
import android.app.Activity;
import android.app.StatusBarManager;
import android.content.Context;
import android.net.NetworkInfo.DetailedState;
import android.os.Bundle;
import android.util.Log;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
@@ -117,6 +116,11 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
mWifiSettings.onAddNetworkPressed();
break;
case R.id.wifi_setup_skip_or_next:
if (TextUtils.equals(getString(R.string.wifi_setup_skip), ((Button)view).getText())) {
// We don't want to let Wifi enabled when a user press skip without choosing
// any access point.
mWifiSettings.disableWifi();
}
setResult(Activity.RESULT_OK);
finish();
break;