Update auto wi-fi to prompt user for permissions
This CL makes it so that auto wi-fi will correctly prompt users to enable the correct permissions before allowing them to turn on the setting. Additionally it provides users with important information regarding each setting. Bug: 67070896 Test: Robotests Change-Id: Ieddfa421be6e45ce69f3d6048ae051a7e3ce4c76
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.wifi;
|
||||
|
||||
import static com.android.settings.wifi.ConfigureWifiSettings.WIFI_WAKEUP_REQUEST_CODE;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
|
||||
public class WifiScanningRequiredFragment extends InstrumentedDialogFragment implements
|
||||
DialogInterface.OnClickListener {
|
||||
|
||||
public static WifiScanningRequiredFragment newInstance() {
|
||||
WifiScanningRequiredFragment fragment = new WifiScanningRequiredFragment();
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
return new AlertDialog.Builder(getContext())
|
||||
.setTitle(R.string.wifi_settings_scanning_required_title)
|
||||
.setView(R.layout.wifi_settings_scanning_required_view)
|
||||
.setNeutralButton(R.string.do_disclosure_learn_more, this)
|
||||
.setPositiveButton(R.string.wifi_settings_scanning_required_turn_on, this)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
// TODO(b/67070896): add metric code
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Context context = getContext();
|
||||
ContentResolver contentResolver = context.getContentResolver();
|
||||
switch(which) {
|
||||
case DialogInterface.BUTTON_POSITIVE:
|
||||
Settings.Global.putInt(contentResolver,
|
||||
Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 1);
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.wifi_settings_scanning_required_enabled),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
getTargetFragment().onActivityResult(
|
||||
getTargetRequestCode(),
|
||||
Activity.RESULT_OK,
|
||||
null);
|
||||
break;
|
||||
case DialogInterface.BUTTON_NEUTRAL:
|
||||
openHelpPage();
|
||||
break;
|
||||
case DialogInterface.BUTTON_NEGATIVE:
|
||||
default:
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
private void openHelpPage() {
|
||||
// TODO(b/67070896): actually open help page on Pixel only
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user