Commit b7d4f7a0 by Kim Jinsung

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

parent e054b7ed
...@@ -4,6 +4,9 @@ import android.content.ContentResolver; ...@@ -4,6 +4,9 @@ import android.content.ContentResolver;
import android.content.ContentValues; import android.content.ContentValues;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; 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.ScanResult;
import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo; import android.net.wifi.WifiInfo;
...@@ -239,4 +242,50 @@ public class ThetaHelper { ...@@ -239,4 +242,50 @@ public class ThetaHelper {
} }
return isConnected; 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; ...@@ -11,12 +11,10 @@ import android.os.Bundle;
import com.theta.helper.ThetaHelper; import com.theta.helper.ThetaHelper;
import jp.agentec.abook.abv.bl.common.Constant; 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.launcher.android.R;
import jp.agentec.abook.abv.ui.common.activity.ABVUIActivity; import jp.agentec.abook.abv.ui.common.activity.ABVUIActivity;
import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil; import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil;
import jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper; import jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper;
import jp.agentec.abook.abv.ui.viewer.activity.theta.task.FinishWlanTask;
/** /**
* Theta関連共通クラス * Theta関連共通クラス
...@@ -44,25 +42,25 @@ public class ThetaActivity extends ABVUIActivity { ...@@ -44,25 +42,25 @@ public class ThetaActivity extends ABVUIActivity {
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
unregisterReceiver(wifiReceiver); unregisterReceiver(wifiReceiver);
boolean isConnected = mThetaHelper.checkThetaCameraWifiConnected(mWifiManager); boolean isConnected = mThetaHelper.checkThetaCameraWifiConnected(mWifiManager);
if (isConnected) {
Logger.d(TAG, "ThetaカメラWi-Fi接続状態"); //THETAカメラ画面閉じる
if (mWifiScanType == Constant.WifiScanType.CloseCameraActivity) { if (mWifiScanType == Constant.WifiScanType.CloseCameraActivity) {
//THETAカメラのWi-Fi機能を無効にするAPI送信 if (isConnected) {
new FinishWlanTask((ThetaCameraActivity) ActivityHandlingHelper.getInstance().getCurrentActivity()).execute(); mThetaHelper.disConnectThetaCameraWifi(mWifiManager);
} else if (mWifiScanType == Constant.WifiScanType.ThetaConnectError) {
thetaCameraWifiConnected();
} }
} else { mThetaHelper.appConnectedWifiDefault();
Logger.d(TAG, "ThetaカメラWi-Fi非接続状態");
if (mWifiScanType == Constant.WifiScanType.CloseCameraActivity) {
finish(); finish();
} else if (mWifiScanType == Constant.WifiScanType.ThetaConnectError) { } 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() { AlertDialogUtil.showAlertDialog(ThetaActivity.this, R.string.app_name, R.string.msg_theta_wifi_disconnect, true, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
closeProgressPopup(); closeProgressPopup();
//Thetaカメラ関連Activity終了 //Thetaカメラ関連Activity終了
ActivityHandlingHelper.getInstance().finishAllThetaActivity(); ActivityHandlingHelper.getInstance().finishAllThetaActivity();
mThetaHelper.appConnectedWifiDefault();
} }
}); });
} }
......
package jp.agentec.abook.abv.ui.viewer.activity.theta.task; 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 android.os.AsyncTask;
import com.theta.helper.ThetaHelper;
import com.theta.network.HttpConnector; import com.theta.network.HttpConnector;
import com.theta.network.ThetaDeviceInfo; import com.theta.network.ThetaDeviceInfo;
...@@ -45,8 +42,9 @@ public class DeviceInfoTask extends AsyncTask<Void, String, ThetaDeviceInfo> { ...@@ -45,8 +42,9 @@ public class DeviceInfoTask extends AsyncTask<Void, String, ThetaDeviceInfo> {
} catch (InterruptedException e1) { } catch (InterruptedException e1) {
e1.printStackTrace(); e1.printStackTrace();
} }
if (retryCount == 0) { if (retryCount == 0) { //失敗時、LTE環境の影響のため、アプリで利用するネットワークを設定
thetaConnectedWifiOnly(); ThetaHelper helper = new ThetaHelper(refActivity.get());
helper.appConnectedWifiOnly();
} }
} else { } else {
...@@ -62,23 +60,4 @@ public class DeviceInfoTask extends AsyncTask<Void, String, ThetaDeviceInfo> { ...@@ -62,23 +60,4 @@ public class DeviceInfoTask extends AsyncTask<Void, String, ThetaDeviceInfo> {
DeviceImageListActivity activity = refActivity.get(); DeviceImageListActivity activity = refActivity.get();
activity.thetaDeviceInfoTaskFinish(deviceInfo); 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; ...@@ -18,7 +18,7 @@ import jp.agentec.abook.abv.launcher.android.R;
* シーン画像ファイルをサーバへ登録する処理クラス * シーン画像ファイルをサーバへ登録する処理クラス
*/ */
public class SceneSendHelper { public class SceneSendHelper {
private static final String TAG = "DeviceImageListHelper"; private static final String TAG = "SceneSendHelper";
private SceneSendHelper.DeviceImageListSendListener listener; private SceneSendHelper.DeviceImageListSendListener listener;
private Context mContext; private Context mContext;
...@@ -69,7 +69,7 @@ public class SceneSendHelper { ...@@ -69,7 +69,7 @@ public class SceneSendHelper {
listener.sceneSendfinish(); listener.sceneSendfinish();
} }
} catch (AcmsException ex) { } catch (AcmsException ex) {
Logger.e(TAG, ex); Logger.e(TAG, ex.toString());
if (ex.getCode() == ABVExceptionCode.P_E_ACMS_P007) { if (ex.getCode() == ABVExceptionCode.P_E_ACMS_P007) {
listener.sceneSendFail(mContext.getString(R.string.error_msg_open_pano_edit)); listener.sceneSendFail(mContext.getString(R.string.error_msg_open_pano_edit));
} else { } else {
...@@ -77,7 +77,7 @@ public class SceneSendHelper { ...@@ -77,7 +77,7 @@ public class SceneSendHelper {
} }
break; break;
} catch (Exception e) { } catch (Exception e) {
Logger.e(TAG, e); Logger.e(TAG, e.toString());
listener.sceneSendFailRetry(needSendImages); listener.sceneSendFailRetry(needSendImages);
break; 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