summaryrefslogtreecommitdiff
path: root/PermissionController/src/com/android/permissioncontroller/permission/ui/handheld/PermissionAppsFragment.java
blob: 220507426cb25b9632cc9385c6aba42ddf92bfac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
/*
 * Copyright (C) 2015 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.permissioncontroller.permission.ui.handheld;

import static com.android.permissioncontroller.Constants.EXTRA_SESSION_ID;
import static com.android.permissioncontroller.Constants.INVALID_SESSION_ID;
import static com.android.permissioncontroller.permission.ui.Category.ALLOWED;
import static com.android.permissioncontroller.permission.ui.Category.ALLOWED_FOREGROUND;
import static com.android.permissioncontroller.permission.ui.Category.ASK;
import static com.android.permissioncontroller.permission.ui.Category.DENIED;
import static com.android.permissioncontroller.permission.ui.handheld.UtilsKt.pressBack;

import android.Manifest;
import android.app.ActionBar;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.ArrayMap;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.lifecycle.ViewModelProvider;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;

import com.android.modules.utils.build.SdkLevel;
import com.android.permissioncontroller.R;
import com.android.permissioncontroller.permission.model.v31.AppPermissionUsage;
import com.android.permissioncontroller.permission.model.v31.PermissionUsages;
import com.android.permissioncontroller.permission.ui.Category;
import com.android.permissioncontroller.permission.ui.ManagePermissionsActivity;
import com.android.permissioncontroller.permission.ui.handheld.v31.CardViewPreference;
import com.android.permissioncontroller.permission.ui.model.PermissionAppsViewModel;
import com.android.permissioncontroller.permission.ui.model.PermissionAppsViewModelFactory;
import com.android.permissioncontroller.permission.utils.KotlinUtils;
import com.android.permissioncontroller.permission.utils.Utils;
import com.android.settingslib.HelpUtils;
import com.android.settingslib.utils.applications.AppUtils;
import com.android.settingslib.widget.FooterPreference;

import java.text.Collator;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;

import kotlin.Pair;
import kotlin.Triple;

/**
 * Show and manage apps which request a single permission group.
 *
 * <p>Shows a list of apps which request at least on permission of this group.
 */
public final class PermissionAppsFragment extends SettingsWithLargeHeader implements
        PermissionUsages.PermissionsUsagesChangeCallback {

    private static final String KEY_SHOW_SYSTEM_PREFS = "_showSystem";
    private static final String CREATION_LOGGED_SYSTEM_PREFS = "_creationLogged";
    private static final String KEY_FOOTER = "_footer";
    private static final String KEY_EMPTY = "_empty";
    private static final String LOG_TAG = "PermissionAppsFragment";
    private static final String STORAGE_ALLOWED_FULL = "allowed_storage_full";
    private static final String STORAGE_ALLOWED_SCOPED = "allowed_storage_scoped";
    private static final String BLOCKED_SENSOR_PREF_KEY = "sensor_card";
    private static final String STORAGE_FOOTER_CATEGORY_KEY = "storage_footer_category";
    private static final String STORAGE_FOOTER_PREFERENCE_KEY = "storage_footer_preference";
    private static final int SHOW_LOAD_DELAY_MS = 200;

    private static final int MENU_PERMISSION_USAGE = MENU_HIDE_SYSTEM + 1;

    /**
     * Create a bundle with the arguments needed by this fragment
     *
     * @param permGroupName The name of the permission group
     * @param sessionId     The current session ID
     * @return A bundle with all of the args placed
     */
    public static Bundle createArgs(String permGroupName, long sessionId) {
        Bundle arguments = new Bundle();
        arguments.putString(Intent.EXTRA_PERMISSION_GROUP_NAME, permGroupName);
        arguments.putLong(EXTRA_SESSION_ID, sessionId);
        return arguments;
    }

    private MenuItem mShowSystemMenu;
    private MenuItem mHideSystemMenu;
    private String mPermGroupName;
    private Collator mCollator;
    private PermissionAppsViewModel mViewModel;
    private PermissionUsages mPermissionUsages;
    private List<AppPermissionUsage> mAppPermissionUsages = new ArrayList<>();
    private Boolean mSensorStatus;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mPermGroupName = getArguments().getString(Intent.EXTRA_PERMISSION_GROUP_NAME);
        if (mPermGroupName == null) {
            mPermGroupName = getArguments().getString(Intent.EXTRA_PERMISSION_NAME);
        }

        mCollator = Collator.getInstance(
                getContext().getResources().getConfiguration().getLocales().get(0));

        PermissionAppsViewModelFactory factory =
                new PermissionAppsViewModelFactory(getActivity().getApplication(), mPermGroupName,
                        this, new Bundle());
        mViewModel = new ViewModelProvider(this, factory).get(PermissionAppsViewModel.class);

        mViewModel.getCategorizedAppsLiveData().observe(this, this::onPackagesLoaded);
        mViewModel.getShouldShowSystemLiveData().observe(this, this::updateMenu);
        mViewModel.getHasSystemAppsLiveData().observe(this, (Boolean hasSystem) ->
                getActivity().invalidateOptionsMenu());

        if (!mViewModel.arePackagesLoaded()) {
            Handler handler = new Handler(Looper.getMainLooper());
            handler.postDelayed(() -> {
                if (!mViewModel.arePackagesLoaded()) {
                    setLoading(true /* loading */, false /* animate */);
                }
            }, SHOW_LOAD_DELAY_MS);
        }

        setHasOptionsMenu(true);
        final ActionBar ab = getActivity().getActionBar();
        if (ab != null) {
            ab.setDisplayHomeAsUpEnabled(true);
        }

        // If the build type is below S, the app ops for permission usage can't be found. Thus, we
        // shouldn't load permission usages, for them.
        if (SdkLevel.isAtLeastS()) {
            Context context = getPreferenceManager().getContext();
            mPermissionUsages = new PermissionUsages(context);

            long filterTimeBeginMillis = mViewModel.getFilterTimeBeginMillis();
            mPermissionUsages.load(null, null, filterTimeBeginMillis, Long.MAX_VALUE,
                    PermissionUsages.USAGE_FLAG_LAST, getActivity().getLoaderManager(),
                    false, false, this, false);

            if (Utils.shouldDisplayCardIfBlocked(mPermGroupName)) {
                mViewModel.getSensorStatusLiveData().observe(this, this::setSensorStatus);
            }
        }
    }

    @Override
    @RequiresApi(Build.VERSION_CODES.S)
    public void onPermissionUsagesChanged() {
        if (mPermissionUsages.getUsages().isEmpty()) {
            return;
        }
        if (getContext() == null) {
            // Async result has come in after our context is gone.
            return;
        }

        mAppPermissionUsages = new ArrayList<>(mPermissionUsages.getUsages());
        onPackagesLoaded(mViewModel.getCategorizedAppsLiveData().getValue());
    }

    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        super.onCreateOptionsMenu(menu, inflater);

        if (mViewModel.getHasSystemAppsLiveData().getValue()) {
            mShowSystemMenu = menu.add(Menu.NONE, MENU_SHOW_SYSTEM, Menu.NONE,
                    R.string.menu_show_system);
            mHideSystemMenu = menu.add(Menu.NONE, MENU_HIDE_SYSTEM, Menu.NONE,
                    R.string.menu_hide_system);
            updateMenu(mViewModel.getShouldShowSystemLiveData().getValue());
        }

        if (KotlinUtils.INSTANCE.shouldShowPermissionsDashboard()) {
            menu.add(Menu.NONE, MENU_PERMISSION_USAGE, Menu.NONE, R.string.permission_usage_title);
        }

        if (!SdkLevel.isAtLeastS()) {
            HelpUtils.prepareHelpMenuItem(getActivity(), menu, R.string.help_app_permissions,
                    getClass().getName());
        }
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                mViewModel.updateShowSystem(false);
                pressBack(this);
                return true;
            case MENU_SHOW_SYSTEM:
            case MENU_HIDE_SYSTEM:
                mViewModel.updateShowSystem(item.getItemId() == MENU_SHOW_SYSTEM);
                break;
            case MENU_PERMISSION_USAGE:
                getActivity().startActivity(new Intent(Intent.ACTION_REVIEW_PERMISSION_USAGE)
                        .setClass(getContext(), ManagePermissionsActivity.class)
                        .putExtra(Intent.EXTRA_PERMISSION_GROUP_NAME, mPermGroupName));
                return true;
        }
        return super.onOptionsItemSelected(item);
    }

    private void updateMenu(Boolean showSystem) {
        if (showSystem == null) {
            showSystem = false;
        }
        if (mShowSystemMenu != null && mHideSystemMenu != null) {
            mShowSystemMenu.setVisible(!showSystem);
            mHideSystemMenu.setVisible(showSystem);
        }
    }

    @RequiresApi(Build.VERSION_CODES.S)
    private void setSensorStatus(Boolean sensorStatus) {
        mSensorStatus = sensorStatus;
        displaySensorCard();
    }

    @RequiresApi(Build.VERSION_CODES.S)
    private void displaySensorCard() {
        if (Utils.shouldDisplayCardIfBlocked(mPermGroupName)) {
            if (mSensorStatus) {
                setSensorCard();
            } else {
                removeSensorCard();
            }
        }
    }

    @RequiresApi(Build.VERSION_CODES.S)
    private void setSensorCard() {
        CardViewPreference sensorCard = findPreference(BLOCKED_SENSOR_PREF_KEY);
        if (sensorCard == null) {
            sensorCard = createSensorCard();
            ensurePreferenceScreen();
            getPreferenceScreen().addPreference(sensorCard);
        }
        sensorCard.setVisible(true);
    }

    private void ensurePreferenceScreen() {
        // Check if preference screen has been already loaded
        if (getPreferenceScreen() != null) {
            return;
        }
        boolean isStorageAndLessThanT = !SdkLevel.isAtLeastT()
                && mPermGroupName.equals(Manifest.permission_group.STORAGE);
        if (isStorageAndLessThanT) {
            addPreferencesFromResource(R.xml.allowed_denied_storage);
        } else {
            addPreferencesFromResource(R.xml.allowed_denied);
        }
        // Hide allowed foreground label by default, to avoid briefly showing it before updating
        findPreference(ALLOWED_FOREGROUND.getCategoryName()).setVisible(false);
    }

    @RequiresApi(Build.VERSION_CODES.S)
    private CardViewPreference createSensorCard() {
        boolean isLocation = Manifest.permission_group.LOCATION.equals(mPermGroupName);
        Context context = getPreferenceManager().getContext();
        String action = isLocation ? Settings.ACTION_LOCATION_SOURCE_SETTINGS
                : Settings.ACTION_PRIVACY_SETTINGS;
        CardViewPreference sensorCard = new CardViewPreference(context, action);
        sensorCard.setKey(BLOCKED_SENSOR_PREF_KEY);
        sensorCard.setIcon(Utils.getBlockedIcon(mPermGroupName));
        sensorCard.setTitle(Utils.getBlockedTitle(mPermGroupName));
        boolean isMicrophone = Manifest.permission_group.MICROPHONE.equals(mPermGroupName);
        int cardSummary =
                isMicrophone ? R.string.blocked_mic_summary : R.string.blocked_sensor_summary;
        sensorCard.setSummary(context.getString(cardSummary));
        sensorCard.setVisible(true);
        sensorCard.setOrder(-1);
        return sensorCard;
    }

    private void addStorageFooterSeeAllFilesAccess() {
        PreferenceScreen screen = getPreferenceScreen();
        Context context = screen.getPreferenceManager().getContext();
        PreferenceCategory preferenceCategory = findPreference(STORAGE_FOOTER_CATEGORY_KEY);
        Preference existingPreference = findPreference(STORAGE_FOOTER_PREFERENCE_KEY);

        if (preferenceCategory == null || existingPreference != null) {
            return;
        }

        FooterPreference preference = new FooterPreference(context);
        preference.setKey(STORAGE_FOOTER_PREFERENCE_KEY);
        preference.setIcon(Utils.applyTint(getActivity(), R.drawable.ic_info_outline,
                android.R.attr.colorControlNormal));
        preference.setLearnMoreText(getString(R.string.storage_footer_hyperlink_text));
        preference.setLearnMoreAction(v -> {
            context.startActivity(
                    new Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION));
        });

        preferenceCategory.addPreference(preference);
    }

    @RequiresApi(Build.VERSION_CODES.S)
    private void removeSensorCard() {
        CardViewPreference sensorCard = findPreference(BLOCKED_SENSOR_PREF_KEY);
        if (sensorCard != null) {
            sensorCard.setVisible(false);
        }
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        bindUi(this, mPermGroupName);
    }

    private static void bindUi(SettingsWithLargeHeader fragment, @NonNull String groupName) {
        Context context = fragment.getContext();
        if (context == null || fragment.getActivity() == null) {
            return;
        }
        Drawable icon = KotlinUtils.INSTANCE.getPermGroupIcon(context, groupName);

        CharSequence label = KotlinUtils.INSTANCE.getPermGroupLabel(context, groupName);
        CharSequence description = KotlinUtils.INSTANCE.getPermGroupDescription(context, groupName);

        fragment.setHeader(icon, label, null, null, true);
        fragment.setSummary(Utils.getPermissionGroupDescriptionString(fragment.getActivity(),
                groupName, description), null);
        fragment.getActivity().setTitle(label);
    }

    private void onPackagesLoaded(Map<Category, List<Pair<String, UserHandle>>> categories) {
        boolean isStorageAndLessThanT = !SdkLevel.isAtLeastT()
                && mPermGroupName.equals(Manifest.permission_group.STORAGE);
        ensurePreferenceScreen();
        Context context = getPreferenceManager().getContext();

        if (context == null || getActivity() == null || categories == null) {
            return;
        }

        Map<String, Preference> existingPrefs = new ArrayMap<>();

        for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); i++) {
            Preference pref = getPreferenceScreen().getPreference(i);
            if (BLOCKED_SENSOR_PREF_KEY.equals(pref.getKey())) {
                continue;
            }
            PreferenceCategory category = (PreferenceCategory) pref;
            category.setOrderingAsAdded(true);
            int numPreferences = category.getPreferenceCount();
            for (int j = 0; j < numPreferences; j++) {
                Preference preference = category.getPreference(j);
                existingPrefs.put(preference.getKey(), preference);
            }
            category.removeAll();
        }

        long viewIdForLogging = new Random().nextLong();
        long sessionId = getArguments().getLong(EXTRA_SESSION_ID, INVALID_SESSION_ID);

        Boolean showAlways = mViewModel.getShowAllowAlwaysStringLiveData().getValue();
        if (!isStorageAndLessThanT) {
            if (showAlways != null && showAlways) {
                findPreference(ALLOWED.getCategoryName()).setTitle(R.string.allowed_always_header);
            } else {
                findPreference(ALLOWED.getCategoryName()).setTitle(R.string.allowed_header);
            }
        }

        // A mapping of user + packageName to their last access timestamps for the permission group.
        Map<String, Long> groupUsageLastAccessTime =
                mViewModel.extractGroupUsageLastAccessTime(mAppPermissionUsages);

        for (Category grantCategory : categories.keySet()) {
            List<Pair<String, UserHandle>> packages = categories.get(grantCategory);
            PreferenceCategory category = findPreference(grantCategory.getCategoryName());


            // If this category is empty, and this isn't the "allowed" category of the storage
            // permission, set up the empty preference.
            if (packages.size() == 0
                    && (!isStorageAndLessThanT || !grantCategory.equals(ALLOWED))) {
                Preference empty = new Preference(context);
                empty.setSelectable(false);
                empty.setKey(category.getKey() + KEY_EMPTY);
                if (grantCategory.equals(ALLOWED)) {
                    empty.setTitle(getString(R.string.no_apps_allowed));
                } else if (grantCategory.equals(ALLOWED_FOREGROUND)) {
                    category.setVisible(false);
                } else if (grantCategory.equals(ASK)) {
                    category.setVisible(false);
                } else {
                    empty.setTitle(getString(R.string.no_apps_denied));
                }
                category.addPreference(empty);
                continue;
            } else if (grantCategory.equals(ALLOWED_FOREGROUND)) {
                category.setVisible(true);
            } else if (grantCategory.equals(ASK)) {
                category.setVisible(true);
            }

            for (Pair<String, UserHandle> packageUserLabel : packages) {
                String packageName = packageUserLabel.getFirst();
                UserHandle user = packageUserLabel.getSecond();

                String key = user + packageName;

                Long lastAccessTime = groupUsageLastAccessTime.get(key);
                Triple<String, Integer, String> summaryTimestamp = Utils
                        .getPermissionLastAccessSummaryTimestamp(
                                lastAccessTime, context, mPermGroupName);

                if (isStorageAndLessThanT && grantCategory.equals(ALLOWED)) {
                    category = mViewModel.packageHasFullStorage(packageName, user)
                            ? findPreference(STORAGE_ALLOWED_FULL)
                            : findPreference(STORAGE_ALLOWED_SCOPED);
                }

                Preference existingPref = existingPrefs.get(key);
                if (existingPref != null) {
                    updatePreferenceSummary(existingPref, summaryTimestamp);
                    category.addPreference(existingPref);
                    continue;
                }

                SmartIconLoadPackagePermissionPreference pref =
                        new SmartIconLoadPackagePermissionPreference(getActivity().getApplication(),
                                packageName, user, context);
                pref.setKey(key);
                pref.setTitle(KotlinUtils.INSTANCE.getPackageLabel(getActivity().getApplication(),
                        packageName, user));
                pref.setOnPreferenceClickListener((Preference p) -> {
                    mViewModel.navigateToAppPermission(this, packageName, user,
                            AppPermissionFragment.createArgs(packageName, null, mPermGroupName,
                                    user, getClass().getName(), sessionId,
                                    grantCategory.getCategoryName()));
                    return true;
                });
                pref.setTitleContentDescription(AppUtils.getAppContentDescription(context,
                        packageName, user.getIdentifier()));

                updatePreferenceSummary(pref, summaryTimestamp);

                category.addPreference(pref);
                if (!mViewModel.getCreationLogged()) {
                    logPermissionAppsFragmentCreated(packageName, user, viewIdForLogging,
                            grantCategory.equals(ALLOWED), grantCategory.equals(ALLOWED_FOREGROUND),
                            grantCategory.equals(DENIED));
                }
            }

            if (isStorageAndLessThanT && grantCategory.equals(ALLOWED)) {
                PreferenceCategory full = findPreference(STORAGE_ALLOWED_FULL);
                PreferenceCategory scoped = findPreference(STORAGE_ALLOWED_SCOPED);
                if (full.getPreferenceCount() == 0) {
                    Preference empty = new Preference(context);
                    empty.setSelectable(false);
                    empty.setKey(STORAGE_ALLOWED_FULL + KEY_EMPTY);
                    empty.setTitle(getString(R.string.no_apps_allowed_full));
                    full.addPreference(empty);
                }

                if (scoped.getPreferenceCount() == 0) {
                    Preference empty = new Preference(context);
                    empty.setSelectable(false);
                    empty.setKey(STORAGE_ALLOWED_FULL + KEY_EMPTY);
                    empty.setTitle(getString(R.string.no_apps_allowed_scoped));
                    scoped.addPreference(empty);
                }
                KotlinUtils.INSTANCE.sortPreferenceGroup(full, this::comparePreference, false);
                KotlinUtils.INSTANCE.sortPreferenceGroup(scoped, this::comparePreference, false);
            } else {
                KotlinUtils.INSTANCE.sortPreferenceGroup(category, this::comparePreference, false);
            }
        }

        if (SdkLevel.isAtLeastT() && Manifest.permission_group.STORAGE.equals(mPermGroupName)) {
            addStorageFooterSeeAllFilesAccess();
        }

        mViewModel.setCreationLogged(true);

        setLoading(false /* loading */, true /* animate */);
    }

    private void updatePreferenceSummary(Preference preference,
            Triple<String, Integer, String> summaryTimestamp) {
        String summary = mViewModel.getPreferenceSummary(getResources(), summaryTimestamp);
        if (!summary.isEmpty()) {
            preference.setSummary(summary);
        }
    }


    private int comparePreference(Preference lhs, Preference rhs) {
        int result = mCollator.compare(lhs.getTitle().toString(),
                rhs.getTitle().toString());
        if (result == 0) {
            result = lhs.getKey().compareTo(rhs.getKey());
        }
        return result;
    }

    private void logPermissionAppsFragmentCreated(String packageName, UserHandle user, long viewId,
            boolean isAllowed, boolean isAllowedForeground, boolean isDenied) {
        long sessionId = getArguments().getLong(EXTRA_SESSION_ID, 0);
        mViewModel.logPermissionAppsFragmentCreated(packageName, user, viewId, isAllowed,
                isAllowedForeground, isDenied, sessionId, getActivity().getApplication(),
                mPermGroupName, LOG_TAG);
    }
}