Search in sources :

Example 61 with RequiresApi

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;
}
Also used : ApplicationInfo(android.content.pm.ApplicationInfo) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) Field(java.lang.reflect.Field) AppOpsManager(android.app.AppOpsManager) RequiresApi(android.support.annotation.RequiresApi)

Example 62 with RequiresApi

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();
}
Also used : Locale(java.util.Locale) CrashlyticsCore(com.crashlytics.android.core.CrashlyticsCore) Configuration(android.content.res.Configuration) CallingWearHelper(com.huami.watch.companion.wearcalling.CallingWearHelper) IMEservice(com.huami.watch.companion.IME.IMEservice) AskAndAnswer(com.huami.watch.companion.findphone.AskAndAnswer) WeatherService(com.huami.watch.companion.weather.WeatherService) AppEnterForegroundCallBack(com.huami.watch.companion.util.AppEnterForegroundCallBack) IntentFilter(android.content.IntentFilter) HttpProxyServer(com.huami.watch.companion.components.bluetoothproxyserver.HttpProxyServer) OtaService(com.huami.watch.companion.otaphone.service.OtaService) Log(com.huami.watch.util.Log) ConnectionReceiver(com.huami.watch.transport.httpsupport.global.ConnectionReceiver) Device(com.huami.watch.companion.device.Device) Intent(android.content.Intent) Crashlytics(com.crashlytics.android.Crashlytics) DataCollection(com.huami.watch.companion.datacollection.DataCollection) BGService_msg(com.huami.watch.hmwatchmanager.bt_connect.BGService_msg) Transporter(com.huami.watch.transport.Transporter) DexWrap(lanchon.dexpatcher.annotation.DexWrap) RequiresApi(android.support.annotation.RequiresApi) SuppressLint(android.annotation.SuppressLint)

Example 63 with RequiresApi

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;
}
Also used : Context(android.content.Context) RequiresApi(android.support.annotation.RequiresApi) DexAdd(lanchon.dexpatcher.annotation.DexAdd)

Example 64 with RequiresApi

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;
}
Also used : StatusBarNotification(android.service.notification.StatusBarNotification) RequiresApi(android.support.annotation.RequiresApi)

Example 65 with RequiresApi

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();
}
Also used : TypedArray(android.content.res.TypedArray) Paint(android.graphics.Paint) RequiresApi(android.support.annotation.RequiresApi)

Aggregations

RequiresApi (android.support.annotation.RequiresApi)191 Intent (android.content.Intent)30 NotificationChannel (android.app.NotificationChannel)28 View (android.view.View)25 NotificationManager (android.app.NotificationManager)17 ViewGroup (android.view.ViewGroup)15 Allocation (android.renderscript.Allocation)14 Bitmap (android.graphics.Bitmap)13 RecyclerView (android.support.v7.widget.RecyclerView)13 ViewTreeObserver (android.view.ViewTreeObserver)12 WindowInsets (android.view.WindowInsets)12 TextView (android.widget.TextView)12 ActionBar (android.support.v7.app.ActionBar)11 Toolbar (android.support.v7.widget.Toolbar)11 Handler (android.os.Handler)10 StatFs (android.os.StatFs)9 Button (android.widget.Button)8 Cipher (javax.crypto.Cipher)8 SuppressLint (android.annotation.SuppressLint)7 Uri (android.net.Uri)7