Yes, it is based on the duration of stay in India.
Use this calculator for determining residential status:
An individual may have any one of the following residential status:
AA] Resident and ordinarily resident in India.
BB] Resident but not ordinarily resident in India.
CC] Non-resident
First determine whether resident or non-resident; then resident & ordinary resident(AA) or resident but not ordinarily resident(BB).
An individual will be treated as a resident in India for a year if he satisfies any of the following conditions (may satisfy any one or may satisfy both the conditions):
1] He is in India for a period of 182 days or more in that year; or
2] He is in India for a period of 60 days or more in the year and for a period of 365 days or more in immediately preceding 4 years.
However, in respect of an Indian citizen and a person of Indian origin who visits India during the year, the period of 60 days as mentioned in (2) above shall be substituted with 182 days.
Individuals not fulfilling any of the above conditions will, hence, be a [Non-Resident (NR)]
Further, A resident individual will be treated as resident and ordinarily resident in India during the year if he satisfies the following conditions:
1] He is resident in India for at least 2 years out of 10 years immediately preceding the relevant year; or
2] His stay in India is for 730 days or more during 7 years immediately preceding the relevant year.