Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5f31f277 authored by Adnan Begovic's avatar Adnan Begovic Committed by Gerrit Code Review
Browse files

fw: Fix protected apps implementation.

 Currently a protected component could be accessed
 from any other means other than the launcher, entirely
 defeating its purpose. Instead, hook into the activity
 stack supervisor and quelch attempts at invocation
 of protected components.

 This implementation also provides feedback to the user
 on any attempt to start the component when its in a
 protected state.

TICKET: CYNGNOS-84
Change-Id: Ib0165e7504adb08e21e9566c7394b37dffd280d4
parent 35671166
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -2046,6 +2046,17 @@ final class ApplicationPackageManager extends PackageManager {
        }
    }

    /** @hide */
    @Override
    public boolean isComponentProtected(String callingPackage, ComponentName componentName) {
        try {
            return mPM.isComponentProtected(callingPackage, componentName, mContext.getUserId());
        } catch (RemoteException re) {
            Log.e(TAG, "Failed to get component protected setting", re);
            return false;
        }
    }

    @Override
    public PackageInstaller getPackageInstaller() {
        synchronized (mLock) {
+4 −0
Original line number Diff line number Diff line
@@ -519,4 +519,8 @@ interface IPackageManager {
    void updateIconMapping(String pkgName);
    ComposedIconInfo getComposedIconInfo();
    int processThemeResources(String themePkgName);

    /** Protected Apps */
    boolean isComponentProtected(in String callingPackage, in ComponentName componentName,
            int userId);
}
+7 −0
Original line number Diff line number Diff line
@@ -4560,6 +4560,13 @@ public abstract class PackageManager {
     */
    public abstract void setComponentProtectedSetting(ComponentName componentName, boolean newState);

    /**
     * Return whether or not a specific component is protected
     * @hide
     */
    public abstract boolean isComponentProtected(String callingPackage,
            ComponentName componentName);

    /**
     * Adds a {@link CrossProfileIntentFilter}. After calling this method all intents sent from the
     * user with id sourceUserId can also be be resolved by activities in the user with id
+28 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2016 The CyanogenMod 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="26dp"
        android:height="24dp"
        android:viewportWidth="26"
        android:viewportHeight="24">

    <path
            android:pathData="M0 0h24v24H0z" />
    <path
            android:fillColor="#000000"
            android:pathData="M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z" />
</vector>
 No newline at end of file
+3 −0
Original line number Diff line number Diff line
@@ -246,4 +246,7 @@
         with spaces on either side. [CHAR LIMIT=3] -->
    <string name="kg_sub_separator" translatable="false">" | "</string>

    <!-- Protected Apps Notification -->
    <string name="notify_package_component_protected_title">Activity launch blocked</string>
    <string name="notify_package_component_protected_text"><xliff:g id="app_name">%1$s</xliff:g> is protected from being launched. Click to authenticate and launch the application.</string>
</resources>
Loading