Clean up codes, fix long lines, improve readability, etc
Update copyright date, remove unused variable, import Change-Id: I731c48c8e5b16cbee5230f1d02109f249b8bab5d
This commit is contained in:
@@ -49,14 +49,13 @@ import android.webkit.WebView;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import android.util.Log;
|
|
||||||
/*
|
/*
|
||||||
* Displays preferences for Tethering.
|
* Displays preferences for Tethering.
|
||||||
*/
|
*/
|
||||||
public class TetherSettings extends SettingsPreferenceFragment
|
public class TetherSettings extends SettingsPreferenceFragment
|
||||||
implements DialogInterface.OnClickListener, Preference.OnPreferenceChangeListener {
|
implements DialogInterface.OnClickListener, Preference.OnPreferenceChangeListener {
|
||||||
private static final String TAG = "TetherSettings";
|
private static final String TAG = "TetherSettings";
|
||||||
private static final boolean DBG = false;
|
|
||||||
|
|
||||||
private static final String USB_TETHER_SETTINGS = "usb_tether_settings";
|
private static final String USB_TETHER_SETTINGS = "usb_tether_settings";
|
||||||
private static final String ENABLE_WIFI_AP = "enable_wifi_ap";
|
private static final String ENABLE_WIFI_AP = "enable_wifi_ap";
|
||||||
|
@@ -196,7 +196,8 @@ final class A2dpProfile implements LocalBluetoothProfile {
|
|||||||
if (V) Log.d(TAG, "finalize()");
|
if (V) Log.d(TAG, "finalize()");
|
||||||
if (mService != null) {
|
if (mService != null) {
|
||||||
try {
|
try {
|
||||||
BluetoothAdapter.getDefaultAdapter().closeProfileProxy(BluetoothProfile.A2DP, mService);
|
BluetoothAdapter.getDefaultAdapter().closeProfileProxy(BluetoothProfile.A2DP,
|
||||||
|
mService);
|
||||||
mService = null;
|
mService = null;
|
||||||
}catch (Throwable t) {
|
}catch (Throwable t) {
|
||||||
Log.w(TAG, "Error cleaning up A2DP proxy", t);
|
Log.w(TAG, "Error cleaning up A2DP proxy", t);
|
||||||
|
@@ -141,7 +141,7 @@ final class BluetoothDiscoverableEnabler implements Preference.OnPreferenceClick
|
|||||||
|
|
||||||
Log.d(TAG, "setEnabled(): enabled = " + enable + "timeout = " + timeout);
|
Log.d(TAG, "setEnabled(): enabled = " + enable + "timeout = " + timeout);
|
||||||
|
|
||||||
if (0 < timeout) {
|
if (timeout > 0) {
|
||||||
BluetoothDiscoverableTimeoutReceiver.setDiscoverableAlarm(mContext, endTimestamp);
|
BluetoothDiscoverableTimeoutReceiver.setDiscoverableAlarm(mContext, endTimestamp);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2008 The Android Open Source Project
|
* Copyright (C) 2012 The Android Open Source Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -16,21 +16,23 @@
|
|||||||
|
|
||||||
package com.android.settings.bluetooth;
|
package com.android.settings.bluetooth;
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.ContentResolver;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.bluetooth.BluetoothAdapter;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
/* Required to handle timeout notification when phone is suspended */
|
/* Required to handle timeout notification when phone is suspended */
|
||||||
import android.app.AlarmManager;
|
import android.app.AlarmManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
|
|
||||||
|
import android.bluetooth.BluetoothAdapter;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.ContentResolver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
|
||||||
public class BluetoothDiscoverableTimeoutReceiver extends BroadcastReceiver {
|
public class BluetoothDiscoverableTimeoutReceiver extends BroadcastReceiver {
|
||||||
private static final String TAG = "BluetoothDiscoverableTimeoutReceiver";
|
private static final String TAG = "BluetoothDiscoverableTimeoutReceiver";
|
||||||
|
|
||||||
private static final String INTENT_DISCOVERABLE_TIMEOUT = "android.bluetooth.intent.DISCOVERABLE_TIMEOUT";
|
private static final String INTENT_DISCOVERABLE_TIMEOUT =
|
||||||
|
"android.bluetooth.intent.DISCOVERABLE_TIMEOUT";
|
||||||
|
|
||||||
static void setDiscoverableAlarm(Context context, long alarmTime) {
|
static void setDiscoverableAlarm(Context context, long alarmTime) {
|
||||||
Log.d(TAG, "setDiscoverableAlarm(): alarmTime = " + alarmTime);
|
Log.d(TAG, "setDiscoverableAlarm(): alarmTime = " + alarmTime);
|
||||||
@@ -73,7 +75,8 @@ public class BluetoothDiscoverableTimeoutReceiver extends BroadcastReceiver {
|
|||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
LocalBluetoothAdapter localBluetoothAdapter = LocalBluetoothAdapter.getInstance();
|
LocalBluetoothAdapter localBluetoothAdapter = LocalBluetoothAdapter.getInstance();
|
||||||
|
|
||||||
if(null != localBluetoothAdapter && localBluetoothAdapter.getState() == BluetoothAdapter.STATE_ON) {
|
if(localBluetoothAdapter != null &&
|
||||||
|
localBluetoothAdapter.getState() == BluetoothAdapter.STATE_ON) {
|
||||||
Log.d(TAG, "Disable discoverable...");
|
Log.d(TAG, "Disable discoverable...");
|
||||||
|
|
||||||
localBluetoothAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE);
|
localBluetoothAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE);
|
||||||
@@ -82,4 +85,3 @@ public class BluetoothDiscoverableTimeoutReceiver extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2011 The Android Open Source Project
|
* Copyright (C) 2012 The Android Open Source Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -176,9 +176,9 @@ final class HeadsetProfile implements LocalBluetoothProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// This function is added as the AUTO CONNECT priority could not be set by using setPreferred(),
|
// This function is added as the AUTO CONNECT priority could not be set by using setPreferred(),
|
||||||
// as setPreferred() takes only boolean input but getPreferred() supports interger output.
|
// as setPreferred() takes only boolean input but getPreferred() supports interger output.
|
||||||
// Also this need not implemented by all profiles so this has been added here.
|
// Also this need not implemented by all profiles so this has been added here.
|
||||||
public void enableAutoConnect(BluetoothDevice device, boolean enable) {
|
public void enableAutoConnect(BluetoothDevice device, boolean enable) {
|
||||||
if (mService == null) return;
|
if (mService == null) return;
|
||||||
if (enable) {
|
if (enable) {
|
||||||
@@ -224,7 +224,8 @@ final class HeadsetProfile implements LocalBluetoothProfile {
|
|||||||
if (V) Log.d(TAG, "finalize()");
|
if (V) Log.d(TAG, "finalize()");
|
||||||
if (mService != null) {
|
if (mService != null) {
|
||||||
try {
|
try {
|
||||||
BluetoothAdapter.getDefaultAdapter().closeProfileProxy(BluetoothProfile.HEADSET, mService);
|
BluetoothAdapter.getDefaultAdapter().closeProfileProxy(BluetoothProfile.HEADSET,
|
||||||
|
mService);
|
||||||
mService = null;
|
mService = null;
|
||||||
}catch (Throwable t) {
|
}catch (Throwable t) {
|
||||||
Log.w(TAG, "Error cleaning up HID proxy", t);
|
Log.w(TAG, "Error cleaning up HID proxy", t);
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2011 The Android Open Source Project
|
* Copyright (C) 2012 The Android Open Source Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -168,7 +168,8 @@ final class HidProfile implements LocalBluetoothProfile {
|
|||||||
if (V) Log.d(TAG, "finalize()");
|
if (V) Log.d(TAG, "finalize()");
|
||||||
if (mService != null) {
|
if (mService != null) {
|
||||||
try {
|
try {
|
||||||
BluetoothAdapter.getDefaultAdapter().closeProfileProxy(BluetoothProfile.INPUT_DEVICE, mService);
|
BluetoothAdapter.getDefaultAdapter().closeProfileProxy(BluetoothProfile.INPUT_DEVICE,
|
||||||
|
mService);
|
||||||
mService = null;
|
mService = null;
|
||||||
}catch (Throwable t) {
|
}catch (Throwable t) {
|
||||||
Log.w(TAG, "Error cleaning up HID proxy", t);
|
Log.w(TAG, "Error cleaning up HID proxy", t);
|
||||||
|
Reference in New Issue
Block a user