Files
app_Settings/src/com/android/settings/utils/NotificationChannelHelper.java
Stephen Chen 2c4b42c0b7 Update "Open networks available" toggle to instead open notification channel preferences.
Bug: 36526438
Test: make ROBOTEST_FILTER=NotifyOpenNetworkPreferenceControllerTest RunSettingsRoboTests -j40
Change-Id: Idde3949856d050e62abff2c75a7b7db475a94d99
2017-04-11 11:54:51 -07:00

65 lines
2.2 KiB
Java

/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.utils;
import android.app.INotificationManager;
import android.app.NotificationChannel;
import android.os.RemoteException;
/**
* Wrappers around methods in {@link INotificationManager} and {@link NotificationChannel} to
* facilitate unit testing.
*
* TODO: delete this class once robolectric supports Android O
*/
public class NotificationChannelHelper {
private INotificationManager mNotificationManager;
public NotificationChannelHelper(
INotificationManager notificationManager) {
mNotificationManager = notificationManager;
}
/**
* Returns the notification channel settings for a app given its package name, user id, and
* channel id.
*/
public NotificationChannelWrapper getNotificationChannelForPackage(String pkg, int uid,
String channelId, boolean includeDeleted) throws RemoteException {
NotificationChannel channel = mNotificationManager.getNotificationChannelForPackage(
pkg, uid, channelId, includeDeleted);
return channel == null ? null : new NotificationChannelWrapper(channel);
}
/**
* Wrapper around {@link NotificationChannel} to facilitate unit testing.
*
* TODO: delete this class once robolectric supports Android O
*/
public class NotificationChannelWrapper {
private NotificationChannel mChannel;
public NotificationChannelWrapper(NotificationChannel channel) {
mChannel = channel;
}
public int getImportance() {
return mChannel.getImportance();
}
}
}