Commit b7d4f7a0 by Kim Jinsung

THETAカメラと接続切断したあと、アプリ側から通常Wi-Fi接続できない問題対応

parent e054b7ed
......@@ -4,6 +4,9 @@ import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.graphics.Bitmap;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkInfo;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
......@@ -239,4 +242,50 @@ public class ThetaHelper {
}
return isConnected;
}
/**
* THETAカメラWi-Fiと非接続接続
*/
public void disConnectThetaCameraWifi(WifiManager wifiManager) {
//既存接続中のネットワーク切断
WifiInfo wifi_inf = wifiManager.getConnectionInfo();
if (wifi_inf.getNetworkId() != -1 ) {
wifiManager.disableNetwork(wifi_inf.getNetworkId());
wifiManager.disconnect();
}
}
/**
* ConnectivityManagerを利用してアプリ(プロセス)全体のネットワークを設定します。
*/
public void appConnectedWifiOnly() {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
ConnectivityManager connectivityManager = (ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivityManager != null) {
if (connectivityManager.getAllNetworks().length > 1) {
for (Network net : connectivityManager.getAllNetworks()) {
NetworkInfo networkInfo = connectivityManager.getNetworkInfo(net);
if (networkInfo != null && networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
connectivityManager.bindProcessToNetwork(net);
break;
}
}
}
}
}
}
/**
* ConnectivityManagerを利用してアプリ(プロセス)全体のネットワークを解除する。
*/
public void appConnectedWifiDefault() {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
ConnectivityManager connectivityManager = (ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivityManager != null) {
if (connectivityManager.getBoundNetworkForProcess() != null) {
connectivityManager.bindProcessToNetwork(null);
}
}
}
}
}
......@@ -11,12 +11,10 @@ import android.os.Bundle;
import com.theta.helper.ThetaHelper;
import jp.agentec.abook.abv.bl.common.Constant;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.common.activity.ABVUIActivity;
import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil;
import jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper;
import jp.agentec.abook.abv.ui.viewer.activity.theta.task.FinishWlanTask;
/**
* Theta関連共通クラス
......@@ -44,25 +42,25 @@ public class ThetaActivity extends ABVUIActivity {
public void onReceive(Context context, Intent intent) {
unregisterReceiver(wifiReceiver);
boolean isConnected = mThetaHelper.checkThetaCameraWifiConnected(mWifiManager);
if (isConnected) {
Logger.d(TAG, "ThetaカメラWi-Fi接続状態");
if (mWifiScanType == Constant.WifiScanType.CloseCameraActivity) {
//THETAカメラのWi-Fi機能を無効にするAPI送信
new FinishWlanTask((ThetaCameraActivity) ActivityHandlingHelper.getInstance().getCurrentActivity()).execute();
} else if (mWifiScanType == Constant.WifiScanType.ThetaConnectError) {
thetaCameraWifiConnected();
//THETAカメラ画面閉じる
if (mWifiScanType == Constant.WifiScanType.CloseCameraActivity) {
if (isConnected) {
mThetaHelper.disConnectThetaCameraWifi(mWifiManager);
}
} else {
Logger.d(TAG, "ThetaカメラWi-Fi非接続状態");
if (mWifiScanType == Constant.WifiScanType.CloseCameraActivity) {
finish();
} else if (mWifiScanType == Constant.WifiScanType.ThetaConnectError) {
mThetaHelper.appConnectedWifiDefault();
finish();
} else if (mWifiScanType == Constant.WifiScanType.ThetaConnectError) { //THETAカメラと通信エラー共通
if (isConnected) {
thetaCameraWifiConnected();
} else {
AlertDialogUtil.showAlertDialog(ThetaActivity.this, R.string.app_name, R.string.msg_theta_wifi_disconnect, true, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
closeProgressPopup();
//Thetaカメラ関連Activity終了
ActivityHandlingHelper.getInstance().finishAllThetaActivity();
mThetaHelper.appConnectedWifiDefault();
}
});
}
......
package jp.agentec.abook.abv.ui.viewer.activity.theta.task;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkInfo;
import android.os.AsyncTask;
import com.theta.helper.ThetaHelper;
import com.theta.network.HttpConnector;
import com.theta.network.ThetaDeviceInfo;
......@@ -45,8 +42,9 @@ public class DeviceInfoTask extends AsyncTask<Void, String, ThetaDeviceInfo> {
} catch (InterruptedException e1) {
e1.printStackTrace();
}
if (retryCount == 0) {
thetaConnectedWifiOnly();
if (retryCount == 0) { //失敗時、LTE環境の影響のため、アプリで利用するネットワークを設定
ThetaHelper helper = new ThetaHelper(refActivity.get());
helper.appConnectedWifiOnly();
}
} else {
......@@ -62,23 +60,4 @@ public class DeviceInfoTask extends AsyncTask<Void, String, ThetaDeviceInfo> {
DeviceImageListActivity activity = refActivity.get();
activity.thetaDeviceInfoTaskFinish(deviceInfo);
}
/**
* LTE環境の場合、THETA端末のWifi接続後、LTE接続される問題でWifi利用するように設定
*/
private void thetaConnectedWifiOnly() {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
DeviceImageListActivity activity = refActivity.get();
ConnectivityManager connectivityManager = (ConnectivityManager)activity.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivityManager != null) {
for (Network net : connectivityManager.getAllNetworks()) {
NetworkInfo networkInfo = connectivityManager.getNetworkInfo(net);
if (networkInfo != null && networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
connectivityManager.bindProcessToNetwork(net);
break;
}
}
}
}
}
}
......@@ -18,7 +18,7 @@ import jp.agentec.abook.abv.launcher.android.R;
* シーン画像ファイルをサーバへ登録する処理クラス
*/
public class SceneSendHelper {
private static final String TAG = "DeviceImageListHelper";
private static final String TAG = "SceneSendHelper";
private SceneSendHelper.DeviceImageListSendListener listener;
private Context mContext;
......@@ -69,7 +69,7 @@ public class SceneSendHelper {
listener.sceneSendfinish();
}
} catch (AcmsException ex) {
Logger.e(TAG, ex);
Logger.e(TAG, ex.toString());
if (ex.getCode() == ABVExceptionCode.P_E_ACMS_P007) {
listener.sceneSendFail(mContext.getString(R.string.error_msg_open_pano_edit));
} else {
......@@ -77,7 +77,7 @@ public class SceneSendHelper {
}
break;
} catch (Exception e) {
Logger.e(TAG, e);
Logger.e(TAG, e.toString());
listener.sceneSendFailRetry(needSendImages);
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment