Loading services/java/com/android/server/ProfileManagerService.java +22 −17 Original line number Diff line number Diff line Loading @@ -25,15 +25,15 @@ import android.app.IProfileManager; import android.app.NotificationGroup; import android.app.Profile; import android.app.ProfileGroup; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.res.XmlResourceParser; import android.net.wifi.SupplicantState; import android.net.wifi.WifiManager; import android.net.wifi.WifiSsid; import android.net.wifi.WifiInfo; import android.os.RemoteException; import android.os.UserHandle; import android.text.TextUtils; Loading Loading @@ -103,19 +103,14 @@ public class ProfileManagerService extends IProfileManager.Stub { } else if (action.equals(Intent.ACTION_SHUTDOWN)) { persistIfDirty(); } else if (action.equals(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION)) { SupplicantState state = intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE); } else if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) { String activeSSID = getActiveSSID(); int triggerState; switch (state) { case COMPLETED: if (activeSSID != null) { triggerState = Profile.TriggerState.ON_CONNECT; mLastConnectedSSID = getActiveSSID(); break; case DISCONNECTED: mLastConnectedSSID = activeSSID; } else { triggerState = Profile.TriggerState.ON_DISCONNECT; break; default: return; } checkTriggers(Profile.TriggerType.WIFI, mLastConnectedSSID, triggerState); } else if (action.equals(BluetoothDevice.ACTION_ACL_CONNECTED) Loading @@ -135,7 +130,9 @@ public class ProfileManagerService extends IProfileManager.Stub { } try { if (!mActiveProfile.getUuid().equals(p.getUuid())) { setActiveProfile(p, true); } } catch (RemoteException e) { Log.e(TAG, "Could not update profile on trigger", e); } Loading @@ -158,7 +155,7 @@ public class ProfileManagerService extends IProfileManager.Stub { IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_LOCALE_CHANGED); filter.addAction(Intent.ACTION_SHUTDOWN); filter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION); filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); filter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED); filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED); mContext.registerReceiver(mIntentReceiver, filter); Loading Loading @@ -198,7 +195,15 @@ public class ProfileManagerService extends IProfileManager.Stub { } private String getActiveSSID() { return mWifiManager.getConnectionInfo().getSSID().replace("\"", ""); WifiInfo wifiinfo = mWifiManager.getConnectionInfo(); if (wifiinfo == null) { return null; } WifiSsid ssid = wifiinfo.getWifiSsid(); if (ssid == null) { return null; } return ssid.toString(); } @Override Loading Loading
services/java/com/android/server/ProfileManagerService.java +22 −17 Original line number Diff line number Diff line Loading @@ -25,15 +25,15 @@ import android.app.IProfileManager; import android.app.NotificationGroup; import android.app.Profile; import android.app.ProfileGroup; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.res.XmlResourceParser; import android.net.wifi.SupplicantState; import android.net.wifi.WifiManager; import android.net.wifi.WifiSsid; import android.net.wifi.WifiInfo; import android.os.RemoteException; import android.os.UserHandle; import android.text.TextUtils; Loading Loading @@ -103,19 +103,14 @@ public class ProfileManagerService extends IProfileManager.Stub { } else if (action.equals(Intent.ACTION_SHUTDOWN)) { persistIfDirty(); } else if (action.equals(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION)) { SupplicantState state = intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE); } else if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) { String activeSSID = getActiveSSID(); int triggerState; switch (state) { case COMPLETED: if (activeSSID != null) { triggerState = Profile.TriggerState.ON_CONNECT; mLastConnectedSSID = getActiveSSID(); break; case DISCONNECTED: mLastConnectedSSID = activeSSID; } else { triggerState = Profile.TriggerState.ON_DISCONNECT; break; default: return; } checkTriggers(Profile.TriggerType.WIFI, mLastConnectedSSID, triggerState); } else if (action.equals(BluetoothDevice.ACTION_ACL_CONNECTED) Loading @@ -135,7 +130,9 @@ public class ProfileManagerService extends IProfileManager.Stub { } try { if (!mActiveProfile.getUuid().equals(p.getUuid())) { setActiveProfile(p, true); } } catch (RemoteException e) { Log.e(TAG, "Could not update profile on trigger", e); } Loading @@ -158,7 +155,7 @@ public class ProfileManagerService extends IProfileManager.Stub { IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_LOCALE_CHANGED); filter.addAction(Intent.ACTION_SHUTDOWN); filter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION); filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); filter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED); filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED); mContext.registerReceiver(mIntentReceiver, filter); Loading Loading @@ -198,7 +195,15 @@ public class ProfileManagerService extends IProfileManager.Stub { } private String getActiveSSID() { return mWifiManager.getConnectionInfo().getSSID().replace("\"", ""); WifiInfo wifiinfo = mWifiManager.getConnectionInfo(); if (wifiinfo == null) { return null; } WifiSsid ssid = wifiinfo.getWifiSsid(); if (ssid == null) { return null; } return ssid.toString(); } @Override Loading