Merge "Fix bugs in auto restriction." into pi-dev am: f6e2c19fcc
am: a9e4d4a42a

Change-Id: If82969696eb492ea3875a0e0fb92f038024f00f9