Hide clock option when there is only 1 option[1/2]

- Not to add clock option(tab) to home page when there is only 1 option
- By default, there should be only 1 clock(Default clock) build-in with device, additional clock content will be provided by another apk, if can not find that apk means we only have 1 clock option, then hide the clock tab

Bug: 146530441
Test: Need work with ag/10361873, modify the mk file to build up additional clock content, then check the Picker app will display Clock tab or not.

Change-Id: Ie64e6f0074869792a956d6b47e4f483a2bbd531f
diff --git a/res/values/override.xml b/res/values/override.xml
index a01507e..1b82e00 100644
--- a/res/values/override.xml
+++ b/res/values/override.xml
@@ -17,6 +17,7 @@
 -->
 <resources>
     <string name="themes_stub_package" translatable="false"/>
+    <string name="clocks_stub_package" translatable="false"/>
     <!-- Authority of a provider in System UI that will provide preview info for available clockfaces. -->
     <string name="clocks_provider_authority" translatable="false">com.android.keyguard.clock</string>
 
diff --git a/src/com/android/customization/model/clock/ContentProviderClockProvider.java b/src/com/android/customization/model/clock/ContentProviderClockProvider.java
index ad60ddc..8f4c031 100644
--- a/src/com/android/customization/model/clock/ContentProviderClockProvider.java
+++ b/src/com/android/customization/model/clock/ContentProviderClockProvider.java
@@ -2,7 +2,9 @@
 
 import android.content.ContentResolver;
 import android.content.Context;
+import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
 import android.content.pm.ProviderInfo;
 import android.database.Cursor;
 import android.net.Uri;
@@ -25,6 +27,7 @@
     private final Context mContext;
     private final ProviderInfo mProviderInfo;
     private List<Clockface> mClocks;
+    private boolean mClockContentAvailable;
 
     public ContentProviderClockProvider(Context context) {
         mContext = context;
@@ -33,11 +36,25 @@
         mProviderInfo = TextUtils.isEmpty(providerAuthority) ? null
                 : mContext.getPackageManager().resolveContentProvider(providerAuthority,
                         PackageManager.MATCH_SYSTEM_ONLY);
+
+        if (TextUtils.isEmpty(mContext.getString(R.string.clocks_stub_package))) {
+            mClockContentAvailable = false;
+        } else {
+            try {
+                ApplicationInfo applicationInfo = mContext.getPackageManager().getApplicationInfo(
+                        mContext.getString(R.string.clocks_stub_package),
+                        PackageManager.MATCH_SYSTEM_ONLY);
+                mClockContentAvailable = applicationInfo != null;
+            } catch (NameNotFoundException e) {
+                mClockContentAvailable = false;
+            }
+        }
     }
 
     @Override
     public boolean isAvailable() {
-        return mProviderInfo != null && (mClocks == null || !mClocks.isEmpty());
+        return mProviderInfo != null && mClockContentAvailable
+                && (mClocks == null || !mClocks.isEmpty());
     }
 
     @Override