Settings: Fix NPE FC when access saved wifi p2p device after screen rotation
Rotating screen, wifi p2p setting fragement will be re-created and the selected wifi p2p device will be saved in onSaveInstanceState. However, now this saved wifi p2p device is restored in onActivityCreated, this is too late. So when getting this saved wifi p2p device return NULL in onCreateDialog and leads to NPE force close. Restore the saved wifi p2p device in onCreateView instead of onActivityCreated. Bug: 220025725 Test: manual test make RunSettingsRoboTests ROBOTEST_FILTER=WifiP2pSettingsTest Change-Id: I9b746e21f7f3651c69b1445f2389c089ec19319c
This commit is contained in:
@@ -47,6 +47,7 @@ import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
@@ -199,7 +200,10 @@ public class WifiP2pSettings extends DashboardFragment
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
final View root = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
final Activity activity = getActivity();
|
||||
if (mWifiP2pManager == null) {
|
||||
mWifiP2pManager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
|
||||
@@ -332,8 +336,7 @@ public class WifiP2pSettings extends DashboardFragment
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user