Loading src/com/android/packageinstaller/permission/ui/ReviewOngoingUsageActivity.java +8 −2 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import androidx.annotation.NonNull; import androidx.fragment.app.FragmentActivity; import com.android.packageinstaller.DeviceUtils; import com.android.packageinstaller.permission.ui.auto.ReviewOngoingUsageAutoFragment; import com.android.packageinstaller.permission.ui.handheld.ReviewOngoingUsageFragment; /** Loading @@ -43,9 +44,14 @@ public final class ReviewOngoingUsageActivity extends FragmentActivity { getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS); long numMillis = getIntent().getLongExtra(Intent.EXTRA_DURATION_MILLIS, DEFAULT_MILLIS); if (DeviceUtils.isAuto(this)) { getSupportFragmentManager().beginTransaction().replace(android.R.id.content, ReviewOngoingUsageAutoFragment.newInstance(numMillis)).commit(); } else { getSupportFragmentManager().beginTransaction().replace(android.R.id.content, ReviewOngoingUsageFragment.newInstance(numMillis)).commit(); } } @Override Loading src/com/android/packageinstaller/permission/ui/auto/ReviewOngoingUsageAutoFragment.java 0 → 100644 +45 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 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.packageinstaller.permission.ui.auto; import android.app.AlertDialog; import android.content.Intent; import android.os.Bundle; import com.android.packageinstaller.permission.ui.handheld.ReviewOngoingUsageFragment; /** * A dialog listing the currently uses of camera, microphone, and location. */ public class ReviewOngoingUsageAutoFragment extends ReviewOngoingUsageFragment { /** * @return A new {@link ReviewOngoingUsageAutoFragment} */ public static ReviewOngoingUsageAutoFragment newInstance(long numMillis) { ReviewOngoingUsageAutoFragment fragment = new ReviewOngoingUsageAutoFragment(); Bundle arguments = new Bundle(); arguments.putLong(Intent.EXTRA_DURATION_MILLIS, numMillis); fragment.setArguments(arguments); return fragment; } @Override protected void setNeutralButton(AlertDialog.Builder builder) { // do nothing } } src/com/android/packageinstaller/permission/ui/handheld/ReviewOngoingUsageFragment.java +15 −10 Original line number Diff line number Diff line Loading @@ -61,7 +61,7 @@ import java.util.concurrent.TimeUnit; /** * A dialog listing the currently uses of camera, microphone, and location. */ public final class ReviewOngoingUsageFragment extends PreferenceFragmentCompat { public class ReviewOngoingUsageFragment extends PreferenceFragmentCompat { private @NonNull PermissionUsages mPermissionUsages; private @Nullable AlertDialog mDialog; Loading Loading @@ -142,19 +142,24 @@ public final class ReviewOngoingUsageFragment extends PreferenceFragmentCompat { } private void showDialog(@NonNull List<Pair<AppPermissionUsage, List<GroupUsage>>> usages) { mDialog = new AlertDialog.Builder(getActivity()) AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()) .setView(createDialogView(usages)) .setPositiveButton(R.string.ongoing_usage_dialog_ok, (dialog, which) -> PermissionControllerStatsLog.write(PRIVACY_INDICATORS_INTERACTED, PRIVACY_INDICATORS_INTERACTED__TYPE__DIALOG_DISMISS, null)) .setNeutralButton(R.string.ongoing_usage_dialog_open_settings, (dialog, which) -> { .setOnDismissListener((dialog) -> getActivity().finish()); setNeutralButton(builder); mDialog = builder.create(); mDialog.show(); } protected void setNeutralButton(AlertDialog.Builder builder) { builder.setNeutralButton(R.string.ongoing_usage_dialog_open_settings, (dialog, which) -> { PermissionControllerStatsLog.write(PRIVACY_INDICATORS_INTERACTED, PRIVACY_INDICATORS_INTERACTED__TYPE__DIALOG_PRIVACY_SETTINGS, null); startActivity(new Intent(Settings.ACTION_PRIVACY_SETTINGS).putExtra( Intent.EXTRA_DURATION_MILLIS, TimeUnit.MINUTES.toMillis(1))); }) .setOnDismissListener((dialog) -> getActivity().finish()) .create(); mDialog.show(); Intent.EXTRA_DURATION_MILLIS, TimeUnit.MINUTES.toMillis(1))); }); } private @NonNull View createDialogView( Loading Loading
src/com/android/packageinstaller/permission/ui/ReviewOngoingUsageActivity.java +8 −2 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import androidx.annotation.NonNull; import androidx.fragment.app.FragmentActivity; import com.android.packageinstaller.DeviceUtils; import com.android.packageinstaller.permission.ui.auto.ReviewOngoingUsageAutoFragment; import com.android.packageinstaller.permission.ui.handheld.ReviewOngoingUsageFragment; /** Loading @@ -43,9 +44,14 @@ public final class ReviewOngoingUsageActivity extends FragmentActivity { getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS); long numMillis = getIntent().getLongExtra(Intent.EXTRA_DURATION_MILLIS, DEFAULT_MILLIS); if (DeviceUtils.isAuto(this)) { getSupportFragmentManager().beginTransaction().replace(android.R.id.content, ReviewOngoingUsageAutoFragment.newInstance(numMillis)).commit(); } else { getSupportFragmentManager().beginTransaction().replace(android.R.id.content, ReviewOngoingUsageFragment.newInstance(numMillis)).commit(); } } @Override Loading
src/com/android/packageinstaller/permission/ui/auto/ReviewOngoingUsageAutoFragment.java 0 → 100644 +45 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 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.packageinstaller.permission.ui.auto; import android.app.AlertDialog; import android.content.Intent; import android.os.Bundle; import com.android.packageinstaller.permission.ui.handheld.ReviewOngoingUsageFragment; /** * A dialog listing the currently uses of camera, microphone, and location. */ public class ReviewOngoingUsageAutoFragment extends ReviewOngoingUsageFragment { /** * @return A new {@link ReviewOngoingUsageAutoFragment} */ public static ReviewOngoingUsageAutoFragment newInstance(long numMillis) { ReviewOngoingUsageAutoFragment fragment = new ReviewOngoingUsageAutoFragment(); Bundle arguments = new Bundle(); arguments.putLong(Intent.EXTRA_DURATION_MILLIS, numMillis); fragment.setArguments(arguments); return fragment; } @Override protected void setNeutralButton(AlertDialog.Builder builder) { // do nothing } }
src/com/android/packageinstaller/permission/ui/handheld/ReviewOngoingUsageFragment.java +15 −10 Original line number Diff line number Diff line Loading @@ -61,7 +61,7 @@ import java.util.concurrent.TimeUnit; /** * A dialog listing the currently uses of camera, microphone, and location. */ public final class ReviewOngoingUsageFragment extends PreferenceFragmentCompat { public class ReviewOngoingUsageFragment extends PreferenceFragmentCompat { private @NonNull PermissionUsages mPermissionUsages; private @Nullable AlertDialog mDialog; Loading Loading @@ -142,19 +142,24 @@ public final class ReviewOngoingUsageFragment extends PreferenceFragmentCompat { } private void showDialog(@NonNull List<Pair<AppPermissionUsage, List<GroupUsage>>> usages) { mDialog = new AlertDialog.Builder(getActivity()) AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()) .setView(createDialogView(usages)) .setPositiveButton(R.string.ongoing_usage_dialog_ok, (dialog, which) -> PermissionControllerStatsLog.write(PRIVACY_INDICATORS_INTERACTED, PRIVACY_INDICATORS_INTERACTED__TYPE__DIALOG_DISMISS, null)) .setNeutralButton(R.string.ongoing_usage_dialog_open_settings, (dialog, which) -> { .setOnDismissListener((dialog) -> getActivity().finish()); setNeutralButton(builder); mDialog = builder.create(); mDialog.show(); } protected void setNeutralButton(AlertDialog.Builder builder) { builder.setNeutralButton(R.string.ongoing_usage_dialog_open_settings, (dialog, which) -> { PermissionControllerStatsLog.write(PRIVACY_INDICATORS_INTERACTED, PRIVACY_INDICATORS_INTERACTED__TYPE__DIALOG_PRIVACY_SETTINGS, null); startActivity(new Intent(Settings.ACTION_PRIVACY_SETTINGS).putExtra( Intent.EXTRA_DURATION_MILLIS, TimeUnit.MINUTES.toMillis(1))); }) .setOnDismissListener((dialog) -> getActivity().finish()) .create(); mDialog.show(); Intent.EXTRA_DURATION_MILLIS, TimeUnit.MINUTES.toMillis(1))); }); } private @NonNull View createDialogView( Loading