Search in sources :

Example 16 with NotificationBackend

use of com.android.settings.notification.NotificationBackend in project android_packages_apps_Settings by omnirom.

the class NotificationAccessDetails method onAttach.

@Override
public void onAttach(Context context) {
    super.onAttach(context);
    final Intent intent = getIntent();
    if (mComponentName == null && intent != null) {
        String cn = intent.getStringExtra(Settings.EXTRA_NOTIFICATION_LISTENER_COMPONENT_NAME);
        if (cn != null) {
            mComponentName = ComponentName.unflattenFromString(cn);
            if (mComponentName != null) {
                final Bundle args = getArguments();
                args.putString(ARG_PACKAGE_NAME, mComponentName.getPackageName());
            }
        }
    }
    mPm = getPackageManager();
    retrieveAppEntry();
    loadNotificationListenerService();
    NotificationBackend backend = new NotificationBackend();
    int listenerTargetSdk = Build.VERSION_CODES.S;
    try {
        listenerTargetSdk = mPm.getTargetSdkVersion(mComponentName.getPackageName());
    } catch (PackageManager.NameNotFoundException e) {
    // how did we get here?
    }
    use(ApprovalPreferenceController.class).setPkgInfo(mPackageInfo).setCn(mComponentName).setNm(context.getSystemService(NotificationManager.class)).setPm(mPm).setParent(this);
    use(HeaderPreferenceController.class).setFragment(this).setPackageInfo(mPackageInfo).setPm(context.getPackageManager()).setServiceName(mServiceName).setBluetoothManager(Utils.getLocalBtManager(context)).setCdm(ICompanionDeviceManager.Stub.asInterface(ServiceManager.getService(Context.COMPANION_DEVICE_SERVICE))).setCn(mComponentName).setUserId(mUserId);
    use(PreUpgradePreferenceController.class).setNm(backend).setCn(mComponentName).setUserId(mUserId).setTargetSdk(listenerTargetSdk);
    use(BridgedAppsLinkPreferenceController.class).setNm(backend).setCn(mComponentName).setUserId(mUserId).setTargetSdk(listenerTargetSdk);
    final int finalListenerTargetSdk = listenerTargetSdk;
    getPreferenceControllers().forEach(controllers -> {
        controllers.forEach(controller -> {
            if (controller instanceof TypeFilterPreferenceController) {
                TypeFilterPreferenceController tfpc = (TypeFilterPreferenceController) controller;
                tfpc.setNm(backend).setCn(mComponentName).setServiceInfo(mServiceInfo).setUserId(mUserId).setTargetSdk(finalListenerTargetSdk);
            }
        });
    });
}
Also used : NotificationBackend(com.android.settings.notification.NotificationBackend) PackageManager(android.content.pm.PackageManager) NotificationManager(android.app.NotificationManager) Bundle(android.os.Bundle) Intent(android.content.Intent)

Example 17 with NotificationBackend

use of com.android.settings.notification.NotificationBackend in project android_packages_apps_Settings by omnirom.

the class BridgedAppsSettings method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    mShowSystem = icicle != null && icicle.getBoolean(EXTRA_SHOW_SYSTEM);
    use(BridgedAppsPreferenceController.class).setNm(new NotificationBackend());
}
Also used : NotificationBackend(com.android.settings.notification.NotificationBackend)

Example 18 with NotificationBackend

use of com.android.settings.notification.NotificationBackend in project android_packages_apps_Settings by omnirom.

the class BubblePreferenceController method applyBubblesApproval.

/**
 * Apply global bubbles approval
 */
public static void applyBubblesApproval(Context context, String pkg, int uid, int pref) {
    NotificationBackend backend = new NotificationBackend();
    backend.setAllowBubbles(pkg, uid, pref);
    // changing the global settings will cause the observer on the host page to reload
    // correct preference state
    Settings.Secure.putInt(context.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
}
Also used : NotificationBackend(com.android.settings.notification.NotificationBackend)

Example 19 with NotificationBackend

use of com.android.settings.notification.NotificationBackend in project android_packages_apps_Settings by omnirom.

the class AppBubbleNotificationSettings method getPreferenceControllers.

protected static List<NotificationPreferenceController> getPreferenceControllers(Context context, AppBubbleNotificationSettings fragment, DependentFieldListener listener) {
    List<NotificationPreferenceController> controllers = new ArrayList<>();
    controllers.add(new HeaderPreferenceController(context, fragment));
    controllers.add(new BubblePreferenceController(context, fragment != null ? fragment.getChildFragmentManager() : null, new NotificationBackend(), true, /* isAppPage */
    listener));
    controllers.add(new AppBubbleListPreferenceController(context, new NotificationBackend()));
    return controllers;
}
Also used : NotificationBackend(com.android.settings.notification.NotificationBackend) ArrayList(java.util.ArrayList) AppBubbleListPreferenceController(com.android.settings.notification.AppBubbleListPreferenceController)

Example 20 with NotificationBackend

use of com.android.settings.notification.NotificationBackend in project android_packages_apps_Settings by omnirom.

the class NotificationHistoryActivity method onResume.

@Override
protected void onResume() {
    super.onResume();
    mPm = getPackageManager();
    mUm = getSystemService(UserManager.class);
    // wait for history loading and recent/snooze loading
    mCountdownLatch = new CountDownLatch(2);
    mTodayView.removeAllViews();
    mHistoryLoader = new HistoryLoader(this, new NotificationBackend(), mPm);
    mHistoryLoader.load(mOnHistoryLoaderListener);
    mNm = INotificationManager.Stub.asInterface(ServiceManager.getService(Context.NOTIFICATION_SERVICE));
    try {
        mListener.registerAsSystemService(this, new ComponentName(getPackageName(), this.getClass().getCanonicalName()), ActivityManager.getCurrentUser());
    } catch (RemoteException e) {
        Log.e(TAG, "Cannot register listener", e);
    }
    bindSwitch();
    mCountdownFuture = ThreadUtils.postOnBackgroundThread(() -> {
        try {
            mCountdownLatch.await(2, TimeUnit.SECONDS);
        } catch (InterruptedException e) {
            Slog.e(TAG, "timed out waiting for loading", e);
        }
        ThreadUtils.postOnMainThread(() -> {
            if (mSwitchBar.isChecked() && findViewById(R.id.today_list).getVisibility() == View.GONE && mSnoozeView.getVisibility() == View.GONE && mDismissView.getVisibility() == View.GONE) {
                mHistoryOn.setVisibility(View.GONE);
                mHistoryEmpty.setVisibility(View.VISIBLE);
            }
        });
    });
    mUiEventLogger.log(NotificationHistoryEvent.NOTIFICATION_HISTORY_OPEN);
}
Also used : NotificationBackend(com.android.settings.notification.NotificationBackend) UserManager(android.os.UserManager) ComponentName(android.content.ComponentName) CountDownLatch(java.util.concurrent.CountDownLatch) RemoteException(android.os.RemoteException)

Aggregations

NotificationBackend (com.android.settings.notification.NotificationBackend)21 Intent (android.content.Intent)10 Bundle (android.os.Bundle)10 HighPowerApplicationsActivity (com.android.settings.Settings.HighPowerApplicationsActivity)9 StorageUseActivity (com.android.settings.Settings.StorageUseActivity)9 WriteSettingsActivity (com.android.settings.Settings.WriteSettingsActivity)9 GamesStorageActivity (com.android.settings.Settings.GamesStorageActivity)8 AllApplicationsActivity (com.android.settings.Settings.AllApplicationsActivity)7 NotificationAppListActivity (com.android.settings.Settings.NotificationAppListActivity)6 Activity (android.app.Activity)4 Application (android.app.Application)2 IUsageStatsManager (android.app.usage.IUsageStatsManager)2 ApplicationInfo (android.content.pm.ApplicationInfo)2 UserManager (android.os.UserManager)2 Settings (com.android.settings.Settings)2 ManageExternalSourcesActivity (com.android.settings.Settings.ManageExternalSourcesActivity)2 OverlaySettingsActivity (com.android.settings.Settings.OverlaySettingsActivity)2 UsageAccessSettingsActivity (com.android.settings.Settings.UsageAccessSettingsActivity)2 SettingsActivity (com.android.settings.SettingsActivity)2 AppStorageSettings (com.android.settings.applications.AppStorageSettings)2