Galaxy S5とAndroid 5.1.1でdo/whileが正しく機能しない
何の変哲もないコードなのですが、Galaxy S5およびAndroid 5.1.1の組合せの場合
のみ、do/while文が不可解な動きをします。原因をご存知の方はいらっしゃらない
でしょうか?
int i = 0;
int j = 0;
do {
Log.d(TAG, "[test do-while 1] i = " + i + ", j = " + j);
i = 0;
Log.d(TAG, "[test do-while 2] i = " + i + ", j = " + j);
i++;
Log.d(TAG, "[test do-while 3] i = " + i + ", j = " + j);
i++;
Log.d(TAG, "[test do-while 4] i = " + i + ", j = " + j);
j++;
Log.d(TAG, "[test do-while 5] i = " + i + ", j = " + j);
} while (j < 5);
Galaxy S5 (Android 5.1.1)で出力したログは以下の通りです。
D/MainActivity( 9856): [test do-while 1] i = 2, j = 0
D/MainActivity( 9856): [test do-while 2] i = 2, j = 0
D/MainActivity( 9856): [test do-while 3] i = 2, j = 0
D/MainActivity( 9856): [test do-while 4] i = 2, j = 0
D/MainActivity( 9856): [test do-while 5] i = 2, j = 1
D/MainActivity( 9856): [test do-while 1] i = 2, j = 1
D/MainActivity( 9856): [test do-while 2] i = 2, j = 1
D/MainActivity( 9856): [test do-while 3] i = 2, j = 1
D/MainActivity( 9856): [test do-while 4] i = 2, j = 1
D/MainActivity( 9856): [test do-while 5] i = 2, j = 2
D/MainActivity( 9856): [test do-while 1] i = 2, j = 2
D/MainActivity( 9856): [test do-while 2] i = 2, j = 2
D/MainActivity( 9856): [test do-while 3] i = 2, j = 2
D/MainActivity( 9856): [test do-while 4] i = 2, j = 2
D/MainActivity( 9856): [test do-while 5] i = 2, j = 3
D/MainActivity( 9856): [test do-while 1] i = 2, j = 3
D/MainActivity( 9856): [test do-while 2] i = 2, j = 3
D/MainActivity( 9856): [test do-while 3] i = 2, j = 3
D/MainActivity( 9856): [test do-while 4] i = 2, j = 3
D/MainActivity( 9856): [test do-while 5] i = 2, j = 4
D/MainActivity( 9856): [test do-while 1] i = 2, j = 4
D/MainActivity( 9856): [test do-while 2] i = 2, j = 4
D/MainActivity( 9856): [test do-while 3] i = 2, j = 4
D/MainActivity( 9856): [test do-while 4] i = 2, j = 4
D/MainActivity( 9856): [test do-while 5] i = 2, j = 5
それ以外の組合せで試すと以下の通り想定通りの動きをします。
D/MainActivity( 9515): [test do-while 1] i = 0, j = 0
D/MainActivity( 9515): [test do-while 2] i = 0, j = 0
D/MainActivity( 9515): [test do-while 3] i = 1, j = 0
D/MainActivity( 9515): [test do-while 4] i = 2, j = 0
D/MainActivity( 9515): [test do-while 5] i = 2, j = 1
D/MainActivity( 9515): [test do-while 1] i = 2, j = 1
D/MainActivity( 9515): [test do-while 2] i = 0, j = 1
D/MainActivity( 9515): [test do-while 3] i = 1, j = 1
D/MainActivity( 9515): [test do-while 4] i = 2, j = 1
D/MainActivity( 9515): [test do-while 5] i = 2, j = 2
D/MainActivity( 9515): [test do-while 1] i = 2, j = 2
D/MainActivity( 9515): [test do-while 2] i = 0, j = 2
D/MainActivity( 9515): [test do-while 3] i = 1, j = 2
D/MainActivity( 9515): [test do-while 4] i = 2, j = 2
D/MainActivity( 9515): [test do-while 5] i = 2, j = 3
D/MainActivity( 9515): [test do-while 1] i = 2, j = 3
D/MainActivity( 9515): [test do-while 2] i = 0, j = 3
D/MainActivity( 9515): [test do-while 3] i = 1, j = 3
D/MainActivity( 9515): [test do-while 4] i = 2, j = 3
D/MainActivity( 9515): [test do-while 5] i = 2, j = 4
D/MainActivity( 9515): [test do-while 1] i = 2, j = 4
D/MainActivity( 9515): [test do-while 2] i = 0, j = 4
D/MainActivity( 9515): [test do-while 3] i = 1, j = 4
D/MainActivity( 9515): [test do-while 4] i = 2, j = 4
D/MainActivity( 9515): [test do-while 5] i = 2, j = 5
その他確認した事実は以下の通りです。
・while文やfor文に書き換えると問題は発生しない。
・logを疑って自作ログに置き換えても事象は変わらない。
・Galaxy S4およびS6では発生しない、Anroid 5.0.2でも発生しない。