13ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren/* 23ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren* Copyright (C) 2014 The Android Open Source Project 33ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren* 43ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren* Licensed under the Apache License, Version 2.0 (the "License"); 53ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren* you may not use this file except in compliance with the License. 63ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren* You may obtain a copy of the License at 73ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren* 83ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren* http://www.apache.org/licenses/LICENSE-2.0 93ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren* 103ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren* Unless required by applicable law or agreed to in writing, software 113ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren* distributed under the License is distributed on an "AS IS" BASIS, 123ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 133ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren* See the License for the specific language governing permissions and 143ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren* limitations under the License. 153ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren*/ 163ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wrenpackage com.android.server.notification; 173ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren 183ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wrenimport android.content.Context; 193ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wrenimport android.util.Slog; 203ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren 21233a5f97ea7b46814747a99f584b08d4e8c70105Julia Reynolds/** 22233a5f97ea7b46814747a99f584b08d4e8c70105Julia Reynolds * Determines if the given notification can display sensitive content on the lockscreen. 23233a5f97ea7b46814747a99f584b08d4e8c70105Julia Reynolds */ 24ef37f284364cc45c2ed91bfe04c489d2cedd32d2Julia Reynoldspublic class VisibilityExtractor implements NotificationSignalExtractor { 25ef37f284364cc45c2ed91bfe04c489d2cedd32d2Julia Reynolds private static final String TAG = "VisibilityExtractor"; 263ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren private static final boolean DBG = false; 273ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren 283ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren private RankingConfig mConfig; 293ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren 305eab2b72afe5b20dc66c237b1cceedfc09de2d52Chris Wren public void initialize(Context ctx, NotificationUsageStats usageStats) { 313ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren if (DBG) Slog.d(TAG, "Initializing " + getClass().getSimpleName() + "."); 323ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren } 333ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren 343ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren public RankingReconsideration process(NotificationRecord record) { 353ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren if (record == null || record.getNotification() == null) { 363ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren if (DBG) Slog.d(TAG, "skipping empty notification"); 373ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren return null; 383ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren } 393ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren 403ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren if (mConfig == null) { 413ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren if (DBG) Slog.d(TAG, "missing config"); 423ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren return null; 433ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren } 443ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren 45ef37f284364cc45c2ed91bfe04c489d2cedd32d2Julia Reynolds record.setPackageVisibilityOverride( 46ef37f284364cc45c2ed91bfe04c489d2cedd32d2Julia Reynolds mConfig.getVisibilityOverride(record.sbn.getPackageName(), record.sbn.getUid())); 473ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren 483ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren return null; 493ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren } 503ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren 513ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren @Override 523ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren public void setConfig(RankingConfig config) { 533ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren mConfig = config; 543ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren } 553ad4e3a45bbe44129b14c4d391431e44f1e04f0cChris Wren} 56