How to unlock phone with pattern in Appium?

I have tried this but it did not unlock my android phone:

public void Tc3_Unlock_Pattern() throws Exception {
System.out.print(“TC3:Unlock pattern”);
Runtime.getRuntime().exec(“adb shell input swipe 257 1235 572 1235”);
Runtime.getRuntime().exec(“adb shell input swipe 572 1235 260 1564”);
Runtime.getRuntime().exec(“adb shell input swipe 260 1564 532 1504”);
System.out.print(“TC3:Executed Successfully”);

Why don’t you just disable the pattern lock on the device while your testing against it, then re-enable it afterwards.

I dont want to disable it so we are testing one application in which we need to change the pattern in between the flow to test the flow completely.I even tried this but it did not work:

Integer x_topLeftCorner=257;
Integer y_topLeftCorner=1235;

	Integer x_topRightCorner=572;
	Integer y_topRightCorner=1235;

	Integer x_bottomLeftCorner= 260;
	Integer y_bottomLeftCorner=1438;

	Integer x_bottomRightCorner=532;
	Integer y_bottomRightCorner=1504;

	//Use coordinates to draw the security pattern and unlock the screen 
	TouchAction obj = new TouchAction(MBase.getDriver());,y_topLeftCorner).moveTo(x_topRightCorner,y_topRightCorner).moveTo(x_bottomLeftCorner,y_bottomLeftCorner).moveTo(x_bottomRightCorner,y_bottomRightCorner).release().perform();