use of android.text.format.Time in project android_frameworks_base by ResurrectionRemix.
the class Shared method formatTime.
public static String formatTime(Context context, long when) {
// TODO: DateUtils should make this easier
Time then = new Time();
then.set(when);
Time now = new Time();
now.setToNow();
int flags = DateUtils.FORMAT_NO_NOON | DateUtils.FORMAT_NO_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL;
if (then.year != now.year) {
flags |= DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE;
} else if (then.yearDay != now.yearDay) {
flags |= DateUtils.FORMAT_SHOW_DATE;
} else {
flags |= DateUtils.FORMAT_SHOW_TIME;
}
return DateUtils.formatDateTime(context, when, flags);
}
use of android.text.format.Time in project android_frameworks_base by ResurrectionRemix.
the class TelephonyRegistry method logServiceStateChanged.
private void logServiceStateChanged(String s, int subId, int phoneId, ServiceState state) {
if (logSSC == null || logSSC.length == 0) {
return;
}
if (logSSC[next] == null) {
logSSC[next] = new LogSSC();
}
Time t = new Time();
t.setToNow();
logSSC[next].set(t, s, subId, phoneId, state);
if (++next >= logSSC.length) {
next = 0;
}
}
use of android.text.format.Time in project android_frameworks_base by ResurrectionRemix.
the class NetworkPolicyManagerService method ensureActiveMobilePolicyNL.
private void ensureActiveMobilePolicyNL(String subscriberId) {
// Poke around to see if we already have a policy
final NetworkIdentity probeIdent = new NetworkIdentity(TYPE_MOBILE, TelephonyManager.NETWORK_TYPE_UNKNOWN, subscriberId, null, false, true);
for (int i = mNetworkPolicy.size() - 1; i >= 0; i--) {
final NetworkTemplate template = mNetworkPolicy.keyAt(i);
if (template.matches(probeIdent)) {
if (LOGD) {
Slog.d(TAG, "Found template " + template + " which matches subscriber " + NetworkIdentity.scrubSubscriberId(subscriberId));
}
return;
}
}
Slog.i(TAG, "No policy for subscriber " + NetworkIdentity.scrubSubscriberId(subscriberId) + "; generating default policy");
// Build default mobile policy, and assume usage cycle starts today
final int dataWarningConfig = mContext.getResources().getInteger(com.android.internal.R.integer.config_networkPolicyDefaultWarning);
final long warningBytes;
if (dataWarningConfig == WARNING_DISABLED) {
warningBytes = WARNING_DISABLED;
} else {
warningBytes = dataWarningConfig * MB_IN_BYTES;
}
final Time time = new Time();
time.setToNow();
final int cycleDay = time.monthDay;
final String cycleTimezone = time.timezone;
final NetworkTemplate template = buildTemplateMobileAll(subscriberId);
final NetworkPolicy policy = new NetworkPolicy(template, cycleDay, cycleTimezone, warningBytes, LIMIT_DISABLED, SNOOZE_NEVER, SNOOZE_NEVER, true, true);
addNetworkPolicyNL(policy);
}
use of android.text.format.Time in project android_frameworks_base by ResurrectionRemix.
the class ShortcutService method formatTime.
static String formatTime(long time) {
Time tobj = new Time();
tobj.set(time);
return tobj.format("%Y-%m-%d %H:%M:%S");
}
use of android.text.format.Time in project android_frameworks_base by ResurrectionRemix.
the class DataUsageController method addMonth.
private static Time addMonth(Time t, int months) {
final Time rt = new Time(t);
rt.set(t.monthDay, t.month + months, t.year);
rt.normalize(false);
return rt;
}
Aggregations