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

Commit 63e71c42 authored by jaimin kalariya's avatar jaimin kalariya Committed by Luca Stefani
Browse files

sdk: Add requiresService attribute

Change-Id: I6d178290dd2def15d169eac521ec5562cfe57a08
parent 95a174bb
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
        <attr name="requiresConfig" format="string" />
        <attr name="requiresConfigMask" format="integer" />
        <attr name="requiresProperty" format="string" />
        <attr name="requiresService" format="string" />
        <attr name="requiresOwner" format="boolean" />
        <attr name="requiresAction" format="string" />
        <attr name="replacesKey" format="string" />
+1 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
  <public type="attr" name="requiresOwner" id="0x3f010006" />
  <public type="attr" name="xmlRes" id="0x3f010007" />
  <public type="attr" name="requiresAction" id="0x3f010008" />
  <public type="attr" name="requiresService" id="0x3f01000c" />
  <public type="attr" name="replacesKey" id="0x3f010009" />
  <public type="attr" name="minSummaryLines" id="0x3f01000a" />

+1 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@
    <java-symbol type="attr" name="requiresProperty" />
    <java-symbol type="attr" name="requiresOwner" />
    <java-symbol type="attr" name="requiresAction" />
    <java-symbol type="attr" name="requiresService" />
    <java-symbol type="attr" name="replacesKey" />

    <java-symbol type="attr" name="xmlRes" />
+17 −0
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.TypedArray;
import android.os.IBinder;
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.telephony.TelephonyManager;
@@ -229,6 +231,21 @@ public class ConstraintsHelper {
                    }
                }
            }

            // Check a system service
            String rService = a.getString(
                    R.styleable.lineage_SelfRemovingPreference_requiresService);
            if (rService != null) {
                boolean negated = isNegated(rService);
                if (negated) {
                    rService = rService.substring(1);
                }
                IBinder value = ServiceManager.getService(rService);
                boolean available = value != null;
                if (available == negated) {
                    return false;
                }
            }
        } finally {
            a.recycle();
        }