use of android.support.annotation.RequiresApi in project XUtil by xuexiangjys.
the class PermissionUtils method isNotificationEnable.
/**
* 通知权限是否打开
* @param context
* @return
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private static boolean isNotificationEnable(Context context) {
AppOpsManager appOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
ApplicationInfo appInfo = context.getApplicationInfo();
String pkg = context.getApplicationContext().getPackageName();
int uid = appInfo.uid;
try {
Class appOpsClass = Class.forName(AppOpsManager.class.getName());
Method checkOpNoThrowMethod = appOpsClass.getMethod("checkOpNoThrow", Integer.TYPE, Integer.TYPE, String.class);
Field opPostNotificationValue = appOpsClass.getDeclaredField("OP_POST_NOTIFICATION");
int value = (Integer) opPostNotificationValue.get(Integer.class);
return ((Integer) checkOpNoThrowMethod.invoke(appOps, value, uid, pkg) == AppOpsManager.MODE_ALLOWED);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return false;
}
use of android.support.annotation.RequiresApi in project AmazMod by edotassi.
the class CompanionApplication method onCreate.
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
@SuppressLint({ "MissingSuperCall", "ResourceType" })
@DexWrap
public void onCreate() {
Boolean enableRtl = PreferenceManager.getBoolean(this, Constants.PREFERENCE_ENABLE_RTL, false);
Configuration configuration = getResources().getConfiguration();
configuration.setLayoutDirection(new Locale(enableRtl ? "fa" : "en"));
getResources().updateConfiguration(configuration, getResources().getDisplayMetrics());
Boolean disableCrashReporting = PreferenceManager.getBoolean(this, Constants.PREFERENCE_DISABLE_CRASH_REPORTING, false);
CrashlyticsCore crashlyticsCore = new CrashlyticsCore.Builder().disabled(!disableCrashReporting.booleanValue()).build();
Fabric.with(this, new Crashlytics.Builder().core(crashlyticsCore).build());
a = this;
if (!Config.isOversea() && !b()) {
return;
}
Box.initDefault(this);
a();
Log.Settings settings = Log.init();
settings.setLogLevel(Config.isDebug() ? Log.LogLevel.FULL : Log.LogLevel.FILE_ONLY).setLogFile(StorageUtil.getLogFile(this));
Log.d("CompanionApp", "OnAppCreate : " + AppUtil.getVersionNameAndCode(this), new Object[0]);
super.onCreate();
/*
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread thread, Throwable throwable) {
Log.e("CompanionApp", "Crash(" + thread + ")", throwable, new Object[0]);
System.exit(1);
}
});
*/
Analytics.config(true, Config.isDebug(), true, this, AppUtil.getMetaDataChannel(this));
AccountManager.getDefault(this).setTestMode(Config.isTestHosts());
// AccountManager.getDefault(this).setGlobalMode(true);
ActiveAndroid.initialize(this, Config.isDebug());
NotificationManager.getManager(this).init();
if (DeviceCompatibility.MIUI.isMIUI(this)) {
MiuiAPI.getInstance(this).init();
}
SyncThrottler.init(this);
BindUtil.unbindUnfinishedDevice(this);
j = Transporter.get(this, "com.huami.watch.companion");
j.addChannelListener(k);
j.addDataListener(l);
j.connectTransportService();
Transporter object = Transporter.get(this, "com.huami.watch.companion.syncdata");
object.addDataListener(m);
object.connectTransportService();
object = Transporter.get(this, "com.huami.action.notification");
object.addDataListener(n);
object.connectTransportService();
o = Transporter.get(this, "com.huami.watch.health");
o.addDataListener(p);
o.connectTransportService();
if (f == null) {
f = new AskAndAnswer(this);
}
if (g == null) {
g = new CallingWearHelper(this);
}
if (h == null) {
h = new DataCollection(this);
}
startService(new Intent(this, BGService_msg.class));
startService(new Intent(this, OtaService.class));
startService(new Intent(this, IMEservice.class));
SyncWatchFaceBgHelper.getHelper().startFileTransporter(this);
AGpsSyncHelper.getHelper().startFileTransporter(this);
if (DeviceManager.getManager(this).hasBoundDevice()) {
AGpsSyncService.scheduleSync(this, "AppOnCreate");
startService(new Intent(this, WeatherService.class));
}
a(this);
SyncWatchHealthHelper.getHelper().init(this);
SyncWatchSportHelper.getHelper().init(this);
WearHttpSupportInterface.doInit(this);
/* Ok */
ConnectionReceiver connectionReceiver = new ConnectionReceiver();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
intentFilter.addAction("com.huami.watch.WATCH_CONNED_4_COMPANION");
intentFilter.addAction("com.huami.watch.companion.action.UnbindDeviceStart");
intentFilter.addAction("com.huami.watch.httpsupport.COLLECT_DATA");
intentFilter.addAction("com.huami.watch.companion.action.HOST_START_SYNC_DATA");
registerReceiver(connectionReceiver, intentFilter);
TimeChangedReceiver timeChangedReceiver = new CompanionApplication.TimeChangedReceiver();
IntentFilter timeSet = new IntentFilter("android.intent.action.TIME_SET");
timeSet.addAction("android.intent.action.TIMEZONE_CHANGED");
registerReceiver(timeChangedReceiver, timeSet);
IntentFilter wifiStateChangeConnectivityChange = new IntentFilter();
wifiStateChangeConnectivityChange.addAction("android.net.wifi.STATE_CHANGE");
wifiStateChangeConnectivityChange.addAction("android.net.conn.CONNECTIVITY_CHANGE");
registerReceiver(q, wifiStateChangeConnectivityChange);
new RxConsumerStarter().init(this);
BindUtil.connectCurrentDevice(this);
Device device = DeviceManager.getManager(this).getCurrentDevice();
if (device != null && DeviceUtil.hasEmptyInfo(device)) {
SyncDeviceInfoHelper.getHelper(this).startAsync();
}
PlayFlavor.initApp(this);
e = new HttpProxyServer(getApplicationContext());
e.init();
if (getResources().getBoolean(2131427330)) {
CommandHandler.getInstance(this);
}
WatchWifiFtpUtil.init(getApplicationContext());
registerActivityLifecycleCallbacks(new AppEnterForegroundCallBack());
BleLostWarningManager.init(getApplicationContext());
if (DeviceCompatibility.isHuaWeiPhone() && !DeviceCompatibility.isO()) {
// DummyJobService.startSchedule(this);
}
FileDownloader.init(getApplicationContext(), new DownloadMgrInitialParams.InitCustomMaker().connectionCreator(new FileDownloadUrlConnection.Creator(new FileDownloadUrlConnection.Configuration().connectTimeout(15000).readTimeout(15000).proxy(Proxy.NO_PROXY))));
Boot.sharedInstance(this).run();
}
use of android.support.annotation.RequiresApi in project AmazMod by edotassi.
the class StatusBarNotificationData method from.
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
@DexAdd
public static StatusBarNotificationData from(StatusBarNotification pStatusBarNotification) {
StatusBarNotificationData statusBarNotificationData = source_from(pStatusBarNotification);
Context context = CompanionApplication.getContext() == null ? NotificationAccessService.context : CompanionApplication.getContext();
if (!PreferenceManager.getBoolean(context, Constants.PREFERENCE_DISABLE_NOTIFICATIONS_MOD, false)) {
statusBarNotificationData.pkg = statusBarNotificationData.pkg + "|" + pStatusBarNotification.getNotification().when;
}
return statusBarNotificationData;
}
use of android.support.annotation.RequiresApi in project USSD4ETECSA by Daym3l.
the class NotificationHelper method verificarNotifications.
/**
* Verificar q la notificacion este activa
*
* @return
*/
@RequiresApi(api = Build.VERSION_CODES.M)
private boolean verificarNotifications() {
final StatusBarNotification[] activeNotifications = this.adminNotifications.getActiveNotifications();
boolean flag = false;
for (StatusBarNotification notification : activeNotifications) {
if (notification.getId() == NOTIFICATION_ID) {
flag = true;
} else {
flag = false;
}
}
return flag;
}
use of android.support.annotation.RequiresApi in project Stylish-Widget-for-Android by shiburagi.
the class AMeter method setCustomAttr.
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
private void setCustomAttr(Context context, AttributeSet attrs) {
initView();
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.meterAttr);
setMeterColor(a.getColor(R.styleable.meterAttr_sw_meterColor, Color.WHITE));
setShowNeedle(a.getBoolean(R.styleable.meterAttr_sw_showNeedle, true));
setLineWidth(a.getFloat(R.styleable.meterAttr_sw_lineWidth, 1f));
setLineStrokeSize(a.getDimension(R.styleable.meterAttr_sw_lineStrokeSize, Utils.convertDpToPixel(10)));
a.recycle();
a = getContext().obtainStyledAttributes(attrs, R.styleable.textAttr);
setTextSize(a.getDimension(R.styleable.textAttr_sw_textSize, getResources().getDimension(R.dimen.meterTextSize)));
int textStyle;
try {
textStyle = a.getInt(R.styleable.textAttr_sw_textStyle, Typeface.BOLD);
} catch (Exception e) {
textStyle = Typeface.BOLD;
}
setTextStyle(textStyle);
a.recycle();
a = getContext().obtainStyledAttributes(attrs, R.styleable.constraintAttr);
setShowText(a.getBoolean(R.styleable.constraintAttr_sw_showText, true));
setValue(a.getFloat(R.styleable.constraintAttr_sw_value, 0f));
setStartValue(a.getFloat(R.styleable.constraintAttr_sw_startValue, 0f));
setMaxValue(a.getFloat(R.styleable.constraintAttr_sw_maxValue, 1f));
setNumberOfLine(a.getInt(R.styleable.constraintAttr_sw_numberOfLine, 1));
setUnit(a.getString(R.styleable.constraintAttr_sw_unit));
a.recycle();
}
Aggregations