恢复出厂设置:
//APK侧
Log.d(TAG, " exeRecovery");
String timeStamp = DateFormat.format("yyyy-MM-ddTHH:mm:ssZ", System.currentTimeMillis()).toString();
String localeArg = "--locale=" + Locale.getDefault().toLanguageTag() ;
Method method;
try {
method = Class.forName("android.os.RecoverySystem")
.getDeclaredMethod("bootCommand", Context.class, String[].class);
method.setAccessible(true);
method.invoke(null, mContext,
new String[]{ null, "--wipe_data", "--reason=com.flyme.mobileservice," + timeStamp, localeArg});
} catch (NoSuchMethodException | ClassNotFoundException | IllegalAccessException |
InvocationTargetException e) {
throw new RuntimeException(e);
}
跳过开机向导:
//APK侧
Log.d(TAG, "exeJumpBootWizard");
try {
Settings.Secure.putInt(mContext.getContentResolver(), "user_setup_complete", 1);
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1);
Runtime.getRuntime().exec("am force-stop com.开机向导.setup");//开机向导apk具体包名自己去确认即可
} catch (IOException e) {
throw new RuntimeException(e);
}
wifi扫描界面筛选显示:
//packages/modules/Wifi/service/java/com/android/server/wifi/WifiServiceImpl.java
private List<String> mExposableScanResults = new ArrayList<String>();
@Override
public List<ScanResult> getScanResults(String callingPackage, String callingFeatureId) {
enforceAccessPermission();
int uid = Binder.getCallingUid();
long ident = Binder.clearCallingIdentity();
if (isVerboseLoggingEnabled()) {
mLog.info("getScanResults uid=%").c(uid).flush();
}
try {
mWifiPermissionsUtil.enforceCanAccessScanResults(callingPackage, callingFeatureId,
uid, null);
List<ScanResult> scanResults = mWifiThreadRunner.call(
mScanRequestProxy::getScanResults, Collections.emptyList());
if (mExposableScanResults.isEmpty()) {
return scanResults;
} else {
Log.d(TAG, "begin to check mExposableScanResults...");
List<ScanResult> scanCheckRes = new ArrayList<>();
for(ScanResult scanResult:scanResults){
if (isContainsWifi(scanResult.SSID))
scanCheckRes.add(scanResult);
}
return scanCheckRes;
}
} catch (SecurityException e) {
Log.w(TAG, "Permission violation - getScanResults not allowed for uid="
+ uid + ", packageName=" + callingPackage + ", reason=" + e);
return new ArrayList<>();
} finally {
Binder.restoreCallingIdentity(ident);
}
}
private boolean isContainsWifi(String SSID) {
for(String scanResult:mExposableScanResults){
if (scanResult.equals(SSID))
return true;
}
return false;
}
public void setExposableScanResults(@NonNull List<String> exposableScanResults) {
Log.d(TAG, "mExposableScanResults clearing...");
mExposableScanResults.clear();
Log.d(TAG, "mExposableScanResults putting...");
for(String scanResult:exposableScanResults){
mExposableScanResults.add(scanResult);
Log.d(TAG, "mExposableScanResults add " + scanResult);
}
}
//packages/modules/Wifi/framework/java/android/net/wifi/WifiManager.java
public void setExposableScanResults(@NonNull List<String> exposableScanResults) {
try {
mService.setExposableScanResults(exposableScanResults);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
//packages/modules/Wifi/framework/java/android/net/wifi/IWifiManager.aidl
void setExposableScanResults(in List<String> exposableScanResults);
//packages/modules/Wifi/framework/java/android/net/wifi/BaseWifiService.java
public void setExposableScanResults(@NonNull List<String> exposableScanResults) {
throw new UnsupportedOperationException();
}
//APK侧
List<String> exposableScanResults = new ArrayList<String>(){{
add("TEST");
add("TEST-GUEST");
add("TEST-SDWAN");
}};
WifiManager wifiManager = ((WifiManager) mContext.getSystemService(WIFI_SERVICE));
try {
Method method = Class.forName("android.net.wifi.WifiManager")
.getMethod("setExposableScanResults", List.class);
method.invoke(wifiManager, exposableScanResults);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException |
ClassNotFoundException e) {
e.printStackTrace();
}
标签:String,mExposableScanResults,exposableScanResults,wifi,List,scanResult,开机,new,An From: https://www.cnblogs.com/1118zjg/p/17649270.html