I want to distinguish between harsh acceleration and normal acceleration as well as harsh braking and normal braking (or even coasting).
On the basis of accelerometer readings, you could place thresholds on acceleration regions or look for outliers based on a profile of "normal" driving.
A typical crash deceleration involves tens of gs (fig 7) and airbags deploy after -1.0g for more than 10ms (page 6).
Therefore, anything close to deviations of 1.0g is already looking suspicious in terms of "feelings" to be expected in normal driving conditions. (Of course, you have to make sure that the phone is fixed firmly on the car). As a side note, typical airliner flight does not seem to go too far above 1.0g (of course, it is more during take off and breaking at landing).
The other approach to take would be to carry your device along with you for a large number of "normal" trips and then process the collected waveforms to establish those "acceptable" limits yourself. This could be seen as Anomaly Detection. In other words, you would be deriving a set of features from your waveforms (modal mean of accelleration over a period of time, variance, median, typical waveforms involved with steering or breaking and accellerating, or other) and then evaluate how "close" a given driving session is to those metrics of normality.
How can I distinguish harsh acceleration and normal acceleration as well as harsh braking and normal braking (or even coasting) in real-time?
Breaking and acceleration are covered above. By coasting, I am assuming that you mean allowing the car to roll in neutral. This is a rather difficult problem to be solved just by looking at a single accellerometer's output. It is very likely that it would have to be augmented by GPS or gyroscope sensors as well (most phones have all three types of sensors today).
To detect coasting, you would basically have to monitor very small changes in the attitude of the chassis. In constant velocity movement, the accelleration is zero and the engine is producing just enough power to counteract the friction of the tyres to the road and the chassis to the air. BUT! Part of the engine's torque is compressing (slightly) the suspension system. Therefore, a car under power tends to "lift its nose" (in side-view, the wheels want to turn in one direction, therefore the chassis tends to turn in the opposite direction. Try to notice the horizon in this video.). Of course, the road is not the track and for every torque setting, it is possible to find just the right downslope that would make the car appear to be coasting but it would still have a gear engaged. Therefore, inclination, either measured by gyro or GPS derived slope would be invaluable in determining coasting.
Hope this helps.