— a/android13/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/connecteddevice/AdvancedConnectedDeviceDashboardFragment.java
+++ b/android13/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/connecteddevice/AdvancedConnectedDeviceDashboardFragment.java
@@ -33,6 +33,15 @@ import com.android.settingslib.search.SearchIndexable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+//add by psj 2024/01/23
+import androidx.preference.Preference;
+import android.os.Bundle;
+import android.util.Log;
+import android.os.SystemProperties;
+import android.content.BroadcastReceiver;
+import android.content.Intent;
+import android.content.IntentFilter;
+
/**
-
This fragment contains all the advanced connection preferences(i.e, Bluetooth, NFC, USB…)
@@ -42,8 +51,12 @@ public class AdvancedConnectedDeviceDashboardFragment extends DashboardFragmentprivate static final String TAG = “AdvancedConnectedDeviceFrag”;
- static final String KEY_BLUETOOTH = “bluetooth_settings”;
-
static final String KEY_BLUETOOTH = “bluetooth_switchbar_screen”;
-
static final String KEY_NFC = "nfc_and_payment_settings";static final String KEY_UWB = “uwb_settings”;
-
private Preference bluetoothPreference; -
private Preference nfcPreference;@Override
public int getMetricsCategory() {
@@ -72,7 +85,86 @@ public class AdvancedConnectedDeviceDashboardFragment extends DashboardFragment
if (uwbPreferenceController != null && getSettingsLifecycle() != null) {
getSettingsLifecycle().addObserver(uwbPreferenceController);
} -
Log.d("test","==AdvancedConnectedDevice===onAttach===");}
-
//add by 2024/01/23 -
//============================================================================================================================= -
public void onCreate(Bundle icicle) { -
super.onCreate(icicle); -
Log.d("test","==AdvancedConnectedDevice===onCreate==="); -
bluetoothPreference = findPreference(KEY_BLUETOOTH); -
nfcPreference = findPreference(KEY_NFC); -
} -
@Override
-
public void onStart() {
-
super.onStart(); -
Log.d("test","==AdvancedConnectedDevice===onStart==="); -
}
-
@Override
-
public void onResume() {
-
super.onResume(); -
Log.d("test","==AdvancedConnectedDevice===onResume==="); -
IntentFilter intentFilter = new IntentFilter(); -
intentFilter.addAction("com.action.bluetooth.enable"); -
intentFilter.addAction("com.action.nfc.enable"); -
getActivity().registerReceiver(receiver,intentFilter); -
boolean isBluetoothVisible = SystemProperties.get("persist.sys.settings_bluetooth_control","1").equals("1") ? true : false; -
boolean isNfcVisible = SystemProperties.get("persist.sys.settings_nfc_control","1").equals("1") ? true : false; -
if(!isBluetoothVisible){ -
getPreferenceScreen().removePreference(bluetoothPreference); -
}else{ -
getPreferenceScreen().addPreference(bluetoothPreference); -
} -
if(!isNfcVisible){ -
getPreferenceScreen().removePreference(nfcPreference); -
}else{ -
getPreferenceScreen().addPreference(nfcPreference); -
} -
}
-
private BroadcastReceiver receiver = new BroadcastReceiver() {
-
@Override -
public void onReceive(Context context, Intent intent) { -
if(intent.getAction().equals("com.action.bluetooth.enable")){ -
boolean enable = intent.getBooleanExtra("enable",true); -
if(enable){ -
getPreferenceScreen().addPreference(bluetoothPreference); -
}else{ -
getPreferenceScreen().removePreference(bluetoothPreference); -
} -
}else if(intent.getAction().equals("com.action.nfc.enable")){ -
boolean enable = intent.getBooleanExtra("enable",true); -
if(enable){ -
getPreferenceScreen().addPreference(nfcPreference); -
}else{ -
getPreferenceScreen().removePreference(nfcPreference); -
} -
} -
} -
};
-
@Override
-
public void onStop() {
-
super.onStop(); -
Log.d("test","==AdvancedConnectedDevice===onStop==="); -
if(receiver!=null){ -
getActivity().unregisterReceiver(receiver); -
//receiver = null; -
} -
}
-
//=============================================================================================================================@Override
protected List createPreferenceControllers(Context context) {
962

被折叠的 条评论
为什么被折叠?



